Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-06-04 04:47:16 -0400
committerUwe Stieber2013-06-04 04:47:16 -0400
commit316e46e53b01320d8db82f0baa3e909e835661c9 (patch)
tree96f5c05190435f3373c2b4fbef686902ce28db3d
parent86b5d21293e0047cf791e7a1df2453ccf83fc5a8 (diff)
downloadorg.eclipse.tcf-316e46e53b01320d8db82f0baa3e909e835661c9.tar.gz
org.eclipse.tcf-316e46e53b01320d8db82f0baa3e909e835661c9.tar.xz
org.eclipse.tcf-316e46e53b01320d8db82f0baa3e909e835661c9.zip
Target Explorer: Allow label customization in process monitor properties view sections
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java497
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/SWTControlUtil.java7
5 files changed, 344 insertions, 258 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java
index ce73e97b2..bb8637aa9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java
@@ -10,20 +10,28 @@
package org.eclipse.tcf.te.tcf.processes.ui.internal.tabbed;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.ISysMonitor;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
+import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
/**
* The property section to display the context IDs of a process.
*/
public class ContextIDSection extends BaseTitledSection {
+ // The selected process node
+ /* default */ IProcessContextNode node;
// The system monitor context for the selected process node.
/* default */ ISysMonitor.SysMonitorContext context;
// The text field to display the id of the process context.
@@ -33,8 +41,10 @@ public class ContextIDSection extends BaseTitledSection {
// The text field to display the process group id.
private Text pgrpText;
// The text field to display the process id.
+ private CLabel pidLabel;
private Text pidText;
// The text field to display the parent process id.
+ private CLabel ppidLabel;
private Text ppidText;
// The text field to display the process TTY group ID.
private Text tgidText;
@@ -54,8 +64,14 @@ public class ContextIDSection extends BaseTitledSection {
idText = createTextField(null, Messages.ContextIDSection_ID);
parentIdText = createTextField(idText, Messages.ContextIDSection_ParentID);
pgrpText = createTextField(parentIdText, Messages.ContextIDSection_GroupID);
- pidText = createTextField(pgrpText, Messages.ContextIDSection_PID);
- ppidText = createTextField(pidText, Messages.ContextIDSection_PPID);
+
+
+ pidText = createText(pgrpText);
+ pidLabel = createLabel(pidText, Messages.ContextIDSection_PID);
+
+ ppidText = createText(pidText);
+ ppidLabel = createLabel(ppidText, Messages.ContextIDSection_PPID);
+
tgidText = createTextField(ppidText, Messages.ContextIDSection_TTY_GRPID);
tracerPidText = createTextField(tgidText, Messages.ContextIDSection_TracerPID);
uidText = createTextField(tracerPidText, Messages.ContextIDSection_UserID);
@@ -69,6 +85,7 @@ public class ContextIDSection extends BaseTitledSection {
protected void updateInput(IPeerModelProvider input) {
Assert.isTrue(input instanceof IProcessContextNode);
final IProcessContextNode node = (IProcessContextNode) input;
+ this.node = node;
Runnable runnable = new Runnable() {
@Override
@@ -86,11 +103,27 @@ public class ContextIDSection extends BaseTitledSection {
*/
@Override
public void refresh() {
+ IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class);
+ IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null;
+ IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null;
+
+ String label = delegate != null ? delegate.getMessage("ContextIDSection_PID") : null; //$NON-NLS-1$
+ if (label != null) SWTControlUtil.setText(pidLabel, label);
+ label = delegate != null ? delegate.getMessage("ContextIDSection_PPID") : null; //$NON-NLS-1$
+ if (label != null) SWTControlUtil.setText(ppidLabel, label);
+
this.idText.setText(context == null ? "" : (context.getID() != null ? context.getID() : "")); //$NON-NLS-1$ //$NON-NLS-2$
this.parentIdText.setText(context == null ? "" : (context.getParentID() != null ? context.getParentID() : "")); //$NON-NLS-1$ //$NON-NLS-2$
this.pgrpText.setText(context == null ? "" : (context.getPGRP() >= 0 ? "" + context.getPGRP() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- this.pidText.setText(context == null ? "" : (context.getPID() >= 0 ? "" + context.getPID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- this.ppidText.setText(context == null ? "" : (context.getPPID() >= 0 ? "" + context.getPPID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ String value = context != null && context.getPID() >= 0 ? Long.toString(context.getPID()) : ""; //$NON-NLS-1$
+ String value2 = delegate != null ? delegate.getText(node, "PID", value) : null; //$NON-NLS-1$
+ SWTControlUtil.setText(pidText, value2 != null ? value2 : value);
+
+ value = context != null && context.getPPID() >= 0 ? Long.toString(context.getPPID()) : ""; //$NON-NLS-1$
+ value2 = delegate != null ? delegate.getText(node, "PPID", value) : null; //$NON-NLS-1$
+ SWTControlUtil.setText(ppidText, value2 != null ? value2 : value);
+
this.tgidText.setText(context == null ? "" : (context.getTGID() >= 0 ? "" + context.getTGID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.tracerPidText.setText(context == null ? "" : (context.getTracerPID() >= 0 ? "" + context.getTracerPID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.uidText.setText(context == null ? "" : (context.getUID() >= 0 ? "" + context.getUID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java
index f10ee8adb..948525b3a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java
@@ -10,12 +10,17 @@
package org.eclipse.tcf.te.tcf.processes.ui.internal.tabbed;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.ISysMonitor;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
+import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
@@ -25,15 +30,21 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
* The property section to display the IDs of a process.
*/
public class IDSection extends BaseTitledSection {
+ // The selected process node
+ /* default */ IProcessContextNode node;
// The system monitor context for the selected process node.
/* default */ ISysMonitor.SysMonitorContext context;
// The text field to display the process id.
+ private CLabel pidLabel;
private Text pidText;
// The text field to display the parent process id.
+ private CLabel ppidLabel;
private Text ppidText;
// The text field to display the internal process id.
+ private CLabel ipidLabel;
private Text ipidText;
// The text field to display the internal parent process id.
+ private CLabel ippidLabel;
private Text ippidText;
/* (non-Javadoc)
@@ -42,10 +53,18 @@ public class IDSection extends BaseTitledSection {
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
- pidText = createTextField(null, Messages.IDSection_ProcessID);
- ppidText = createTextField(pidText, Messages.IDSection_ParentID);
- ipidText = createTextField(ppidText, Messages.IDSection_InternalID);
- ippidText = createTextField(ipidText, Messages.IDSection_InternalPPID);
+
+ pidText = createText(null);
+ pidLabel = createLabel(pidText, Messages.IDSection_ProcessID);
+
+ ppidText = createText(pidText);
+ ppidLabel = createLabel(ppidText, Messages.IDSection_ParentID);
+
+ ipidText = createText(ppidText);
+ ipidLabel = createLabel(ipidText, Messages.IDSection_InternalID);
+
+ ippidText = createText(ipidText);
+ ippidLabel = createLabel(ippidText, Messages.IDSection_InternalPPID);
}
/*
@@ -56,6 +75,7 @@ public class IDSection extends BaseTitledSection {
protected void updateInput(IPeerModelProvider input) {
Assert.isTrue(input instanceof IProcessContextNode);
final IProcessContextNode node = (IProcessContextNode) input;
+ this.node = node;
Runnable runnable = new Runnable() {
@Override
@@ -73,10 +93,33 @@ public class IDSection extends BaseTitledSection {
*/
@Override
public void refresh() {
- SWTControlUtil.setText(pidText, context != null && context.getPID() >= 0 ? Long.toString(context.getPID()) : ""); //$NON-NLS-1$
- SWTControlUtil.setText(ppidText, context != null && context.getPPID() >= 0 ? Long.toString(context.getPPID()) : ""); //$NON-NLS-1$
+ IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class);
+ IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null;
+ IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null;
+
+ String label = delegate != null ? delegate.getMessage("IDSection_Title") : null; //$NON-NLS-1$
+ if (label != null && section != null && !section.isDisposed()) section.setText(label);
+
+ label = delegate != null ? delegate.getMessage("IDSection_ProcessID") : null; //$NON-NLS-1$
+ if (label != null) SWTControlUtil.setText(pidLabel, label);
+ label = delegate != null ? delegate.getMessage("IDSection_ParentID") : null; //$NON-NLS-1$
+ if (label != null) SWTControlUtil.setText(ppidLabel, label);
+ label = delegate != null ? delegate.getMessage("IDSection_InternalID") : null; //$NON-NLS-1$
+ if (label != null) SWTControlUtil.setText(ipidLabel, label);
+ label = delegate != null ? delegate.getMessage("IDSection_InternalPPID") : null; //$NON-NLS-1$
+ if (label != null) SWTControlUtil.setText(ippidLabel, label);
+
+ String value = context != null && context.getPID() >= 0 ? Long.toString(context.getPID()) : ""; //$NON-NLS-1$
+ String value2 = delegate != null ? delegate.getText(node, "PID", value) : null; //$NON-NLS-1$
+ SWTControlUtil.setText(pidText, value2 != null ? value2 : value);
+
+ value = context != null && context.getPPID() >= 0 ? Long.toString(context.getPPID()) : ""; //$NON-NLS-1$
+ value2 = delegate != null ? delegate.getText(node, "PPID", value) : null; //$NON-NLS-1$
+ SWTControlUtil.setText(ppidText, value2 != null ? value2 : value);
+
SWTControlUtil.setText(ipidText, context != null && context.getID() != null ? context.getID() : ""); //$NON-NLS-1$
SWTControlUtil.setText(ippidText, context != null && context.getParentID() != null ? context.getParentID() : ""); //$NON-NLS-1$
+
super.refresh();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
index fd929166c..b0e7a07f5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
@@ -88,7 +88,7 @@ EditSpeedGradeDialog_NameLabel=Name:
EditSpeedGradeDialog_ValueLabel=Value:
IDSection_InternalID=Internal PID:
-IDSection_InternalPPID=InternalPPID:
+IDSection_InternalPPID=Internal PPID:
IDSection_ParentID=Parent ID:
IDSection_ProcessID=Process ID:
IDSection_Title=Process IDs
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java
index f1fe33b35..e5bc10cd4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java
@@ -1,248 +1,251 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 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.tabbed;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-/**
- * The base section that displays a title in a title bar.
- */
-public abstract class BaseTitledSection extends AbstractPropertySection implements PropertyChangeListener {
-
- // The main composite used to create the section content.
- protected Composite composite;
-
- protected IPropertyChangeProvider viewerInput;
-
- // The input node.
- protected IPeerModelProvider provider;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- */
- @Override
- public void setInput(IWorkbenchPart part, ISelection selection) {
- super.setInput(part, selection);
- if (this.viewerInput != null) {
- this.viewerInput.removePropertyChangeListener(this);
- }
- Assert.isTrue(selection instanceof IStructuredSelection);
- Object input = ((IStructuredSelection) selection).getFirstElement();
- if (input instanceof IPeerModelProvider) {
- this.provider = (IPeerModelProvider) input;
- IPeerModel peerNode = this.provider.getPeerModel();
- this.viewerInput = (IPropertyChangeProvider) peerNode.getAdapter(IPropertyChangeProvider.class);
- if (this.viewerInput != null) {
- this.viewerInput.addPropertyChangeListener(this);
- }
- } else {
- this.provider = null;
- this.viewerInput = null;
- }
- updateInput(provider);
- }
-
- /**
- * Update the input node.
- *
- * @param input The input node.
- */
- protected void updateInput(IPeerModelProvider input) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#aboutToBeHidden()
- */
- @Override
- public void aboutToBeHidden() {
- if(this.viewerInput != null) {
- this.viewerInput.removePropertyChangeListener(this);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
- */
- @Override
- public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
- super.createControls(parent, aTabbedPropertySheetPage);
- parent.setLayout(new FormLayout());
-
- Section section = getWidgetFactory().createSection(parent, ExpandableComposite.TITLE_BAR);
- section.setText(getText());
- FormData data = new FormData();
- data.left = new FormAttachment(0, ITabbedPropertyConstants.HMARGIN);
- data.right = new FormAttachment(100, -ITabbedPropertyConstants.HMARGIN);
- data.top = new FormAttachment(0, 2 * ITabbedPropertyConstants.VMARGIN);
- section.setLayoutData(data);
-
- composite = getWidgetFactory().createComposite(parent);
- FormLayout layout = new FormLayout();
- layout.spacing = ITabbedPropertyConstants.HMARGIN;
- composite.setLayout(layout);
-
- data = new FormData();
- data.left = new FormAttachment(0, 2 * ITabbedPropertyConstants.HMARGIN);
- data.right = new FormAttachment(100, -2 * ITabbedPropertyConstants.HMARGIN);
- data.top = new FormAttachment(section, ITabbedPropertyConstants.VSPACE);
- data.bottom = new FormAttachment(100, 0);
- composite.setLayoutData(data);
- }
-
- /**
- * Create a label for the control using the specified text.
- *
- * @param control The control for which the label is created.
- * @param text The label text.
- */
- protected void createLabel(Control control, String text) {
- CLabel nameLabel = getWidgetFactory().createCLabel(composite, text);
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(control, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(control, 0, SWT.CENTER);
- nameLabel.setLayoutData(data);
- }
-
- /**
- * Create a text field and a label with the specified label
- * relative to the specified control.
- *
- * @param control The control relative to.
- * @param label The text of the label.
- * @return The new text created.
- */
- protected Text createTextField(Control control, String label) {
- Text text = createText(control);
- createLabel(text, label);
- return text;
- }
-
- /**
- * Create a wrap text field and a label with the specified label
- * relative to the specified control.
- *
- * @param control The control relative to.
- * @param label The text of the label.
- * @return The new wrap text created.
- */
- protected Text createWrapTextField(Control control, String label) {
- Text text = createWrapText(control);
- createLabel(text, label);
- return text;
- }
-
- /**
- * Create a text field relative to the specified control.
- *
- * @param control The control to layout the new text field.
- * @return The new text field created.
- */
- private Text createText(Control control) {
- Text text = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- FormData data = new FormData();
- data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
- data.right = new FormAttachment(100, 0);
- if (control == null) {
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- }
- else {
- data.top = new FormAttachment(control, ITabbedPropertyConstants.VSPACE);
- }
- text.setLayoutData(data);
- text.setEditable(false);
- return text;
- }
-
- /**
- * Create a wrap text field relative to the specified control.
- *
- * @param control The control to layout the new wrap text field.
- * @return The new wrap text field created.
- */
- private Text createWrapText(Control control) {
- Text text = getWidgetFactory().createText(composite, "", SWT.WRAP); //$NON-NLS-1$
- FormData data = new FormData();
- data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
- data.right = new FormAttachment(100, 0);
- if (control == null) {
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- }
- else {
- data.top = new FormAttachment(control, ITabbedPropertyConstants.VSPACE);
- }
- data.width = 200;
- text.setLayoutData(data);
- text.setEditable(false);
- return text;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
- */
- @Override
- public void refresh() {
- if (composite != null) {
- composite.layout();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getSource() == provider) {
- updateInput(provider);
- Display display = getPart().getSite().getShell().getDisplay();
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- refresh();
- }
- });
- }
- }
-
- /**
- * Get the text which is used as the title in the title bar of the section.
- *
- * @return A text string representing the section.
- */
- protected abstract String getText();
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.tabbed;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * The base section that displays a title in a title bar.
+ */
+public abstract class BaseTitledSection extends AbstractPropertySection implements PropertyChangeListener {
+ // The section
+ protected Section section;
+
+ // The main composite used to create the section content.
+ protected Composite composite;
+
+ protected IPropertyChangeProvider viewerInput;
+
+ // The input node.
+ protected IPeerModelProvider provider;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ if (this.viewerInput != null) {
+ this.viewerInput.removePropertyChangeListener(this);
+ }
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object input = ((IStructuredSelection) selection).getFirstElement();
+ if (input instanceof IPeerModelProvider) {
+ this.provider = (IPeerModelProvider) input;
+ IPeerModel peerNode = this.provider.getPeerModel();
+ this.viewerInput = (IPropertyChangeProvider) peerNode.getAdapter(IPropertyChangeProvider.class);
+ if (this.viewerInput != null) {
+ this.viewerInput.addPropertyChangeListener(this);
+ }
+ } else {
+ this.provider = null;
+ this.viewerInput = null;
+ }
+ updateInput(provider);
+ }
+
+ /**
+ * Update the input node.
+ *
+ * @param input The input node.
+ */
+ protected void updateInput(IPeerModelProvider input) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#aboutToBeHidden()
+ */
+ @Override
+ public void aboutToBeHidden() {
+ if(this.viewerInput != null) {
+ this.viewerInput.removePropertyChangeListener(this);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ parent.setLayout(new FormLayout());
+
+ section = getWidgetFactory().createSection(parent, ExpandableComposite.TITLE_BAR);
+ section.setText(getText());
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, ITabbedPropertyConstants.HMARGIN);
+ data.right = new FormAttachment(100, -ITabbedPropertyConstants.HMARGIN);
+ data.top = new FormAttachment(0, 2 * ITabbedPropertyConstants.VMARGIN);
+ section.setLayoutData(data);
+
+ composite = getWidgetFactory().createComposite(parent);
+ FormLayout layout = new FormLayout();
+ layout.spacing = ITabbedPropertyConstants.HMARGIN;
+ composite.setLayout(layout);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 2 * ITabbedPropertyConstants.HMARGIN);
+ data.right = new FormAttachment(100, -2 * ITabbedPropertyConstants.HMARGIN);
+ data.top = new FormAttachment(section, ITabbedPropertyConstants.VSPACE);
+ data.bottom = new FormAttachment(100, 0);
+ composite.setLayoutData(data);
+ }
+
+ /**
+ * Create a label for the control using the specified text.
+ *
+ * @param control The control for which the label is created.
+ * @param text The label text.
+ */
+ protected CLabel createLabel(Control control, String text) {
+ CLabel nameLabel = getWidgetFactory().createCLabel(composite, text);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(control, -ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(control, 0, SWT.CENTER);
+ nameLabel.setLayoutData(data);
+ return nameLabel;
+ }
+
+ /**
+ * Create a text field and a label with the specified label
+ * relative to the specified control.
+ *
+ * @param control The control relative to.
+ * @param label The text of the label.
+ * @return The new text created.
+ */
+ protected Text createTextField(Control control, String label) {
+ Text text = createText(control);
+ createLabel(text, label);
+ return text;
+ }
+
+ /**
+ * Create a wrap text field and a label with the specified label
+ * relative to the specified control.
+ *
+ * @param control The control relative to.
+ * @param label The text of the label.
+ * @return The new wrap text created.
+ */
+ protected Text createWrapTextField(Control control, String label) {
+ Text text = createWrapText(control);
+ createLabel(text, label);
+ return text;
+ }
+
+ /**
+ * Create a text field relative to the specified control.
+ *
+ * @param control The control to layout the new text field.
+ * @return The new text field created.
+ */
+ protected Text createText(Control control) {
+ Text text = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
+ data.right = new FormAttachment(100, 0);
+ if (control == null) {
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ }
+ else {
+ data.top = new FormAttachment(control, ITabbedPropertyConstants.VSPACE);
+ }
+ text.setLayoutData(data);
+ text.setEditable(false);
+ return text;
+ }
+
+ /**
+ * Create a wrap text field relative to the specified control.
+ *
+ * @param control The control to layout the new wrap text field.
+ * @return The new wrap text field created.
+ */
+ protected Text createWrapText(Control control) {
+ Text text = getWidgetFactory().createText(composite, "", SWT.WRAP); //$NON-NLS-1$
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
+ data.right = new FormAttachment(100, 0);
+ if (control == null) {
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ }
+ else {
+ data.top = new FormAttachment(control, ITabbedPropertyConstants.VSPACE);
+ }
+ data.width = 200;
+ text.setLayoutData(data);
+ text.setEditable(false);
+ return text;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ if (composite != null) {
+ composite.layout();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getSource() == provider) {
+ updateInput(provider);
+ Display display = getPart().getSite().getShell().getDisplay();
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ refresh();
+ }
+ });
+ }
+ }
+
+ /**
+ * Get the text which is used as the title in the title bar of the section.
+ *
+ * @return A text string representing the section.
+ */
+ protected abstract String getText();
} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/SWTControlUtil.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/SWTControlUtil.java
index bde8ef511..8378d5475 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/SWTControlUtil.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/SWTControlUtil.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.ui.swt;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@@ -58,6 +59,9 @@ public final class SWTControlUtil {
if (control instanceof Label) {
return ((Label)control).getText().trim();
}
+ if (control instanceof CLabel) {
+ return ((CLabel)control).getText().trim();
+ }
if (control instanceof Link) {
return ((Link)control).getText().trim();
}
@@ -98,6 +102,9 @@ public final class SWTControlUtil {
if (control instanceof Label) {
((Label)control).setText(trimmedValue);
}
+ if (control instanceof CLabel) {
+ ((CLabel)control).setText(trimmedValue);
+ }
if (control instanceof Link) {
((Link)control).setText(trimmedValue);
}

Back to the top