Author: dazarov
Date: 2009-11-25 06:16:25 -0500 (Wed, 25 Nov 2009)
New Revision: 18819
Added:
trunk/common/plugins/org.jboss.tools.common.ui/.classpath
trunk/common/plugins/org.jboss.tools.common.ui/.project
trunk/common/plugins/org.jboss.tools.common.ui/META-INF/
trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.ui/build.properties
trunk/common/plugins/org.jboss.tools.common.ui/plugin.properties
trunk/common/plugins/org.jboss.tools.common.ui/src/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIPlugin.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ButtonFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CheckBoxFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ComboFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CompositeEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/IFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/INamedElement.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ITaggedFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LabelFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LinkFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/RadioFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedComboFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedRadioFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TextFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/BaseField.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/CheckBoxField.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/ComboBoxField.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/LinkField.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/PushButtonField.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/RadioField.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/TextField.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4990
Added: trunk/common/plugins/org.jboss.tools.common.ui/.classpath
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/.classpath (rev
0)
+++ trunk/common/plugins/org.jboss.tools.common.ui/.classpath 2009-11-25 11:16:25 UTC (rev
18819)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/common/plugins/org.jboss.tools.common.ui/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/common/plugins/org.jboss.tools.common.ui/.project
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/.project (rev
0)
+++ trunk/common/plugins/org.jboss.tools.common.ui/.project 2009-11-25 11:16:25 UTC (rev
18819)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.common.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/common/plugins/org.jboss.tools.common.ui/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Common Ui
+Bundle-SymbolicName: org.jboss.tools.common.ui
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.osgi;bundle-version="3.5.0",
+ org.jboss.tools.common;bundle-version="2.0.0",
+ org.eclipse.ui;bundle-version="3.5.0",
+ org.eclipse.core.runtime;bundle-version="3.5.0"
+Export-Package: org.jboss.tools.common.ui.widget.editor,
+ org.jboss.tools.common.ui.widget.field
Property changes on: trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/common/plugins/org.jboss.tools.common.ui/build.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/build.properties
(rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.ui/build.properties 2009-11-25 11:16:25
UTC (rev 18819)
@@ -0,0 +1,3 @@
+source.. = src/
+bin.includes = META-INF/,\
+ .
Property changes on: trunk/common/plugins/org.jboss.tools.common.ui/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/common/plugins/org.jboss.tools.common.ui/plugin.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/plugin.properties
(rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.ui/plugin.properties 2009-11-25 11:16:25
UTC (rev 18819)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.common.ui
+Bundle-Vendor.0 = JBoss by Red Hat
+Bundle-Name.0 = Common UI Plug-in
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common.ui/plugin.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CommonUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.common.ui.messages";//$NON-NLS-1$
+
+ private CommonUIMessages() {
+ // Do not instantiate
+ }
+
+ public static String BASE_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT;
+
+ public static String BASE_FIELD_EDITOR_NO_LABEL;
+
+ public static String BASE_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE;
+
+ public static String BASE_FIELD_EDITOR_PARENT_FOR_LABEL_IS_DIFFERENT;
+
+ public static String BUTTON_FIELD_EDITOR_BROWSE;
+
+ public static String BUTTON_FIELD_EDITOR_NOT_IMPLEMENTED_YET;
+
+ public static String COMPOSITE_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT;
+
+ public static String COMPOSITE_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE;
+
+ public static String COMPOSITE_EDITOR_THIS_METOD_CAN_BE_INVOKED;
+
+ public static String TEXT_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT;
+
+ public static String TEXT_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, CommonUIMessages.class);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIPlugin.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIPlugin.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIPlugin.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.ui;
+
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class CommonUIPlugin extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.common.ui";
//$NON-NLS-1$
+
+ // The shared instance
+ private static CommonUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public CommonUIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CommonUIPlugin getDefault() {
+ return plugin;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIPlugin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,12 @@
+BASE_FIELD_EDITOR_NO_LABEL=No label
+BASE_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE=Parent control should be Composite
+BASE_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT=Editor supports only grid layout
+BASE_FIELD_EDITOR_PARENT_FOR_LABEL_IS_DIFFERENT=Parent for label is different
+BUTTON_FIELD_EDITOR_BROWSE=Browse...
+BUTTON_FIELD_EDITOR_NOT_IMPLEMENTED_YET=Not implemented yet. Please setup real acion for
editor.
+COMPOSITE_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE=Parent control should be Composite
+COMPOSITE_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT=Editor supports only grid layout
+COMPOSITE_EDITOR_THIS_METOD_CAN_BE_INVOKED=This metod can be invoked after
getEditorControls(parent) only
+TEXT_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE=Parent control should be Composite
+TEXT_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT=Editor supports only grid layout
+
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Widget;
+import org.jboss.tools.common.ui.CommonUIMessages;
+
+/**
+ *
+ * @author eskimo
+ *
+ */
+public abstract class BaseFieldEditor implements IFieldEditor {
+
+ protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ Set<DisposeListener> disposeListeners = new HashSet<DisposeListener>();
+
+ private Object value = new Object();
+
+ private String labelText = CommonUIMessages.BASE_FIELD_EDITOR_NO_LABEL;
+
+ private String nameText = null;
+
+ Label labelControl = null;
+
+ protected Map<Object, Object> data = null;
+
+ private boolean enabled = true;
+
+ /**
+ *
+ * @param name
+ * @param label
+ * @param defaultValue
+ */
+ public BaseFieldEditor(String name, String label,Object defaultValue) {
+ this.value = defaultValue;
+ this.labelText = label;
+ this.nameText = name;
+ }
+
+ /**
+ *
+ * @param parent
+ */
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
CommonUIMessages.BASE_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
+ Assert.isTrue(((Composite)parent).getLayout() instanceof
GridLayout,CommonUIMessages.BASE_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
+ Composite aComposite = (Composite) parent;
+ final Control[] controls = (Control[])getEditorControls(aComposite);
+ GridLayout gl = (GridLayout)((Composite)parent).getLayout();
+
+ doFillIntoGrid(aComposite,gl.numColumns);
+ if(controls.length>0) {
+ controls[0].addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ controls[0].removeDisposeListener(this);
+ }
+ });
+ }
+ }
+
+ /**
+ * @param composite
+ * @param numColumns
+ */
+ protected void doFillIntoGrid(Composite composite, int numColumns) {
+
+ }
+
+ /**
+ *
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ /**
+ *
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ /**
+ *
+ * @param parent
+ * @return
+ */
+ public Label createLabelControl(Composite parent) {
+ if(labelControl==null) {
+ labelControl = new Label(parent,SWT.NO_BACKGROUND);
+ labelControl.setText(this.labelText);
+ } else if(parent!=null) {
+ if(labelControl.getParent()!=parent)
+ throw new
IllegalArgumentException(CommonUIMessages.BASE_FIELD_EDITOR_PARENT_FOR_LABEL_IS_DIFFERENT);
+ }
+ return labelControl;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Label getLabelControl() {
+ return createLabelControl(null);
+ }
+
+ /**
+ *
+ */
+ public abstract Object[] getEditorControls(Object composite);
+
+ /**
+ *
+ */
+ public abstract Object[] getEditorControls();
+
+ /**
+ *
+ * @return
+ */
+ public Control[] getSwtControls() {
+ return (Control[])getEditorControls();
+ }
+
+ /**
+ *
+ */
+ public abstract int getNumberOfControls();
+
+ /**
+ *
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ *
+ */
+ public String getValueAsString() {
+ return getValue().toString();
+ }
+
+ /**
+ *
+ */
+ public boolean isEnabled() {
+ return this.enabled ;
+ }
+
+ /**
+ *
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ Control[] controls = getSwtControls();
+ if(controls==null) {
+ return;
+ }
+ for(int i=0;i<controls.length;i++) {
+ Control control = controls[i];
+ control.setEnabled(enabled);
+ if(control instanceof Composite) {
+ setEnabled((Composite)control, enabled);
+ }
+ }
+ }
+
+ private void setEnabled(Composite composite, boolean enabled) {
+ Control[] controls = composite.getChildren();
+ for(int i=0;i<controls.length;i++) {
+ Control control = controls[i];
+ control.setEnabled(enabled);
+ if(control instanceof Composite) {
+ setEnabled((Composite)control, enabled);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean setFocus() {
+ return true;
+ }
+
+ /**
+ *
+ * @param newValue
+ */
+ public void setValue(Object newValue) {
+ Object oldValue = value;
+ value = newValue;
+ pcs.firePropertyChange(nameText,oldValue,newValue);
+ }
+
+ /**
+ *
+ */
+ public void setValueAsString(String stringValue) {
+ value = stringValue;
+ }
+
+ /**
+ *
+ */
+ public String getName() {
+ return nameText;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#dispose()
+ */
+ public void dispose() {
+ PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ PropertyChangeListener propertyChangeListener = listeners[i];
+ pcs.removePropertyChangeListener(propertyChangeListener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#dispose(org.eclipse.swt.events.DisposeEvent)
+ */
+ public void dispose(DisposeEvent e) {
+ dispose();
+ for (DisposeListener disposeListener : disposeListeners) {
+ disposeListener.widgetDisposed(e);
+ }
+ disposeListeners.clear();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#addDisposeListener(org.eclipse.swt.events.DisposeListener)
+ */
+ public void addDisposeListener(DisposeListener listener) {
+ disposeListeners.add(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditor#removeDisposeListener(org.eclipse.swt.events.DisposeListener)
+ */
+ public void removeDisposeListener(DisposeListener listener) {
+ disposeListeners.remove(listener);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getLabelText() {
+ return labelText;
+ }
+
+ /**
+ *
+ * @param labelText
+ */
+ public void setLabelText(String labelText) {
+ this.labelText = labelText;
+ }
+
+ /**
+ *
+ */
+ private boolean editable = true;
+
+ /**
+ *
+ */
+ public boolean isEditable() {
+ return editable;
+ }
+
+ /**
+ *
+ */
+ public void setEditable(boolean aEditable) {
+ this.editable = aEditable;
+ }
+
+ public Object getData(Object key) {
+ if(data==null) {
+ return null;
+ }
+ return data.get(key);
+ }
+
+ public void setData(Object key, Object value) {
+ if(data==null) {
+ data = new HashMap<Object, Object>();
+ }
+ data.put(key, value);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ButtonFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ButtonFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ButtonFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.CommonUIMessages;
+import org.jboss.tools.common.ui.widget.field.PushButtonField;
+
+/**
+ * @author eskimo
+ *
+ */
+public class ButtonFieldEditor extends BaseFieldEditor {
+
+ PushButtonField button= null;
+
+ private ButtonPressedAction buttonAction = new
ButtonPressedAction(CommonUIMessages.BUTTON_FIELD_EDITOR_BROWSE) {
+ @Override
+ public void run() {
+ throw new
IllegalStateException(CommonUIMessages.BUTTON_FIELD_EDITOR_NOT_IMPLEMENTED_YET);
+ }
+ };
+
+ public ButtonFieldEditor(String name, String label) {
+ super(name, label, new Object());
+ }
+
+ public ButtonFieldEditor(String name, ButtonPressedAction action, Object defaultValue)
{
+ super(name, action.getText(), defaultValue);
+ buttonAction = action;
+ buttonAction.setFieldEditor(this);
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ if(button==null) {
+ return null;
+ }
+ return new Control[]{button.getControl()};
+ }
+
+ @Override
+ public boolean isEditable() {
+ return false;
+ }
+
+ public void save(Object object) {
+ }
+
+ @Override
+ public void setEditable(boolean ediatble) {
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ if(button==null && composite!=null) {
+ button = new PushButtonField((Composite)composite,buttonAction);
+ setEnabled(isEnabled());
+ }
+ return new Control[]{button.getControl()};
+ }
+
+ public ButtonPressedAction getButtonaction() {
+ return buttonAction;
+ }
+
+ public static class ButtonPressedAction extends Action implements SelectionListener{
+
+ private IFieldEditor editor = null;
+
+ public ButtonPressedAction(String label) {
+ super(label);
+ }
+
+ public void setFieldEditor(IFieldEditor newEditor) {
+ editor = newEditor;
+ }
+
+ public IFieldEditor getFieldEditor() {
+ return editor;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ run();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ButtonFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CheckBoxFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CheckBoxFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CheckBoxFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.widget.field.CheckBoxField;
+
+/**
+ * @author eskimo
+ *
+ */
+public class CheckBoxFieldEditor extends BaseFieldEditor implements
PropertyChangeListener {
+
+ private Control checkBoxControl;
+
+ /**
+ * @param name
+ * @param label
+ * @param defaultValue
+ */
+ public CheckBoxFieldEditor(String name, String label, Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.internal.project.facet.BaseFieldEditor#createEditorControls(java.lang.Object)
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ return new Control[] {createCheckBoxControl((Composite)composite)};
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.internal.project.facet.BaseFieldEditor#getEditorControls()
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] {getCheckBoxControl()};
+ }
+
+ public Control getCheckBoxControl() {
+ return createCheckBoxControl(null);
+ }
+
+ private Control createCheckBoxControl(Composite parent) {
+ if(checkBoxControl==null) {
+ CheckBoxField checkBoxFild= new CheckBoxField(parent);
+ checkBoxFild.addPropertyChangeListener(this);
+ checkBoxControl = checkBoxFild.getCheckBox();
+ if(getValue() instanceof Boolean) {
+ checkBoxFild.getCheckBox().setSelection(((Boolean)getValue()).booleanValue());
+ }
+ } else if(parent!=null) {
+ Assert.isTrue(checkBoxControl.getParent()==parent);
+ }
+ return checkBoxControl;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.internal.project.facet.IFieldEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.internal.project.facet.IFieldEditor#save(java.lang.Object)
+ */
+ public void save(Object object) {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.internal.project.facet.IFieldEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ }
+
+ @Override
+ public void setValue(Object newValue) {
+ ((Button)checkBoxControl).setSelection(Boolean.parseBoolean(newValue.toString()));
+ super.setValue(newValue);
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setValue(evt.getNewValue());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CheckBoxFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ComboFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ComboFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ComboFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.widget.field.ComboBoxField;
+
+public class ComboFieldEditor extends BaseFieldEditor implements
ITaggedFieldEditor,PropertyChangeListener{
+
+ List values = null;
+
+ boolean editable = false;
+
+ public ComboFieldEditor(String name, String label, List values,Object
defaultValue,boolean editableSelection) {
+ super(name, label, defaultValue);
+ this.values = Collections.unmodifiableList(values);
+ this.editable = editableSelection;
+ }
+
+ private ComboBoxField comboField;
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ return new Control[] {getComboControl((Composite)composite)};
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ }
+
+ public Control getComboControl(Composite composite) {
+ if(comboField == null) {
+ comboField = new ComboBoxField(composite,values,getValue(),editable);
+ comboField.addPropertyChangeListener(this);
+ final Combo combo =comboField.getComboControl();
+ combo.addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose(e);
+ combo.removeDisposeListener(this);
+ }
+ });
+ } else if(composite!=null) {
+ Assert.isTrue(comboField.getControl().getParent()==composite);
+ }
+ return comboField.getControl();
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[]{comboField.getControl()};
+ }
+
+ public void save(Object object) {
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setValue(evt.getNewValue());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#getTags()
+ */
+ public String[] getTags() {
+ return comboField.getComboControl().getItems();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#setTags(java.lang.String[])
+ */
+ public void setTags(String[] tags) {
+ if(comboField!=null) {
+ comboField.setTags(tags,getValueAsString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ super.setEditable(ediatble);
+ comboField.setEditable(ediatble);
+ }
+
+ public void setValue(Object newValue) {
+ if(newValue==null) {
+ return;
+ }
+ super.setValue(newValue);
+ if(comboField!=null) {
+ comboField.removePropertyChangeListener(this);
+ comboField.setValue(newValue.toString());
+ comboField.addPropertyChangeListener(this);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ComboFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CompositeEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CompositeEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CompositeEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.CommonUIMessages;
+
+/**
+ * @author eskimo
+ *
+ */
+public class CompositeEditor extends BaseFieldEditor implements PropertyChangeListener {
+
+ public CompositeEditor(String name, String label, Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ CommonUIMessages.COMPOSITE_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ CommonUIMessages.COMPOSITE_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
+
+ Composite aComposite = (Composite) parent;
+ final Control[] controls = (Control[]) getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ for (int i = 0; i < controls.length; i++) {
+ GridData gd = new GridData();
+ gd.horizontalSpan = i == 1 ? gl.numColumns - controls.length + 1 : 1;
+ if (controls[i] instanceof Combo && i == (controls.length - 1)) {
+ gd.horizontalAlignment = SWT.BEGINNING;
+ } else {
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = (i == 1);
+ }
+
+ controls[i].setLayoutData(gd);
+ controls[i].setEnabled(isEnabled());
+
+ if(i==0) {
+ controls[i].addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ controls[0].removeDisposeListener(this);
+ }
+ });
+ }
+ }
+ }
+
+ List<Control> controls = new ArrayList<Control>();
+
+ @Override
+ public Object[] getEditorControls() {
+ if(!controls.isEmpty()) return controls.toArray();
+ else throw new
IllegalStateException(CommonUIMessages.COMPOSITE_EDITOR_THIS_METOD_CAN_BE_INVOKED);
+ }
+
+ @Override
+ public Object[] getEditorControls(Object parent) {
+ for (IFieldEditor editor : editors) {
+ controls.addAll(Arrays.asList((Control[])editor.getEditorControls(parent)));
+ }
+ return controls.toArray(new Control[]{});
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return editors.size();
+ }
+
+ @Override
+ public boolean isEditable() {
+ return true;
+ }
+
+ public void save(Object object) {
+ }
+
+ @Override
+ public void setEditable(boolean ediatble) {
+ }
+
+ List<IFieldEditor> editors = new ArrayList<IFieldEditor>();
+
+ public CompositeEditor addFieldEditors(IFieldEditor[] editors) {
+ this.editors.addAll( Arrays.asList(editors));
+ for (IFieldEditor editor : Arrays.asList(editors)) {
+ editor.addPropertyChangeListener(this);
+ }
+ return this;
+ }
+
+ @Override
+ public void setValue(Object newValue) {
+ for (IFieldEditor editor : editors) {
+ editor.removePropertyChangeListener(this);
+ editor.setValue(newValue);
+ editor.addPropertyChangeListener(this);
+ }
+ super.setValue(newValue);
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ for (IFieldEditor editor : editors) {
+ if(event.getSource()!=editor) {
+ editor.removePropertyChangeListener(this);
+ editor.setValue(event.getNewValue());
+ editor.addPropertyChangeListener(this);
+ }
+ }
+ super.setValue(event.getNewValue());
+ }
+
+ @Override
+ public void setEnabled(boolean set) {
+ for (IFieldEditor editor : editors) {
+ editor.setEnabled(set);
+ }
+ }
+
+ public List<IFieldEditor> getEditors() {
+ return Collections.unmodifiableList(editors);
+ }
+
+ public IFieldEditor getEditorByName(String name) {
+ for (IFieldEditor editor : editors) {
+ if(name.equals(editor.getName())) {
+ return editor;
+ }
+ }
+ return null;
+ }
+
+ public void setData(Object key, Object value) {
+ super.setData(key, value);
+ for (IFieldEditor editor : editors) {
+ editor.setData(key, value);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/CompositeEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/IFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/IFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/IFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Listener;
+
+public interface IFieldEditor extends INamedElement {
+
+ /**
+ *
+ * @param composite
+ */
+ public Object[] getEditorControls(Object composite);
+
+ /**
+ *
+ * @return
+ */
+ public Object[] getEditorControls();
+
+ /**
+ *
+ * @return
+ */
+ public int getNumberOfControls();
+
+ /**
+ *
+ * @param parent
+ */
+ public void doFillIntoGrid(Object parent);
+
+ /**
+ *
+ * @param listener
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
+ public void addDisposeListener(DisposeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
+ public void removeDisposeListener(DisposeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ *
+ * @return
+ */
+ public boolean isEditable();
+
+ /**
+ *
+ * @param aEdiatble
+ */
+ public void setEditable(boolean aEdiatble);
+
+ /**
+ * @return
+ *
+ */
+ public boolean setFocus();
+
+ /**
+ *
+ * @return
+ */
+ public boolean isEnabled();
+
+ /**
+ *
+ * @param enabled
+ */
+ public void setEnabled(boolean enabled);
+
+ /**
+ *
+ */
+ public void dispose();
+
+ /**
+ *
+ * @param e
+ */
+ public void dispose(DisposeEvent e);
+
+ /**
+ * Sets the application defined property of this editor
+ * @param data
+ * @param key
+ */
+ public void setData(Object key, Object data);
+
+ /**
+ * Gets the application defined property of this editor
+ * @param key
+ * @return
+ */
+ public Object getData(Object key);
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/IFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/INamedElement.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/INamedElement.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/INamedElement.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+public interface INamedElement {
+
+ public abstract String getName();
+
+ /**
+ *
+ * @return
+ */
+ public abstract Object getValue();
+
+ /**
+ *
+ */
+ public abstract void setValue(Object newValue);
+
+ /**
+ *
+ * @return
+ */
+ public abstract String getValueAsString();
+
+ /**
+ *
+ * @param aValue
+ */
+ public abstract void setValueAsString(String aValue);
+
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/INamedElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ITaggedFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ITaggedFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ITaggedFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+/**
+ * @author eskimo
+ *
+ */
+public interface ITaggedFieldEditor extends IFieldEditor {
+
+ /**
+ *
+ * @return
+ */
+ public String[] getTags();
+
+ /**
+ *
+ * @param tags
+ */
+ public void setTags(String[] tags);
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ITaggedFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LabelFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LabelFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LabelFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.ui.widget.editor;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author eskimo
+ *
+ */
+public class LabelFieldEditor extends BaseFieldEditor {
+
+ public LabelFieldEditor(String name, String label) {
+ super(name, label, ""); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#doFillIntoGrid(java.lang.Object)
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getEditorControls(java.lang.Object)
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ // TODO Auto-generated method stub
+ return new Control[]{createLabelControl((Composite)composite)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getEditorControls()
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return getEditorControls(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#save(java.lang.Object)
+ */
+ public void save(Object object) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setValue(Object value) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ // TODO Auto-generated method stub
+ return 1;
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LabelFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LinkFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LinkFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LinkFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,67 @@
+package org.jboss.tools.common.ui.widget.editor;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.CommonUIMessages;
+import org.jboss.tools.common.ui.widget.editor.ButtonFieldEditor.ButtonPressedAction;
+import org.jboss.tools.common.ui.widget.field.LinkField;
+
+public class LinkFieldEditor extends BaseFieldEditor {
+ LinkField link;
+
+ private ButtonPressedAction buttonAction = new
ButtonPressedAction(CommonUIMessages.BUTTON_FIELD_EDITOR_BROWSE) {
+ @Override
+ public void run() {
+ throw new
IllegalStateException(CommonUIMessages.BUTTON_FIELD_EDITOR_NOT_IMPLEMENTED_YET);
+ }
+ };
+
+ public LinkFieldEditor(String name, String label) {
+ super(name, label, new Object());
+ }
+
+ public LinkFieldEditor(String name, ButtonPressedAction action, Object defaultValue) {
+ super(name, action.getText(), defaultValue);
+ buttonAction = action;
+ buttonAction.setFieldEditor(this);
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[]{link.getControl()};
+ }
+
+ @Override
+ public boolean isEditable() {
+ return false;
+ }
+
+ public void save(Object object) {
+ }
+
+ @Override
+ public void setEditable(boolean ediatble) {
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ if(link == null && composite != null) {
+ link = new LinkField((Composite)composite, buttonAction);
+ }
+ return new Control[]{link.getControl()};
+ }
+
+ public ButtonPressedAction getButtonaction() {
+ return buttonAction;
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/LinkFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/RadioFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/RadioFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/RadioFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,108 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.widget.field.RadioField;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class RadioFieldEditor extends BaseFieldEditor implements
ITaggedFieldEditor,PropertyChangeListener{
+ List values = null;
+ List<String> labels;
+
+ RadioField radioField;
+
+ public RadioFieldEditor(String name, String label, List<String> labels, List
values,Object defaultValue) {
+ super(name, label, defaultValue);
+ this.labels = labels;
+ this.values = Collections.unmodifiableList(values);
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ return new Control[] {getComboControl((Composite)composite)};
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ }
+
+ public Control getComboControl(Composite composite) {
+ if(radioField == null) {
+ radioField = new RadioField(composite,labels, values,getValue(), false);
+ radioField.addPropertyChangeListener(this);
+ } else if(composite!=null) {
+ Assert.isTrue(radioField.getControl().getParent()==composite);
+ }
+ return radioField.getControl();
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[]{radioField.getControl()};
+ }
+
+ public void save(Object object) {
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setValue(evt.getNewValue());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#getTags()
+ */
+ public String[] getTags() {
+ String[] result = new String[values.size()];
+ for (int i = 0; i < result.length; i++) result[i] = values.get(0).toString();
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#setTags(java.lang.String[])
+ */
+ public void setTags(String[] tags) {
+ values.clear();
+ for (int i = 0; i < tags.length; i++) values.add(tags[i]);
+ //TODO
+// radioField.setTags(tags,getValueAsString());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ public void setValue(Object newValue) {
+ if(newValue==null) {
+ return;
+ }
+ super.setValue(newValue);
+ if(radioField!=null) {
+ radioField.removePropertyChangeListener(this);
+ radioField.setValue(newValue.toString());
+ radioField.addPropertyChangeListener(this);
+ }
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/RadioFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedComboFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedComboFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedComboFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Combo;
+
+/**
+ *
+ */
+public class TaggedComboFieldEditor extends CompositeEditor implements
ITaggedFieldEditor, PropertyChangeListener{
+
+ List values = null;
+
+ boolean floatStyle = true;
+
+ ComboFieldEditor combo = null;
+
+ public TaggedComboFieldEditor(String name, String label, List values,
+ Object defaultValue, boolean editable) {
+
+ super(name, label, defaultValue==null?"":defaultValue.toString());
//$NON-NLS-1$
+ this.values = Collections.unmodifiableList(values);
+ this.floatStyle = editable;
+ combo = new ComboFieldEditor(
+ name,label,values,getValue(),editable);
+ addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
+ combo});
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#getTags()
+ */
+ public String[] getTags() {
+ return ((Combo)getEditorControls()[1]).getItems();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#setTags(java.lang.String[])
+ */
+ public void setTags(String[] tags) {
+ combo.setTags(tags);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ combo.setEditable(ediatble);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ return combo.isEditable();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedComboFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedRadioFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedRadioFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedRadioFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,68 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class TaggedRadioFieldEditor extends CompositeEditor implements
ITaggedFieldEditor, PropertyChangeListener{
+
+ List values = null;
+ RadioFieldEditor radios = null;
+
+ public TaggedRadioFieldEditor(String name, String label, List<String> labels, List
values,
+ Object defaultValue) {
+
+ super(name, label, defaultValue==null?"":defaultValue.toString());
//$NON-NLS-1$
+ this.values = Collections.unmodifiableList(values);
+ radios = new RadioFieldEditor(
+ name,label,labels, values,getValue());
+ addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
+ radios});
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#getTags()
+ */
+ public String[] getTags() {
+ return radios.getTags();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#setTags(java.lang.String[])
+ */
+ public void setTags(String[] tags) {
+ radios.setTags(tags);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ radios.setEditable(ediatble);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ return radios.isEditable();
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TaggedRadioFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TextFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TextFieldEditor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TextFieldEditor.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.editor;
+
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Assert;
+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.jboss.tools.common.ui.CommonUIMessages;
+import org.jboss.tools.common.ui.widget.field.TextField;
+
+/**
+ *
+ * @author eskimo(dgolovin(a)exadel.com)
+ *
+ */
+public class TextFieldEditor extends BaseFieldEditor implements PropertyChangeListener{
+
+ /**
+ *
+ */
+ public static final int UNLIMITED = -1;
+
+ protected int style = -1;
+
+ /**
+ *
+ * @param name
+ * @param aLabelText
+ * @param defaultvalue
+ */
+ public TextFieldEditor(String name,String aLabelText,String defaultvalue) {
+ super(name, aLabelText, defaultvalue);
+ }
+
+ /**
+ *
+ * @param name
+ * @param aLabelText
+ * @param defaultvalue
+ * @param editable
+ */
+ public TextFieldEditor(String name,String aLabelText,String defaultvalue,boolean
editable) {
+ super(name, aLabelText, defaultvalue);
+ setEditable(editable);
+ }
+
+ /**
+ *
+ */
+ protected TextField fTextField = null;
+
+ /**
+ *
+ */
+ protected int fWidthInChars = 0;
+
+ /**
+ *
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] {getTextControl()};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#doFillIntoGrid(java.lang.Object)
+ */
+ @Override
+ public void doFillIntoGrid(Object aParent) {
+ Assert.isTrue(aParent instanceof Composite,
CommonUIMessages.TEXT_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
+ Assert.isTrue(((Composite)aParent).getLayout() instanceof
GridLayout,CommonUIMessages.TEXT_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
+ Composite aComposite = (Composite) aParent;
+ Control[] controls = (Control[])getEditorControls(aComposite);
+ GridLayout gl = (GridLayout)((Composite)aParent).getLayout();
+ getTextControl(aComposite);
+
+ GridData gd = new GridData();
+
+ gd.horizontalSpan = gl.numColumns - 1;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+
+ fTextField.getTextControl().setLayoutData(gd);
+ }
+
+ /**
+ *
+ * @param parent
+ * @return
+ */
+ public Text getTextControl(Composite parent) {
+ if (fTextField == null) {
+ fTextField = new TextField(parent, getInitialStyle());
+ Text textField = fTextField.getTextControl();
+ textField.setFont(parent.getFont());
+ Object value = getValue();
+ textField.setText(getValue().toString());
+ textField.setEditable(isEditable());
+ textField.setEnabled(isEnabled());
+ fTextField.addPropertyChangeListener(this);
+ } else if (parent!=null){
+ Assert.isTrue(parent==fTextField.getTextControl().getParent());
+ }
+ return fTextField.getTextControl();
+ }
+
+ /**
+ *
+ */
+ protected void updateWidgetValues() {
+ setValueAsString(getValueAsString());
+ }
+
+ /**
+ *
+ * @return
+ */
+ protected int getInitialStyle() {
+ if(this.style >= 0) return style;
+ return SWT.SINGLE | SWT.BORDER;
+ }
+
+ /*
+ * @param value
+ * @return
+ */
+ private String checkCollection(Object value){
+
+ return value != null && (!((Collection)value).isEmpty()) ?
prepareCollectionToString((Collection)value) : ""; //$NON-NLS-1$
+ }
+
+ /*
+ * @param collection
+ * @return
+ */
+ private String prepareCollectionToString(Collection collection)
+ {
+ String stringValue = ""; //$NON-NLS-1$
+ Object[] objects = collection.toArray();
+ for(int i = 0; i < objects.length; i++){
+ stringValue += objects[i];
+ if(i < objects.length - 1)
+ stringValue += " "; //$NON-NLS-1$
+ }
+ return stringValue;
+ }
+
+
+ /*
+ * @param value
+ * @return
+ */
+ private String checkSimple(Object value){
+ return (value != null) ? value.toString() : ""; //$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 2;
+ }
+
+ /**
+ * Returns this field editor's text control.
+ *
+ * @return the text control, or <code>null</code> if no
+ * text field is created yet
+ */
+ protected Text getTextControl() {
+ return fTextField!=null?fTextField.getTextControl():null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#setFocus()
+ */
+ @Override
+ public boolean setFocus() {
+ boolean setfocus = false;
+ if(fTextField!=null && !fTextField.getTextControl().isDisposed())
+ setfocus = fTextField.getTextControl().setFocus();
+ return setfocus;
+ }
+
+ /**
+ *
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ return new Control[]{getTextControl((Composite)composite)};
+ }
+
+ /**
+ *
+ * @param object
+ */
+ public void save(Object object) {
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void setValue(Object newValue) {
+ super.setValue(newValue);
+ if(fTextField!=null){
+ fTextField.removePropertyChangeListener(this);
+ fTextField.getTextControl().setText(newValue.toString());
+ fTextField.addPropertyChangeListener(this);
+ }
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void setEditable(boolean aEditable) {
+ super.setEditable(aEditable);
+ if(getTextControl()!=null) getTextControl().setEditable(aEditable);
+ }
+
+ /**
+ *
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ super.setValue(evt.getNewValue());
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/TextFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/BaseField.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/BaseField.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/BaseField.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.field;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+import org.eclipse.swt.widgets.Control;
+
+public abstract class BaseField {
+
+ public static final String PROPERTY_NAME = "value"; //$NON-NLS-1$
+
+ private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void firePropertyChange(Object oldValue, Object newValue) {
+ pcs.firePropertyChange(PROPERTY_NAME, oldValue, newValue);
+ }
+
+ abstract public Control getControl();
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/BaseField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/CheckBoxField.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/CheckBoxField.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/CheckBoxField.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.field;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class CheckBoxField extends BaseField implements SelectionListener {
+ private Button checkBox = null;
+
+ public CheckBoxField(Composite parent) {
+ checkBox = new Button(parent, SWT.CHECK);
+ checkBox.addSelectionListener(this);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ checkBox.getSelection();
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ firePropertyChange(!checkBox.getSelection(),
+ checkBox.getSelection());
+ }
+
+ public Button getCheckBox() {
+ return checkBox;
+ }
+
+ @Override
+ public Control getControl() {
+ return getCheckBox();
+ }
+
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/CheckBoxField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/ComboBoxField.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/ComboBoxField.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/ComboBoxField.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.field;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * @author eskimo
+ *
+ */
+public class ComboBoxField extends BaseField implements ISelectionChangedListener {
+
+ ComboViewer comboControl = null;
+ List values = new ArrayList();
+
+ public ComboBoxField(Composite parent,List values, ILabelProvider labelProvider,
+ Object value, boolean flatStyle) {
+ this(parent, values, value, flatStyle);
+ comboControl.setLabelProvider(labelProvider);
+ }
+
+ public ComboBoxField(Composite parent,List values, Object value, boolean editable) {
+ this.values = values;
+ /*
+ * Used combo box instead of custom combobox(CCombo),
+ * CCombo looks ugly under MAC OS X
+ */
+ Combo combo;
+ if(editable==true) {
+
+ combo = new Combo(parent, SWT.DROP_DOWN);
+ } else {
+ combo = new Combo(parent, SWT.READ_ONLY);
+ }
+ combo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ comboControl = new ComboViewer(combo);
+ comboControl.setContentProvider(new IStructuredContentProvider() {
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ComboBoxField.this.values.toArray();
+ }
+ });
+
+ comboControl.addSelectionChangedListener(this);
+ comboControl.getCombo().addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ firePropertyChange(new Object(), comboControl.getCombo().getText());
+ }});
+ comboControl.setLabelProvider(new ILabelProvider() {
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ public String getText(Object element) {
+ return element.toString();
+ }
+ });
+ comboControl.setInput(values);
+ comboControl.setSelection(new StructuredSelection(value), true);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ firePropertyChange("",
((StructuredSelection)event.getSelection()).getFirstElement()); //$NON-NLS-1$
+ }
+
+ public Combo getComboControl() {
+ return comboControl.getCombo();
+ }
+
+ @Override
+ public Control getControl() {
+ return getComboControl();
+ }
+
+ public void setValue(Object newValue) {
+ comboControl.setSelection(new StructuredSelection(newValue));
+ comboControl.getCombo().setText(newValue.toString());
+ }
+
+ public void setTags(String[] tags,String value) {
+ values = Arrays.asList(tags);
+ comboControl.removeSelectionChangedListener(this);
+ comboControl.refresh(true);
+ comboControl.addPostSelectionChangedListener(this);
+ comboControl.setSelection(new StructuredSelection(value));
+ }
+ /*
+ * We can't modify combo, change style of this object,
+ * if we such functionality please use CCombo
+ *
+ */
+ public void setEditable(
+ boolean ediatble) {
+ //comboControl.getCCombo().setEditable(false);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/ComboBoxField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/LinkField.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/LinkField.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/LinkField.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,28 @@
+package org.jboss.tools.common.ui.widget.field;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.jboss.tools.common.ui.widget.editor.ButtonFieldEditor.ButtonPressedAction;
+
+public class LinkField extends BaseField {
+
+ Link link;
+
+ /**
+ *
+ */
+ @Override
+ public Control getControl() {
+ return link;
+ }
+
+
+ public LinkField(Composite composite, ButtonPressedAction listener) {
+ link = new Link(composite,SWT.NONE);
+ link.setText(listener.getText());
+ link.addSelectionListener(listener);
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/LinkField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/PushButtonField.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/PushButtonField.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/PushButtonField.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.field;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.widget.editor.ButtonFieldEditor.ButtonPressedAction;
+
+/**
+ * @author eskimo
+ *
+ */
+public class PushButtonField extends BaseField {
+
+ Button button;
+
+ /**
+ *
+ */
+ @Override
+ public Control getControl() {
+ return button;
+ }
+
+
+ public PushButtonField(Composite composite, ButtonPressedAction listener) {
+ button = new Button(composite,SWT.PUSH);
+ button.setText(listener.getText());
+ button.addSelectionListener(listener);
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/PushButtonField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/RadioField.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/RadioField.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/RadioField.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,102 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.field;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * A group of labels and radio buttons.
+ * @author Alexey Kazakov
+ */
+public class RadioField extends BaseField implements SelectionListener {
+
+ private Composite topComposite;
+ private Button[] radios;
+ private Object value;
+
+ public RadioField(Composite parent, List<String> labels, List<Object>
values, Object defaultValue, boolean verticalLayout) {
+ topComposite = new Composite(parent, SWT.NONE);
+ topComposite.setLayout(new GridLayout(verticalLayout ? 1 : values.size(), false));
+ if(verticalLayout) {
+ topComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ radios = new Button[values.size()];
+ if(defaultValue==null && !values.isEmpty()) {
+ defaultValue = values.get(0);
+ }
+ for (int i = 0; i < radios.length; i++) {
+ radios[i] = new Button(topComposite, SWT.RADIO);
+ radios[i].setText(labels.get(i));
+ radios[i].addSelectionListener(this);
+ radios[i].setLayoutData(new GridData(verticalLayout ? GridData.FILL_HORIZONTAL :
GridData.BEGINNING));
+ Object value = values.get(i);
+ radios[i].setData(value);
+ if(value != null && value.equals(defaultValue)) {
+ radios[i].setSelection(true);
+ this.value = value;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.field.BaseField#getControl()
+ */
+ @Override
+ public Control getControl() {
+ return topComposite;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent event) {
+ value = event.widget.getData();
+ firePropertyChange("", value); //$NON-NLS-1$
+ }
+
+ /**
+ * @return Value of selected button
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ *
+ * @param value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ for (int i = 0; i < radios.length; i++) {
+ if(value.equals(radios[i].getData())) {
+ radios[i].setSelection(true);
+ } else {
+ radios[i].setSelection(false);
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/RadioField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/TextField.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/TextField.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/TextField.java 2009-11-25
11:16:25 UTC (rev 18819)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui.widget.field;
+
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+
+public class TextField extends BaseField implements ModifyListener{
+
+
+ Text textField = null;
+
+ public TextField(Composite parent, int style) {
+ textField = new Text(parent,style);
+ textField.addModifyListener(this);
+ }
+
+ public void modifyText(ModifyEvent e) {
+ firePropertyChange(new Object(),((Text)e.widget).getText().trim());
+ }
+
+ public Text getTextControl() {
+ return textField;
+ }
+
+ @Override
+ public Control getControl() {
+ return getTextControl();
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/field/TextField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain