Skip to content

Commit fa61db5

Browse files
authored
Workbench improvements: Pan (ITISFoundation#2564)
1 parent 3fc5855 commit fa61db5

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
128128
__selectedItemId: null,
129129
__startHint: null,
130130
__dropHint: null,
131+
__panning: null,
131132

132133
_addItemsToLayout: function() {
133134
this.__addInputNodesLayout();
@@ -148,7 +149,7 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
148149
});
149150

150151
const workbenchLayoutScroll = this._workbenchLayoutScroll = new qx.ui.container.Scroll();
151-
osparc.utils.Utils.setIdToWidget(workbenchLayoutScroll, "hithere");
152+
osparc.utils.Utils.setIdToWidget(workbenchLayoutScroll, "WorkbenchUI-scroll");
152153
const workbenchLayout = this.__workbenchLayout = new qx.ui.container.Composite(new qx.ui.layout.Canvas());
153154
workbenchLayoutScroll.add(workbenchLayout);
154155
workbenchLayer.add(workbenchLayoutScroll, {
@@ -1097,6 +1098,39 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
10971098
};
10981099
},
10991100

1101+
__mouseDown: function(e) {
1102+
if (e.isMiddlePressed()) {
1103+
this.__panning = true;
1104+
this.__pointerPos = this.__pointerEventToWorkbenchPos(e, true);
1105+
this.set({
1106+
cursor: "move"
1107+
});
1108+
}
1109+
},
1110+
1111+
__mouseMove: function(e) {
1112+
if (this.__panning && e.isMiddlePressed()) {
1113+
const oldPos = this.__pointerPos;
1114+
const newPos = this.__pointerPos = this.__pointerEventToWorkbenchPos(e, true);
1115+
const moveX = parseInt((oldPos.x-newPos.x) * this.getScale());
1116+
const moveY = parseInt((oldPos.y-newPos.y) * this.getScale());
1117+
this._workbenchLayoutScroll.scrollToX(this._workbenchLayoutScroll.getScrollX() + moveX);
1118+
this._workbenchLayoutScroll.scrollToY(this._workbenchLayoutScroll.getScrollY() + moveY);
1119+
this.set({
1120+
cursor: "move"
1121+
});
1122+
}
1123+
},
1124+
1125+
__mouseUp: function() {
1126+
if (this.__panning) {
1127+
this.__panning = false;
1128+
this.set({
1129+
cursor: "auto"
1130+
});
1131+
}
1132+
},
1133+
11001134
__mouseWheel: function(e) {
11011135
this.__pointerPos = this.__pointerEventToWorkbenchPos(e, false);
11021136
const zoomIn = e.getWheelDelta() < 0;
@@ -1218,6 +1252,9 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
12181252
domEl.addEventListener("drop", this.__drop.bind(this), false);
12191253

12201254
this.addListener("mousewheel", this.__mouseWheel, this);
1255+
this.addListener("mousedown", this.__mouseDown, this);
1256+
this.addListener("mousemove", this.__mouseMove, this);
1257+
this.addListener("mouseup", this.__mouseUp, this);
12211258

12221259
commandDel.setEnabled(true);
12231260
commandEsc.setEnabled(true);

services/web/client/source/class/osparc/desktop/StudyEditor.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,16 @@ qx.Class.define("osparc.desktop.StudyEditor", {
184184
});
185185
})
186186
.catch(err => {
187+
let msg = "";
187188
if ("status" in err && err["status"] == 423) { // Locked
188-
const msg = study.getName() + this.tr(" is already opened");
189-
osparc.component.message.FlashMessenger.getInstance().logAs(msg, "ERROR");
190-
this.fireEvent("forceBackToDashboard");
189+
msg = study.getName() + this.tr(" is already opened");
191190
} else {
192191
console.error(err);
192+
msg = this.tr("Error opening study");
193+
msg += "<br>" + osparc.data.Resources.getErrorMsg(err);
193194
}
195+
osparc.component.message.FlashMessenger.getInstance().logAs(msg, "ERROR");
196+
this.fireEvent("forceBackToDashboard");
194197
});
195198

196199
this.__workbenchView.setStudy(study);

0 commit comments

Comments
 (0)