Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Split UI loading procedure into a set of steps.

  • Loading branch information...
commit 587d417912c198fb5f0b94fded70e3c28f6f7263 1 parent 16fcbd7
@arcusfelis authored
View
2  q_src/class/cascadae/BasicTable.js
@@ -473,11 +473,11 @@ qx.Class.define("cascadae.BasicTable",
*/
updateFilters : function()
{
- this.info("change selection");
var tm = this.__tableModel;
var newSel = this.__mainTable.getSelectedIds();
if (qx.lang.Array.equals(this._oldSelection, newSel)) return;
+ this.info("change selection");
this.fireDataEvent("d_updateFilters", {"torrent_ids": newSel});
this._oldSelection = qx.lang.Array.clone(newSel);
View
70 q_src/class/cascadae/Container.js
@@ -30,9 +30,6 @@ qx.Class.define("cascadae.Container",
this.__application = app;
this._initializeCommands();
- socket.addListener("connect", this.__setEnabled, this);
- socket.addListener("disconnect", this.__setDisabled, this);
-
// Create header
this.__header = new cascadae.Header();
this.add(this.__header, { edge : "north" });
@@ -47,10 +44,6 @@ qx.Class.define("cascadae.Container",
this.__stack.exclude();
this.__mainStack = new qx.ui.container.Stack;
- this.__table = new cascadae.Table();
- this.__socket.addListener("rd_logEvent", this.__table.logHandler, this.__table);
- this.__mainStack.add(this.__table);
- socket.registerObject(this.__table);
this.__infosplit = new qx.ui.splitpane.Pane("horizontal");
this.__infosplit.setDecorator(null);
@@ -59,11 +52,6 @@ qx.Class.define("cascadae.Container",
this.__infosplit.add(this.__mainStack, 2);
this.__infosplit.add(this.__stack, 1);
- this._initToolbarButtonActivation();
-// this._initToolbarFileButtonActivation();
-
- this.setEnabled(false);
-
// Set "dead" zones (never will get focus)
this.__header.setKeepFocus(true);
this.__toolBar.setKeepFocus(true);
@@ -103,29 +91,67 @@ qx.Class.define("cascadae.Container",
finalize : function()
{
- var container = this;
+ qx.event.Timer.once(this._initToolBar, this, 100);
+ },
+
+ _initToolBar: function()
+ {
+ this.__toolBar.finalize();
+ qx.event.Timer.once(this._initMainTable, this, 100);
+ },
+
+ _initMainTable: function()
+ {
+ var socket = this.__socket;
+ this.__table = new cascadae.Table();
+ this.__socket.addListener("rd_logEvent", this.__table.logHandler, this.__table);
+ this.__mainStack.add(this.__table);
+ socket.registerObject(this.__table);
+
+ this.setEnabled(false);
+ socket.addListener("connect", this.__setEnabled, this);
+ socket.addListener("disconnect", this.__setDisabled, this);
+
+ this._initToolbarButtonActivation();
+// this._initToolbarFileButtonActivation();
// Do heavy calculations in idle time
// document.setTimeout
- qx.event.Timer.once(container._initViews, container, 3000);
+ qx.event.Timer.once(this._initViews, this, 3000);
},
_initViews : function()
{
- if (!this.__table) throw("Init the main table first!");
+ if (!this.__table) {
+ // main table is not ready
+ qx.event.Timer.once(this._initViews, this, 3000);
+ return;
+ }
this.__peersTable = new cascadae.peers.Table();
this.__peersTable.initFilters(this.__table);
this.__socket.registerObject(this.__peersTable);
+ qx.event.Timer.once(this._initViews2, this, 300);
+ },
+ _initViews2 : function()
+ {
this.__logTable = new cascadae.log.Table();
this.__logTable.initFilters(this.__table);
this.__socket.registerObject(this.__logTable);
this.__socket.addListener("rd_logEvent", this.__logTable.logHandler, this.__logTable);
+ qx.event.Timer.once(this._initViews3, this, 300);
+ },
+ _initViews3 : function()
+ {
this.__filesTree = new cascadae.files.Tree();
this.__socket.registerObject(this.__filesTree);
+ qx.event.Timer.once(this._initViews4, this, 300);
+ },
+ _initViews4 : function()
+ {
// There is property binding here.
// If table.torrentId will changed, than __filesTree.torrentId will be
// changed too.
@@ -168,18 +194,24 @@ qx.Class.define("cascadae.Container",
});
},
+ __lastButtonSetName : "torrent_table",
__focusInHandler : function(e)
{
var t = e.getTarget();
var n = this.getName(t);
- this.__toolBar.activate(n);
+ if (n && this.__lastButtonSetName != n)
+ {
+ this.__toolBar.deactivate(this.__lastButtonSetName);
+ this.__toolBar.activate(n);
+ this.__lastButtonSetName = n;
+ }
},
__focusOutHandler : function(e)
{
- var t = e.getTarget();
- var n = this.getName(t);
- this.__toolBar.deactivate(n);
+// var t = e.getTarget();
+// var n = this.getName(t);
+// this.__toolBar.deactivate(n);
},
getName: function(t)
View
205 q_src/class/cascadae/ToolBar.js
@@ -57,105 +57,6 @@ qx.Class.define("cascadae.ToolBar",
{
this.base(arguments);
this.__controller = controller;
-
- this.__reconnectBtn = new qx.ui.toolbar.Button(this.tr("Reconnect"),
- "icon/22/devices/network-wired.png");
- this.__reconnectBtn.setCommand(controller.getCommand("reconnect"));
-
- this.__reloadBtn = new qx.ui.toolbar.Button(this.tr("Refresh"),
- "icon/22/actions/view-refresh.png");
- this.__reloadBtn.setCommand(controller.getCommand("reload"));
-
- // Add/Remove buttons
- this.__addBtn = new qx.ui.toolbar.Button(this.tr("Add"),
- "icon/22/actions/list-add.png");
- this.__addBtn.setCommand(controller.getCommand("addTorrent"));
-
- this.__removeBtn = new qx.ui.toolbar.Button(this.tr("Remove"),
- "icon/22/actions/list-remove.png");
- this.__removeBtn.setCommand(controller.getCommand("removeSelectedRows"));
-
- this.__startBtn = new qx.ui.toolbar.Button(this.tr("Start"),
- "icon/22/actions/media-playback-start.png");
- this.__startBtn.setCommand(controller.getCommand("startSelectedRows"));
-
- this.__stopBtn = new qx.ui.toolbar.Button(this.tr("Pause"),
- "icon/22/actions/media-playback-pause.png");
- this.__stopBtn.setCommand(controller.getCommand("stopSelectedRows"));
-
- this.__wishBtn = new qx.ui.toolbar.Button(this.tr("Wish files"),
- "icon/22/actions/dialog-apply.png");
- this.__wishBtn.setCommand(controller.getCommand("wishSelectedFiles"));
-
- this.__skipBtn = new qx.ui.toolbar.Button(this.tr("Skip files"),
- "icon/22/actions/dialog-close.png");
- this.__skipBtn.setCommand(controller.getCommand("skipSelectedFiles"));
-
- this.__unskipBtn = new qx.ui.toolbar.Button(this.tr("Unskip files"),
- "icon/22/actions/dialog-cancel.png");
- this.__unskipBtn.setCommand(controller.getCommand("unskipSelectedFiles"));
-
- this.__peersView = new qx.ui.toolbar.RadioButton(this.tr("Peers"),
- "icon/22/apps/preferences-users.png");
- this.__peersView.setUserData("value", "peers");
-
- this.__filesView = new qx.ui.toolbar.RadioButton(this.tr("Files"),
- "icon/22/places/folder-open.png");
- this.__filesView.setUserData("value", "files");
-
- this.__wishesView = new qx.ui.toolbar.RadioButton(this.tr("Wishes"),
- "icon/22/actions/view-sort-descending.png");
- this.__wishesView.setUserData("value", "wishlist");
-
- this.__logView = new qx.ui.toolbar.RadioButton(this.tr("Log"),
- "icon/22/apps/utilities-log-viewer.png");
- this.__logView.setUserData("value", "log");
-
- this.__ctrlButtons = new qx.ui.toolbar.Part;
- this.__viewButtons = new qx.ui.toolbar.Part;
- this.__fileButtons = new qx.ui.toolbar.Part;
- this.__mainButtons = new qx.ui.toolbar.Part;
-
- this.__ctrlButtons.add(this.__reconnectBtn);
-// this.__ctrlButtons.add(this.__reloadBtn);
-
- this.__viewButtons.add(this.__peersView);
- this.__viewButtons.add(this.__filesView);
- this.__viewButtons.add(this.__wishesView);
- this.__viewButtons.add(this.__logView);
-
- this.__viewGroup = new qx.ui.form.RadioGroup;
- this.__viewGroup.setAllowEmptySelection(true);
- this.__viewGroup.add(this.__logView);
- this.__viewGroup.add(this.__filesView);
- this.__viewGroup.add(this.__wishesView);
- this.__viewGroup.add(this.__peersView);
- this.__viewGroup.addListener("changeSelection", controller.syncStackView,
- controller);
-
- this.__fileButtons.add(this.__wishBtn);
- this.__fileButtons.add(this.__skipBtn);
- this.__fileButtons.add(this.__unskipBtn);
-
-// this.__mainButtons.add(this.__removeBtn);
- this.__mainButtons.add(this.__addBtn);
- this.__mainButtons.add(this.__startBtn);
- this.__mainButtons.add(this.__stopBtn);
-
- this.add(this.__ctrlButtons);
- this.add(this.__mainButtons);
- this.__spacer = this.addSpacer();
- this.add(this.__viewButtons);
-
-
- this.__addRadioCommand("showPeerView", this.__peersView);
- this.__addRadioCommand("showFileView", this.__filesView);
- this.__addRadioCommand("showWishView", this.__wishesView);
- this.__addRadioCommand("showLogView", this.__logView);
-
- this.enableRowButtons(false);
- this.enableFileRowButtons(false);
- this.activate("torrent_table");
},
members :
@@ -163,6 +64,112 @@ qx.Class.define("cascadae.ToolBar",
__isRowButtonsEnabled : false,
__isFileRowButtonsEnabled : false,
+ finalize : function()
+ {
+ var controller = this.__controller;
+
+ this.__reconnectBtn = new qx.ui.toolbar.Button(this.tr("Reconnect"),
+ "icon/22/devices/network-wired.png");
+ this.__reconnectBtn.setCommand(controller.getCommand("reconnect"));
+
+ this.__reloadBtn = new qx.ui.toolbar.Button(this.tr("Refresh"),
+ "icon/22/actions/view-refresh.png");
+ this.__reloadBtn.setCommand(controller.getCommand("reload"));
+
+ // Add/Remove buttons
+ this.__addBtn = new qx.ui.toolbar.Button(this.tr("Add"),
+ "icon/22/actions/list-add.png");
+ this.__addBtn.setCommand(controller.getCommand("addTorrent"));
+
+ this.__removeBtn = new qx.ui.toolbar.Button(this.tr("Remove"),
+ "icon/22/actions/list-remove.png");
+ this.__removeBtn.setCommand(controller.getCommand("removeSelectedRows"));
+
+ this.__startBtn = new qx.ui.toolbar.Button(this.tr("Start"),
+ "icon/22/actions/media-playback-start.png");
+ this.__startBtn.setCommand(controller.getCommand("startSelectedRows"));
+
+ this.__stopBtn = new qx.ui.toolbar.Button(this.tr("Pause"),
+ "icon/22/actions/media-playback-pause.png");
+ this.__stopBtn.setCommand(controller.getCommand("stopSelectedRows"));
+
+ this.__wishBtn = new qx.ui.toolbar.Button(this.tr("Wish files"),
+ "icon/22/actions/dialog-apply.png");
+ this.__wishBtn.setCommand(controller.getCommand("wishSelectedFiles"));
+
+ this.__skipBtn = new qx.ui.toolbar.Button(this.tr("Skip files"),
+ "icon/22/actions/dialog-close.png");
+ this.__skipBtn.setCommand(controller.getCommand("skipSelectedFiles"));
+
+ this.__unskipBtn = new qx.ui.toolbar.Button(this.tr("Unskip files"),
+ "icon/22/actions/dialog-cancel.png");
+ this.__unskipBtn.setCommand(controller.getCommand("unskipSelectedFiles"));
+
+ this.__peersView = new qx.ui.toolbar.RadioButton(this.tr("Peers"),
+ "icon/22/apps/preferences-users.png");
+ this.__peersView.setUserData("value", "peers");
+
+ this.__filesView = new qx.ui.toolbar.RadioButton(this.tr("Files"),
+ "icon/22/places/folder-open.png");
+ this.__filesView.setUserData("value", "files");
+
+ this.__wishesView = new qx.ui.toolbar.RadioButton(this.tr("Wishes"),
+ "icon/22/actions/view-sort-descending.png");
+ this.__wishesView.setUserData("value", "wishlist");
+
+ this.__logView = new qx.ui.toolbar.RadioButton(this.tr("Log"),
+ "icon/22/apps/utilities-log-viewer.png");
+ this.__logView.setUserData("value", "log");
+
+ this.__ctrlButtons = new qx.ui.toolbar.Part;
+ this.__viewButtons = new qx.ui.toolbar.Part;
+ this.__fileButtons = new qx.ui.toolbar.Part;
+ this.__mainButtons = new qx.ui.toolbar.Part;
+
+ this.__ctrlButtons.add(this.__reconnectBtn);
+// this.__ctrlButtons.add(this.__reloadBtn);
+
+ this.__viewButtons.add(this.__peersView);
+ this.__viewButtons.add(this.__filesView);
+ this.__viewButtons.add(this.__wishesView);
+ this.__viewButtons.add(this.__logView);
+
+ this.__viewGroup = new qx.ui.form.RadioGroup;
+ this.__viewGroup.setAllowEmptySelection(true);
+ this.__viewGroup.add(this.__logView);
+ this.__viewGroup.add(this.__filesView);
+ this.__viewGroup.add(this.__wishesView);
+ this.__viewGroup.add(this.__peersView);
+ this.__viewGroup.addListener("changeSelection", controller.syncStackView,
+ controller);
+
+ this.__fileButtons.add(this.__wishBtn);
+ this.__fileButtons.add(this.__skipBtn);
+ this.__fileButtons.add(this.__unskipBtn);
+
+// this.__mainButtons.add(this.__removeBtn);
+ this.__mainButtons.add(this.__addBtn);
+ this.__mainButtons.add(this.__startBtn);
+ this.__mainButtons.add(this.__stopBtn);
+
+ this.add(this.__ctrlButtons);
+ this.add(this.__mainButtons);
+ this.__spacer = this.addSpacer();
+ this.add(this.__viewButtons);
+
+
+ this.__addRadioCommand("showPeerView", this.__peersView);
+ this.__addRadioCommand("showFileView", this.__filesView);
+ this.__addRadioCommand("showWishView", this.__wishesView);
+ this.__addRadioCommand("showLogView", this.__logView);
+
+ this.enableRowButtons(false);
+ this.enableFileRowButtons(false);
+ this.activate("torrent_table");
+
+ this.setEnabled(false);
+ },
+
__addRadioCommand : function(name, btn)
{
View
6 q_src/class/cascadae/files/Tree.js
@@ -157,7 +157,6 @@ qx.Class.define("cascadae.files.Tree",
addRows : function(tid, /*sid*/ parent_sid, rows)
{
- this.info("addRows");
var dm = this.getDataModel();
var n2p = this.__n2p;
var ids = this.__ids;
@@ -189,10 +188,8 @@ qx.Class.define("cascadae.files.Tree",
var is_empty = row.capacity == 0;
var is_open = -1 != this.__openSids[tid].indexOf(sid);
var icon = this.__folderIcon(mode, is_open);
- this.info("B - addBranch");
var nid = dm.addBranch(parent_nid, name, is_open, is_empty,
icon, icon);
- this.info("E - addBranch");
}
}
// save indexes
@@ -639,9 +636,7 @@ qx.Class.define("cascadae.files.Tree",
var tid = this.getTorrentId(),
dm = this.getDataModel();
var dirSids = this.__dirSids;
- this.info("Saving selection.");
var selected = dm.getSelection();
- this.info("Save selection.");
this.__clearState();
this.__dirSids = dirSids;
// this.__openSids[tid] is the same.
@@ -655,7 +650,6 @@ qx.Class.define("cascadae.files.Tree",
this.addRows(tid, parent_sid, rows);
}
- console.dir(selected);
// update data in the table
dm.setData();
dm.setSelection(selected);

0 comments on commit 587d417

Please sign in to comment.
Something went wrong with that request. Please try again.