Author: scabanovich
Date: 2011-12-30 15:21:49 -0500 (Fri, 30 Dec 2011)
New Revision: 37599
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultComboBoxValueAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultTreeSelectionAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultValueAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkLineFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java
Log:
JBIDE-10576
https://issues.joss.org/browse/JBIDE-10576
Linking capability is moved from StringButtonFieldEditorEx to basic ExtendedFieldEditor.
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultComboBoxValueAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultComboBoxValueAdapter.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultComboBoxValueAdapter.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -14,6 +14,7 @@
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
+import org.jboss.tools.common.model.ui.actions.IActionProvider;
import org.jboss.tools.common.model.ui.attribute.IListContentProvider;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.ILabelProvider;
@@ -63,6 +64,9 @@
}
return this.listContentProvider;
}
+ if (adapter == IActionProvider.class) {
+ return getActionProvider();
+ }
Assert.isTrue(true, "DefaultValueAdapter instance itself cannot provide adapter
for "+adapter.getName()); //$NON-NLS-1$
return null;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultTreeSelectionAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultTreeSelectionAdapter.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultTreeSelectionAdapter.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -20,14 +20,14 @@
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
-import org.jboss.tools.common.model.ui.ModelUIMessages;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.attribute.editor.ExtendedFieldEditor;
import org.jboss.tools.common.model.ui.attribute.editor.PropertyEditor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -45,10 +45,8 @@
import org.jboss.tools.common.model.ui.actions.IActionProvider;
public class DefaultTreeSelectionAdapter extends DefaultValueAdapter implements
IAdaptable, ISelectionProvider, ISelectionChangedListener {
+ public static final String LINK_ACTION = "linkAction"; //$NON-NLS-1$
- private static final String STRING_BUTTON_ACTION = "Label.Selected";
//$NON-NLS-1$
- private static final String STRING_BUTTON_XACTION = "linkAction";
//$NON-NLS-1$
-
protected ILabelProvider labelProvider;
protected ITreeContentProvider treeContentProvider;
@@ -162,40 +160,13 @@
private ActionProvider actionProvider;
private XActionWrapper labelAction;
- private ActionProvider getActionProvider() {
- if (this.actionProvider==null) this.actionProvider = new ActionProvider();
+ protected ActionProvider getActionProvider() {
+ if (this.actionProvider == null) {
+ this.actionProvider = new ActionProvider();
+ }
return this.actionProvider;
}
- class XActionWrapper extends Action {
-
- private XAction xaction = null;
-
- public XActionWrapper(XAction xaction) {
- this.xaction = xaction;
- }
-
- public void setXModelObject(XModelObject xmo) {
- if (xmo != null && xaction != null) {
-// this.setEnabled(xaction.isEnabled(xmo));
- this.setEnabled(Boolean.TRUE.booleanValue());
- } else {
- this.setEnabled(Boolean.FALSE.booleanValue());
- }
- }
-
- public void run() {
- if (xaction != null) {
- if(xaction.isEnabled(getModelObject())) {
- XActionInvoker.invoke(xaction.getPath(), modelObject, new Properties());
- } else {
- Shell shell =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
- MessageDialog.openWarning(shell, "Warning", "Resource does not
exist.");
- }
- }
- }
- }
-
class ActionProvider implements IActionProvider {
private HashMap<String,IAction> actions = new HashMap<String,IAction>();
@@ -239,7 +210,7 @@
private void initActions() {
treeContentProvider = getTreeContentProvider();
if (treeContentProvider instanceof DefaultXAttributeTreeContentProvider) {
- String linkActionName =
((DefaultXAttributeTreeContentProvider)treeContentProvider).getProperties().getProperty(STRING_BUTTON_XACTION);
+ String linkActionName =
((DefaultXAttributeTreeContentProvider)treeContentProvider).getProperties().getProperty(LINK_ACTION);
if (linkActionName!=null) {
XAction xAction = XActionInvoker.getAction(linkActionName, modelObject);
if (xAction!=null) {
@@ -249,7 +220,7 @@
// XModelObject object =
(XModelObject)getObjectByPath(this.getStringValue(Boolean.TRUE.booleanValue()));
// linkAction.setXModelObject(object);
linkAction.setEnabled(true);
- getActionProvider().putAction(STRING_BUTTON_ACTION, linkAction);
+ getActionProvider().putAction(ExtendedFieldEditor.LABEL_SELECTED, linkAction);
}
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultValueAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultValueAdapter.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/DefaultValueAdapter.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -13,18 +13,29 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.util.Properties;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.actions.IActionProvider;
import org.jboss.tools.common.model.ui.attribute.IValueFilter;
+import org.jboss.tools.common.model.ui.attribute.editor.ExtendedFieldEditor;
import org.jboss.tools.common.model.ui.attribute.editor.IPropertyEditor;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.action.XAction;
+import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.meta.action.XAttributeData;
+import org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintProperties;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
@@ -188,6 +199,9 @@
return valueFilter;
}
}
+ if (adapter == IActionProvider.class) {
+ return getActionProvider();
+ }
return null;
}
@@ -267,4 +281,76 @@
}
return XMarkerManager.getInstance().getError(modelObject, attribute.getName());
}
+
+ protected XActionWrapper labelAction;
+ protected IActionProvider actionProvider;
+
+ protected IActionProvider getActionProvider() {
+ if(actionProvider == null) {
+ String actionPath = null;
+ if(attribute != null) {
+ if(attribute.getConstraint() instanceof XAttributeConstraintProperties) {
+ actionPath =
((XAttributeConstraintProperties)attribute.getConstraint()).getProperties().getProperty(DefaultTreeSelectionAdapter.LINK_ACTION);
+ } else {
+ actionPath = attribute.getProperty(DefaultTreeSelectionAdapter.LINK_ACTION);
+ }
+ }
+ if(actionPath != null) {
+ actionProvider = new ActionProvider();
+ XAction xaction = XActionInvoker.getAction(actionPath, modelObject);
+ labelAction = (xaction != null) ? new XActionWrapper(xaction) : null;
+ if(labelAction != null) {
+ labelAction.setXModelObject(getModelObject());
+ }
+ }
+ }
+
+ return actionProvider;
+ }
+
+ protected class XActionWrapper extends Action {
+ private XAction xaction = null;
+
+ public XActionWrapper(XAction xaction) {
+ this.xaction = xaction;
+ }
+
+ public void setXModelObject(XModelObject xmo) {
+ if (xmo != null && xaction != null) {
+// this.setEnabled(xaction.isEnabled(xmo));
+ this.setEnabled(true);
+ } else {
+ this.setEnabled(false);
+ }
+ }
+
+ public void run() {
+ if (xaction != null) {
+ if(xaction.isEnabled(getModelObject())) {
+ XActionInvoker.invoke(xaction.getPath(), modelObject, new Properties());
+ } else {
+ Shell shell =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageDialog.openWarning(shell, "Warning", "Resource does not
exist.");
+ }
+ }
+ }
+ }
+
+ protected class ActionProvider implements IActionProvider {
+
+ public ActionProvider() {}
+
+ public IAction getAction(String actionName) {
+ if (ExtendedFieldEditor.LABEL_SELECTED.equals(actionName)) {
+ return labelAction;
+ }
+ return null;
+ }
+
+ public IAction[] getActions() {
+ return new IAction[] {labelAction};
+ }
+ public void update(ISelection selection) {}
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -20,11 +20,9 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.jface.fieldassist.ComboContentAdapter;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
-import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
@@ -49,11 +47,13 @@
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
+import org.jboss.tools.common.model.ui.actions.IActionProvider;
import
org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.common.model.ui.attribute.IListContentProvider;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.jboss.tools.common.model.ui.widgets.BorderedControl;
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
+import org.jboss.tools.common.model.ui.widgets.WhiteSettings;
import org.jboss.tools.common.model.ui.widgets.border.Border;
public class ComboBoxFieldEditor extends ExtendedFieldEditor implements
IFieldEditor, IPropertyFieldEditor, IPropertyChangeListener, PropertyChangeListener {
@@ -393,6 +393,14 @@
labelProvider = (ILabelProvider)propertyEditor.getAdapter(ILabelProvider.class);
listContentProvider =
(IListContentProvider)propertyEditor.getAdapter(IListContentProvider.class);
setErrorProvider((IAttributeErrorProvider)propertyEditor.getAdapter(IAttributeErrorProvider.class));
+ IActionProvider actionProvider =
(IActionProvider)propertyEditor.getAdapter(IActionProvider.class);
+ if (actionProvider != null) {
+ if (getSettings() instanceof WhiteSettings) {
+ setLabelAction(actionProvider.getAction(StringButtonFieldEditorEx.LABEL_SELECTED));
+ } else {
+ // none
+ }
+ }
}
setPropertyChangeListener(this);
valueProvider.addValueChangeListener(this);
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -15,13 +15,18 @@
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.navigator.LabelDecoratorImpl;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
@@ -37,15 +42,21 @@
import org.jboss.tools.common.model.ui.widgets.DefaultSettings;
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
import org.jboss.tools.common.model.ui.widgets.WhiteSettings;
+import org.jboss.tools.common.model.ui.widgets.xpl.SelectableFormLabel;
public abstract class ExtendedFieldEditor extends
org.eclipse.jface.preference.FieldEditor {
+ public final static String LABEL_SELECTED = "Label.Selected"; //$NON-NLS-1$
public static final String IS_VALID = "field_editor_is_valid";//$NON-NLS-1$
public static final String VALUE = "field_editor_value";//$NON-NLS-1$
protected static final int HORIZONTAL_GAP = 8;
private IPreferenceStore preferenceStore = null;
private boolean isDefaultPresented = false;
+
private Label label;
+ private IAction labelAction;
+ private boolean selectableLabel;
+
private boolean enabled = Boolean.TRUE.booleanValue();
private IAttributeErrorProvider errorProvider;
@@ -150,17 +161,114 @@
}
protected Label createLabelControl(Composite parent) {
+ if (label == null) { // cannot comment this! for details see label.addDisposeListener
+ int style;
+ Color fg;
+ Color activeColor;
+ Color disabled;
+ Font font;
+ Cursor cursor;
+ if (getLabelAction()!=null) {
+ style = getSettings().getStyle("Hyperlink.Style"); //$NON-NLS-1$
+ fg = getSettings().getColor("Hyperlink.Foreground"); //$NON-NLS-1$
+ disabled = getSettings().getColor("Hyperlink.Disabled"); //$NON-NLS-1$
+ activeColor = getSettings().getColor("Hyperlink.ActiveColor");
//$NON-NLS-1$
+ font = getSettings().getFont("Hyperlink.Font"); //$NON-NLS-1$
+ cursor = getSettings().getCursor("Hyperlink.ActiveCursor"); //$NON-NLS-1$
+
+ if (style==SWT.DEFAULT) style = SWT.NONE;
+ SelectableFormLabel selectableLabel = new SelectableFormLabel(parent, style);
+
+ selectableLabel.setFont(font);
+ selectableLabel.setActiveCursor(cursor);
+ selectableLabel.setPassiveColor(fg);
+ selectableLabel.setActiveColor(activeColor);
+ selectableLabel.setActiveCursor(cursor);
+ selectableLabel.setDisabledColor(disabled);
+ boolean enabled = getLabelAction().isEnabled() && isEnabled();
+ selectableLabel.setEnabled(enabled);
+ selectableLabel.setToolTipText(enabled ? getHyperlinkLableToolTip() : null);
+
+ label = selectableLabel;
+
+ selectableLabel.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ if (labelAction!=null) labelAction.run();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ getLabelAction().addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
+ if (IAction.ENABLED.equals(event.getProperty())) {
+ boolean enabled = getLabelAction().isEnabled();
+ ((SelectableFormLabel)label).setEnabled(enabled);
+ label.setToolTipText(enabled ? getHyperlinkLableToolTip() : null);
+ ((SelectableFormLabel)label).redraw();
+ }
+ }
+ });
+ // by default
+// getLabelAction().setEnabled(Boolean.FALSE.booleanValue());
+ } else {
+ style = getSettings().getStyle("Label.Style"); //$NON-NLS-1$
+ if (style==SWT.DEFAULT) style = SWT.NONE;
+ fg = getSettings().getColor("Label.Foreground"); //$NON-NLS-1$
+ font = getSettings().getFont("Label.Font"); //$NON-NLS-1$
+ label = new Label(parent, style);
+
+ label.setFont(font);
+ label.setForeground(fg);
+ label.setEnabled(isEnabled());
+ }
+ String text = getLabelText();
+ if (text != null)
+ label.setText(text);
+ label.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ label = null;
+ }
+ });
+ if(settings instanceof WhiteSettings) {
+ label.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ }
+ } else {
+ checkParent(label, parent);
+ }
+ return label;
+ }
+
+ public IAction getLabelAction() {
+ return labelAction;
+ }
+
+ public void setLabelAction(IAction action) {
+ labelAction = action;
+ setSelectableLabel(labelAction != null);
+ }
+
+ protected String getHyperlinkLableToolTip() {
+ return null;
+ }
+
+ public boolean isSelectableLabel() {
+ return selectableLabel;
+ }
+
+ public void setSelectableLabel(boolean b) {
+ selectableLabel = b;
+ }
+
+ /*
+ protected Label createLabelControl(Composite parent) {
if (getLabelControl() == null) { // cannot comment this! for details see
label.addDisposeListener
int style = getSettings().getStyle("Label.Style"); //$NON-NLS-1$
-/// Color bg = parent.getBackground();
- ///getSettings().getColor("Label.Background");
Color fg = getSettings().getColor("Label.Foreground"); //$NON-NLS-1$
Font font = getSettings().getFont("Label.Font"); //$NON-NLS-1$
if (style==SWT.DEFAULT) style = SWT.NONE;
style |= SWT.RIGHT;
label = new Label(parent, style);
label.setFont(font);
-/// label.setBackground(bg);
label.setForeground(fg);
if(settings instanceof WhiteSettings) {
label.setForeground(getForeground());
@@ -181,6 +289,7 @@
}
return label;
}
+ */
public IPreferenceStore getPreferenceStore() {
return preferenceStore;
@@ -251,8 +360,7 @@
}
}
- protected void setButtonLayoutData(Button button) {
-
+ protected void setButtonLayoutData(Button button) {
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
// Compute and store a font metric
@@ -273,8 +381,12 @@
public void setEnabled(boolean enabled) {
this.enabled = enabled;
- if ((this.label!=null)&&(!this.label.isDisposed())) {
- label.setEnabled(this.enabled);
+ if (label != null && !label.isDisposed()) {
+ if (getLabelAction()!=null) {
+ label.setEnabled(getLabelAction().isEnabled() && enabled);
+ } else {
+ label.setEnabled(enabled);
+ }
}
}
@@ -283,7 +395,9 @@
}
public IWidgetSettings getSettings() {
- if (this.settings==null) settings = DefaultSettings.getDefault();
+ if (settings == null) {
+ settings = DefaultSettings.getDefault();
+ }
return settings;
}
@@ -322,6 +436,4 @@
updateErrorState();
}
}
-
}
-
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkLineFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkLineFieldEditor.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkLineFieldEditor.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -17,22 +17,13 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
-import org.eclipse.jdt.internal.ui.dialogs.OpenTypeSelectionDialog;
-import
org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.JFaceResources;
@@ -43,10 +34,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
-import org.eclipse.ui.menus.IWorkbenchWidget;
import org.jboss.tools.common.meta.XAttribute;
-import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -55,14 +43,12 @@
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.jboss.tools.common.model.ui.attribute.adapter.IModelPropertyEditorAdapter;
-import org.jboss.tools.common.model.ui.templates.ControlContentAssistHelper;
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
import org.jboss.tools.common.model.ui.wizards.INewClassWizard;
import org.jboss.tools.common.model.ui.wizards.INewClassWizardFactory;
import org.jboss.tools.common.model.ui.wizards.NewClassWizard;
import org.jboss.tools.common.model.ui.wizards.NewTypeWizardAdapter;
import org.jboss.tools.common.model.util.AccessibleJava;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.model.util.XModelObjectUtil;
@@ -126,7 +112,6 @@
valueChangeListener =
(IValueChangeListener)propertyEditor.getAdapter(IValueChangeListener.class);
if(project != null) {
setLabelAction(new OpenJavaEditorAction());
- setSelectableLabel(Boolean.TRUE.booleanValue());
setChangeButtonText(JFaceResources.getString("openBrowse")); //$NON-NLS-1$
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -19,24 +19,14 @@
import org.jboss.tools.common.model.ui.IValueProvider;
import
org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
-import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Font;
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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -46,21 +36,15 @@
import org.jboss.tools.common.model.ui.actions.IActionProvider;
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
import org.jboss.tools.common.model.ui.widgets.WhiteSettings;
-import org.jboss.tools.common.model.ui.widgets.xpl.SelectableFormLabel;
public class StringButtonFieldEditorEx extends StringButtonFieldEditor implements
IFieldEditor, IPropertyChangeListener, PropertyChangeListener, IPropertyFieldEditor {
- public final static String LABEL_SELECTED = "Label.Selected"; //$NON-NLS-1$
public final static String BUTTON_SELECTED = "Button.Selected"; //$NON-NLS-1$
protected PropertyEditorDialog editorDialog;
protected IPropertyEditor propertyEditor;
protected IValueProvider valueProvider;
protected IValueChangeListener valueChangeListener;
protected Composite composite;
- private Label label;
- private boolean selectableLabel;
private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
- private IActionProvider actionProvider;
- private IAction labelAction;
// private IAction buttonAction;
public StringButtonFieldEditorEx() {
@@ -72,99 +56,6 @@
this.setChangeButtonText(EditorMessages.getString("StringButtonFieldEditorEx_Browse"));
//$NON-NLS-1$
}
- public Label getLabelControl() {
- return label;
- }
-
- protected String getHyperlinkLableToolTip() {
- return null;
- }
-
- protected Label createLabelControl(Composite parent) {
- if (label == null) { // cannot comment this! for details see label.addDisposeListener
- int style;
-/// Color bg;
- Color fg;
- Color activeColor;
- Color disabled;
- Font font;
- Cursor cursor;
- if (getLabelAction()!=null) {
- style = getSettings().getStyle("Hyperlink.Style"); //$NON-NLS-1$
-/// bg = parent.getBackground();
- ///getSettings().getColor("Hyperlink.Background");
- fg = getSettings().getColor("Hyperlink.Foreground"); //$NON-NLS-1$
- disabled = getSettings().getColor("Hyperlink.Disabled"); //$NON-NLS-1$
- activeColor = getSettings().getColor("Hyperlink.ActiveColor");
//$NON-NLS-1$
- font = getSettings().getFont("Hyperlink.Font"); //$NON-NLS-1$
- cursor = getSettings().getCursor("Hyperlink.ActiveCursor"); //$NON-NLS-1$
-
- if (style==SWT.DEFAULT) style = SWT.NONE;
- SelectableFormLabel selectableLabel = new SelectableFormLabel(parent, style);
-
- selectableLabel.setFont(font);
-/// selectableLabel.setBackground(bg);
- selectableLabel.setActiveCursor(cursor);
- selectableLabel.setPassiveColor(fg);
- selectableLabel.setActiveColor(activeColor);
- selectableLabel.setActiveCursor(cursor);
- selectableLabel.setDisabledColor(disabled);
- boolean enabled = getLabelAction().isEnabled() && isEnabled();
- selectableLabel.setEnabled(enabled);
- selectableLabel.setToolTipText(enabled ? getHyperlinkLableToolTip() : null);
-
- label = selectableLabel;
-
- selectableLabel.addSelectionListener(new SelectionListener(){
- public void widgetSelected(SelectionEvent e) {
- if (labelAction!=null) labelAction.run();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- getLabelAction().addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (IAction.ENABLED.equals(event.getProperty())) {
- boolean enabled = getLabelAction().isEnabled();
- ((SelectableFormLabel)label).setEnabled(enabled);
- label.setToolTipText(enabled ? getHyperlinkLableToolTip() : null);
- ((SelectableFormLabel)label).redraw();
- }
- }
- });
- // by default
-// getLabelAction().setEnabled(Boolean.FALSE.booleanValue());
- } else {
- style = getSettings().getStyle("Label.Style"); //$NON-NLS-1$
- if (style==SWT.DEFAULT) style = SWT.NONE;
-/// bg = parent.getBackground();
- ///getSettings().getColor("Label.Background");
- fg = getSettings().getColor("Label.Foreground"); //$NON-NLS-1$
- font = getSettings().getFont("Label.Font"); //$NON-NLS-1$
- label = new Label(parent, style);
-
- label.setFont(font);
-/// label.setBackground(bg);
- label.setForeground(fg);
- label.setEnabled(isEnabled());
- }
- String text = getLabelText();
- if (text != null)
- label.setText(text);
- label.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- label = null;
- }
- });
- if(settings instanceof WhiteSettings) {
- label.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- }
- } else {
- checkParent(label, parent);
- }
- return label;
- }
-
public void addPropertyChangeListener(PropertyChangeListener listener) {
pcs.addPropertyChangeListener(listener);
}
@@ -174,7 +65,6 @@
public void firePropertyChange(java.beans.PropertyChangeEvent event) {
pcs.firePropertyChange(event);
}
-
public void setPropertyEditor(IPropertyEditor propertyEditor) {
this.propertyEditor = propertyEditor;
@@ -182,15 +72,14 @@
valueChangeListener =
(IValueChangeListener)propertyEditor.getAdapter(IValueChangeListener.class);
setPropertyChangeListener(this);
valueProvider.addValueChangeListener(this);
- actionProvider = (IActionProvider)propertyEditor.getAdapter(IActionProvider.class);
+ IActionProvider actionProvider =
(IActionProvider)propertyEditor.getAdapter(IActionProvider.class);
setErrorProvider((IAttributeErrorProvider)propertyEditor.getAdapter(IAttributeErrorProvider.class));
- if (actionProvider!=null) {
+ if (actionProvider != null) {
if (getSettings() instanceof WhiteSettings) {
- labelAction = actionProvider.getAction(StringButtonFieldEditorEx.LABEL_SELECTED);
+ setLabelAction(actionProvider.getAction(StringButtonFieldEditorEx.LABEL_SELECTED));
} else {
// none
}
- if (labelAction!=null) this.selectableLabel = Boolean.TRUE.booleanValue();
// buttonAction =
actionProvider.getAction(StringButtonFieldEditorEx.BUTTON_SELECTED);
}
}
@@ -200,7 +89,7 @@
}
protected String changePressed() {
- if (propertyEditor!=null) {
+ if (propertyEditor != null) {
if(propertyEditor.getInput() instanceof DefaultValueAdapter) {
((DefaultValueAdapter)propertyEditor.getInput()).fireEvent(BUTTON_SELECTED,
"false", "true");
}
@@ -304,9 +193,9 @@
protected void valueChanged() {
super.valueChanged();
- if(isSelectableLabel() && label != null && !label.isDisposed()) {
+ if(isSelectableLabel() && getLabelControl() != null &&
!getLabelControl().isDisposed()) {
boolean enabled = getLabelAction() != null && getLabelAction().isEnabled();
- label.setToolTipText(enabled ? getHyperlinkLableToolTip() : null);
+ getLabelControl().setToolTipText(enabled ? getHyperlinkLableToolTip() : null);
}
}
@@ -343,31 +232,8 @@
return new Control[] {getLabelComposite(parent), getTextChangeControl(parent)};
}
- public boolean isSelectableLabel() {
- return selectableLabel;
- }
-
- public void setSelectableLabel(boolean b) {
- selectableLabel = b;
- }
-
- public IAction getLabelAction() {
- return labelAction;
- }
-
- public void setLabelAction(IAction action) {
- labelAction = action;
- }
-
public void setEnabled(boolean enabled){
super.setEnabled(enabled); // label
- if (getLabelComposite()!=null) {
- if (getLabelAction()!=null) {
- getLabelControl().setEnabled(getLabelAction().isEnabled() && enabled);
- } else {
- getLabelControl().setEnabled(enabled);
- }
- }
}
protected boolean isAlwaysReadOnly() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java 2011-12-30
19:55:40 UTC (rev 37598)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java 2011-12-30
20:21:49 UTC (rev 37599)
@@ -11,7 +11,7 @@
package org.jboss.tools.common.model.ui.attribute.editor;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;