You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by rv...@apache.org on 2015/07/03 21:21:42 UTC
[41/51] [partial] incubator-geode git commit: SGA #2
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/MiscellaneousPrefsPageIcon.png
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/MiscellaneousPrefsPageIcon.png b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/MiscellaneousPrefsPageIcon.png
new file mode 100644
index 0000000..09da2e2
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/MiscellaneousPrefsPageIcon.png differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/PartitionedRegion.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/PartitionedRegion.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/PartitionedRegion.ico
new file mode 100644
index 0000000..1b2f872
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/PartitionedRegion.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryPrefsPageIcon.png
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryPrefsPageIcon.png b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryPrefsPageIcon.png
new file mode 100644
index 0000000..09da2e2
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryPrefsPageIcon.png differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryResultsTablIcon.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryResultsTablIcon.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryResultsTablIcon.ico
new file mode 100644
index 0000000..813fafb
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryResultsTablIcon.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Region.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Region.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Region.ico
new file mode 100644
index 0000000..ca232e8
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Region.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Results.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Results.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Results.ico
new file mode 100644
index 0000000..687fa88
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Results.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityDisabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityDisabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityDisabled.PNG
new file mode 100644
index 0000000..94cd8b8
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityDisabled.PNG differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityEnabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityEnabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityEnabled.PNG
new file mode 100644
index 0000000..74f4db0
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityEnabled.PNG differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityPrefsPageIcon.png
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityPrefsPageIcon.png b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityPrefsPageIcon.png
new file mode 100644
index 0000000..09da2e2
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/SecurityPrefsPageIcon.png differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ServerGroup01.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ServerGroup01.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ServerGroup01.ico
new file mode 100644
index 0000000..4c14cc1
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ServerGroup01.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Statistics.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Statistics.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Statistics.ico
new file mode 100644
index 0000000..f4d5729
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Statistics.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Trace.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Trace.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Trace.ico
new file mode 100644
index 0000000..2363817
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Trace.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/splash.bmp
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/splash.bmp b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/splash.bmp
new file mode 100644
index 0000000..4a89361
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/splash.bmp differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/text-document-16x16.png
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/text-document-16x16.png b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/text-document-16x16.png
new file mode 100644
index 0000000..09da2e2
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/text-document-16x16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/AboutDlg.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/AboutDlg.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/AboutDlg.java
new file mode 100644
index 0000000..1bfc634
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/AboutDlg.java
@@ -0,0 +1,70 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Button;
+
+
+/**
+ * @author mghosh
+ *
+ */
+public class AboutDlg extends TitleAreaDialog {
+ private final String dialogText;
+ /**
+ * @param parentShell
+ */
+ public AboutDlg(Shell parentShell, String text) {
+ super(parentShell);
+ dialogText = text;
+ create();
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ getShell().setText("About GemFire DataBrowser");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ // MGH: Guaranteed by javadocs that the returned Control is a Composite
+ Composite ctrl = ( Composite )super.createDialogArea(parent);
+ Text text = new Text(ctrl, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.heightHint = 250;
+ data.widthHint = 450;
+ text.setLayoutData(data);
+
+ text.setText(dialogText);
+ return ctrl;
+ }
+
+ /*
+ * Add buttons to the dialog's button bar.
+ *
+ * @param parent
+ * the button bar composite
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ Button b = createButton(parent, IDialogConstants.OK_ID,
+ IDialogConstants.OK_LABEL, true);
+ b.setFocus();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQResultsPanel.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQResultsPanel.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQResultsPanel.java
new file mode 100644
index 0000000..6b58e28
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQResultsPanel.java
@@ -0,0 +1,546 @@
+/*=========================================================================
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+import com.gemstone.gemfire.cache.query.CqStatistics;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.CQQuery;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.EventData;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.event.ErrorEvent;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.event.ICQEvent;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.event.RowAdded;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.model.CQueryResultsInput;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.tree.ExploreAction;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+/**
+ * @author mjha
+ *
+ */
+public class CQResultsPanel extends Composite {
+ private static final int WIDTH = 100;
+
+ private List<TableViewer> tblResults_ = null;
+ private CTabFolder resultsContainer_;
+ private CQQuery query;
+ StatisticsPanel statsPanel;
+
+ private Text exceptions;
+
+ /**
+ * @param parent
+ * @param style
+ */
+ public CQResultsPanel(Composite parent, int style) {
+ super(parent, style);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+
+ this.setLayout(layout);
+
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+
+ SashForm sashForm= new SashForm(this, SWT.FLAT | SWT.VERTICAL);
+ layout = new GridLayout();
+ layout.numColumns = 1;
+ sashForm.setLayout(layout);
+ sashForm.setLayoutData(data);
+
+ Composite topComposite = new Composite(sashForm, SWT.NONE);
+ layout = new GridLayout();
+ layout.numColumns = 1;
+ topComposite.setLayout(layout);
+ data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ topComposite.setLayoutData(data);
+
+ data = new GridData(SWT.FILL, SWT.FILL, true, false);
+ ScrolledComposite scrolledComposite = new ScrolledComposite(topComposite,SWT.H_SCROLL| SWT.V_SCROLL);
+ scrolledComposite.setLayoutData(data);
+ GridLayout gridLayout = new GridLayout();
+ scrolledComposite.setLayout(gridLayout);
+ scrolledComposite.setMinWidth(400);
+ scrolledComposite.setMinHeight(40);
+ scrolledComposite.setExpandHorizontal(true);
+ scrolledComposite.setExpandVertical(true);
+
+ data = new GridData(SWT.FILL, SWT.FILL, true, false);
+ statsPanel = new StatisticsPanel(scrolledComposite);
+ statsPanel.setLayoutData(data);
+
+ scrolledComposite.setContent(statsPanel);
+
+ data = new GridData(SWT.FILL, SWT.FILL, true, true);
+
+ Composite subPanel = new Composite(topComposite, SWT.NONE);
+ subPanel.setLayoutData(data);
+
+ GridLayout fl = new GridLayout();
+ subPanel.setLayout(fl);
+ resultsContainer_ = new CTabFolder(subPanel, SWT.NONE);
+ resultsContainer_.setBorderVisible(true);
+
+ resultsContainer_.setSimple(false);
+ resultsContainer_.setUnselectedCloseVisible(true);
+ resultsContainer_.setUnselectedImageVisible(true);
+ // resultsContainer_.addControlListener(new
+ // ResultsTabFolderResizeHandler(this));
+ resultsContainer_
+ .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ fl = new GridLayout();
+ resultsContainer_.setLayout(fl);
+
+ addDummyTabs();
+
+ subPanel.layout();
+ // subPanel.pack();
+
+ {
+ Group group = new Group(sashForm, SWT.SHADOW_ETCHED_IN);
+ group.setText("CQ Console");
+ group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
+ GridLayout lytGrpDisc = new GridLayout();
+ lytGrpDisc.numColumns = 1;
+ group.setLayout(lytGrpDisc);
+
+ exceptions = new Text(group, SWT.MULTI | SWT.READ_ONLY | SWT.LEFT
+ | SWT.BORDER | SWT.V_SCROLL);
+ data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ exceptions.setLayoutData(data);
+ }
+
+ sashForm.setWeights(new int[]{80,20});
+
+ this.layout();
+ this.pack();
+
+ }
+
+ private void addDummyTabs() {
+ int iStyle = SWT.NONE;
+ iStyle |= SWT.BORDER;
+ CTabItem ti = new CTabItem(resultsContainer_, iStyle, 0);
+ ti.setText("Results");
+ ti.setControl(getDummyTable());
+ resultsContainer_.setSelection(0);
+ }
+
+ private Composite getDummyTable() {
+ Composite tableComp = new Composite(resultsContainer_, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ tableComp.setLayout(layout);
+ tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ TableViewer viewer = new TableViewer(tableComp, SWT.SINGLE
+ | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL);
+
+ TableLayout lytTable = new TableLayout();
+
+ for (int i = 0; i < 2; i++) {
+ lytTable.addColumnData(new ColumnPixelData(WIDTH, true));
+ }
+
+ viewer.getTable().setLayout(lytTable);
+ viewer.getTable().setHeaderVisible(true);
+ viewer.getTable().setLinesVisible(true);
+
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ viewer.getTable().setLayoutData(gd);
+
+ String colName = "Key";
+ TableColumn col = new TableColumn(viewer.getTable(), SWT.NONE, 0);
+ col.setText(colName);
+ col.setResizable(true);
+
+ colName = "Value";
+ col = new TableColumn(viewer.getTable(), SWT.NONE, 1);
+ col.setText(colName);
+ col.setResizable(true);
+
+ return tableComp;
+ }
+
+ public void setQuery(CQQuery qry) {
+ disposeOldResults();
+ addDummyTabs();
+ query = qry;
+ }
+
+ private void disposeOldResults() {
+ CTabItem[] items = resultsContainer_.getItems();
+ for (int i = 0; i < items.length; i++) {
+ items[i].getControl().dispose();
+ items[i].dispose();
+ }
+ if (tblResults_ != null) {
+ tblResults_.clear();
+ tblResults_ = null;
+ }
+ if (exceptions != null && !exceptions.isDisposed()) {
+ exceptions.setText("");
+ }
+ }
+
+ public void close() {
+ }
+
+ public void processCqEvent(ICQEvent cqEvent) {
+ if (cqEvent instanceof ErrorEvent) {
+ if (cqEvent.getThrowable() != null) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ cqEvent.getThrowable().printStackTrace(pw);
+ exceptions.append(sw.toString());
+
+ try {
+ pw.close();
+ sw.close();
+ } catch (IOException e) {
+ }
+ }
+ } else {
+ if (tblResults_ != null) {
+ for (int i = 0; i < tblResults_.size(); i++) {
+ TableViewer tableViewer = tblResults_.get(i);
+ synchronized (tableViewer) {
+ CQueryResultsInput input = (CQueryResultsInput) tableViewer
+ .getInput();
+ if( null != input ) {
+ input.processEvent(cqEvent);
+ }
+ }
+ }
+ }
+ }
+ statsPanel.update(query.getStatistics());
+ }
+
+ public void processNewTypeEvent(final IntrospectionResult result) {
+ if (tblResults_ == null)
+ disposeOldResults();
+
+ int iStyle = SWT.NONE;
+ iStyle |= SWT.BORDER;
+ int index = resultsContainer_.getItemCount();
+
+ // TODO FINDBUG MGH - false positive reported 'Dead store to local variable' on ti
+ CTabItem ti = new CTabItem(resultsContainer_, iStyle, index++);
+ CQDataTab dataTab = new CQDataTab(resultsContainer_, result);
+ dataTab.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ ti.setText(result.getJavaTypeName());
+ ti.setControl(dataTab);
+ CQResultsPanel.this.resultsContainer_.setSelection(0);
+ }
+
+ static private class ResultsTabFolderResizeHandler implements ControlListener {
+ CQResultsPanel parent_;
+
+ ResultsTabFolderResizeHandler(CQResultsPanel p) {
+ parent_ = p;
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ Rectangle rcClntArea = parent_.getClientArea();
+ int clntWd = rcClntArea.width;
+ int clntHt = rcClntArea.height;
+
+ if (e.widget == parent_.resultsContainer_) {
+ parent_.resultsContainer_.setBounds(0, 0, clntWd, clntHt);
+ }
+ }
+ }
+
+ private static class StatisticsPanel extends Composite {
+
+ private Label numEvents;
+ private Label numInserts;
+ private Label numUpdates;
+ private Label numDeletes;
+
+ public StatisticsPanel(Composite parent) {
+ super(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 4;
+ layout.makeColumnsEqualWidth = false;
+ this.setLayout(layout);
+
+ Label temp = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ temp.setText("Number of Events :");
+ GridData gridData = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
+ temp.setLayoutData(gridData);
+
+ numEvents = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ numEvents.setText("");
+ numEvents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ temp = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ temp.setText("Number of Inserts : ");
+ temp.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false));
+
+ numInserts = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ numInserts.setText("");
+ numInserts.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ temp = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ temp.setText("Number of Updates : ");
+ temp.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false));
+
+ numUpdates = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ numUpdates.setText("");
+ numUpdates.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ temp = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ temp.setText("Number of Deletes : ");
+ temp.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false));
+
+ numDeletes = new Label(this, SWT.HORIZONTAL | SWT.LEFT);
+ numDeletes.setText("");
+ numDeletes.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ this.layout();
+// this.pack();
+ }
+
+ public void update(CqStatistics statistics) {
+ numEvents.setText(String.valueOf(statistics.numEvents()));
+ numInserts.setText(String.valueOf(statistics.numInserts()));
+ numUpdates.setText(String.valueOf(statistics.numUpdates()));
+ numDeletes.setText(String.valueOf(statistics.numDeletes()));
+ }
+ }
+
+ private class CQDataTab extends Composite {
+ private Combo columnSelection;
+ private TableViewer dataTable;
+
+ public CQDataTab(Composite parent, final IntrospectionResult metaInfo) {
+ super(parent, SWT.NONE);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ this.setLayout(layout);
+
+ columnSelection = new Combo(this, SWT.DROP_DOWN);
+ columnSelection.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,
+ false, false));
+
+ // TODO MGH - make this 'un-anonymous'
+ columnSelection.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int index = columnSelection.getSelectionIndex();
+
+ int colIndex;
+ if (index == 0) {
+ colIndex = CQueryResultsInput.NO_PRIMARY_COL_SELECTED;
+ } else {
+ colIndex = index - 1;
+ }
+
+ CQueryResultsInput currentInput = (CQueryResultsInput) dataTable
+ .getInput();
+
+ if (currentInput.getPrimaryColIndex() != colIndex) {
+ CQueryResultsInput newInput = new CQueryResultsInput(dataTable,
+ query.getQueryResult(), metaInfo, colIndex);
+
+ synchronized (dataTable) {
+ dataTable.setInput(newInput);
+ }
+
+ Set<Object> keys = query.getQueryResult().getKeys();
+
+ Iterator<Object> iter = keys.iterator();
+ while (iter.hasNext()) {
+ Object key = iter.next();
+ EventData value = query.getQueryResult().getValueForKey(key);
+ if (value != null) {
+ newInput.processEvent(new RowAdded(value));
+ }
+ }
+ }
+ }
+ });
+
+ // Add data in Combo.
+ columnSelection.add("None");
+
+ int columnCount = metaInfo.getColumnCount();
+ for (int i = 0; i < columnCount; i++) {
+ try {
+ columnSelection.add(metaInfo.getColumnName(i));
+ } catch (ColumnNotFoundException e) {
+ LogUtil.error("Exception when adding column names in CQDataTab()", e );
+ }
+ }
+
+ columnSelection.select(0);
+
+ // Add columns in the table.
+
+ dataTable = new TableViewer(this, SWT.SINGLE | SWT.FULL_SELECTION
+ | SWT.H_SCROLL | SWT.V_SCROLL);
+ dataTable.getTable().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, true));
+ TableLayout lytTable = new TableLayout();
+ columnCount = metaInfo.getColumnCount();
+
+ for (int i = 0; i < columnCount; i++) {
+ lytTable.addColumnData(new ColumnPixelData(WIDTH, true));
+ }
+
+ dataTable.getTable().setLayout(lytTable);
+ dataTable.getTable().setHeaderVisible(true);
+ dataTable.getTable().setLinesVisible(true);
+
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ dataTable.getTable().setLayoutData(gd);
+ for (int i = 0; i < columnCount; i++) {
+ try {
+ String colName = metaInfo.getColumnName(i);
+ TableColumn col = new TableColumn(dataTable.getTable(), SWT.NONE, i);
+ col.setText(colName);
+ col.setResizable(true);
+ } catch (ColumnNotFoundException e) {
+ LogUtil.error( "Exception when adding column in CQDataTab()", e );
+ continue;
+ }
+ }
+
+ CQTableContentProvider prov = new CQTableContentProvider(dataTable);
+ dataTable.setContentProvider(prov);
+ dataTable.setLabelProvider(new ResultTableLabelProvider(dataTable));
+
+ CQueryResultsInput queryResultsInput = new CQueryResultsInput(dataTable,
+ query.getQueryResult(), metaInfo, -1);
+ dataTable.setInput(queryResultsInput);
+
+ ExploreAction exploreAction = new ExploreAction(this.getShell(), dataTable);
+ MenuManager manager = new MenuManager();
+ dataTable.getTable().setMenu(manager.createContextMenu(dataTable.getTable()));
+ manager.add(exploreAction);
+
+
+ if (tblResults_ == null)
+ tblResults_ = new ArrayList<TableViewer>();
+
+ tblResults_.add(dataTable);
+
+ }
+
+ }
+
+ public static class CQTableContentProvider implements IStructuredContentProvider {
+
+ private TableViewer viewer;
+
+ public CQTableContentProvider(TableViewer vwr) {
+ super();
+ viewer = vwr;
+
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return new Object[0];
+ }
+
+ public void dispose() {
+ CQueryResultsInput input = (CQueryResultsInput) viewer.getInput();
+ input.dispose();
+ }
+
+ public void inputChanged(Viewer vwr, Object oldInput, Object newInput) {
+
+ }
+ }
+
+ private static class ResultTableLabelProvider implements ITableLabelProvider {
+ private TableViewer viewer_;
+
+ ResultTableLabelProvider(TableViewer viewer) {
+ viewer_ = viewer;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ String res = "";
+ if (element == null)
+ return res;
+
+ EventData data = (EventData) element;
+ Object value = data.getValue();
+ CQueryResultsInput input = (CQueryResultsInput) viewer_.getInput();
+ try {
+ Object columnValue = input.getColumnValue(value, columnIndex);
+ if (columnValue != null)
+ res = columnValue.toString();
+ } catch (ColumnNotFoundException e) {
+ return "N/A";
+ } catch (ColumnValueNotAvailableException e) {
+ return "N/A";
+ }
+
+ return res;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowCoolBarManager.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowCoolBarManager.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowCoolBarManager.java
new file mode 100644
index 0000000..8b886cc
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowCoolBarManager.java
@@ -0,0 +1,52 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+
+//import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.CoolBar;
+
+/**
+ * @author mghosh
+ *
+ */
+public class CQWindowCoolBarManager extends MainWindowCoolBarManager {
+
+ private CqAppWindow parentWin_;
+
+ /**
+ *
+ */
+ public CQWindowCoolBarManager() {
+ init();
+ }
+
+ /**
+ * @param coolBar
+ */
+ public CQWindowCoolBarManager(CoolBar coolBar) {
+ super(coolBar);
+ }
+
+ /**
+ * @param style
+ */
+ public CQWindowCoolBarManager(CqAppWindow win, int style) {
+ super(style);
+ parentWin_= win;
+ init();
+ }
+
+ @Override
+ protected void init() {
+ if (parentWin_ != null) {
+ CQWindowToolBarManager tbm = new CQWindowToolBarManager(parentWin_,
+ SWT.FLAT, 0);
+ this.add(tbm);
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowToolBarManager.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowToolBarManager.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowToolBarManager.java
new file mode 100644
index 0000000..e25c5ee
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQWindowToolBarManager.java
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.ToolBar;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.actions.AbstractDataBrowserAction;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.actions.ExecuteCQuery;
+
+/**
+ * @author mjha
+ *
+ */
+public class CQWindowToolBarManager extends ToolBarManager {
+
+ // MGH - If the order of the actions here is changed, change the indices for
+ // the connect and disconnect items
+ // in inner class TBMgr_CnxnMsgHndlr
+ private final AbstractDataBrowserAction[][] actionsTypes_ = new AbstractDataBrowserAction[1][1];
+
+ /**
+ *
+ */
+ @SuppressWarnings("unused")
+ private CQWindowToolBarManager() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ *
+ */
+ public CQWindowToolBarManager(int iOrdinal) {
+ // TODO Auto-generated constructor stub
+ init(iOrdinal);
+ }
+
+ /**
+ * @param style
+ */
+ public CQWindowToolBarManager(CqAppWindow win, int style, int iOrdinal) {
+ super(style);
+ actionsTypes_[0][0] = new com.gemstone.gemfire.mgmt.DataBrowser.ui.actions.ExecuteCQuery(win);
+ win.setExecuteCQueryAction((ExecuteCQuery)actionsTypes_[0][0]);
+ init(iOrdinal);
+ }
+
+ /**
+ * @param toolbar
+ */
+ public CQWindowToolBarManager(ToolBar toolbar, int iOrdinal) {
+ super(toolbar);
+ init(iOrdinal);
+ // TODO Auto-generated constructor stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.action.ToolBarManager#createControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ @Override
+ public ToolBar createControl(Composite parent) {
+
+ return super.createControl(parent);
+ }
+
+ private void init(int iOrdinal) {
+ if (iOrdinal < actionsTypes_.length) {
+ int iNumActions = actionsTypes_[iOrdinal].length;
+ for (int j = 0; j < iNumActions; j++) {
+ this.add(actionsTypes_[iOrdinal][j]);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQueryView.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQueryView.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQueryView.java
new file mode 100644
index 0000000..d2f7a08
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CQueryView.java
@@ -0,0 +1,210 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.CQQuery;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.event.ICQEvent;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.actions.ExecuteCQuery;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.actions.ExecuteQuery;
+
+/**
+ * @author mjha
+ *
+ */
+public class CQueryView extends QueryView {
+ // -- this needs to be done in a cleaner fashion
+ static protected final int IDX_PANEL_RESULTS = 0;
+ static protected final int IDX_PANEL_MESSAGE = 1;
+
+ static final String sTabIconPaths[] = {
+ "/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Results.ico",
+ "/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Messages.ico",
+ };
+
+ static final String[] sTabLabels = { "Results", "Messages" };
+
+ private CqAppWindow cqWindow_;
+ private Composite[] tabPanels_;
+ private CTabFolder taFolder_;
+ private CQQuery cQuery_;
+ private CqExec_CqEvtHndlr cqEventHandler;
+ private CqExec_SetCqQueryEvtHndlr setCqQueryHandler;
+ private ExecuteCQuery executeCQuery_;
+ private GetConnect_MsgHndlr hndlrConnectMsgs;
+ private GetDisconnect_MsgHndlr hndlrDisconnectMsgs;
+
+ /**
+ * @param parent
+ * @param style
+ */
+ public CQueryView(CqAppWindow cqwin, Composite parent, int style) {
+ super(parent, style);
+ cqWindow_ = cqwin;
+ cqEventHandler = new CqExec_CqEvtHndlr(this);
+ setCqQueryHandler = new CqExec_SetCqQueryEvtHndlr(this);
+ hndlrConnectMsgs = new GetConnect_MsgHndlr(this);
+ hndlrDisconnectMsgs = new GetDisconnect_MsgHndlr(this);
+
+ addShortCutForExecuteQuery();
+ registerForMessages();
+ }
+
+ @Override
+ protected void registerForMessages() {
+ if (cqWindow_ != null) {
+ cqWindow_.addCustomMessageListener(
+ CustomUIMessages.QRY_MSG_GET_CQ_QUERY_STR_FOR_EXEC,
+ hndlrGetQueryStrMsgs);
+ cqWindow_.addCustomMessageListener(
+ CustomUIMessages.QRY_MSG_SET_CQ_QUERY_FOR_DISP, setCqQueryHandler);
+ cqWindow_.addCustomMessageListener(
+ CustomUIMessages.QRY_MSG_PROCESS_CQ_QUERY_EVT, cqEventHandler);
+ cqWindow_.addCustomMessageListener(CustomUIMessages.DS_CONNECTED,
+ hndlrConnectMsgs);
+ cqWindow_.addCustomMessageListener(CustomUIMessages.DS_DISCONNECTED,
+ hndlrDisconnectMsgs);
+ }
+ }
+ @Override
+ protected ExecuteQuery getExecuteQueryAction(){
+ return cqWindow_.getExecuteCQueryAction();
+ }
+
+ @Override
+ protected void addTabs(CTabFolder folder) {
+ taFolder_ = folder;
+ tabPanels_ = new Composite[1];
+ tabPanels_[0] = new CQResultsPanel(folder, SWT.NULL);
+ // tabPanels_[1] = new MessagePanel(folder, SWT.NULL);
+
+ final HashMap<String, Image> imgs = getTabItemImages();
+ for (int i = 0; i < tabPanels_.length; i++) {
+ CTabItem ti = new CTabItem(folder, SWT.NONE, i);
+ ti.setText(CQueryView.sTabLabels[i]);
+ ti.setControl(tabPanels_[i]);
+ ti.setImage(imgs.get(CQueryView.sTabLabels[i]));
+ }
+ taFolder_.setSelection(CQueryView.IDX_PANEL_RESULTS);
+ }
+
+ private CQResultsPanel getCQPanel() {
+ return (CQResultsPanel) tabPanels_[0];
+ }
+
+ private MessagePanel getMsgPanel() {
+ return (MessagePanel) tabPanels_[1];
+ }
+
+ public void setQuery(CQQuery query) {
+ cQuery_ = query;
+ getCQPanel().setQuery(cQuery_);
+ }
+
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
+
+ private void onEvent(final ICQEvent cqEvent) {
+ getCQPanel().processCqEvent(cqEvent);
+ }
+
+ private void onNewTypeAdded(final IntrospectionResult result) {
+ getCQPanel().processNewTypeEvent(result);
+ }
+
+ static private class CqExec_CqEvtHndlr implements
+ CustomMsgDispatcher.ICustomMessageListener {
+ final CQueryView parent_;
+
+ CqExec_CqEvtHndlr(CQueryView qv) {
+ parent_ = qv;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seecom.gemstone.gemfire.mgmt.DataBrowser.ui.CustomMsgDispatcher.
+ * ICustomMessageListener#handleEvent(java.lang.String, java.util.ArrayList,
+ * java.util.ArrayList)
+ */
+ public void handleEvent(String msg, ArrayList<Object> params,
+ ArrayList<Object> results) {
+
+ if (false == params.isEmpty()) {
+ for (int i = 0; i < params.size(); i++) {
+ Object oParam = params.get(i);
+ if(oParam instanceof IntrospectionResult)
+ parent_.onNewTypeAdded((IntrospectionResult) oParam);
+ else if(oParam instanceof ICQEvent)
+ parent_.onEvent((ICQEvent) oParam);
+ }
+
+ } // params.isEmpty()
+ }
+ }
+
+ static private class CqExec_SetCqQueryEvtHndlr implements
+ CustomMsgDispatcher.ICustomMessageListener {
+ final CQueryView parent_;
+
+ CqExec_SetCqQueryEvtHndlr(CQueryView qv) {
+ parent_ = qv;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seecom.gemstone.gemfire.mgmt.DataBrowser.ui.CustomMsgDispatcher.
+ * ICustomMessageListener#handleEvent(java.lang.String, java.util.ArrayList,
+ * java.util.ArrayList)
+ */
+ public void handleEvent(String msg, ArrayList<Object> params,
+ ArrayList<Object> results) {
+
+ if (false == params.isEmpty()) {
+ // -- MGH - only one param, cq event
+ Object oParam = params.get(0);
+ parent_.setQuery((CQQuery) oParam);
+ } // params.isEmpty()
+ }
+ }
+ private static class GetConnect_MsgHndlr implements
+ CustomMsgDispatcher.ICustomMessageListener {
+ final QueryView parent_;
+
+ GetConnect_MsgHndlr(QueryView qv) {
+ parent_ = qv;
+ }
+
+ public void handleEvent(String msg, ArrayList<Object> params,
+ ArrayList<Object> results) {
+ parent_.addShortCutForExecuteQuery();
+ }
+ }
+
+ private static class GetDisconnect_MsgHndlr implements
+ CustomMsgDispatcher.ICustomMessageListener {
+ final QueryView parent_;
+
+ GetDisconnect_MsgHndlr(QueryView qv) {
+ parent_ = qv;
+ }
+
+ public void handleEvent(String msg, ArrayList<Object> params,
+ ArrayList<Object> results) {
+ parent_.removeShortCutForExecuteQuery();
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ClientAreaComposite.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ClientAreaComposite.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ClientAreaComposite.java
new file mode 100644
index 0000000..ae9f784
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ClientAreaComposite.java
@@ -0,0 +1,24 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author mghosh
+ *
+ */
+public class ClientAreaComposite extends Composite {
+
+ /**
+ * @param parent
+ * @param style
+ */
+ public ClientAreaComposite(Composite parent, int style) {
+ super(parent, style);
+ // TODO Auto-generated constructor stub
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectToDSDlg.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectToDSDlg.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectToDSDlg.java
new file mode 100644
index 0000000..9c7d79c
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectToDSDlg.java
@@ -0,0 +1,387 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import java.util.LinkedList;
+
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.HelpEvent;
+import org.eclipse.swt.events.HelpListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.prefs.DataBrowserPreferences;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.DataValidator;
+
+/**
+ * @author mghosh
+ *
+ */
+public class ConnectToDSDlg extends TrayDialog {
+
+ private final static String DIALOG_TITLE = "Connect to GemFire Distributed System";
+ private final static String GRP_JMX = "Connect to Gemfire Locator/JMX Manager";
+ private static final String LBL_HOST = "Host: ";
+ private static final String LBL_PORT = "Port: ";
+ private static final String LBL_USER = "Username: ";
+ private static final String LBL_PSSWD = "Password: ";
+
+ private Composite parent_ = null;
+ private Group grpJmx_;
+
+ // -- this dialog's data
+ private Data data_ = new Data();
+ private Combo txtHost_;
+ private Combo txtPort_;
+ private Text txtUser_;
+ private Text txtPsswd_;
+
+ private LinkedList<String> enteredHosts = new LinkedList<String>();
+
+ private LinkedList<String> enteredPorts = new LinkedList<String>();
+
+ /**
+ * @param shell
+ */
+ public ConnectToDSDlg(Shell shell) {
+ super(shell);
+ }
+
+ /**
+ * @param parentShell
+ */
+ public ConnectToDSDlg(IShellProvider parentShell) {
+ super(parentShell);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ @Override
+ protected Control createContents(Composite prnt) {
+ parent_ = prnt;
+ parent_.getShell().setText(ConnectToDSDlg.DIALOG_TITLE);
+ GridLayout rwl = new GridLayout(1, false);
+ parent_.setLayout(rwl);
+
+ grpJmx_ = new Group(parent_, SWT.SHADOW_ETCHED_IN);
+ grpJmx_.setText(GRP_JMX);
+ grpJmx_.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
+ GridLayout lytGrpDisc = new GridLayout();
+ lytGrpDisc.numColumns = 6;
+ lytGrpDisc.marginRight = 10;
+ lytGrpDisc.makeColumnsEqualWidth = true;
+ grpJmx_.setLayout(lytGrpDisc);
+
+ Label lblMCastAddr = new Label(grpJmx_, SWT.BOLD);
+ lblMCastAddr.setText(LBL_HOST);
+ txtHost_ = new Combo(grpJmx_, SWT.DROP_DOWN | SWT.BORDER);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 5;
+ txtHost_.setLayoutData(gridData);
+ txtHost_.addListener(SWT.FocusIn, getHostListener());
+ if (!DataBrowserPreferences.getConnectionMRUHosts().isEmpty())
+ txtHost_.setText(DataBrowserPreferences.getConnectionMRUHosts().getFirst());
+
+ Label lblMCastAddr1 = new Label(grpJmx_, SWT.BOLD);
+ lblMCastAddr1.setText(LBL_PORT);
+ txtPort_ = new Combo(grpJmx_, SWT.DROP_DOWN | SWT.BORDER);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 5;
+ txtPort_.setLayoutData(gridData);
+ txtPort_.addListener(SWT.FocusIn, getPortListener());
+ if (!DataBrowserPreferences.getConnectionMRUPorts().isEmpty())
+ txtPort_.setText(DataBrowserPreferences.getConnectionMRUPorts().getFirst());
+
+ enteredHosts = DataBrowserPreferences.getConnectionMRUHosts();
+ enteredPorts = DataBrowserPreferences.getConnectionMRUPorts();
+
+ Label lblUserName = new Label(grpJmx_, SWT.BOLD);
+ lblUserName.setText(LBL_USER);
+ txtUser_ = new Text(grpJmx_, SWT.BORDER);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 5;
+ txtUser_.setLayoutData(gridData);
+
+
+ Label lblPassword = new Label(grpJmx_, SWT.BOLD);
+ lblPassword.setText(LBL_PSSWD);
+ txtPsswd_ = new Text(grpJmx_, SWT.BORDER);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 5;
+ txtPsswd_.setLayoutData(gridData);
+ txtPsswd_.setEchoChar('*');
+
+ Control ctrlRet = super.createContents(parent_);
+// parent_.addHelpListener( new C2DSHelpLstnr( this ));
+
+ return ctrlRet;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.TrayDialog#isHelpAvailable()
+ */
+ @Override
+ public boolean isHelpAvailable() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.TrayDialog#createHelpControl(org.eclipse.swt.
+ * widgets.Composite)
+ */
+ // @Override
+ // protected Control createHelpControl(Composite parent) {
+ // Control ctrlHelp = super.createHelpControl(parent);
+ // getParentShell().addHelpListener(new C2DSHelpLstnr(this));
+ // return ctrlHelp;
+ // }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
+ */
+ @Override
+ protected void initializeBounds() {
+ super.initializeBounds();
+
+ //
+ // MGH There seems to be bug in the docs for getBounds() and setBounds().
+ // getBounds() seems to return 'absolute' coordinates. Hence, setting x, y
+ // in
+ // setBounds() to those returned by getBounds() and changing the width to
+ // widen the control results in the control being offset by 'x' pixels.
+ //
+
+ // TODO MGH - perhaps layout info can be used to get the margin width.
+ // Using default 5 px for now
+ // -- set bounds of the pane containing the locator and multi-case data
+ // panes
+ Rectangle rcAncestorClntArea = grpJmx_.getClientArea();
+ Rectangle rcCurrElemBounds = grpJmx_.getBounds();
+ grpJmx_.setBounds(5, rcCurrElemBounds.y, rcAncestorClntArea.width - 10,
+ rcCurrElemBounds.height);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // We keep the data to restore it if 'retry' is attempted.
+ // -- Get security stuff
+ data_.host = this.txtHost_.getText().trim();
+ String sPort = this.txtPort_.getText().trim();
+ data_.userName = this.txtUser_.getText().trim();
+ data_.password = this.txtPsswd_.getText().trim();
+ boolean fErr = false;
+ if (this.data_.host.trim().length() == 0) {
+ String errMsg = "";
+ Shell shl = getShell();
+ MessageBox mb = new MessageBox(shl, SWT.OK);
+ mb.setText("GemFire DataBrowser - Connection Error");
+ errMsg = "No host entered";
+ mb.setMessage(errMsg);
+ mb.open();
+
+ fErr = true;
+ }
+
+ boolean isValidPort = DataValidator.isValidTCPPort(sPort);
+
+ if(!fErr ) {
+ if( false == isValidPort ) {
+ String errMsg = "";
+ Shell shl = getShell();
+ MessageBox mb = new MessageBox(shl, SWT.OK);
+ mb.setText("GemFire DataBrowser Error");
+ errMsg = "Port entered is not valid";
+ if( 0 != sPort.trim().length())
+ errMsg += " [" + sPort + "]";
+ mb.setMessage(errMsg);
+ mb.open();
+ fErr = true;
+ } else {
+ data_.port = Integer.valueOf(sPort).intValue();
+ }
+ }
+
+ if (false == fErr) {
+ adjustConnectionMRUHostList(data_.host);
+ adjustConnectionMRUPortList(String.valueOf(sPort));
+ super.okPressed();
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // Listener for help control
+ // -----------------------------------------------------------------
+ private static class C2DSHelpLstnr implements HelpListener {
+ private final ConnectToDSDlg parent_;
+
+ C2DSHelpLstnr(ConnectToDSDlg dlg) {
+ parent_ = dlg;
+ }
+
+ public void helpRequested(HelpEvent e) {
+ parent_.showHelp();
+ }
+ } // C2DSHelpLstnr
+
+ public void showHelp() {
+ // TODO MGH - hook to display Help window with relevant information
+ MessageBox mb = new MessageBox(getShell());
+ mb.setText("GemFire DataBrowser");
+ mb.setMessage("Would show help for Connecting to a DS here!!");
+ mb.open();
+ }
+
+ protected void adjustConnectionMRUHostList(String host) {
+ if(DataBrowserPreferences.getConnectionMRUHListLimit() == 0) {
+ return;
+ }
+
+ //First clear the position.
+ if(!enteredHosts.remove(host)) {
+ //If the list is full, clear the last entry.
+ if(enteredHosts.size() == DataBrowserPreferences.getConnectionMRUHListLimit()) {
+ enteredHosts.removeLast();
+ }
+ }
+
+ //Add the entry to the top.
+ enteredHosts.addFirst(host);
+
+ DataBrowserPreferences.setConnectionMRUHosts(enteredHosts);
+ }
+
+ protected void adjustConnectionMRUPortList(String port) {
+ if(DataBrowserPreferences.getConnectionMRUHListLimit() == 0) {
+ return;
+ }
+
+ //First clear the position.
+ if(!enteredPorts.remove(port)) {
+ //If the list is full, clear the last entry.
+ if(enteredPorts.size() == DataBrowserPreferences.getConnectionMRUHListLimit()) {
+ enteredPorts.removeLast();
+ }
+ }
+
+ //Add the entry to the top.
+ enteredPorts.addFirst(port);
+
+ DataBrowserPreferences.setConnectionMRUPorts(enteredPorts);
+ }
+
+ public final ConnectToDSDlg.Data getData() {
+ return data_;
+ }
+
+ public void setData(ConnectToDSDlg.Data d) {
+ data_ = d;
+ }
+
+ protected Listener getHostListener() {
+ return new Listener() {
+ /* currently entered value in the combo */
+ private String currentValue;
+
+ public void handleEvent(Event event) {
+ Combo widget = (Combo)event.widget;
+ currentValue = widget.getText();
+ widget.removeAll();
+ if (currentValue != null && !currentValue.equals("")) {
+ widget.add(currentValue);
+ widget.setText(currentValue);
+ }
+ LinkedList<String> hosts = DataBrowserPreferences.getConnectionMRUHosts();
+ for(String host : hosts) {
+ if(!host.equalsIgnoreCase(currentValue)) {
+ widget.add(host);
+ }
+ }
+ }
+ };
+ }
+
+ protected Listener getPortListener() {
+ return new Listener() {
+ /* currently entered value in the combo */
+ private String currentValue;
+
+ public void handleEvent(Event event) {
+
+ Combo widget = (Combo)event.widget;
+ currentValue = widget.getText();
+ widget.removeAll();
+ if (currentValue != null && !currentValue.equals("")) {
+ widget.add(currentValue);
+ widget.setText(currentValue);
+ }
+ LinkedList<String> ports = DataBrowserPreferences.getConnectionMRUPorts();
+ for(String port : ports) {
+ if(!port.equalsIgnoreCase(currentValue)) {
+ widget.add(port);
+ }
+ }
+ }
+ };
+ }
+
+ /*
+ * Encapsulates the data for this UI window
+ */
+ public static class Data {
+ public String host;
+ public int port;
+ public String userName;
+ public String password;
+
+ Data() {
+ host = "";
+ port = 0;
+ userName = "";
+ password = "";
+ }
+ }
+
+ public static void main(String[] args) {
+ ConnectToDSDlg connectToDSDlg = new ConnectToDSDlg((Shell) null);
+ connectToDSDlg.open();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectionPrefsPage.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectionPrefsPage.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectionPrefsPage.java
new file mode 100644
index 0000000..1cba173
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/ConnectionPrefsPage.java
@@ -0,0 +1,539 @@
+/*=========================================================================
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Text;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.prefs.DataBrowserPreferences;
+import com.gemstone.gemfire.mgmt.DataBrowser.prefs.DefaultPreferences;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+/**
+ * @author mjha
+ *
+ */
+public class ConnectionPrefsPage extends PreferencePage implements
+ IDataBrowserPrefsPage {
+
+ // -- MGH - fixing a default size. Unable to figure out how to dynamically
+ // size (or it is possible?)
+ // private static final Point ptDef = new Point( 450, 450 );
+
+ private Composite parent_ = null;
+ private Composite basePane_ = null;
+ private Group grp1_ = null;
+ private Group clientGroup = null;
+ private ImageDescriptor imgDesc_;
+ private Image img_;
+ //private Text txtReconnectInterval;
+ //private Text txtNoOfReconnect;
+ private Text txtTimeout;
+ private Text txtMru;
+ private Text socketReadTimeout;
+
+ /**
+ *
+ */
+ public ConnectionPrefsPage() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param title
+ */
+ public ConnectionPrefsPage(String title) {
+ super(title);
+ }
+
+ /**
+ * @param title
+ * @param image
+ */
+ public ConnectionPrefsPage(String title, ImageDescriptor image) {
+ super(title, image);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ if( null != img_ ) {
+ img_.dispose();
+ }
+
+ imgDesc_ = null;
+ super.dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.
+ * swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite prnt) {
+ parent_ = prnt;
+ basePane_ = new Composite(parent_, SWT.NONE);
+
+ FillLayout lytBase = new FillLayout();
+ lytBase.type = SWT.VERTICAL;
+ lytBase.marginHeight = 5;
+ lytBase.marginWidth = 5;
+ basePane_.setLayout(lytBase);
+
+ grp1_ = new Group(basePane_, SWT.SHADOW_ETCHED_IN);
+ grp1_.setText("Locator/JMX Manager Connection");
+
+ GridLayout lytGridGrp1 = new GridLayout();
+ lytGridGrp1.numColumns = 2;
+ lytGridGrp1.verticalSpacing = 20;
+ lytGridGrp1.marginHeight = 20;
+ lytGridGrp1.makeColumnsEqualWidth = true;
+ grp1_.setLayout(lytGridGrp1);
+
+ GridData gridData = new GridData(SWT.BEGINNING, SWT.TOP, false, false);
+ gridData.verticalSpan = 2;
+
+ Label lblMru = new Label(grp1_, SWT.BOLD);
+ lblMru.setLayoutData(gridData);
+ String text = "Number of Locator/JMX Manager entries, to keep in history: ";
+ lblMru.setText(text);
+
+ txtMru = new Text(grp1_, SWT.BORDER);
+ txtMru.setToolTipText("Number of host/port MRU entries for Locator/JMX Manager to store");
+ txtMru.addModifyListener(new PrefModifyListenerAdapter(this));
+
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BOTTOM;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.verticalSpan = 2;
+ txtMru.setLayoutData(gridData);
+
+
+ Label lblTimeout = new Label(grp1_, SWT.BOLD);
+ lblTimeout.setText("Timeout on connection with Locator/JMX Manager (ms): ");
+
+ txtTimeout = new Text(grp1_, SWT.BORDER);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ txtTimeout.setLayoutData(gridData);
+ txtTimeout.setToolTipText("Timeout to set on the connection attempts to the Locator/JMX Manager in milliseconds");
+ txtTimeout.addModifyListener(new PrefModifyListenerAdapter(this));
+
+ clientGroup = new Group(basePane_, SWT.SHADOW_ETCHED_IN);
+ clientGroup.setText("Client Connection");
+
+ GridLayout lytGridGrp2 = new GridLayout();
+ lytGridGrp2.numColumns = 2;
+ lytGridGrp2.verticalSpacing = 20;
+ lytGridGrp2.marginHeight = 20;
+ lytGridGrp2.makeColumnsEqualWidth = true;
+ clientGroup.setLayout(lytGridGrp2);
+
+ Label lblsockTimeout = new Label(clientGroup, SWT.BOLD);
+ lblsockTimeout.setText("Server Response Timeout (ms): ");
+
+ socketReadTimeout = new Text(clientGroup, SWT.BORDER);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ socketReadTimeout.setLayoutData(gridData);
+ socketReadTimeout.setToolTipText("The amount of time, in milliseconds, to wait for a response from a server");
+ socketReadTimeout.addModifyListener(new PrefModifyListenerAdapter(this));
+
+ /*Label reconnectLabel = new Label(grp1_, SWT.NONE);
+ reconnectLabel.setText( "Retry attempts to connect to AdminAgent:" );
+ gridData = new GridData(SWT.BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING,
+ false, false);
+ reconnectLabel.setLayoutData(gridData);
+
+ txtNoOfReconnect = new Text(grp1_, SWT.BORDER);
+ gridData = new GridData(SWT.FILL, GridData.VERTICAL_ALIGN_BEGINNING,
+ true, false);
+ txtNoOfReconnect.setLayoutData(gridData);
+ txtNoOfReconnect.setEditable(true);
+ txtNoOfReconnect.setToolTipText("Number of attemtps to connect to the AdminAgent");
+ txtNoOfReconnect.addModifyListener(new PrefModifyListenerAdapter(this));
+
+ Label reconnectIntervalLabel = new Label(grp1_, SWT.NONE);
+ reconnectIntervalLabel.setText("Reconnect attempt interval (ms): ");
+ gridData = new GridData(SWT.BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING,
+ false, false);
+ reconnectIntervalLabel.setLayoutData(gridData);
+
+ txtReconnectInterval = new Text(grp1_, SWT.BORDER);
+ gridData = new GridData(SWT.FILL, GridData.VERTICAL_ALIGN_BEGINNING,
+ true, false);
+ txtReconnectInterval.setLayoutData(gridData);
+ txtReconnectInterval.setEditable(true);
+ txtReconnectInterval.setToolTipText("Wait time between reconnect attemtps in milliseconds");
+ txtReconnectInterval.addModifyListener(new PrefModifyListenerAdapter(this)); */
+ setPreferences(false);
+
+ return basePane_;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performHelp()
+ */
+ @Override
+ public void performHelp() {
+ // TODO MGH - hook to display Help window with relevant information
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performApply()
+ */
+ @Override
+ protected void performApply() {
+ String mruStr = txtMru.getText();
+ String timeoutStr = txtTimeout.getText();
+ String socketReadTimeoutStr = socketReadTimeout.getText();
+// String noOfReconnectStr = txtNoOfReconnect.getText();
+// String reconnectintervalStr = txtReconnectInterval.getText();
+
+ long reconnectinterval;
+ long timeout;
+ int readTimeout;
+ int mru;
+ int noOfReconnect;
+// try {
+// reconnectinterval = Long.valueOf(reconnectintervalStr);
+// }
+// catch (NumberFormatException e) {
+// MessageBox mb = new MessageBox(getShell());
+// mb.setText("DataBrowser Error");
+// mb.setMessage("Please enter a valid ( greater than zero ) value for the reconnect interval.");
+// mb.open();
+// txtReconnectInterval.setFocus();
+// return ;
+// }
+//
+// if(reconnectinterval <= 0) {
+// MessageBox mb = new MessageBox(getShell());
+// mb.setText("DataBrowser Error");
+// mb.setMessage("Please enter a valid ( greater than zero ) value for the reconnect interval.");
+// mb.open();
+// this.txtReconnectInterval.setFocus();
+// return;
+// }
+
+
+ try {
+ timeout = Long.valueOf(timeoutStr);
+ }
+ catch (NumberFormatException e) {
+ MessageBox mb = new MessageBox(getShell());
+ mb.setText("DataBrowser Error");
+ mb.setMessage("Please enter a valid ( greater than zero ) value for the connection timeout interval (in milliseconds).");
+ mb.open();
+ txtTimeout.setFocus();
+ return;
+ }
+
+ if(timeout <= 0) {
+ MessageBox mb = new MessageBox(getShell());
+ mb.setText("DataBrowser Error");
+ mb.setMessage("Please enter a valid ( greater than zero ) value for the connection timeout interval (in milliseconds).");
+ mb.open();
+ this.txtTimeout.setFocus();
+ return;
+ }
+
+
+ try {
+ mru = Integer.valueOf(mruStr);
+ }
+ catch (NumberFormatException e) {
+ MessageBox mb = new MessageBox(getShell());
+ mb.setText("DataBrowser Error");
+ mb.setMessage("Please enter a valid ( non negative ) value for the number of Locator/JMX Manager entries to keep in the history");
+ mb.open();
+ txtMru.setFocus();
+ return ;
+ }
+
+ if(mru < 0) {
+ MessageBox mb = new MessageBox(getShell());
+ mb.setText("DataBrowser Error");
+ mb.setMessage("Please enter a valid ( non negative ) value for the number of Locator/JMX Manager entries to keep in the history");
+ mb.open();
+ this.txtMru.setFocus();
+ return;
+ }
+
+ try {
+ readTimeout = Integer.valueOf(socketReadTimeoutStr);
+ } catch (NumberFormatException e) {
+ MessageBox mb = new MessageBox(getShell());
+ mb.setText("DataBrowser Error");
+ mb.setMessage("Please enter a valid ( greater than zero ) numeric value for server response timeout interval (in milliseconds).");
+ mb.open();
+ socketReadTimeout.setFocus();
+ return;
+ }
+
+ if(readTimeout <= 0) {
+ MessageBox mb = new MessageBox(getShell());
+ mb.setText("DataBrowser Error");
+ mb.setMessage("Please enter a valid ( greater than zero ) value for server response timeout interval (in milliseconds).");
+ mb.open();
+ this.socketReadTimeout.setFocus();
+ return;
+ }
+
+
+// try {
+// noOfReconnect = Integer.valueOf(noOfReconnectStr);
+// }
+// catch (NumberFormatException e) {
+// MessageBox mb = new MessageBox(getShell());
+// mb.setText("DataBrowser Error");
+// mb.setMessage( "Please enter a valid ( non negative ) value for the number of retry attempts." );
+// mb.open();
+// txtNoOfReconnect.setFocus();
+// return;
+// }
+//
+// if(noOfReconnect < 0) {
+// MessageBox mb = new MessageBox(getShell());
+// mb.setText("DataBrowser Error");
+// mb.setMessage("Please enter a valid ( non negative ) value for the number of retry attempts.");
+// mb.open();
+// this.txtNoOfReconnect.setFocus();
+// return;
+// }
+
+
+ DataBrowserPreferences.setConnectionMRUHListLimit(mru);
+ DataBrowserPreferences.setConnectionTimeoutInterval(timeout);
+ DataBrowserPreferences.setSocketReadTimeoutInterval(readTimeout);
+// DataBrowserPreferences.setConRetryInterval(reconnectinterval);
+// DataBrowserPreferences.setConRetryAttempts(noOfReconnect);
+ }
+
+ @Override
+ public boolean performOk() {
+ performApply();
+ return super.performOk();
+ }
+
+ public boolean isValid() {
+ String mruStr = txtMru.getText();
+ String timeoutStr = txtTimeout.getText();
+ String readTimeoutStr = socketReadTimeout.getText();
+// String noOfReconnectStr = txtNoOfReconnect.getText();
+// String reconnectintervalStr = txtReconnectInterval.getText();
+
+ long temp1;
+ int temp2;
+ long readTimoutLong;
+
+ try {
+ temp2 = Integer.valueOf(mruStr);
+ }
+ catch (NumberFormatException e) {
+ temp2 = -1;
+ }
+
+ if(temp2 < 0) {
+ setErrorMessage("Please enter a valid ( non negative ) value for the number of Locator/JMX Manager entries to keep in the history");
+ txtTimeout.setEnabled(false);
+ socketReadTimeout.setEnabled(false);
+// txtNoOfReconnect.setEnabled(false);
+// txtReconnectInterval.setEnabled(false);
+ return false;
+ }
+
+ try {
+ temp1 = Long.valueOf(timeoutStr);
+ }
+ catch (NumberFormatException e) {
+ temp1 = -1;
+ }
+
+ if(temp1 <= 0) {
+ setErrorMessage("Please enter a valid ( greater than zero ) value for the connection timeout interval (in milliseconds).");
+ txtMru.setEnabled(false);
+ socketReadTimeout.setEnabled(false);
+// txtNoOfReconnect.setEnabled(false);
+// txtReconnectInterval.setEnabled(false);
+ return false;
+ }
+
+ try {
+ readTimoutLong = Long.valueOf(readTimeoutStr);
+ }
+ catch (NumberFormatException e) {
+ readTimoutLong = -1;
+ }
+
+ if(readTimoutLong <= 0) {
+ setErrorMessage("Please enter a valid ( greater than zero ) numeric value for server response timeout interval (in milliseconds).");
+ txtMru.setEnabled(false);
+ txtTimeout.setEnabled(false);
+// txtNoOfReconnect.setEnabled(false);
+// txtReconnectInterval.setEnabled(false);
+ return false;
+ }
+
+// try {
+// temp2 = Integer.valueOf(noOfReconnectStr);
+// }
+// catch (NumberFormatException e) {
+// temp2 = -1;
+// }
+//
+// if(temp2 < 0) {
+// setErrorMessage("Please enter a valid ( non negative ) value for the number of retry attempts.");
+// txtMru.setEnabled(false);
+// txtTimeout.setEnabled(false);
+// txtReconnectInterval.setEnabled(false);
+// return false;
+// }
+
+// try {
+// temp1 = Long.valueOf(reconnectintervalStr);
+// }
+// catch (NumberFormatException e) {
+// temp1 = -1;
+// }
+//
+// if(temp1 <= 0) {
+// setErrorMessage("Please enter a valid ( greater than zero ) value for the reconnect interval.");
+// txtTimeout.setEnabled(false);
+// txtNoOfReconnect.setEnabled(false);
+// txtMru.setEnabled(false);
+// return false;
+// }
+
+ setErrorMessage(null);
+ txtMru.setEnabled(true);
+ txtTimeout.setEnabled(true);
+ socketReadTimeout.setEnabled(true);
+// txtNoOfReconnect.setEnabled(true);
+// txtReconnectInterval.setEnabled(true);
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ @Override
+ protected void performDefaults() {
+ setPreferences(true);
+ super.performDefaults();
+ }
+
+ private void setPreferences(boolean isDefault){
+ String temp1 ;
+ String temp2 ;
+ String readTimeoutStr ;
+
+ if(isDefault) {
+ temp1 = String.valueOf(DefaultPreferences.DEFAULT_MRU_HOST_PORT_LIST_LIMIT);
+ temp2 = String.valueOf(DefaultPreferences.DEFAULT_CONNECTION_TIMEOUT);
+ readTimeoutStr = String.valueOf(DefaultPreferences.DEFAULT_SOCKET_READ_TIMEOUT);
+
+ } else {
+ temp1 = String.valueOf(DataBrowserPreferences.getConnectionMRUHListLimit());
+ temp2 = String.valueOf(DataBrowserPreferences.getConnectionTimeoutInterval());
+ readTimeoutStr = String.valueOf(DataBrowserPreferences.getSocketReadTimeoutInterval());
+ }
+
+ txtMru.setText(temp1);
+ txtTimeout.setText(temp2);
+ socketReadTimeout.setText(readTimeoutStr);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#setTitle(java.lang.String)
+ */
+ @Override
+ public void setTitle(String title) {
+ super.setTitle("Connection Options");
+ }
+
+ // ----------------------------------------------------------------------------
+ // IDataBrowserPrefsPage methods
+ // ----------------------------------------------------------------------------
+
+ public String getID() {
+ return "Connection";
+ }
+
+ public String getLabel() {
+ return "Connection";
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ final String fqnImage_ = "/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/QueryPrefsPageIcon.png";
+ InputStream isImage = null;
+ try {
+ isImage = getClass().getResourceAsStream(fqnImage_);
+
+ if (null != isImage) {
+ img_ = new Image(null, isImage);
+ imgDesc_ = ImageDescriptor.createFromImage(img_);
+ }
+ } catch (NullPointerException xptn) {
+ // handler for getResourceAsStream
+ LogUtil.warning( "NullPointedException in QueryPrefsPage.getImageDescriptor (getResourceAsStream). Continuing...", xptn );
+ } catch (SWTException xptn) {
+ // handler for org.eclipse.swt.graphics.Image ctor
+ // we continue an try to add the other nodes
+ LogUtil.warning( "SWTException in QueryPrefsPage.getImageDescriptor (org.eclipse.swt.graphics.Image ctor). Continuing...", xptn );
+ } catch (SWTError err) {
+ // Log this (Image ctor could throw this), and rethrow
+ LogUtil.error( "SWTError in QueryPrefsPage.getImageDescriptor (org.eclipse.swt.graphics.Image ctor). This could be due to handles in the underlying widget kit being exhaused. Terminating.", err );
+ throw err;
+ }
+ finally {
+ if( null != isImage ) {
+ try {
+ isImage.close();
+ } catch (IOException e) {
+ LogUtil.warning( "IOException in QueryPrefsPage.getImageDescriptor (isImage.close(..)). Ignoring.", e );
+ }
+ isImage = null;
+ }
+ }
+
+ return imgDesc_;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CqAppWindow.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CqAppWindow.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CqAppWindow.java
new file mode 100644
index 0000000..899bad2
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CqAppWindow.java
@@ -0,0 +1,180 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.action.CoolBarManager;
+import org.eclipse.jface.window.ApplicationWindow;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.app.DataBrowserApp;
+import com.gemstone.gemfire.mgmt.DataBrowser.controller.DataBrowserController;
+import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.CustomMsgDispatcher.ICustomMessageListener;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.actions.ExecuteCQuery;
+
+/**
+ * @author mghosh
+ *
+ */
+public class CqAppWindow extends ApplicationWindow {
+ private static final String prefix = "CqWindow";
+ private static int noOfInstanceOpened = 0;
+ final private Shell parentShell_;
+ final private MainAppWindow mainWindow_;
+
+ final static CustomMsgDispatcher msgDispatcher_ = new CustomMsgDispatcher();
+
+ private Shell shell_ = null;
+ private final String id ;
+ MainWindowMenuManager menuManager_ = null;
+ MainWindowCoolBarManager coolBarManager_ = null;
+
+ // -- 'control/feedback' elements : [cool/tool]bars, status, menus
+ Composite parentPane_ = null;
+ CQueryView queryView_ = null;
+ private GemFireMember gemfireMember_;
+ private ExecuteCQuery cQueryAction_;
+
+
+
+
+ /**
+ * @param parentShell
+ */
+ public CqAppWindow(MainAppWindow mainWin, GemFireMember mem) {
+ super(null);
+ parentShell_ = mainWin.getShell();
+ mainWindow_ = mainWin;
+ gemfireMember_ = mem;
+ setBlockOnOpen(true);
+ addCoolBar(SWT.NONE);
+ noOfInstanceOpened++;
+ id = prefix + String.valueOf(noOfInstanceOpened);
+ }
+
+ public String getId(){
+ return id;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#handleShellCloseEvent()
+ */
+ @Override
+ protected void handleShellCloseEvent() {
+ mainWindow_.removeCqWindow(this);
+ super.handleShellCloseEvent();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.ApplicationWindow#createCoolBarManager(int)
+ */
+ @Override
+ protected CoolBarManager createCoolBarManager(int style) {
+ if (null == coolBarManager_) {
+ coolBarManager_ = new CQWindowCoolBarManager(this, SWT.FLAT);
+ }
+
+ return coolBarManager_;
+ }
+
+ public ExecuteCQuery getExecuteCQueryAction(){
+ return cQueryAction_;
+ }
+
+ public void setExecuteCQueryAction(ExecuteCQuery queryAction){
+ cQueryAction_ = queryAction;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.window.ApplicationWindow#configureShell(org.eclipse.swt
+ * .widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+
+ shell_ = shell;
+
+ // -- set title
+ shell_.setText("CQ Window -" + gemfireMember_.getRepresentationName());
+ int y = parentShell_.getSize().y;
+ shell_.setSize(y, 90* y/ 100);
+ }
+
+ public GemFireMember getAssociatedMember(){
+ return gemfireMember_;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.ApplicationWindow#canHandleShellCloseEvent()
+ */
+ @Override
+ protected boolean canHandleShellCloseEvent() {
+ // TODO MGH: Check if any background ops are in progress before returning
+ return super.canHandleShellCloseEvent();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.
+ * Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ parentPane_ = parent;
+
+ createPane(parentPane_);
+ return parentPane_;
+ }
+
+ @Override
+ public boolean close() {
+ DataBrowserController controller = DataBrowserApp.getInstance().getController();
+ controller.closeCq(id);
+ return super.close();
+ }
+
+ private void createPane(Composite prnt) {
+ queryView_ = new CQueryView(this, prnt, SWT.FLAT);
+ }
+
+ public CQueryView getQueryView(){
+ return queryView_;
+ }
+
+ public boolean addCustomMessageListener(String msg,
+ ICustomMessageListener lstnrNew) {
+ return CqAppWindow.msgDispatcher_.addCustomMessageListener(msg + id, lstnrNew);
+ }
+
+ // TODO MGH - eventually change the code elsewhere in the ui package to
+ // directly call the dispatcher
+ public void sendCustomMessage(String msg, ArrayList<Object> prms,
+ ArrayList<Object> res) {
+ if (null != msg) {
+ CqAppWindow.msgDispatcher_.sendCustomMessage(msg + id, prms, res);
+ }
+ }
+
+// public static void main(String[] args) {
+// CqAppWindow cqAppWindow = new CqAppWindow(null);
+// cqAppWindow.open();
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomMsgDispatcher.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomMsgDispatcher.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomMsgDispatcher.java
new file mode 100644
index 0000000..a8c9fc9
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomMsgDispatcher.java
@@ -0,0 +1,79 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+
+
+/**
+ * @author mghosh
+ *
+ */
+public class CustomMsgDispatcher {
+
+ public interface ICustomMessageListener {
+ void handleEvent( String msg, ArrayList< Object > params, ArrayList< Object > results );
+ }
+
+ static private HashMap< String, ArrayList< ICustomMessageListener > > customMsgHandlers_;
+
+
+ // -- Init storage for custom message handling
+ static {
+ CustomMsgDispatcher.customMsgHandlers_ = new HashMap< String, ArrayList< ICustomMessageListener > >();
+ for( String s : CustomUIMessages.customMessages_ ) {
+ CustomMsgDispatcher.customMsgHandlers_.put( s, new ArrayList< ICustomMessageListener >() );
+ }
+ }
+
+ public synchronized boolean addCustomMessageListener( String msg, ICustomMessageListener lstnrNew ) {
+ ArrayList< ICustomMessageListener > lstnrs = CustomMsgDispatcher.customMsgHandlers_.get( msg );
+ if( null == lstnrs ) {
+ lstnrs = new ArrayList< ICustomMessageListener >();
+ customMsgHandlers_.put( msg , lstnrs );
+ }
+ boolean fRet = true;
+ if( false == lstnrs.contains( lstnrNew )) {
+ LogUtil.fine( "addCustomMessageListener : lstnrs does not contain " + lstnrNew );
+ fRet = lstnrs.add( lstnrNew );
+ }
+ else {
+ LogUtil.fine( "addCustomMessageListener : lstnrs **does** contain " + lstnrNew );
+ }
+
+ return fRet;
+ }
+
+ public synchronized void sendCustomMessage( String msg, ArrayList< Object > prms, ArrayList< Object > res ) {
+ if( null != msg ) {
+ ArrayList< ICustomMessageListener > listeners = customMsgHandlers_.get( msg );
+ ArrayList< Object > resTmp = new ArrayList< Object >();
+ for( ICustomMessageListener l : listeners ) {
+ l.handleEvent(msg, prms, resTmp );
+ res.addAll( resTmp );
+ resTmp.clear();
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public CustomMsgDispatcher() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomUIMessages.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomUIMessages.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomUIMessages.java
new file mode 100644
index 0000000..478940f
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/ui/CustomUIMessages.java
@@ -0,0 +1,85 @@
+/**
+ *
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.ui;
+
+import java.util.ArrayList;
+
+/**
+ * @author mghosh
+ *
+ */
+public abstract class CustomUIMessages {
+ // -------------------------------------------------------------
+ // -- Query stuff
+ // -------------------------------------------------------------
+ // -- Sent to the pane containg the query string
+ // Param -
+ // an int value that can be one of the following
+ // 0 -> Get selection
+ // 1 -> Get last line
+ // 2 -> Get all the contents of the pane.
+ // Res -
+ // a string containing the results or a null if there is nothing to return (no selection or no content)
+ public static final String QRY_MSG_GET_QUERY_STR_FOR_EXEC = "Get Query String For Execution";
+ public static final String QRY_MSG_ADD_QUERY_SINGLE_RESULT = "Add Query Single Result";
+
+ // -- Show/hide the tabs showing the results of query execution
+ public static final String QRY_MSG_SHOW_QUERY_TRACE_PANE = "Hide Query Trace Pane";
+ public static final String QRY_MSG_SHOW_QUERY_STATISTICS_PANE = "Hide Query Log Pane";
+ public static final String QRY_MSG_SHOW_QUERY_MESSAGES_PANE = "Hide Query Messages Pane";
+ public static final String QRY_MSG_SHOW_QUERY_EXECPLAN_PANE = "Hide Query ExecutionPlan Pane";
+
+ public static final String QRY_MEMBER_SELECTED_FOR_QUERY_EXEC = "Get Selected Memebr For Query Execution";
+ public static final String DISPOSE_QUERY_RESULTS = "Dispose Query Results";
+
+ // for CQ
+ public static final String QRY_MSG_GET_CQ_QUERY_STR_FOR_EXEC = "Get CQ Query String For Execution";
+ public static final String QRY_MSG_SET_CQ_QUERY_FOR_DISP = "Set CQ Query For For Result Display";
+ public static final String QRY_MSG_PROCESS_CQ_QUERY_EVT = "Process CQ Query New Type added Event";
+
+ // -------------------------------------------------------------
+ // -- Tree stuff
+ // -------------------------------------------------------------
+ public static final String DSTREE_MSG_UPDATE_SNAPSHOT = "Update DS Snapshot";
+ public static final String UPDATE_MEMBER_EVENT = "Update Gemfire Member";
+
+ // -------------------------------------------------------------
+ // -- Overall activity events stuff
+ // -------------------------------------------------------------
+ // Single parameter for each of the following event - the DSSnapShot
+ public static final String DS_CONNECTED = "Connected to DS";
+ public static final String DS_DISCONNECTED = "Disconnected from DS";
+
+ protected final static ArrayList< String > customMessages_ = new ArrayList< String >();
+
+ static {
+ CustomUIMessages.customMessages_.add( CustomUIMessages.QRY_MSG_GET_QUERY_STR_FOR_EXEC );
+
+ CustomUIMessages.customMessages_.add( CustomUIMessages.QRY_MSG_SHOW_QUERY_TRACE_PANE );
+ CustomUIMessages.customMessages_.add( CustomUIMessages.QRY_MSG_SHOW_QUERY_STATISTICS_PANE );
+ CustomUIMessages.customMessages_.add( CustomUIMessages.QRY_MSG_SHOW_QUERY_MESSAGES_PANE );
+ CustomUIMessages.customMessages_.add( CustomUIMessages.QRY_MSG_SHOW_QUERY_EXECPLAN_PANE );
+
+ CustomUIMessages.customMessages_.add( CustomUIMessages.DSTREE_MSG_UPDATE_SNAPSHOT );
+
+ CustomUIMessages.customMessages_.add( CustomUIMessages.DS_CONNECTED );
+ CustomUIMessages.customMessages_.add( CustomUIMessages.DS_DISCONNECTED );
+ }
+
+ /**
+ *
+ */
+ public CustomUIMessages() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+}