Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-09-18 04:38:35 -0400
committerUwe Stieber2013-09-18 08:06:09 -0400
commit6ed2614942c85108b84f0a1daf655d2766e32caa (patch)
tree3f59b283e40b77118b9bb40da0664bf593ff248e /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf
parentd294f6a7ccf6549c63a2c0f6fcbea41a4c82cc09 (diff)
downloadorg.eclipse.tcf-6ed2614942c85108b84f0a1daf655d2766e32caa.tar.gz
org.eclipse.tcf-6ed2614942c85108b84f0a1daf655d2766e32caa.tar.xz
org.eclipse.tcf-6ed2614942c85108b84f0a1daf655d2766e32caa.zip
Target Explorer: Visualize the active connection as status bar trim area
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ActiveConnectionStatusTrimControl.java96
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties3
3 files changed, 101 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ActiveConnectionStatusTrimControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ActiveConnectionStatusTrimControl.java
new file mode 100644
index 000000000..5a020d44d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ActiveConnectionStatusTrimControl.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.controls;
+
+import java.util.EventObject;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+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.Text;
+import org.eclipse.tcf.te.runtime.events.ChangeEvent;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.ISelectionService;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
+
+/**
+ * Default selection status bar trim control implementation.
+ */
+public class ActiveConnectionStatusTrimControl extends WorkbenchWindowControlContribution implements IEventListener {
+ private Text text = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createControl(Composite parent) {
+ Composite panel = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+
+ text = new Text(panel, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ String selected = ""; //$NON-NLS-1$
+
+ ISelectionService service = ServiceManager.getInstance().getService(ISelectionService.class);
+ if (service != null) {
+ IPeerModel peerModel = service.getDefaultSelection(null);
+ if (peerModel != null) {
+ selected = NLS.bind(Messages.ActiveConnectionStatusTrimControl_label, peerModel.getName());
+ }
+ }
+
+ text.setText(selected);
+
+ // Register as listener to the selection service
+ EventManager.getInstance().addEventListener(this, ChangeEvent.class, ISelectionService.class);
+
+ return panel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Remove ourself as listener
+ EventManager.getInstance().removeEventListener(this);
+
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (event.getSource() instanceof ISelectionService) {
+ String selected = ""; //$NON-NLS-1$
+
+ ISelectionService service = (ISelectionService)event.getSource();
+ IPeerModel peerModel = service.getDefaultSelection(null);
+ if (peerModel != null) {
+ selected = NLS.bind(Messages.ActiveConnectionStatusTrimControl_label, peerModel.getName());
+ }
+
+ SWTControlUtil.setText(text, selected);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
index eb97503c4..4bf693963 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
@@ -239,4 +239,6 @@ public class Messages extends NLS {
public static String PeerImportWizardPage_overwrite_button;
public static String PeerImportWizardPage_overwriteDialog_message;
public static String PeerImportWizardPage_overwriteDialogToggle_message;
+
+ public static String ActiveConnectionStatusTrimControl_label;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
index 58a2fe177..9b831c3ed 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
@@ -198,3 +198,6 @@ PeerImportWizardPage_locationIsFile_error=Please enter or select a valid directo
PeerImportWizardPage_overwrite_button=Overwrite existing configuration(s) without warning
PeerImportWizardPage_overwriteDialog_message=The configuration ''{0}'' already exists. Do you want to overwrite it?
PeerImportWizardPage_overwriteDialogToggle_message=Remember my decision
+
+ActiveConnectionStatusTrimControl_label=Active Connection: {0}
+

Back to the top