Permalink
Browse files

fixed issue 4

  • Loading branch information...
1 parent cf8257e commit e5f61e16bdc24b538717917ece52cbf238e789eb tomek committed Sep 21, 2012
@@ -644,7 +644,7 @@ qx.Class.define("dialog.Form",
this.hide();
if( this.getCallback() )
{
- this.getCallback()( qx.util.Serializer.toNativeObject( this.getModel() ) );
+ this.getCallback()(this.getContext(), qx.util.Serializer.toNativeObject( this.getModel() ) );
}
this.resetCallback();
}
@@ -20,6 +20,7 @@ qx.Class.define("helenos.components.RightContentPane",
construct : function()
{
this.base(arguments);
+ this.setContentPadding(3);
this.add(new helenos.components.tab.WelcomePage());
}
});
@@ -62,6 +62,9 @@ qx.Class.define("helenos.components.SchemaPane",
this.refreshSchemaTree();
},
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
__addKeyspace : function() {
var formData = {
'keyspaceName' : {
@@ -90,12 +93,12 @@ qx.Class.define("helenos.components.SchemaPane",
}
}
};
- dialog.Dialog.form('<h4>Create new keyspace</h4>', formData, function(result) {
+ dialog.Dialog.form('<h3>Create new keyspace</h3>', formData, function(context, result) {
if (result != null) {
helenos.util.RpcActionsProvider.createKeyspace(result);
helenos.util.GuiObserver.refreshSchemaTree();
}
- });
+ }, this);
},
refreshSchemaTree : function() {
@@ -71,13 +71,16 @@ qx.Class.define('helenos.components.menu.ColumnFamilyContextMenu',
return menu;
},
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
__truncateColumnFamily : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
var cfName = e.getTarget().getUserData('CFNAME');
dialog.Dialog.confirm(this.tr('loss.data.alert'), function(ret) {
if (ret == true) {
helenos.util.RpcActionsProvider.truncateColumnFamily(ksName, cfName);
- //helenos.util.GuiObserver.refreshSchemaTree();
+ helenos.util.GuiObserver.refreshSchemaTree();
}
}, this);
},
@@ -94,6 +97,9 @@ qx.Class.define('helenos.components.menu.ColumnFamilyContextMenu',
helenos.util.GuiObserver.showBrowseBySliceTab(ksName, cfName);
},
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
__dropColumnFamily : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
var cfName = e.getTarget().getUserData('CFNAME');
@@ -43,6 +43,9 @@ qx.Class.define('helenos.components.menu.KeyspaceContextMenu',
helenos.util.GuiObserver.showKeyspaceInfoTab(ksName);
},
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
__dropKeyspace : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
dialog.Dialog.confirm(this.tr('loss.data.alert'), function(ret) {
@@ -53,6 +56,9 @@ qx.Class.define('helenos.components.menu.KeyspaceContextMenu',
}, this);
},
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
__addColumnFamily : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
var formData = {
@@ -124,13 +130,13 @@ qx.Class.define('helenos.components.menu.KeyspaceContextMenu',
'value' : ''
}
};
- dialog.Dialog.form('<h4>Create new column family</h4>', formData, function(result) {
+ dialog.Dialog.form('<h4>Create new column family</h4>', formData, function(context, result) {
if (result != null) {
result['keyspaceName'] = ksName;
helenos.util.RpcActionsProvider.createColumnFamily(result);
helenos.util.GuiObserver.refreshSchemaTree();
}
- });
+ }, this);
}
}
});
@@ -114,7 +114,10 @@ qx.Class.define("helenos.components.tab.ColumnFamilyInfoPage",
var gb = new qx.ui.groupbox.GroupBox('Column metadata');
gb.setLayout(new qx.ui.layout.VBox());
- gb.add(table, {flex : 1});
+ var sp = new qx.ui.core.scroll.ScrollPane();
+ sp.add(table);
+
+ gb.add(sp, {flex : 1});
this.add(gb, {flex : 1});
}
}
@@ -8,6 +8,9 @@ Authors:
************************************************************************ */
/*
#asset(qx/icon/${qx.icontheme}/16/devices/network-wired.png)
+#asset(qx/icon/${qx.icontheme}/16/actions/list-add.png)
+#asset(qx/icon/${qx.icontheme}/16/actions/edit-cut.png)
+#asset(qx/icon/${qx.icontheme}/16/actions/list-remove.png)
*/
qx.Class.define("helenos.components.tab.ConnectionsEditorPage",
{
@@ -27,57 +30,188 @@ qx.Class.define("helenos.components.tab.ConnectionsEditorPage",
icon: 'icon/16/devices/network-wired.png',
layout: new qx.ui.layout.VBox(3, 'top')
});
-
-
+
+ this.__addConnectionsTable();
},
members :
{
- __addNameAtom : function(ksDef) {
- var atom = new helenos.ui.RichAtom('Keyspace: <b>' + ksDef.name + '</b>', "icon/64/status/dialog-information.png");
- atom.setFont(new qx.bom.Font(22, ["OpenSansRegular", "Helvetica Neue", "Helvetica", "Arial", "sans-serif"]));
- this.add(atom);
- },
-
- __addBasicInfoGroup : function(ksDef) {
- var gb = new qx.ui.groupbox.GroupBox('Basic');
- gb.setLayout(new qx.ui.layout.VBox());
+ __connectionsTable : null,
+ __addButton : null,
+ __connectButton : null,
+ __editButton : null,
+ __deleteButton : null,
+
+ __addConnectionsTable : function() {
+ this.__connectionsTable = new qx.ui.table.Table(new helenos.remote.ConnectionsTableModel());
+ this.__connectionsTable.getTableColumnModel().setDataCellRenderer(3, new qx.ui.table.cellrenderer.Boolean());
+ this.__connectionsTable.getSelectionModel().addListener('changeSelection', this.__onTableSelectionChanged, this);
- var a1 = new helenos.ui.RichAtom('Strategy class: <b>' + ksDef.strategyClass + '</b>');
- var a2 = new helenos.ui.RichAtom('Replication factor: <b>' + ksDef.replicationFactor + '</b>');
+ var gb = new qx.ui.groupbox.GroupBox('Available connections');
+ gb.setLayout(new qx.ui.layout.VBox(5));
- gb.add(a1);
- gb.add(a2);
- this.add(gb);
+ var sp = new qx.ui.core.scroll.ScrollPane();
+ sp.add(this.__connectionsTable);
+
+ gb.add(sp, {
+ flex : 1
+ });
+ gb.add(this.__getActionButtonsPane());
+ this.add(gb, {
+ flex : 1
+ });
},
- __addCFTable : function(ksDef) {
- var tableModel = new qx.ui.table.model.Simple();
- tableModel.setColumns(['Id','Name','Type', 'Comparator', 'Sub comparator', 'Key validation','Default validation','Row cache', 'Key cache', 'GC grace sec'],['id','name','columnType','comparatorType_typeName', 'subComparatorType_typeName', 'keyValidationClass_normalized','defaultValidationClass_normalized','rowCacheSize', 'keyCacheSize', 'gcGraceSeconds']);
-
- // qx.lang.Core.arrayForEach(this.__convertCF, ksDef.cfDefs);
+ __getActionButtonsPane : function() {
+ var pane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'right'));
+ this.__addButton = new qx.ui.form.Button('Add', 'icon/16/actions/list-add.png');
+ this.__addButton.addListener('execute', this.__onAddConnection, this);
- tableModel.setDataAsMapArray(ksDef.cfDefs.map(this.__convertCF));
- //alert(qx.lang.Object.getKeysAsString(ksDef.cfDefs[0]));
- var table = new qx.ui.table.Table(tableModel);
+ this.__connectButton = new qx.ui.form.Button('Connect to', 'helenos/connect.png');
+ this.__connectButton.addListener('execute', this.__onConnectToConnection, this);
+ this.__connectButton.setEnabled(false);
- var gb = new qx.ui.groupbox.GroupBox('Column families');
- gb.setLayout(new qx.ui.layout.VBox());
+ this.__deleteButton = new qx.ui.form.Button('Delete', 'icon/16/actions/list-remove.png');
+ this.__deleteButton.addListener('execute', this.__ondeleteConnection, this);
+ this.__deleteButton.setEnabled(false);
- gb.add(table, {flex : 1});
+ this.__editButton = new qx.ui.form.Button('Edit', 'icon/16/actions/edit-cut.png');
+ this.__editButton.addListener('execute', this.__onEditConnection, this);
+ this.__editButton.setEnabled(false);
- this.add(gb, {flex : 1});
+ pane.add(this.__addButton);
+ pane.add(this.__editButton);
+ pane.add(this.__connectButton);
+ pane.add(this.__deleteButton);
+ return pane;
+ },
+
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
+ __onAddConnection : function(e) {
+ var formData = {
+ 'alias' : {
+ 'type' : 'TextField',
+ 'label' : 'Alias (unique)',
+ 'value' : '',
+ 'validation' : {
+ 'required' : true
+ }
+ },
+ 'hosts' : {
+ 'type' : 'TextField',
+ 'label' : 'Hosts (comma separated)',
+ 'value' : '',
+ 'validation' : {
+ 'required' : true
+ }
+ },
+ 'clusterName' :
+ {
+ 'type' : 'TextArea',
+ 'label' : 'Cluster name',
+ 'lines' : 4,
+ 'value' : '',
+ 'validation' : {
+ 'required' : true
+ }
+ }
+ };
+ dialog.Dialog.form('<h3>Create connection</h3>', formData, function(context, result) {
+ if (result != null) {
+ result['active'] = false;
+ helenos.util.RpcActionsProvider.storeConnection(result);
+ context._reloadConnectionsTable();
+ }
+ }, this);
+ },
+
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
+ __onEditConnection : function(e) {
+ var alias = this.__getSelectedAlias();
+ var cc = helenos.util.RpcActionsProvider.getConnectionByAlias(alias);
+ var formData = {
+ 'hosts' : {
+ 'type' : 'TextField',
+ 'label' : 'Hosts (comma separated)',
+ 'value' : cc.hosts,
+ 'validation' : {
+ 'required' : true
+ }
+ },
+ 'clusterName' :
+ {
+ 'type' : 'TextField',
+ 'label' : 'Cluster name',
+ 'value' : cc.clusterName,
+ 'validation' : {
+ 'required' : true
+ }
+ }
+ };
+ dialog.Dialog.form('<h3>Edit connection</h3>', formData, function(context, result) {
+ if (result != null) {
+ result['alias'] = cc.alias;
+ result['active'] = cc.active;
+ helenos.util.RpcActionsProvider.storeConnection(result);
+ context._reloadConnectionsTable();
+ }
+ }, this);
},
- //TODO move 'replace' code to some helper obj
- __convertCF : function(obj ) {
- obj['comparatorType_typeName'] = obj.comparatorType.typeName;
- obj['subComparatorType_typeName'] = obj.subComparatorType ? obj.subComparatorType.typeName : '';
- obj['keyValidationClass_normalized'] = obj.keyValidationClass.replace('org.apache.cassandra.db.marshal.','');
- obj['defaultValidationClass_normalized'] = obj.defaultValidationClass.replace('org.apache.cassandra.db.marshal.','');
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
+ __ondeleteConnection : function(e) {
+ var selectionModel = this.__connectionsTable.getSelectionModel();
+ var selectedRow = selectionModel.getSelectedRanges()[0].minIndex;
+ var active = this.__connectionsTable.getTableModel().getValue(3, selectedRow);
- return obj;
- }
+ if (active == true) {
+ dialog.Dialog.error('Active connection can not be deleted !');
+ } else {
+ var alias = this.__connectionsTable.getTableModel().getValue(0, selectedRow);
+ dialog.Dialog.confirm(this.tr('are.you.sure'), function(ret) {
+ if (ret == true) {
+ helenos.util.RpcActionsProvider.deleteConnection(alias);
+ this._reloadConnectionsTable();
+ }
+ }, this);
+ }
+ },
+
+ _reloadConnectionsTable : function() {
+ this.__connectionsTable.resetSelection();
+ this.__connectionsTable.getTableModel().reloadData();
+ },
+ __getSelectedAlias : function() {
+ var selectedRow = this.__connectionsTable.getSelectionModel().getSelectedRanges()[0].minIndex;
+ return this.__connectionsTable.getTableModel().getValue(0, selectedRow);
+ },
+
+ /**
+ * @lint ignoreUndefined(dialog)
+ */
+ __onConnectToConnection : function(e) {
+ var alias = this.__getSelectedAlias();
+ dialog.Dialog.confirm(this.tr('are.you.sure'), function(ret) {
+ if (ret == true) {
+ helenos.util.RpcActionsProvider.activate(alias);
+ this._reloadConnectionsTable();
+ helenos.util.GuiObserver.refreshSchemaTree();
+ }
+ }, this);
+ },
+
+ __onTableSelectionChanged : function(e) {
+ var isSelected = !this.__connectionsTable.getSelectionModel().isSelectionEmpty();
+ this.__connectButton.setEnabled(isSelected);
+ this.__deleteButton.setEnabled(isSelected);
+ this.__editButton.setEnabled(isSelected);
+ }
}
});
@@ -70,7 +70,10 @@ qx.Class.define("helenos.components.tab.KeyspaceInfoPage",
var gb = new qx.ui.groupbox.GroupBox('Column families');
gb.setLayout(new qx.ui.layout.VBox());
- gb.add(table, {flex : 1});
+ var sp = new qx.ui.core.scroll.ScrollPane();
+ sp.add(table);
+
+ gb.add(sp, {flex : 1});
this.add(gb, {flex : 1});
},
@@ -0,0 +1,29 @@
+/* ************************************************************************
+Copyright:
+ 2012 Tomek Kuprowski
+License:
+ GPLv2: http://www.gnu.org/licences/gpl.html
+Authors:
+ Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ ************************************************************************ */
+
+qx.Class.define('helenos.remote.ConnectionsTableModel',
+{
+ extend: qx.ui.table.model.Remote,
+
+ construct: function() {
+ this.base(arguments);
+ this.setColumns(['Alias','Hosts','Cluster name', 'Active'],['alias','hosts','clusterName', 'active']);
+ },
+
+ members:
+ {
+ _loadRowCount : function() {
+ this._onRowCountLoaded(helenos.util.RpcActionsProvider.getConnectionsCount());
+ },
+
+ _loadRowData : function() {
+ this._onRowDataLoaded(helenos.util.RpcActionsProvider.getAllConnections());
+ }
+ }
+});
Oops, something went wrong.

0 comments on commit e5f61e1

Please sign in to comment.