Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-09-18 08:38:35 +0000
committerUwe Stieber2013-09-18 12:06:09 +0000
commit6ed2614942c85108b84f0a1daf655d2766e32caa (patch)
tree3f59b283e40b77118b9bb40da0664bf593ff248e /target_explorer
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')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ISelectionService.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml10
-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
5 files changed, 115 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ISelectionService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ISelectionService.java
index 363191594..208c7eece 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ISelectionService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ISelectionService.java
@@ -32,11 +32,12 @@ public interface ISelectionService extends IService {
/**
* Return a list of possible peer model node candidates.
- * The Se
+ * <p>
* If a selection is given and the filter applies, it will be used as the first element(s).
* Otherwise if a default selection was set using setDefaultSelection(IPeerModel)
* and the filter applies, it will be used as the first element.
* UI implementations of the service should then check the current editor and the system management selection.
+ *
* @param currentSelection The current selection (i.e. from a command handler) or <code>null</code>.
* @param filter The filter for the peer model node candidates or <code>null</code>
* @return Array of peer model nodes or an empty array.
@@ -45,12 +46,14 @@ public interface ISelectionService extends IService {
/**
* Set a new default selection.
+ *
* @param peerModel The default peer model node or <code>null</code> to reset the default.
*/
public void setDefaultSelection(IPeerModel peerModel);
/**
* Get the default selection.
+ *
* @param filter The filter for the peer model node candidates or <code>null</code>
* @return The set default selection if set and the filter applies, <code>null</code> otherwise.
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
index 8f6a75449..bdd1b5716 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
@@ -454,6 +454,16 @@
<command commandId="org.eclipse.tcf.te.tcf.ui.editor.command.debug"/>
</menuContribution>
+ <!-- Status line trim area -->
+ <menuContribution locationURI="toolbar:org.eclipse.ui.trim.status">
+ <toolbar id="org.eclipse.tcf.te.tcf.ui.trim.status.activeconnection">
+ <control
+ class="org.eclipse.tcf.te.tcf.ui.controls.ActiveConnectionStatusTrimControl"
+ id="org.eclipse.tcf.te.tcf.ui.trim.status.ActiveConnectionStatusTrimControl">
+ </control>
+ </toolbar>
+ </menuContribution>
+
</extension>
<!-- Command contributions -->
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