From 6ed2614942c85108b84f0a1daf655d2766e32caa Mon Sep 17 00:00:00 2001
From: Uwe Stieber
Date: Wed, 18 Sep 2013 10:38:35 +0200
Subject: Target Explorer: Visualize the active connection as status bar trim
area
---
.../interfaces/services/ISelectionService.java | 5 +-
.../plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml | 10 +++
.../ActiveConnectionStatusTrimControl.java | 96 ++++++++++++++++++++++
.../org/eclipse/tcf/te/tcf/ui/nls/Messages.java | 2 +
.../eclipse/tcf/te/tcf/ui/nls/Messages.properties | 3 +
5 files changed, 115 insertions(+), 1 deletion(-)
create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ActiveConnectionStatusTrimControl.java
(limited to 'target_explorer')
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
+ *
* 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 null
.
* @param filter The filter for the peer model node candidates or null
* @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 null
to reset the default.
*/
public void setDefaultSelection(IPeerModel peerModel);
/**
* Get the default selection.
+ *
* @param filter The filter for the peer model node candidates or null
* @return The set default selection if set and the filter applies, null
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 @@
+
+
+
+
+
+
+
+
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}
+
--
cgit v1.2.3