Author: dennyxu
Date: 2008-09-02 03:18:00 -0400 (Tue, 02 Sep 2008)
New Revision: 10019
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs
trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/jar_obj.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java
Log:
Initial import. Add ESB project facet and wizard
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath 2008-09-02 07:18:00 UTC
(rev 10019)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project (rev
0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project 2008-09-02 07:18:00 UTC (rev
10019)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.esb.project.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.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,7 @@
+#Wed Aug 27 16:06:10 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Esbproject Plug-in
+Bundle-SymbolicName: org.jboss.tools.esb.project.ui;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.esb.project.ui.ESBProjectPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.pde.ui,
+ org.eclipse.pde.ui.templates,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.wst.web.ui,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.frameworks.ui,
+ org.eclipse.wst.common.core,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.server.ui,
+ org.eclipse.wst.web,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.wst.server.core,
+ org.eclipse.jst.server.core,
+ org.eclipse.jst.servlet.ui;bundle-version="1.1.200",
+ org.eclipse.jst.common.frameworks;bundle-version="1.1.200",
+ org.eclipse.jst.common.project.facet.core;bundle-version="1.3.0",
+ org.eclipse.jst.j2ee;bundle-version="1.1.200",
+ org.eclipse.jst.j2ee.web;bundle-version="1.1.200",
+ org.eclipse.jst.j2ee.core;bundle-version="1.1.200",
+ org.eclipse.jst.j2ee.ui;bundle-version="1.1.200",
+ org.eclipse.jdt.core;bundle-version="3.4.0",
+ org.jboss.tools.esb.project.core;bundle-version="1.0.0"
+Eclipse-LazyStart: true
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties 2008-09-02 07:18:00
UTC (rev 10019)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/jar_obj.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/jar_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties 2008-09-02 07:18:00
UTC (rev 10019)
@@ -0,0 +1 @@
+JBOSS_ESB_PREFERENCE_PAGE=JBoss ESB Runtimes
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml 2008-09-02 07:18:00 UTC
(rev 10019)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="org.jboss.tools.esb.project.ui.template"
name="ESB Template"
schema="schema/org.jboss.tools.esb.project.ui.template.exsd"/>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="org.jboss.tools.esb.category1"
+ class="org.jboss.tools.esb.project.ui.wizards.ESBProjectWizard"
+ id="JBoss.ESB.Project.Wizard"
+ name="ESB Project Wizard"
+ project="true">
+ </wizard>
+ <category
+ id="org.jboss.tools.esb.category1"
+ name="ESB Wizard">
+ </category>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.wizardPages">
+ <wizard-pages
+ action="jst.jboss.esb.install">
+ <page
+
class="org.jboss.tools.esb.project.ui.wizards.pages.ESBFacetInstallationPage">
+ </page>
+ </wizard-pages>
+ </extension>
+<extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.jboss.ide.eclipse.ui.MainPreferencePage"
+
class="org.jboss.tools.esb.project.ui.preference.controls.JBossESBRuntimePreferencePage"
+ id="org.jboss.tools.esb.project.runtime.preference"
+ name="JBoss ESB Runtimes">
+ </page>
+ </extension>
+
+</plugin>
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,50 @@
+package org.jboss.tools.esb.project.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ESBProjectPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.esb.project.ui";
+
+ // The shared instance
+ private static ESBProjectPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ESBProjectPlugin() {
+ }
+
+ /*
+ * (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 ESBProjectPlugin getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class JBossESBUIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.tools.esb.project.preference";
+
+ // The shared instance
+ private static JBossESBUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public JBossESBUIPlugin() {
+ }
+
+ /*
+ * (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 JBossESBUIPlugin getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ path = "icons/" + path; //$NON-NLS-1$
+ return
AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.esb.project.ui",
path); //$NON-NLS-1$
+ }
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author Grid Qian
+ */
+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();
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+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.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public abstract class BaseFieldEditor implements IFieldEditor {
+
+ PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ Set<DisposeListener> disposeListeners = new HashSet<DisposeListener>();
+
+ private Object value = new Object();
+
+ private String labelText;
+
+ 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,
JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)parent).getLayout() instanceof
GridLayout,JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ 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(JBossESBUIMessages.Error_JBossWS_Basic_Editor_Different);
+ }
+ return labelControl;
+ }
+
+ public Label getLabelControl() {
+ return createLabelControl(null);
+ }
+
+ public abstract Object[] getEditorControls(Object composite);
+
+ public abstract Object[] getEditorControls();
+
+ 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;
+ }
+
+ public void dispose() {
+ PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ PropertyChangeListener propertyChangeListener = listeners[i];
+ pcs.removePropertyChangeListener(propertyChangeListener);
+ }
+ }
+
+ public void dispose(DisposeEvent e) {
+ dispose();
+ for (DisposeListener disposeListener : disposeListeners) {
+ disposeListener.widgetDisposed(e);
+ }
+ disposeListeners.clear();
+ }
+
+ public void addDisposeListener(DisposeListener listener) {
+ disposeListeners.add(listener);
+ }
+
+ public void removeDisposeListener(DisposeListener listener) {
+ disposeListeners.remove(listener);
+ }
+
+ 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);
+ }
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+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.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class ButtonFieldEditor extends BaseFieldEditor {
+
+ PushButtonField button= null;
+ int style;
+
+ private ButtonPressedAction buttonAction = new
ButtonPressedAction(JBossESBUIMessages.JBossWS_Button_Field_Editor_Browse) {
+ @Override
+ public void run() {
+ throw new
RuntimeException(JBossESBUIMessages.Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet);
+ }
+ };
+
+ public ButtonFieldEditor(String name, String label, int style) {
+ super(name, label, new Object());
+ this.style = style;
+ }
+
+ 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, style, 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();
+ }
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+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.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+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,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+
+ 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.size()>0) return controls.toArray();
+ else throw new
IllegalStateException(JBossESBUIMessages.JBossWS_Composite_Editor_This_Method_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
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+
+/**
+ * @author Grid Qian
+ */
+public interface IFieldEditor extends INamedElement {
+
+ /**
+ *
+ * @param composite
+ */
+ public Object[] getEditorControls(Object composite);
+
+ public Object[] getEditorControls();
+
+ 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);
+
+ public boolean isEditable();
+
+ /**
+ *
+ * @param aEdiatble
+ */
+ public void setEditable(boolean aEdiatble);
+
+ public boolean setFocus();
+
+ 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);
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+/**
+ * @author Grid Qian
+ */
+public interface INamedElement {
+
+ public abstract String getName();
+
+ public abstract Object getValue();
+
+ public abstract void setValue(Object newValue);
+
+ public abstract String getValueAsString();
+
+ public abstract void setValueAsString(String aValue);
+
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeManager;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossESBRuntimePreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+
+ public JBossESBRuntimePreferencePage() {
+ super();
+ noDefaultAndApplyButton();
+ }
+
+ private static final int COLUMNS = 3;
+
+ JBossRuntimeListFieldEditor jbossRuntimes = new JBossRuntimeListFieldEditor(
+ "rtlist", JBossESBUIMessages.JBossWS_Preference_Page_Runtimes, new
ArrayList<JBossRuntime>(Arrays.asList(JBossRuntimeManager.getInstance().getRuntimes())));
//$NON-NLS-1$
+
+ /**
+ * Create contents of JBoss ESB preferences page. list editor
+ * is created
+ *
+ * @return Control
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite root = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout(COLUMNS, false);
+ root.setLayout(gl);
+ jbossRuntimes.doFillIntoGrid(root);
+
+ return root;
+ }
+
+ /**
+ * Inherited from IWorkbenchPreferencePage
+ *
+ * @param workbench
+ * {@link IWorkbench}
+ *
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /**
+ * Save JBossRuntime list
+ */
+ @Override
+ protected void performApply() {
+ for (JBossRuntime rt : jbossRuntimes.getAddedJBossRuntimes()) {
+ JBossRuntimeManager.getInstance().addRuntime(rt);
+ }
+ jbossRuntimes.getAddedJBossRuntimes().clear();
+ for (JBossRuntime rt : jbossRuntimes.getRemoved()) {
+ JBossRuntimeManager.getInstance().removeRuntime(rt);
+ }
+ jbossRuntimes.getRemoved().clear();
+ JBossRuntime defaultRuntime = jbossRuntimes
+ .getDefaultJBossRuntime();
+ // reset default runtime
+ for (JBossRuntime jbossWSRuntime : JBossRuntimeManager
+ .getInstance().getRuntimes()) {
+ jbossWSRuntime.setDefault(false);
+ }
+ // set deafult runtime
+ if (defaultRuntime != null) {
+ defaultRuntime.setDefault(true);
+ }
+ jbossRuntimes.setDefaultJBossRuntime(null);
+ Map<JBossRuntime, JBossRuntime> changed = jbossRuntimes
+ .getChangedJBossRuntimes();
+ for (JBossRuntime c : changed.keySet()) {
+ JBossRuntime o = changed.get(c);
+ o.setHomeDir(c.getHomeDir());
+ o.setVersion(c.getVersion());
+ String oldName = o.getName();
+ String newName = c.getName();
+ if (!oldName.equals(newName)) {
+ JBossRuntimeManager.getInstance().changeRuntimeName(oldName,
+ newName);
+ }
+ o.setDefault(c.isDefault());
+ o.setUserConfigClasspath(c.isUserConfigClasspath());
+ o.setLibraries(c.getLibraries());
+ }
+ jbossRuntimes.getChangedJBossRuntimes().clear();
+
+ JBossRuntimeManager.getInstance().save();
+ }
+
+ /**
+ * Restore original preferences values
+ */
+ @Override
+ protected void performDefaults() {
+ setValid(true);
+ setMessage(null);
+ performApply();
+ }
+
+ /**
+ * See {@link PreferencePage} for details
+ *
+ * @return Boolean
+ */
+ @Override
+ public boolean performOk() {
+ performApply();
+ return super.performOk();
+ }
+
+ public JBossRuntimeListFieldEditor getJBossRuntimes() {
+ return jbossRuntimes;
+ }
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,584 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+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;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.project.ui.preference.JBossESBUIPlugin;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossLibraryListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private TreeViewer listView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private JBossRuntime tempJbesb;
+
+
+
+
+ private Group jarGroup;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing JBossRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossLibraryListFieldEditor(String name, String label,
+ JBossRuntime jbws) {
+ super(name, label, jbws);
+ this.tempJbesb = new JBossRuntime();
+ if(jbws != null){
+ this.tempJbesb.setUserConfigClasspath(jbws.isUserConfigClasspath());
+ this.tempJbesb.getLibraries().addAll(jbws.getLibraries());
+ }
+
+ }
+
+
+ public Object getValue(){
+ return this.tempJbesb;
+ }
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new GridLayout());
+
+ createCheckButton(root);
+
+ jarGroup = new Group(root, SWT.BORDER);
+ jarGroup.setText("Library Jars");
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+
+
+ jarGroup.setLayoutData(gd);
+ jarGroup.setLayout(new FormLayout());
+
+ createListView(jarGroup);
+ createActionBar(jarGroup);
+
+ FormData listData = new FormData();
+ listData.left = new FormAttachment(0, 5);
+ listData.right = new FormAttachment(actionPanel, -5);
+ listData.top = new FormAttachment(0, 5);
+ listData.bottom = new FormAttachment(100, -5);
+ listView.getControl().setLayoutData(listData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+
+ setJarGroupStatus();
+ return new Control[] { root };
+ }
+
+ protected void createCheckButton(Composite parent){
+ final Button btnDefault = new Button(parent, SWT.CHECK);
+ btnDefault.setText(JBossESBUIMessages.JBossWS_Runtime_Check_Field_Default_Classpath);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ btnDefault.setLayoutData(gd);
+
+ btnDefault.setSelection(tempJbesb.isUserConfigClasspath());
+ btnDefault.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ tempJbesb.setUserConfigClasspath(btnDefault.getSelection());
+ setJarGroupStatus();
+ setValue(null);
+ }
+ });
+
+
+ }
+
+ protected void setJarGroupStatus(){
+ boolean isUserConfig = tempJbesb.isUserConfigClasspath();
+ jarGroup.setEnabled(isUserConfig);
+ listView.getTree().setEnabled(isUserConfig);
+ actionPanel.setEnabled(isUserConfig);
+ }
+
+ protected void createListView(Composite parent) {
+ listView = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ listView.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ listView.setContentProvider(new ITreeContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof JBossRuntime) {
+ return ((JBossRuntime) inputElement).getLibraries().toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ });
+
+ listView.setLabelProvider(new ILabelProvider() {
+
+ Image jarImg;
+ 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) {
+ if (jarImg == null){
+ ImageDescriptor jarImgDesc =
JBossESBUIPlugin.getImageDescriptor("obj16/jar_obj.gif");
+ jarImg = jarImgDesc.createImage();
+ }
+ return jarImg;
+ }
+
+ public String getText(Object element) {
+ String fullName = (String)element;
+ File jarFile = new File(fullName);
+ return jarFile.getName() + " - " + jarFile.getParentFile().toString();
+ }
+ });
+
+
+ listView.setInput(getValue());
+
+ }
+
+ protected void createActionBar(Composite parent) {
+ actionPanel = new ActionPanel(parent, new BaseAction[] { new AddAction(),
+ new RemoveAction() });
+ listView.addSelectionChangedListener(actionPanel);
+ }
+
+
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see
org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ String[] jars = new String[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<String> rts = new ArrayList<String>();
+ for (Object jarfile : ((IStructuredSelection) selection).toArray()) {
+ rts.add((String) jarfile);
+ }
+ jars = rts.toArray(new String[] {});
+ } else {
+ jars = new String[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ FileDialog dialog = new FileDialog(Display.getCurrent()
+ .getActiveShell(), SWT.MULTI);
+ dialog.setFilterExtensions(new String[] { "*.jar;*.zip" });
+ String fileName = dialog.open();
+ String[] fileNames = dialog.getFileNames();
+ if (fileName != null) {
+ File filePath = new File(fileName);
+ filePath = filePath.getParentFile();
+ for (int i = 0; i < fileNames.length; i++) {
+ IPath path = new Path(filePath.getAbsolutePath())
+ .append(fileNames[i]);
+ if (!tempJbesb.getLibraries().contains(path.toOSString())) {
+ tempJbesb.getLibraries().add(path.toOSString());
+ }
+ }
+
+ listView.refresh();
+ setValue(null);
+ }
+ }
+ }
+
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(jars.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (String jar : jars) {
+ tempJbesb.getLibraries().remove(jar);
+ }
+ listView.refresh();
+ // just try to fire property change listener
+ setValue(null);
+ }
+
+
+ }
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,1143 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+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;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeManager;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private CheckboxTableViewer tableView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private Map<JBossRuntime, JBossRuntime> changed = new HashMap<JBossRuntime,
JBossRuntime>();
+
+ private JBossRuntime checkedElement = new JBossRuntime();
+
+ private List<JBossRuntime> added = new ArrayList<JBossRuntime>();
+
+ private List<JBossRuntime> removed = new ArrayList<JBossRuntime>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing JBossRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossRuntimeListFieldEditor(String name, String label,
+ Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ /**
+ * TBD
+ *
+ * @return JBossRuntime;
+ */
+ public JBossRuntime getDefaultJBossRuntime() {
+ return checkedElement;
+ }
+
+ public void setDefaultJBossRuntime(JBossRuntime rt) {
+ checkedElement = rt;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossRuntime>
+ */
+ public List<JBossRuntime> getAddedJBossRuntimes() {
+ return added;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossRuntime>
+ */
+ public Map<JBossRuntime, JBossRuntime> getChangedJBossRuntimes() {
+ return changed;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossRuntime>
+ */
+ public List<JBossRuntime> getRemoved() {
+ return removed;
+ }
+
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new FormLayout());
+ createTableView();
+ createActionBar();
+
+ FormData tableData = new FormData();
+ tableData.left = new FormAttachment(0, 5);
+ tableData.right = new FormAttachment(actionPanel, -5);
+ tableData.top = new FormAttachment(0, 5);
+ tableData.bottom = new FormAttachment(100, -5);
+ tableView.getControl().setLayoutData(tableData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+ return new Control[] { root };
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createTableView() {
+ tableView = CheckboxTableViewer.newCheckList(root, SWT.V_SCROLL
+ | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
+
+ TableColumn tc1 = new TableColumn(tableView.getTable(), SWT.CENTER);
+ tc1.setWidth(TC_DEFAULT_WIDTH);
+ tc1.setResizable(false);
+
+ TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc2.setWidth(TC_NAME_WIDTH);
+ tc2.setText(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Name);
+
+ TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc3.setWidth(TC_VERSION_WIDTH);
+ tc3
+ .setText(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Version);
+
+ TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc4.setWidth(TC_PATH_WIDTH);
+ tc4.setText(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
+
+ tableView.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List<JBossRuntime>) inputElement).toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+ });
+
+ tableView.setLabelProvider(new ITableLabelProvider() {
+
+ private static final int TC_DEFAULT_NUMBER = 0;
+ private static final int TC_NAME_NUMBER = 1;
+ private static final int TC_VERSION_NUMBER = 2;
+ private static final int TC_PATH_NUMBER = 3;
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ JBossRuntime rt = (JBossRuntime) element;
+ if (columnIndex == TC_DEFAULT_NUMBER) {
+ return ""; //$NON-NLS-1$
+ }
+ if (columnIndex == TC_NAME_NUMBER) {
+ return rt.getName();
+ }
+ if (columnIndex == TC_VERSION_NUMBER) {
+ return rt.getVersion().toString();
+ }
+ if (columnIndex == TC_PATH_NUMBER) {
+ return rt.getHomeDir();
+ }
+ return ""; //$NON-NLS-1$
+ }
+ });
+
+ tableView.setInput(getValue());
+ tableView.getTable().setLinesVisible(true);
+ tableView.getTable().setHeaderVisible(true);
+ tableView.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ JBossRuntime selRt = (JBossRuntime) event.getElement();
+ if (event.getChecked()) {
+ JBossRuntime deselRt = null;
+ Object[] selRts = tableView.getCheckedElements();
+
+ for (int i = 0; i < selRts.length; i++) {
+ JBossRuntime rt = (JBossRuntime) selRts[i];
+ if (rt != selRt) {
+ deselRt = rt;
+ break;
+ }
+ }
+
+ if (deselRt != null) {
+ Object[] newChecked = new Object[selRts.length - 1];
+ checkedElement = null;
+ int i = 0;
+ for (Object object : selRts) {
+ JBossRuntime rt = (JBossRuntime) object;
+ if (rt == selRt) {
+ newChecked[i] = rt;
+ checkedElement = rt;
+ i++;
+ }
+ }
+ tableView.setCheckedElements(newChecked);
+ } else {
+ checkedElement = (JBossRuntime) event.getElement();
+ }
+ } else {
+ if (checkedElement == selRt) {
+ checkedElement = null;
+ }
+ }
+ pcs.firePropertyChange(getName(), null, getValue());
+ }
+ });
+
+ for (JBossRuntime rt : (List<JBossRuntime>) getValue()) {
+ if (rt.isDefault()) {
+ tableView.setChecked(rt, true);
+ checkedElement = rt;
+ }
+ }
+ }
+
+ protected void createActionBar() {
+ actionPanel = new ActionPanel(root, new BaseAction[] { new AddAction(),
+ new EditAction(), new RemoveAction() });
+ tableView.addSelectionChangedListener(actionPanel);
+ }
+
+ /**
+ * Checks all runtimes and set default one if user did not do it.
+ */
+ @SuppressWarnings("unchecked")
+ private void setDefaultRuntime() {
+ List<JBossRuntime> runtimes = (List<JBossRuntime>) getValue();
+ boolean checked = false;
+ for (JBossRuntime jbossRuntime : runtimes) {
+
+ if (checkedElement == jbossRuntime) {
+ checked = true;
+ tableView.setChecked(checkedElement, true);
+ break;
+ }
+ }
+ if (!checked && runtimes.size() > 0) {
+ if (tableView.getCheckedElements() == null
+ || tableView.getCheckedElements().length == 0) {
+ tableView.setChecked(runtimes.get(0), true);
+ checkedElement = runtimes.get(0);
+ }
+ }
+
+ }
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+ /**
+ * Wizard page for editing JBossWS Runtime parameters
+ *
+ */
+ public static class JBossWSRuntimeWizardPage extends WizardPage implements
+ PropertyChangeListener {
+
+ private static final String SRT_NAME = "name";
+ private static final String SRT_VERSION = "version";
+ private static final String SRT_HOMEDIR = "homeDir";
+
+ private static final int GL_PARENT_COLUMNS = 1;
+ private static final int GL_CONTENT_COLUMNS = 3;
+
+ List<JBossRuntime> value = null;
+
+ IFieldEditor name = createTextEditor(SRT_NAME,
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Name2, "");
//$NON-NLS-1$
+
+ IFieldEditor version = createTextEditor(SRT_VERSION,
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Version, "");
//$NON-NLS-1$
+
+ IFieldEditor homeDir = createBrowseFolderEditor(
+ SRT_HOMEDIR,
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Home_Folder,
+ ""); //$NON-NLS-1$
+
+ JBossRuntime current = null;
+
+ IFieldEditor jars = null;
+
+ public JBossWSRuntimeWizardPage(List<JBossRuntime> editedList) {
+ super(
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+
+ setMessage(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Create_A_Runtime);
+ setTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime);
+ value = editedList;
+ }
+
+ /**
+ * Create Wizard page content
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ public void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(GL_PARENT_COLUMNS, false));
+ GridData dg = new GridData();
+ dg.horizontalAlignment = GridData.FILL;
+ dg.grabExcessHorizontalSpace = true;
+ Composite root = new Composite(parent, SWT.NONE);
+ root.setLayoutData(dg);
+ GridLayout gl = new GridLayout(GL_CONTENT_COLUMNS, false);
+ root.setLayout(gl);
+ name.doFillIntoGrid(root);
+ name.addPropertyChangeListener(this);
+ version.doFillIntoGrid(root);
+ version.addPropertyChangeListener(this);
+ homeDir.doFillIntoGrid(root);
+ homeDir.addPropertyChangeListener(this);
+
+ jars = new JBossLibraryListFieldEditor("", "", current);
+ jars.doFillIntoGrid(root);
+ jars.addPropertyChangeListener(this);
+ setPageComplete(false);
+ setControl(root);
+ }
+
+ /**
+ * Process evt: setup default values based on JBossWS Home folder and
+ * validate user input
+ *
+ * @param evt
+ * PropertyChangeEvent describes changes in wizard
+ */
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if ("homeDir".equals(evt.getPropertyName())) {
+ if (name.getValueAsString() == null
+ || "".equals(name.getValueAsString().trim())
+ || this.getErrorMessage() != null) {
+ String homeDirName = homeDir.getValueAsString();
+ if (homeDirName != null && !"".equals(homeDirName.trim())) {
+ File folder = new File(homeDirName);
+ homeDirName = folder.getName();
+ }
+ name.setValue(homeDirName);
+ }
+ }
+
+ if (name.getValueAsString() == null || "".equals(//$NON-NLS-1$
+ name.getValueAsString().toString().trim())) {
+ setErrorMessage(JBossESBUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!name.getValueAsString().matches(
+ "[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
+ setErrorMessage(JBossESBUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct);
+ setPageComplete(false);
+ return;
+ }
+ for (JBossRuntime rt : value) {
+ if (current != null && current.getName().equals(rt.getName())) {
+ continue;
+ }
+ if (rt.getName().equals(name.getValueAsString())) {
+ setErrorMessage(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime
+ + name.getValueAsString()
+ + JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Already_Exists);
+ setPageComplete(false);
+ return;
+ }
+ }
+
+ JBossRuntime jarJbws = (JBossRuntime) jars.getValue();
+ if (current != null
+ && current.getName().equals(name.getValueAsString())
+ && current.getHomeDir().equals(homeDir.getValueAsString())
+ && current.getVersion().equals(version.getValueAsString())
+ && current.isUserConfigClasspath() == jarJbws
+ .isUserConfigClasspath()
+ && (!jarJbws.isUserConfigClasspath() || hasSameLibraies(
+ current.getLibraries(), jarJbws.getLibraries()))) {
+
+ setErrorMessage(null);
+ setPageComplete(false);
+ return;
+ }
+
+ if (jarJbws.isUserConfigClasspath()
+ && jarJbws.getLibraries().size() == 0) {
+ setErrorMessage("The library must contian at least one jar.");
+ setPageComplete(false);
+ return;
+ }
+
+ if (homeDir.getValueAsString() == null
+ || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
+ setErrorMessage(JBossESBUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!runtimeExist(homeDir.getValueAsString())) {
+ setErrorMessage(JBossESBUIMessages.Label_JBossWS_Runtime_Load_Error);
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+
+ private boolean hasSameLibraies(List<String> lib1, List<String> lib2) {
+ if (lib1.size() != lib2.size())
+ return false;
+ for (String jar : lib1) {
+ if (!lib2.contains(jar))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return JBossWS Runtime instance initialized by user input
+ *
+ * @return JBossRuntime instance
+ */
+ public JBossRuntime getRuntime() {
+ JBossRuntime newRt = new JBossRuntime();
+ newRt.setName(name.getValueAsString());
+ newRt.setVersion(version.getValueAsString());
+ newRt.setHomeDir(homeDir.getValueAsString());
+ JBossRuntime rt = (JBossRuntime) jars.getValue();
+ newRt.setLibraries(rt.getLibraries());
+ newRt.setUserConfigClasspath(rt.isUserConfigClasspath());
+ return newRt;
+ }
+
+ public IFieldEditor createTextEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor.addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue) });
+ return editor;
+ }
+
+ public IFieldEditor createBrowseFolderEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor
+ .addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue),
+ new ButtonFieldEditor(
+ name,
+ createSelectFolderAction(JBossESBUIMessages.JBossWS_SWT_Field_Editor_Factory_Browse),
+ defaultValue) });
+ return editor;
+ }
+
+ public ButtonFieldEditor.ButtonPressedAction createSelectFolderAction(
+ String buttonName) {
+ return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+ @Override
+ public void run() {
+ DirectoryDialog dialog = new DirectoryDialog(Display
+ .getCurrent().getActiveShell());
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ dialog
+ .setMessage(JBossESBUIMessages.JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder);
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ String directory = dialog.open();
+ if (directory != null) {
+ getFieldEditor().setValue(directory);
+ }
+ }
+ };
+ }
+
+ private boolean runtimeExist(String path) {
+
+ File jbosswsHomeDir = new File(path);
+ if (!jbosswsHomeDir.isDirectory())
+ return false;
+
+ if(!isValidESBStandaloneRuntimeDir(path)
+ && !isValidESBServer(path)){
+ return false;
+ }
+
+
+ return true;
+ }
+
+ private boolean isValidESBStandaloneRuntimeDir(String path) {
+ IPath location = new Path(path);
+ IPath esblocation =
location.append("lib").append("jbossesb.esb");
+ IPath sarLocation =
location.append("lib").append("jbossesb.sar");
+ if (!esblocation.toFile().isDirectory()) {
+ return false;
+ }
+ if (!sarLocation.toFile().isDirectory()) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean isValidESBServer(String path){
+ IPath serverLocation = new Path(path);
+
+ String esbLcoationSeg = "server" + File.separator + "default"
+ + File.separator + "deploy" + File.separator
+ + "jbossesb.esb";
+ String sarLocationSeg = "server" + File.separator + "default"
+ + File.separator + "deploy" + File.separator
+ + "jbossesb.sar";
+ IPath esbLocation = serverLocation.append(esbLcoationSeg);
+ IPath sarLocation = serverLocation.append(sarLocationSeg);
+
+ if(!esbLocation.toFile().isDirectory()){
+ return false;
+ }
+ if(!sarLocation.toFile().isDirectory()){
+ return false;
+ }
+
+
+ return true;
+ }
+
+ }
+
+
+
+ /**
+ * Wizard collect information and creates new JBossRuntime instances.
+ *
+ */
+ public static class JBossRuntimeNewWizard extends Wizard {
+
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossRuntime> added = null;
+ List<JBossRuntime> value = null;
+
+ public JBossRuntimeNewWizard(List<JBossRuntime> exist,
+ List<JBossRuntime> added) {
+ super();
+ setWindowTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(exist);
+ addPage(page1);
+ this.value = exist;
+ this.added = added;
+ }
+
+ /**
+ * Do finish steps
+ *
+ * @return boolean
+ */
+ @Override
+ public boolean performFinish() {
+ JBossRuntime rt = page1.getRuntime();
+ added.add(rt);
+ value.add(rt);
+
+ return true;
+ }
+
+ protected JBossRuntime getRuntime() {
+ return page1.getRuntime();
+ }
+
+ }
+
+ /**
+ * Wizard for editing JBossWS Runtime parameters: name and path to home
+ * folder
+ *
+ */
+ public static class JBossWSRuntimeEditWizard extends Wizard {
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossRuntime> added = null;
+ Map<JBossRuntime, JBossRuntime> changed = null;
+ List<JBossRuntime> value = null;
+ JBossRuntime source = null;
+
+ /**
+ * Constructor with almost all initialization parameters
+ *
+ * @param existing
+ * List<JBossRuntime> - edited list of JBossWS
+ * Runtimes
+ * @param source
+ * JBossRuntime - edited JBossWS Runtime
+ * @param added
+ * List<JBossRuntime> - TBD
+ * @param changed
+ * List<JBossRuntime> - TBD
+ */
+ public JBossWSRuntimeEditWizard(List<JBossRuntime> existing,
+ JBossRuntime source, List<JBossRuntime> added,
+ Map<JBossRuntime, JBossRuntime> changed) {
+ super();
+ setWindowTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(existing);
+ page1
+ .setMessage(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Modify_Runtime);
+ page1
+ .setTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ addPage(page1);
+ this.value = existing;
+ this.added = added;
+ this.changed = changed;
+ this.source = source;
+ page1.name.setValue(source.getName());
+ page1.version.setValue(source.getVersion());
+ page1.homeDir.setValue(source.getHomeDir());
+ page1.current = source;
+ }
+
+ /**
+ * Perform operations to finish editing JBossWS Runtime parameters
+ *
+ * @return boolean - always true
+ */
+ @Override
+ public boolean performFinish() {
+ JBossRuntime rt = page1.getRuntime();
+
+ if (added.contains(source) || changed.containsKey(source)) {
+ source.setName(rt.getName());
+ source.setHomeDir(rt.getHomeDir());
+ source.setVersion(rt.getVersion());
+ source.setUserConfigClasspath(rt.isUserConfigClasspath());
+ source.setLibraries(rt.getLibraries());
+ } else {
+ changed.put(rt, source);
+ if (source.isDefault()) {
+ rt.setDefault(true);
+ }
+ int i = value.indexOf(source);
+ if (i >= 0) {
+ value.set(i, rt);
+
+ } else {
+ value.remove(source);
+ value.add(rt);
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see
org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ JBossRuntime[] runtimes = new JBossRuntime[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<JBossRuntime> rts = new ArrayList<JBossRuntime>();
+ for (Object rt : ((IStructuredSelection) selection).toArray()) {
+ rts.add((JBossRuntime) rt);
+ }
+ runtimes = rts.toArray(new JBossRuntime[] {});
+ } else {
+ runtimes = new JBossRuntime[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ Wizard wiz = new JBossRuntimeNewWizard(
+ (List<JBossRuntime>) getValue(), added);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+ }
+
+ /**
+ * Action starts an editing selected JBossWS Runtime in Edit JBossWS Runtime
+ * dialog
+ *
+ */
+ public class EditAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Edit";
+
+ /**
+ * Create EditAction with default name
+ *
+ * @param text
+ */
+ public EditAction() {
+ super(ACTION_NAME);
+ }
+
+ /**
+ * Edit action is enabled when the only JBossWS Runtime is selected
+ */
+ @Override
+ protected void updateEnablement() {
+ // available when the only JBossRuntime is selected
+ setEnabled(runtimes.length == 1);
+ }
+
+ /**
+ * Start editing selected JBossWS Runtime in Edit JBossWS Runtime Wizard
+ * Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ JBossRuntime selected = runtimes[0];
+ Wizard wiz = new JBossWSRuntimeEditWizard(
+ (List<JBossRuntime>) getValue(), runtimes[0], added,
+ changed);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ JBossRuntime c = null;
+ if (changed.containsValue(selected)) {
+ c = findChangedRuntime(selected);
+ if (c != null) {
+ tableView.setSelection(new StructuredSelection(c));
+ }
+ }
+ if (c != null && c.isDefault()) {
+ checkedElement = c;
+ }
+ setDefaultRuntime();
+ }
+
+ private JBossRuntime findChangedRuntime(JBossRuntime source) {
+ for (JBossRuntime r : changed.keySet()) {
+ if (source == changed.get(r)) {
+ return r;
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(runtimes.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (JBossRuntime rt : runtimes) {
+ removeRuntime(rt);
+ }
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeRuntime(JBossRuntime r) {
+ boolean used = JBossRuntimeManager.isRuntimeUsed(r.getName());
+ String title = JBossESBUIMessages.JBossWS_Runtime_Delete_Confirm_Title;
+ String message = (used) ? NLS.bind(
+ JBossESBUIMessages.JBossWS_Runtime_Delete_Used_Confirm, r
+ .getName()) : NLS.bind(
+ JBossESBUIMessages.JBossWS_Runtime_Delete_Not_Used_Confirm,
+ r.getName());
+ boolean b = MessageDialog.openConfirm(tableView.getControl()
+ .getShell(), title, message);
+ if (b) {
+ if (changed.containsKey(r)) {
+ r = changed.remove(r);
+ }
+ removed.add(r);
+ if (added.contains(r)) {
+ added.remove(r);
+ }
+ ((List) getValue()).remove(r);
+ }
+ if (checkedElement == r) {
+ checkedElement = null;
+ }
+ }
+ }
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author Grid Qian
+ */
+public class LabelFieldEditor extends BaseFieldEditor {
+
+ public LabelFieldEditor(String name, String label) {
+ super(name, label, ""); //$NON-NLS-1$
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ // TODO Auto-generated method stub
+ return new Control[]{createLabelControl((Composite)composite)};
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ return getEditorControls(null);
+ }
+
+ @Override
+ public boolean isEditable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void save(Object object) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setEditable(boolean ediatble) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setValue(Object value) {
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ // TODO Auto-generated method stub
+ return 1;
+ }
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import
org.jboss.tools.esb.project.ui.preference.controls.ButtonFieldEditor.ButtonPressedAction;
+
+/**
+ * @author Grid Qian
+ *
+ */
+public class PushButtonField extends BaseField {
+
+ Button button;
+
+ /**
+ *
+ */
+ @Override
+ public Control getControl() {
+ return button;
+ }
+
+
+ public PushButtonField(Composite composite, int style, ButtonPressedAction listener) {
+ button = new Button(composite, style);
+ button.setText(listener.getText());
+ button.addSelectionListener(listener);
+ }
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+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;
+
+/**
+ * @author Grid Qian
+ */
+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;
+ }
+
+ public Control getControl() {
+ return getTextControl();
+ }
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+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.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ *
+ * @author Grid Qian
+ *
+ */
+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()};
+ }
+
+ @Override
+ public void doFillIntoGrid(Object aParent) {
+ Assert.isTrue(aParent instanceof Composite,
JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)aParent).getLayout() instanceof
GridLayout,JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) aParent;
+ 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());
+ 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());
+ }
+
+ protected int getInitialStyle() {
+ if(this.style >= 0) return style;
+ return SWT.SINGLE | SWT.BORDER;
+ }
+
+ /*
+ * @param value
+ * @return
+ */
+ @SuppressWarnings({ "unchecked", "unused" })
+ private String checkCollection(Object value){
+
+ return value != null && (((Collection)value).size() > 0) ?
prepareCollectionToString((Collection)value) : ""; //$NON-NLS-1$
+ }
+
+ /*
+ * @param collection
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ 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
+ */
+ @SuppressWarnings("unused")
+ 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;
+ }
+
+ @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
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,37 @@
+Label_JBossWS_Runtime_Load_Error=Error occurred while loading JBoss ESB runtime. Please
select a correct ESB runtime or SOA-P location
+
+Command=wsconsume.sh
+Bin=bin
+Client=client
+Lib=lib
+Endorsed=endorsed
+
+Error_JBossWS_Basic_Editor_Composite=Parent control should be Composite
+Error_JBossWS_Basic_Editor_Support=Editor supports only grid layout
+Error_JBossWS_Basic_Editor_Different=Parent for label is different
+JBossWS_Runtime_List_Field_Editor_Name=Name
+JBossWS_Runtime_List_Field_Editor_Version=Version
+JBossWS_Runtime_List_Field_Editor_Path=Path
+JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be=inputElement must be
+JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List=an instance of
List<JBossRuntime>.
+JBossWS_Runtime_Delete_Confirm_Title=Confirm Runtime Delete
+JBossWS_Runtime_Delete_Used_Confirm=Runtime ''{0}'' is used by JBoss ESB
projects. Are you sure you want to delete it?
+JBossWS_Runtime_Delete_Not_Used_Confirm=Are you sure you want to delete runtime
''{0}''?
+JBossWS_Runtime_List_Field_Editor_Edit_Runtime=Edit JBoss ESB Runtime
+JBossWS_Runtime_List_Field_Editor_Modify_Runtime=Input new values
+JBossWS_Runtime_List_Field_Editor_New_Runtime=New JBoss ESB Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty=Path to
JBoss ESB runtime home directory cannot be empty
+JBossWS_Runtime_List_Field_Editor_Already_Exists=' already exists
+JBossWS_Runtime_List_Field_Editor_Runtime=JBoss ESB Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct=Runtime name is not
correct
+Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty=Name cannot be empty
+JBossWS_Runtime_List_Field_Editor_Create_A_Runtime=Create a JBoss ESB Runtime
+JBossWS_Runtime_List_Field_Editor_Home_Folder=Home Folder:
+JBossWS_Composite_Editor_This_Method_Can_Be_Invoked=This metod can be invoked after
getEditorControls(parent) only
+JBossWS_Button_Field_Editor_Browse=Browse...
+Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet=Not implemented yet. Please setup
real acion for editor.
+JBossWS_SWT_Field_Editor_Factory_Browse=Browse...
+JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder=Select JBoss ESB runtime Home Folder
+JBossWS_Runtime_List_Field_Editor_Name2=Name:
+JBossWS_Runtime_Check_Field_Default_Classpath=Customize JBoss ESB runtime jars
+JBossWS_Preference_Page_Runtimes=JBoss ESB Runtimes
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public final class JBossESBUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
+ "org.jboss.tools.esb.project.ui.preference.messages.JBossESBUI"; //$NON-NLS-1$
+
+ private JBossESBUIMessages() {
+ // Do not instantiate
+ }
+
+ public static String Label_JBossWS_Runtime_Load_Error;
+
+ public static String Bin;
+ public static String Command;
+ public static String Client;
+ public static String Lib;
+ public static String Endorsed;
+
+ public static String Error_JBossWS_Basic_Editor_Composite;
+ public static String Error_JBossWS_Basic_Editor_Support;
+ public static String Error_JBossWS_Basic_Editor_Different;
+ public static String JBossWS_Runtime_List_Field_Editor_Name;
+ public static String JBossWS_Runtime_List_Field_Editor_Version;
+ public static String JBossWS_Runtime_List_Field_Editor_Path;
+ public static String JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be;
+ public static String JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List;
+ public static String JBossWS_Runtime_Delete_Confirm_Title;
+ public static String JBossWS_Runtime_Delete_Used_Confirm;
+ public static String JBossWS_Runtime_Delete_Not_Used_Confirm;
+ public static String JBossWS_Runtime_List_Field_Editor_Edit_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Modify_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_New_Runtime;
+ public static String
Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Already_Exists;
+ public static String JBossWS_Runtime_List_Field_Editor_Runtime;
+ public static String
Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Create_A_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Home_Folder;
+ public static String JBossWS_Composite_Editor_This_Method_Can_Be_Invoked;
+ public static String JBossWS_Button_Field_Editor_Browse;
+ public static String Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet;
+ public static String JBossWS_SWT_Field_Editor_Factory_Browse;
+ public static String JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder;
+ public static String JBossWS_Runtime_List_Field_Editor_Name2;
+ public static String JBossWS_Runtime_Check_Field_Default_Classpath;
+ public static String JBossWS_Preference_Page_Runtimes;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossESBUIMessages.class);
+ }
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,502 @@
+/*******************************************************************************
+ * 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.esb.project.ui.utils;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Grid Qian
+ */
+public class UIUtils {
+ /**
+ * A default padding value for horizontalResize().
+ */
+ public final static int DEFAULT_PADDING = 35;
+
+ String infoPopid_;
+
+ public UIUtils(String infoPopid) {
+ infoPopid_ = infoPopid;
+ }
+
+ public Button createRadioButton(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.RADIO, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createCheckbox(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.CHECK, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createPushButton(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.NONE, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createButton(int kind, Composite parent, String labelName,
+ String tooltip, String infopop) {
+ Button button = new Button(parent, kind);
+
+ tooltip = tooltip == null ? labelName : tooltip;
+ button.setText(labelName);
+ button.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(button,
+ infoPopid_ + "." + infopop);
+
+ return button;
+ }
+
+ public Combo createCombo(Composite parent, String labelName,
+ String tooltip, String infopop, int style) {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ if (labelName != null) {
+ Label label = new Label(parent, SWT.WRAP);
+ label.setText(labelName);
+ label.setToolTipText(tooltip);
+ }
+
+ Combo combo = new Combo(parent, style);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+
+ combo.setLayoutData(griddata);
+ combo.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(combo,
+ infoPopid_ + "." + infopop);
+
+ return combo;
+ }
+
+ public Text createText(Composite parent, String labelName, String tooltip,
+ String infopop, int style) {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ if (labelName != null) {
+ Label label = new Label(parent, SWT.WRAP);
+ label.setText(labelName);
+ label.setToolTipText(tooltip);
+ }
+
+ Text text = new Text(parent, style);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+
+ text.setLayoutData(griddata);
+ text.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(text,
+ infoPopid_ + "." + infopop);
+
+ return text;
+ }
+
+ public Composite createComposite(Composite parent, int columns) {
+ return createComposite(parent, columns, -1, -1);
+ }
+
+ public Composite createComposite(Composite parent, int columns,
+ int marginHeight, int marginWidth) {
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ GridLayout gridlayout = new GridLayout();
+ gridlayout.numColumns = columns;
+
+ if (marginHeight >= 0)
+ gridlayout.marginHeight = marginHeight;
+ if (marginWidth >= 0)
+ gridlayout.marginWidth = marginWidth;
+
+ composite.setLayout(gridlayout);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ composite.setLayoutData(griddata);
+
+ return composite;
+
+ }
+
+ public Group createGroup(Composite parent, String groupName,
+ String tooltip, String infopop) {
+ return createGroup(parent, groupName, tooltip, infopop, 1, -1, -1);
+ }
+
+ public Group createGroup(Composite parent, String groupName,
+ String tooltip, String infopop, int columns, int marginHeight,
+ int marginWidth) {
+ Group newGroup = new Group(parent, SWT.NONE);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ GridLayout gridlayout = new GridLayout();
+
+ gridlayout.numColumns = columns;
+
+ if (marginHeight >= 0)
+ gridlayout.marginHeight = marginHeight;
+ if (marginWidth >= 0)
+ gridlayout.marginWidth = marginWidth;
+
+ tooltip = tooltip == null ? groupName : tooltip;
+ newGroup.setLayout(gridlayout);
+ newGroup.setText(groupName);
+ newGroup.setLayoutData(griddata);
+ newGroup.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newGroup,
+ infoPopid_ + "." + infopop);
+
+ return newGroup;
+ }
+
+ public Tree createTree(Composite parent, String tooltip, String infopop,
+ int style) {
+
+ tooltip = tooltip == null ? "" : tooltip;
+
+ Tree tree = new Tree(parent, style);
+
+ tree.setLayoutData(createFillAll());
+ tree.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(tree,
+ infoPopid_ + "." + infopop);
+
+ return tree;
+
+ }
+
+ public Table createTable(Composite parent, String tooltip, String infopop,
+ int style) {
+
+ tooltip = tooltip == null ? "" : tooltip;
+
+ Table table = new Table(parent, style);
+
+ // table.setLayoutData( createFillAll() );
+ table.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(table,
+ infoPopid_ + "." + infopop);
+
+ return table;
+
+ }
+
+ public Label createHorizontalSeparator(Composite parent, int spacing) {
+ Composite composite = createComposite(parent, 1, spacing, -1);
+
+ Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ separator.setLayoutData(griddata);
+
+ return separator;
+ }
+
+ public GridData createFillAll() {
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL
+ | GridData.GRAB_VERTICAL);
+ return data;
+ }
+
+ public void createInfoPop(Control ctrl, String infopop) {
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(ctrl,
+ infoPopid_ + "." + infopop);
+ }
+
+ /**
+ * Resizes the width of the target composite so that it is as wide as the
+ * reference composite plus a padding value.
+ *
+ * @param target
+ * The composite to resize.
+ * @param reference
+ * The reference composite
+ * @param padding
+ * The padding value
+ */
+ public void horizontalResize(Composite target, Composite reference,
+ int padding) {
+
+ Point originalSize = target.getSize();
+ Point referenceSize = reference.getSize();
+
+ padding = padding >= 0 ? padding : DEFAULT_PADDING;
+
+ if (referenceSize.x + padding > originalSize.x)
+ target.setSize(referenceSize.x + padding, originalSize.y);
+ }
+
+ public static void writePropertyToFile(File file,String key, String value) throws
IOException {
+ Writer out = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file), "8859_1"));
+ out.write(key+"="+value+"\n");
+ out.close();
+ }
+
+ // file util
+ public static void copyFile(String src, String dest) {
+ InputStream is = null;
+ FileOutputStream fos = null;
+
+ try
+ {
+ is = new FileInputStream(src);
+ fos = new FileOutputStream(dest);
+ int c = 0;
+ byte[] array = new byte[1024];
+ while ((c = is.read(array)) >= 0){
+ fos.write(array, 0, c);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ fos.close();
+ is.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static File createFileAndParentDirectories(String fileName) throws Exception {
+ File file = new File(fileName);
+ File parent = file.getParentFile();
+ if (!parent.exists()){
+ parent.mkdirs();
+ }
+ file.createNewFile();
+ return file;
+ }
+
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ return dir.delete();
+ }
+
+ public static void deleteDirectories(File dir) {
+ File[] children = dir.listFiles();
+ for (int i = 0; i < children.length; i++){
+ if (children[i].list() != null && children[i].list().length > 0){
+ deleteDirectories(children[i]);
+ }
+ else{
+ children[i].delete();
+ }
+ }
+ dir.delete();
+ }
+
+ public static void deleteDirectories(String dir) {
+ File directory = new File(dir);
+ deleteDirectories(directory);
+ }
+
+ public static void createTargetFile(String sourceFileName, String targetFileName)
+ throws Exception {
+ createTargetFile(sourceFileName, targetFileName, false);
+ }
+
+ public static void createTargetFile(String sourceFileName, String targetFileName,
+ boolean overwrite) throws Exception{
+ File idealResultFile = new File(targetFileName);
+ if (overwrite || !idealResultFile.exists())
+ {
+ createFileAndParentDirectories(targetFileName);
+ copyFile(sourceFileName, targetFileName);
+ }
+ }
+
+ public static boolean createDirectory(String directory){
+ // Create a directory; all ancestor directories must exist
+ boolean success = (new File(directory)).mkdir();
+ if (!success) {
+ // Directory creation failed
+ }
+ return success;
+ }
+
+ public static boolean createDirectorys(String directory){
+ // Create a directory; all ancestor directories must exist
+ boolean success = (new File(directory)).mkdirs();
+ if (!success) {
+ // Directory creation failed
+ }
+ return success;
+ }
+
+ //Copies all files under srcDir to dstDir.
+ // If dstDir does not exist, it will be created.
+ public static void copyDirectory(File srcDir, File dstDir) throws IOException {
+ if (srcDir.isDirectory()) {
+ if (!dstDir.exists()) {
+ dstDir.mkdir();
+ }
+
+ String[] children = srcDir.list();
+ for (int i=0; i<children.length; i++) {
+ copyDirectory(new File(srcDir, children[i]),
+ new File(dstDir, children[i]));
+ }
+ } else {
+ copy(srcDir, dstDir);
+ }
+ }
+
+ //Copies src file to dst file.
+ // If the dst file does not exist, it is created
+ public static void copy(File src, File dst) throws IOException {
+ InputStream in = new FileInputStream(src);
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
+ public static String addAnotherNodeToPath(String currentPath, String newNode) {
+ return currentPath + File.separator + newNode;
+ }
+
+ public static String addNodesToPath(String currentPath, String[] newNode) {
+ String returnPath=currentPath;
+ for (int i = 0; i < newNode.length; i++) {
+ returnPath = returnPath + File.separator + newNode[i];
+ }
+ return returnPath;
+ }
+
+ public static String addNodesToPath(StringBuffer currentPath, String[] pathNodes) {
+ for (int i = 0; i < pathNodes.length; i++){
+ currentPath.append(File.separator);
+ currentPath.append(pathNodes[i]);
+ }
+ return currentPath.toString();
+ }
+
+ public static String addNodesToURL(String currentPath, String[] newNode) {
+ String returnPath=currentPath;
+ for (int i = 0; i < newNode.length; i++) {
+ returnPath = returnPath + "/" + newNode[i];
+ }
+ return returnPath;
+ }
+
+ /**
+ * Get the list of file with a prefix of <code>fileNamePrefix</code>
& an extension of
+ * <code>extension</code>
+ *
+ * @param sourceDir The directory in which to search the files
+ * @param fileNamePrefix The prefix to look for
+ * @param extension The extension to look for
+ * @return The list of file with a prefix of <code>fileNamePrefix</code>
& an extension of
+ * <code>extension</code>
+ */
+ public static File[] getMatchingFiles(String sourceDir, String fileNamePrefix, String
extension) {
+ List<File> fileList = new ArrayList<File>();
+ File libDir = new File(sourceDir);
+ String libDirPath = libDir.getAbsolutePath();
+ String[] items = libDir.list();
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ String item = items[i];
+ if (fileNamePrefix != null && extension != null) {
+ if (item.startsWith(fileNamePrefix) &&
item.endsWith(extension)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else if (fileNamePrefix == null && extension != null) {
+ if (item.endsWith(extension)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else if (fileNamePrefix != null && extension == null) {
+ if (item.startsWith(fileNamePrefix)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ }
+ return (File[]) fileList.toArray(new File[fileList.size()]);
+ }
+ return new File[0];
+ }
+
+ /**
+ * Filter out files inside a <code>sourceDir</code> with matching
<codefileNamePrefix></code>
+ * and <code>extension</code>
+ * @param sourceDir The directory to filter the files
+ * @param fileNamePrefix The filtering filename prefix
+ * @param extension The filtering file extension
+ */
+ public static void filterOutRestrictedFiles(String sourceDir, String fileNamePrefix,
String extension){
+ File[] resultedMatchingFiles = getMatchingFiles(sourceDir, fileNamePrefix,
extension);
+ for (int i = 0; i < resultedMatchingFiles.length; i++) {
+ File matchingFilePath = new File(resultedMatchingFiles[i].getAbsolutePath());
+ matchingFilePath.delete();
+ }
+ }
+
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,54 @@
+package org.jboss.tools.esb.project.ui.wizards;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
+import org.eclipse.jst.common.project.facet.core.JavaFacet;
+import org.eclipse.ui.INewWizard;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+import org.jboss.tools.esb.project.ui.wizards.pages.ESBProjectFirstPage;
+
+public class ESBProjectWizard extends NewProjectDataModelFacetWizard implements
+ INewWizard {
+
+ public ESBProjectWizard() {
+ setWindowTitle("New ESB Project Wizard");
+ }
+
+ public ESBProjectWizard(IDataModel model) {
+ super(model);
+ setWindowTitle("New ESB Project Wizard");
+
+ }
+
+ @Override
+ protected IDataModel createDataModel() {
+ return DataModelFactory.createDataModel(new
JBossESBFacetProjectCreationDataModelProvider());
+ }
+
+ @Override
+ protected IWizardPage createFirstPage() {
+ return new ESBProjectFirstPage(model, "first.page");
+ }
+
+ @Override
+ protected ImageDescriptor getDefaultPageImageDescriptor() {
+ return null;
+ }
+
+ @Override
+ protected IFacetedProjectTemplate getTemplate() {
+ return
ProjectFacetsManager.getTemplate(ESBProjectUtilities.ESB_PROJECT_FACET_TEMPLATE);
+ }
+
+
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,40 @@
+package org.jboss.tools.esb.project.ui.wizards;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
+import org.eclipse.jst.common.project.facet.JavaFacetInstallDataModelProvider;
+import
org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.core.facet.JBossESBFacetDataModelProvider;
+
+public class JBossESBFacetProjectCreationDataModelProvider extends
+ FacetProjectCreationDataModelProvider {
+
+
+ public void init() {
+ super.init();
+
+ FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP);
+ IDataModel javaFacet = DataModelFactory.createDataModel(new
JavaFacetInstallDataModelProvider());
+ map.add(javaFacet);
+
+ IDataModel esbFacet = DataModelFactory.createDataModel(new
JBossESBFacetDataModelProvider());
+ map.add(esbFacet);
+ String esbSrc =
esbFacet.getStringProperty(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ javaFacet.setProperty(IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME,
esbSrc);
+
+ }
+
+
+
+ @Override
+ public IStatus validate(String propertyName) {
+
+ return super.validate(propertyName);
+ }
+
+
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,362 @@
+package org.jboss.tools.esb.project.ui.wizards.pages;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jst.common.project.facet.JavaFacetUtils;
+import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
+import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
+import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeManager;
+import org.jboss.tools.esb.project.ui.preference.controls.JBossRuntimeListFieldEditor;
+import org.jboss.tools.esb.project.ui.wizards.ESBProjectWizard;
+
+public class ESBFacetInstallationPage extends AbstractFacetWizardPage implements
IFacetWizardPage, IJBossESBFacetDataModelProperties {
+
+ private Label configFolderLabel;
+ private Text configFolder;
+ private Label contextRootLabel;
+ private Text contentFolder;
+ private IDataModel model;
+ private boolean hasValidContentFolder = true;
+ private boolean hasValidSrc = true;
+ private boolean hasRuntime = true;
+ private Combo cmbRuntimes;
+
+ public ESBFacetInstallationPage() {
+ super( "esb.facet.install.page"); //$NON-NLS-1$
+ setTitle("Install ESB Facet");
+ setDescription("Configure project structure and classpath");
+
+ }
+
+ private void setDefaultOutputFolder(){
+ JavaFacetInstallConfig cfg = findJavaFacetInstallConfig();
+ cfg.setDefaultOutputFolder(new Path(ESBProjectUtilities.BUILD_CLASSES));
+ }
+
+ protected Composite createTopLevelComposite(Composite parent) {
+ //setInfopopID(IWstWebUIContextIds.NEW_STATIC_WEB_PROJECT_PAGE3);
+ final Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ createProjectGroup(composite);
+ createRuntimeGroup(composite);
+
+ setDefaultOutputFolder();
+
+ //synchHelper.synchText(configFolder, CONTENT_DIR, null);
+ Dialog.applyDialogFont(parent);
+
+
+ return composite;
+ }
+
+ private void createProjectGroup(Composite parent){
+
+ Group prjGroup = new Group(parent, SWT.BORDER);
+ prjGroup.setText("Project Folders");
+ prjGroup.setLayout(new GridLayout(1, false));
+ prjGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+
+ this.contextRootLabel = new Label(prjGroup, SWT.NONE);
+ this.contextRootLabel.setText("Content Directory");
+ this.contextRootLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ this.contentFolder = new Text(prjGroup, SWT.BORDER);
+ this.contentFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.contentFolder.setData("label", this.contextRootLabel); //$NON-NLS-1$
+ this.contentFolder.setText(model.getStringProperty(ESB_CONTENT_FOLDER));
+ contentFolder.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e){
+ String content = contentFolder.getText();
+ if(content != null && !content.equals("")){
+ model.setProperty(ESB_CONTENT_FOLDER, content);
+ }
+ changePageStatus();
+ }
+ });
+
+ configFolderLabel = new Label(prjGroup, SWT.NONE);
+ configFolderLabel.setText("Java Source Directory");
+ configFolderLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ configFolder = new Text(prjGroup, SWT.BORDER);
+ configFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ configFolder.setData("label", configFolderLabel); //$NON-NLS-1$
+ configFolder.setText("src");
+ configFolder.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e){
+ String srcFolder = configFolder.getText();
+ if(srcFolder != null && !srcFolder.equals("")){
+ model.setProperty(ESB_SOURCE_FOLDER, srcFolder);
+ setConfigFolder(srcFolder);
+ }
+ changePageStatus();
+ }
+
+ });
+ }
+
+ private void setConfigFolder(String folderName){
+ JavaFacetInstallConfig cfg = findJavaFacetInstallConfig();
+ cfg.setSourceFolder(new Path(folderName));
+ }
+
+
+ private JavaFacetInstallConfig findJavaFacetInstallConfig()
+ {
+ ESBProjectWizard wizard = (ESBProjectWizard)this.getWizard();
+ IDataModel wModel = wizard.getDataModel();
+ final IFacetedProjectWorkingCopy fpjwc
+ = (IFacetedProjectWorkingCopy) wModel.getProperty(
FACETED_PROJECT_WORKING_COPY );
+
+ if( fpjwc != null )
+ {
+ final IFacetedProject.Action javaInstallAction
+ = fpjwc.getProjectFacetAction( JavaFacetUtils.JAVA_FACET );
+
+ final Object config = javaInstallAction.getConfig();
+
+ if( config instanceof JavaFacetInstallConfig )
+ {
+ return (JavaFacetInstallConfig) config;
+ }
+ else
+ {
+ return (JavaFacetInstallConfig) Platform.getAdapterManager().getAdapter(
config, JavaFacetInstallConfig.class );
+ }
+ }
+
+ return null;
+ }
+
+ private void createRuntimeGroup(Composite parent){
+
+ Group runtimeGroup = new Group(parent, SWT.BORDER);
+ runtimeGroup.setText("JBoss ESB Runtime");
+ runtimeGroup.setLayout(new GridLayout(4, false));
+ runtimeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ /* Button btnServerSupplied = new Button(runtimeGroup, SWT.RADIO);
+
+ GridData gd = new GridData();
+
+ gd.horizontalSpan = 1;
+ btnServerSupplied.setLayoutData(gd);*/
+
+ /*Label lblServerSupplied = new Label(runtimeGroup, SWT.NONE);
+
+ lblServerSupplied.setText("Server supplied ESB Runtime");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ lblServerSupplied.setLayoutData(gd);
+
+ Button btnUserSupplied = new Button(runtimeGroup, SWT.RADIO);*/
+
+
+ cmbRuntimes = new Combo(runtimeGroup, SWT.READ_ONLY);
+ cmbRuntimes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ cmbRuntimes.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ String runtimeName = cmbRuntimes.getText();
+ JBossRuntime jr = (JBossRuntime) cmbRuntimes
+ .getData(runtimeName);
+ saveJBosswsRuntimeToModel(jr);
+ }
+ });
+ initializeRuntimesCombo(cmbRuntimes, null);
+
+ Button btnNew = new Button(runtimeGroup, SWT.NONE);
+ btnNew.setText("New");
+ btnNew.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ newJBossWSRuntime();
+ changePageStatus();
+ }
+ });
+
+
+ }
+
+
+
+ /*
+ * create a new jbossws runtime and set user supplied runtime to the new one
+ */
+ protected void newJBossWSRuntime() {
+ List<JBossRuntime> exists = new
ArrayList<JBossRuntime>(Arrays.asList(JBossRuntimeManager.getInstance().getRuntimes()));
+ List<JBossRuntime> added = new ArrayList<JBossRuntime>();
+
+ JBossRuntimeListFieldEditor.JBossRuntimeNewWizard newRtwizard = new
JBossRuntimeListFieldEditor.JBossRuntimeNewWizard(
+ exists, added) {
+ public boolean performFinish() {
+ JBossRuntime rt = getRuntime();
+ rt.setDefault(true);
+ JBossRuntimeManager.getInstance().addRuntime(rt);
+ JBossRuntimeManager.getInstance().save();
+
+ return true;
+ }
+ };
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), newRtwizard);
+ if (dialog.open() == WizardDialog.OK) {
+ initializeRuntimesCombo(cmbRuntimes, null);
+ //cmbRuntimes.select(0);
+ }
+ }
+
+ protected void initializeRuntimesCombo(Combo cmRuntime, String runtimeName) {
+ JBossRuntime selectedJbws = null;
+ JBossRuntime defaultJbws = null;
+ int selectIndex = 0;
+ int defaultIndex = 0;
+ cmRuntime.removeAll();
+ JBossRuntime[] runtimes = JBossRuntimeManager.getInstance()
+ .getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ JBossRuntime jr = runtimes[i];
+ cmRuntime.add(jr.getName());
+ cmRuntime.setData(jr.getName(), jr);
+
+ if(jr.getName().equals(runtimeName)){
+ selectedJbws = jr;
+ selectIndex = i;
+ }
+ // get default jbossws runtime
+ if (jr.isDefault()) {
+ defaultJbws = jr;
+ defaultIndex = i;
+ }
+ }
+
+ if(selectedJbws != null){
+ cmRuntime.select(selectIndex);
+ saveJBosswsRuntimeToModel(selectedJbws);
+ }else if(defaultJbws != null){
+ cmRuntime.select(defaultIndex);
+ saveJBosswsRuntimeToModel(defaultJbws);
+ }
+ }
+
+ protected void saveJBosswsRuntimeToModel(JBossRuntime jbws) {
+ /* String duplicateMsg = "";
+ try {
+ duplicateMsg = ESBProjectUtil.getDuplicateJars(model, jbws.getName());
+ } catch (JavaModelException e1) {
+ JBossESBPlugin.getDefault().getLog().log(
+ StatusUtils.errorStatus(e1));
+ }*/
+ if (jbws != null) {
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_HOME,
+ jbws.getHomeDir());
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_ID, jbws
+ .getName());
+ hasRuntime = true;
+ }else{
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_ID, null);
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_HOME, null);
+ hasRuntime = false;
+ }
+ }
+
+
+
+ private void changePageStatus(){
+ //String duplicateMsg = "";
+ /*try {
+ duplicateMsg = ESBProjectUtil.getDuplicateJars(model, cmbRuntimes.getText());
+ } catch (JavaModelException e1) {
+ JBossESBPlugin.getDefault().getLog().log(
+ StatusUtils.errorStatus(e1));
+ }*/
+
+ if(contentFolder.getText().trim().equals("")){
+ setErrorMessage("Please specify a valid content folder.");
+ hasValidContentFolder = false;
+ setPageComplete(isPageComplete());
+ }
+ else if(configFolder.getText().trim().equals("")){
+ setErrorMessage("Please specify a valid source folder.");
+ hasValidSrc = false;
+ setPageComplete(isPageComplete());
+ }
+ /* else if (!duplicateMsg.equals("")) {
+ setErrorMessage("Duplicated jar on classpath:" + duplicateMsg);
+ }*/
+ else{
+ setErrorMessage(null);
+ hasValidSrc = true;
+ hasValidContentFolder = true;
+ setPageComplete(isPageComplete());
+
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return hasValidContentFolder
+ && hasValidSrc
+ && hasRuntime;
+ }
+
+
+ private void fillMessageGroup(Composite parent){
+ Group messageGroup = new Group(parent, SWT.BORDER);
+ messageGroup.setText("Target Message Product");
+ messageGroup.setLayout(new GridLayout(1, false));
+ messageGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ }
+
+
+ public void setConfig(Object config) {
+ this.model = (IDataModel)config;
+ }
+
+
+ public void createControl(Composite parent) {
+
+ setControl(createTopLevelComposite(parent));
+ }
+
+
+ public Object create() throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java 2008-09-02
07:18:00 UTC (rev 10019)
@@ -0,0 +1,26 @@
+package org.jboss.tools.esb.project.ui.wizards.pages;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+
+public class ESBProjectFirstPage extends DataModelFacetCreationWizardPage {
+
+ public ESBProjectFirstPage(IDataModel dataModel, String pageName) {
+ super(dataModel, pageName);
+ setTitle("JBoss ESB Project");
+ setDescription("Create a new JBoss ESB project.");
+ }
+
+ protected String getModuleTypeID() {
+ return ESBProjectUtilities.ESB_PROJECT_FACET;
+ }
+
+ protected void createPresetPanel(Composite top) {
+ new Label(top, SWT.NONE);
+ }
+
+}