Permalink
Browse files

removed single column browsing

updated version info
ZeroClipboard implemented
  • Loading branch information...
1 parent 1c6cb2b commit 907027895f8eb1d59fa7069b7abb1cbd3e22b3b1 tomek committed Oct 10, 2012
View
@@ -5,7 +5,7 @@
<groupId>com.kuprowski</groupId>
<artifactId>helenos</artifactId>
- <version>1.1</version>
+ <version>1.2</version>
<packaging>war</packaging>
<name>helenos</name>
<developers>
@@ -46,7 +46,7 @@
"CACHE" : "${TMPDIR}/qx${QOOXDOO_VERSION}/cache",
"ROOT" : ".",
"BUILD_PATH" : "../../../target/helenos-${HELENOS_VER}/gui/",
- "HELENOS_VER" : "1.1"
+ "HELENOS_VER" : "1.2"
},
"jobs" :
@@ -8,7 +8,9 @@ Authors:
************************************************************************ */
/* ************************************************************************
#asset(helenos/*)
+#asset(ZeroClipboard*.*)
************************************************************************ */
+
/**
* This is the main application class of your custom application "helenos"
*/
@@ -42,6 +44,7 @@ qx.Class.define("helenos.Application",
}
qx.locale.Manager.getInstance().setLocale("en");
+ qx.Class.include(qx.ui.treevirtual.TreeVirtual, qx.ui.table.MTableContextMenu);
this.getRoot().add(new helenos.components.TopComposite(), {
edge : 0
});
@@ -27,8 +27,11 @@ qx.Class.define('helenos.components.menu.ColumnFamilyContextMenu',
propsButton.addListener('execute', this.__showProperties);
this.add(propsButton);
- var browserMenu = new qx.ui.menu.Button('Browse', null, null, this.__getBrowseSubMenu(ksName, cfName));
- this.add(browserMenu);
+ var browseButton = new qx.ui.menu.Button('Browse data', 'icon/16/apps/office-spreadsheet.png');
+ browseButton.setUserData('KSNAME', ksName);
+ browseButton.setUserData('CFNAME', cfName);
+ browseButton.addListener('execute', this.__showBrowseByPredicatePane);
+ this.add(browseButton);
this.add(new qx.ui.menu.Separator());
@@ -49,29 +52,9 @@ qx.Class.define('helenos.components.menu.ColumnFamilyContextMenu',
__showProperties : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
var cfName = e.getTarget().getUserData('CFNAME');
-
helenos.util.GuiObserver.showColumnFamilyInfoTab(ksName, cfName);
},
- __getBrowseSubMenu : function(ksName, cfName) {
- var menu = new qx.ui.menu.Menu();
-
- var byKeyButton = new qx.ui.menu.Button('Single column', 'icon/16/apps/utilities-keyring.png');
- byKeyButton.setUserData('KSNAME', ksName);
- byKeyButton.setUserData('CFNAME', cfName);
- byKeyButton.addListener('execute', this.__showBrowseBySingleColumnPane);
-
- var predicateButton = new qx.ui.menu.Button('Predicate', 'icon/16/apps/office-spreadsheet.png');
- predicateButton.setUserData('KSNAME', ksName);
- predicateButton.setUserData('CFNAME', cfName);
- predicateButton.addListener('execute', this.__showBrowseByPredicatePane);
-
- menu.add(byKeyButton);
- menu.add(predicateButton);
- //menu.add(keyRangeButton);
- return menu;
- },
-
/**
* @lint ignoreUndefined(dialog)
*/
@@ -86,12 +69,6 @@ qx.Class.define('helenos.components.menu.ColumnFamilyContextMenu',
}, this);
},
- __showBrowseBySingleColumnPane : function(e) {
- var ksName = e.getTarget().getUserData('KSNAME');
- var cfName = e.getTarget().getUserData('CFNAME');
- helenos.util.GuiObserver.showBrowseBySingleColumnTab(ksName, cfName);
- },
-
__showBrowseByPredicatePane : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
var cfName = e.getTarget().getUserData('CFNAME');
@@ -25,7 +25,7 @@ qx.Class.define("helenos.components.tab.browse.PredicatePage",
__keyFromTF : null,
__keyToTF : null,
- __keyMode : null,
+ __keyMode : 'predicate',
__nameStartTF : null,
__nameEndTF : null,
@@ -36,6 +36,8 @@ qx.Class.define("helenos.components.tab.browse.PredicatePage",
__rangeFromToCP : null,
__reversedCB : null,
+ _tree : null,
+
_performSearch : function(e) {
var keyFrom = this.__keyFromTF.getValue();
var keyTo = this.__keyToTF.getValue();
@@ -60,29 +62,11 @@ qx.Class.define("helenos.components.tab.browse.PredicatePage",
},
_getResultComponent : function(result) {
- var tree = new qx.ui.treevirtual.TreeVirtual(["Name", "Value", "Clock", "TTL"]);
- tree.setAlwaysShowOpenCloseSymbol(true);
- tree.setUseTreeLines(true);
+ this._tree = new helenos.ui.treevirtual.ResultsTree(result);
+
var tablePane = new qx.ui.core.scroll.ScrollPane().set({allowGrowX : true, allowGrowY : true});
- var i;
- var dataModel = tree.getDataModel();
-
- //var branch = dataModel.addBranch(null, this.__keyTF.getValue(), true);
- for(i = 0; i < result.length; i++) {
- var row = result[i];
- var branch = dataModel.addBranch(null, row.key, true);
- var j;
- for (j = 0; j < row.columns.length; j++) {
- var col = row.columns[j];
- var leaf = dataModel.addLeaf(branch, col.name);
- dataModel.setColumnData(leaf, 1, col.value);
- dataModel.setColumnData(leaf, 2, col.clock);
- dataModel.setColumnData(leaf, 3, col.ttl);
- }
- }
- dataModel.setData();
- tablePane.add(tree);
+ tablePane.add(this._tree);
return tablePane;
},
@@ -1,80 +0,0 @@
-/* ************************************************************************
-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.components.tab.browse.SingleColumnPage",
-{
- extend : helenos.components.tab.browse.AbstractBrowsePage,
-
- construct : function(ksName, cfName)
- {
- this.base(arguments, ksName, cfName);
- this.set({
- icon : 'icon/16/apps/utilities-keyring.png'
- });
- },
-
- members :
- {
- __keyTF : null,
- __nameTF : null,
- __sNameTF : null,
-
- _performSearch : function(e) {
- var key = this.__keyTF.getValue();
- var name = this.__nameTF.getValue();
- var sName = (this.__sNameTF == null ? null : this.__sNameTF.getValue());
- var column = helenos.util.RpcActionsProvider.querySingleColumn(this._cfDef, key, name, sName );
-
- this._resultView.removeAll();
- if (this._rajCB.getValue()) {
- this._resultView.add(this._getTreeFromJson(key, column.value), {flex: 1});
-
- } else {
- this._resultView.add(new helenos.ui.CompositeH([new qx.ui.basic.Label('Value'),
- new qx.ui.form.TextArea(column.value)]), {flex: 1});
- }
-
- this._resultView.add(this._getDetailsBox(column));
- },
-
- _getDetailsBox : function(column) {
- return new helenos.ui.CompositeH([
- new helenos.ui.BoldLabel('Column name:'),
- new qx.ui.form.TextField('' + column.name).set({width: 180}),
- new helenos.ui.BoldLabel('Clock:'),
- new qx.ui.form.TextField('' + column.clock).set({width: 150}),
- new helenos.ui.BoldLabel('TTL:'),
- new qx.ui.form.TextField('' + column.ttl).set({width: 150})
- ]);
- },
-
- _getCriteriaComponents : function() {
- var ret = new Array();
- this.__keyTF = new helenos.ui.RequiredTextField(this._cfDef.keyValidationClass);
- this.__nameTF = new helenos.ui.RequiredTextField(this._cfDef.comparatorType.className);
- this._manager.add(this.__keyTF);
- this._manager.add(this.__nameTF);
- //var searchButton = this._getSearchButton();
-
- ret.push(new helenos.ui.CompositeV([new qx.ui.basic.Label('Key:'), this.__keyTF]));
-
- if (this._cfDef.columnType == 'Super') {
- this.__sNameTF = new helenos.ui.RequiredTextField(this._cfDef.subComparatorType.className);
- this._manager.add(this.__sNameTF);
- ret.push(new helenos.ui.CompositeV([new qx.ui.basic.Label('Super column name:'), this.__sNameTF]));
- }
-
- ret.push(new helenos.ui.CompositeV([new qx.ui.basic.Label('Column name:'), this.__nameTF]));
- //filterGB.add(searchButton);
- //filterGB.add(this._rajCB);
-
- //this.add(filterGB);
- return ret;
- }
- }
-});
@@ -0,0 +1,72 @@
+/* ************************************************************************
+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.ui.treevirtual.ResultsTree",
+{
+ extend : qx.ui.treevirtual.TreeVirtual,
+
+ construct : function(data)
+ {
+ this.base(arguments, ["Name", "Value", "Clock", "TTL"]);
+ this.set({alwaysShowOpenCloseSymbol : true, useTreeLines : true});
+
+ var resizeBehavior = this.getTableColumnModel().getBehavior();
+ resizeBehavior.set(1, { width:"1*", minWidth:200 });
+ resizeBehavior.setWidth(3, 60);
+
+ this.setData(data);
+
+ ZeroClipboard.setMoviePath("resource/ZeroClipboard10.swf");
+ this.setContextMenuHandler(0, this._contextMenuHandler);
+ this.setContextMenuHandler(1, this._contextMenuHandler);
+ this.setContextMenuHandler(2, this._contextMenuHandler);
+ this.setContextMenuHandler(3, this._contextMenuHandler);
+ },
+
+ members : {
+
+ _contextMenuHandler : function(col, row, table, dataModel, contextMenu) {
+ var copyBtn = new qx.ui.menu.Button('Copy to clipboard');
+ var clip = new ZeroClipboard.Client();
+
+ clip.addEventListener('complete', function (client, text) {
+ client.destroy();
+ },this);
+ if (!table.getSelectionModel().isSelectionEmpty()) {
+ var text = dataModel.getValue(col, row);
+ clip.setText(text);
+ }
+
+ copyBtn.addListener("appear", function(e) {
+ clip.glue(e.getTarget().getContentElement().getDomElement());
+ }, this);
+
+ contextMenu.add(copyBtn);
+ return true;
+ },
+
+ setData : function(data) {
+ var dataModel = this.getDataModel();
+
+ var i;
+ for(i = 0; i < data.length; i++) {
+ var row = data[i];
+ var branch = dataModel.addBranch(null, row.key, true);
+ var j;
+ for (j = 0; j < row.columns.length; j++) {
+ var col = row.columns[j];
+ var leaf = dataModel.addLeaf(branch, col.name);
+ dataModel.setColumnData(leaf, 1, col.value);
+ dataModel.setColumnData(leaf, 2, col.clock);
+ dataModel.setColumnData(leaf, 3, col.ttl);
+ }
+ }
+ dataModel.setData();
+ }
+ }
+});
@@ -35,12 +35,6 @@ qx.Class.define("helenos.util.GuiObserver",
this._addPageToTab(ksPage);
},
- showBrowseBySingleColumnTab : function(keyspaceName, columnFamily) {
- qx.core.Assert.assertNotNull(this.__tabbedPane,'tabbed pane not registered yet');
- var dataPage = new helenos.components.tab.browse.SingleColumnPage(keyspaceName, columnFamily);
- this._addPageToTab(dataPage);
- },
-
showBrowseByPredicateTab : function(keyspaceName, columnFamily) {
qx.core.Assert.assertNotNull(this.__tabbedPane,'tabbed pane not registered yet');
var dataPage = new helenos.components.tab.browse.PredicatePage(keyspaceName, columnFamily);
@@ -118,27 +118,6 @@ qx.Class.define('helenos.util.RpcActionsProvider', {
return rpc.callSync('createKeyspace', formData);
},
- querySingleColumn : function(cfDef, key, name, sName) {
- var query = {};
-
- query.keyClass = this.__findParamClass(cfDef.keyValidationClass);
- query.nameClass = this.__findParamClass(cfDef.comparatorType.className);
- query.keyspace = cfDef.keyspaceName;
- query.columnFamily = cfDef.name;
- query.key = key;
- query.name = name;
-
- var rpc = null;
- if (cfDef.columnType == 'Standard') {
- rpc = new helenos.util.Rpc(this._STANDARDQUERY);
- } else {
- rpc = new helenos.util.Rpc(this._SUPERQUERY);
- query.sNameClass = this.__findParamClass(cfDef.subComparatorType.className);
- query.sName = sName;
- }
- return rpc.callSync('singleColumn', query );
- },
-
queryPredicate : function(cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed ) {
var query = {};
@@ -4,7 +4,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Helenos</title>
<link rel="icon" type="image/ico" href="/helenos/resource/favicon.ico"/>
+ <script type="text/javascript" src="resource/ZeroClipboard.js"></script>
<script type="text/javascript" src="script/helenos.js"></script>
+
</head>
<body></body>
</html>
Oops, something went wrong.

0 comments on commit 9070278

Please sign in to comment.