Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2015-05-12 07:24:09 -0400
committerUwe Stieber2015-05-12 07:24:09 -0400
commitd5a9b8c17e042603050fa0cabf9c60bb56ae6f3f (patch)
treed70744daf8fa54e423be2c8c760a100d78d7ba7b
parent2671cd6ca24be3355c3af74ec480755f6441f7e5 (diff)
downloadorg.eclipse.tcf-d5a9b8c17e042603050fa0cabf9c60bb56ae6f3f.tar.gz
org.eclipse.tcf-d5a9b8c17e042603050fa0cabf9c60bb56ae6f3f.tar.xz
org.eclipse.tcf-d5a9b8c17e042603050fa0cabf9c60bb56ae6f3f.zip
Target Explorer: Decorate the connection details editor details page form header and editor tooltip with connection state
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/interfaces/IConnectable.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.java43
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.properties10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractCustomFormToolkitEditorPage.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java50
7 files changed, 154 insertions, 6 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/interfaces/IConnectable.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/interfaces/IConnectable.java
index 8ccb1b734..5ba2a8753 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/interfaces/IConnectable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/interfaces/IConnectable.java
@@ -69,7 +69,7 @@ public interface IConnectable {
* Check whether a state change to the given state is allowed.
*
* @param state The new state to check.
- * @return <code>true</code> if a state change to the given state is currently allwoed.
+ * @return <code>true</code> if a state change to the given state is currently allowed.
*/
public boolean isConnectStateChangeAllowed(int state);
@@ -77,7 +77,7 @@ public interface IConnectable {
* Check whether a state change action is allowed.
*
* @param action The action to execute.
- * @return <code>true</code> if a state change action is currently allwoed.
+ * @return <code>true</code> if a state change action is currently allowed.
*/
public boolean isConnectStateChangeActionAllowed(int action);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.java
index b897f955c..fd61d1694 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.java
@@ -9,6 +9,8 @@
*******************************************************************************/
package org.eclipse.tcf.te.core.nls;
+import java.lang.reflect.Field;
+
import org.eclipse.osgi.util.NLS;
/**
@@ -27,10 +29,51 @@ public class Messages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
+ /**
+ * Returns the corresponding string for the given externalized strings
+ * key or <code>null</code> if the key does not exist.
+ *
+ * @param key The externalized strings key or <code>null</code>.
+ * @return The corresponding string or <code>null</code>.
+ */
+ public static String getString(String key) {
+ if (key != null) {
+ try {
+ Field field = Messages.class.getDeclaredField(key);
+ return (String)field.get(null);
+ } catch (Exception e) { /* ignored on purpose */ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the string representation of the given connect state.
+ *
+ * @param state The connect state.
+ * @return The string representation of the state or <code>null</code>.
+ */
+ public static String getConnectStateString(int state) {
+ String key = "Connectable_state_"; //$NON-NLS-1$
+ if (state < 0) key += "minus_"; //$NON-NLS-1$
+ key += Integer.toString(Math.abs(state));
+ return getString(key);
+ }
+
// **** Declare externalized string id's down here *****
public static String ModelNodePersistableAdapter_export_invalidPersistable;
public static String ModelNodePersistableAdapter_export_unknownType;
public static String ModelNodePersistableAdapter_import_invalidReference;
public static String ModelNodePersistableAdapter_import_cannotLoadClass;
+
+ public static String Connectable_state_0;
+ public static String Connectable_state_1;
+ public static String Connectable_state_11;
+ public static String Connectable_state_21;
+ public static String Connectable_state_minus_1;
+ public static String Connectable_state_minus_2;
+ public static String Connectable_state_minus_11;
+ public static String Connectable_state_minus_12;
+ public static String Connectable_state_minus_21;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.properties
index 26fb1d9aa..97ccdac05 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nls/Messages.properties
@@ -12,3 +12,13 @@ ModelNodePersistableAdapter_export_invalidPersistable=Persistable for object typ
ModelNodePersistableAdapter_export_unknownType=No strategy to persist an object of type ''{0}'', key = ''{1}''.
ModelNodePersistableAdapter_import_invalidReference=Reference provides incomplete information for property ''{0}'' to restore the object.
ModelNodePersistableAdapter_import_cannotLoadClass=Cannot load class for name ''{0}''
+
+Connectable_state_0=Unknown
+Connectable_state_1=Disconnected
+Connectable_state_11=Connected
+Connectable_state_21=Connection Lost
+Connectable_state_minus_1=Disconnect Scheduled
+Connectable_state_minus_2=Disconnecting...
+Connectable_state_minus_11=Connect Scheduled
+Connectable_state_minus_12=Connecting...
+Connectable_state_minus_21=Connection Recovering...
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java
index 677609daa..f84b36090 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java
@@ -73,6 +73,7 @@ public abstract class AbstractConfigurationEditorPage extends AbstractCustomForm
@Override
public void run() {
if (!getManagedForm().getForm().isDisposed()) {
+ setFormTitle(getFormTitle());
setFormImage(getFormImage());
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractCustomFormToolkitEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractCustomFormToolkitEditorPage.java
index 02f51e8d0..4ffd8934c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractCustomFormToolkitEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractCustomFormToolkitEditorPage.java
@@ -11,6 +11,7 @@
package org.eclipse.tcf.te.tcf.ui.editor;
import java.util.EventObject;
+import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.jface.action.IContributionItem;
@@ -18,6 +19,8 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.core.interfaces.IConnectable;
import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
import org.eclipse.tcf.te.runtime.events.ChangeEvent;
import org.eclipse.tcf.te.runtime.events.EventManager;
@@ -109,4 +112,36 @@ public abstract class AbstractCustomFormToolkitEditorPage extends org.eclipse.tc
}
};
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#getFormTitleStateDecoration()
+ */
+ @SuppressWarnings("restriction")
+ @Override
+ public String getFormTitleStateDecoration() {
+ String stateStr = null;
+
+ if (getEditorInputNode() instanceof IPeerNode) {
+ final AtomicInteger state = new AtomicInteger(IConnectable.STATE_UNKNOWN);
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ state.set(((IPeerNode)getEditorInputNode()).getConnectState());
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ final int s = state.get();
+ if (s == IConnectable.STATE_CONNECTED || s == IConnectable.STATE_CONNECTING || s == IConnectable.STATE_CONNECTION_LOST
+ || s == IConnectable.STATE_CONNECTION_RECOVERING || s == IConnectable.STATE_DISCONNECTING) {
+ String candidate = org.eclipse.tcf.te.core.nls.Messages.getConnectStateString(s);
+ if (candidate != null) stateStr = "(" + candidate + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ return stateStr;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
index 25d9e08c7..094fb1494 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage;
import org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage;
import org.eclipse.tcf.te.ui.views.extensions.EditorPageBinding;
import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
@@ -98,12 +99,28 @@ public final class Editor extends FormEditor implements IPersistableEditor, ITab
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#setTitleImage(org.eclipse.swt.graphics.Image)
+ *
+ * Re-export the method as public!
*/
@Override
public void setTitleImage(Image titleImage) {
super.setTitleImage(titleImage);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#getTitleToolTip()
+ */
+ @Override
+ public String getTitleToolTip() {
+ String fullToolTip = super.getTitleToolTip();
+ IFormPage page = getActivePageInstance();
+ if (page instanceof AbstractCustomFormToolkitEditorPage) {
+ String titleStateDecoration = ((AbstractCustomFormToolkitEditorPage)page).getFormTitleStateDecoration();
+ if (titleStateDecoration != null) fullToolTip += " " + titleStateDecoration; //$NON-NLS-1$
+ }
+ return fullToolTip;
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.forms.editor.FormEditor#getActivePageInstance()
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
index 822a06917..f7de5b7a1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
@@ -175,8 +175,12 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
// Decorate the form header
getFormToolkit().getFormToolkit().decorateFormHeading(managedForm.getForm().getForm());
- // And set the header text and image
- if (getFormTitle() != null) managedForm.getForm().getForm().setText(getFormTitle());
+
+ // Set the header text
+ String title = getFormTitle();
+ if (title != null) setFormTitle(title);
+
+ // Set the header image
managedForm.getForm().getForm().setImage(getFormImage());
// Add the toolbar items which will appear in the form header
@@ -199,6 +203,7 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
// }
// // Trigger an update of the menu widget
// menuManager.update(true);
+
// Trigger an update of the toolbar widget
toolBarManager.update(true);
}
@@ -215,13 +220,22 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
/**
* Returns the form title to set to the top form header.
*
- * @return The form title.
+ * @return The form title or <code>null</code>.
*/
protected String getFormTitle() {
return null;
}
/**
+ * Returns the form title state decoration.
+ *
+ * @return The form title state decoration or <code>null</code>.
+ */
+ public String getFormTitleStateDecoration() {
+ return null;
+ }
+
+ /**
* Returns the image to be set to the top form header.
*
* @return The image or <code>null</code> to use no image.
@@ -238,10 +252,29 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
return image;
}
+ /**
+ * Update the form header title.
+ *
+ * @param title The title text. Must not be <code>null</code>:
+ */
public void setFormTitle(String title) {
- getManagedForm().getForm().setText(title);
+ Assert.isNotNull(title);
+
+ String fullTitle = title;
+ String titleStateDecoration = getFormTitleStateDecoration();
+ if (titleStateDecoration != null) fullTitle += " " + titleStateDecoration; //$NON-NLS-1$
+
+ String oldTitle = getManagedForm().getForm().getText();
+ if (!fullTitle.equals(oldTitle)) {
+ getManagedForm().getForm().setText(fullTitle);
+ }
}
+ /**
+ * Update the form header image.
+ *
+ * @param image The image or <code>null</code>.
+ */
public void setFormImage(Image image) {
getManagedForm().getForm().setImage(image);
if (getEditor() instanceof Editor) {
@@ -249,6 +282,15 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#setActive(boolean)
+ */
+// @Override
+// public void setActive(boolean active) {
+// if (active) setFormTitle(getFormTitle());
+// super.setActive(active);
+// }
+
/**
* Create the toolbar contribution items.
*

Back to the top