Author: dennyxu
Date: 2008-08-27 03:56:48 -0400 (Wed, 27 Aug 2008)
New Revision: 9915
Added:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ESBProjectUtil.java
Removed:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/project/facet/
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/nature/
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ResourceUtils.java
Modified:
workspace/Denny/org.jboss.tools.esb/META-INF/MANIFEST.MF
workspace/Denny/org.jboss.tools.esb/plugin.xml
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/AbstractESBWizardPage.java
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/ESBFacetInstallationPage.java
Log:
Modified: workspace/Denny/org.jboss.tools.esb/META-INF/MANIFEST.MF
===================================================================
--- workspace/Denny/org.jboss.tools.esb/META-INF/MANIFEST.MF 2008-08-27 00:41:46 UTC (rev
9914)
+++ workspace/Denny/org.jboss.tools.esb/META-INF/MANIFEST.MF 2008-08-27 07:56:48 UTC (rev
9915)
@@ -28,6 +28,9 @@
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.jst.j2ee.ui;bundle-version="1.1.200",
+ org.jboss.tools.esb.project;bundle-version="1.0.0",
+ org.jboss.tools.esb.project.preference;bundle-version="1.0.0",
+ org.eclipse.jdt.core;bundle-version="3.4.0"
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.esb.projects.wizards.pages
Modified: workspace/Denny/org.jboss.tools.esb/plugin.xml
===================================================================
--- workspace/Denny/org.jboss.tools.esb/plugin.xml 2008-08-27 00:41:46 UTC (rev 9914)
+++ workspace/Denny/org.jboss.tools.esb/plugin.xml 2008-08-27 07:56:48 UTC (rev 9915)
@@ -6,7 +6,7 @@
point="org.eclipse.ui.newWizards">
<wizard
category="org.jboss.tools.esb.category1"
-
class="org.jboss.tools.esb.projects.wizards.ESBProjectCreationWizard"
+ class="org.jboss.tools.esb.projects.wizards.ESBProjectWizard"
id="JBoss.ESB.Project.Wizard"
name="ESB Project Wizard"
project="true">
@@ -16,90 +16,11 @@
name="ESB Wizard">
</category>
</extension>
+
<extension
- point="org.eclipse.wst.common.project.facet.core.facets">
- <project-facet
- id="jboss.esb">
- <label>
- JBoss ESB
- </label>
- </project-facet>
- <project-facet-version
- facet="jboss.esb"
- version="4.2">
- <action
- facet="jboss.esb"
- type="install"
- version="4.2">
- <delegate
-
class="org.jboss.tools.esb.project.facet.JBossESBFacetInstallationDelegate">
- </delegate>
- <config-factory
-
class="org.jboss.tools.esb.project.facet.JBossESBFacetInstallationConfig">
- </config-factory>
- </action>
- </project-facet-version>
- <project-facet-version
- facet="jboss.esb"
- version="4.3">
- <action
- facet="jboss.esb"
- id="jboss.esb.install"
- type="install"
- version="4.3">
- <delegate
-
class="org.jboss.tools.esb.project.facet.JBossESBFacetInstallationDelegate">
- </delegate>
- <config-factory
-
class="org.jboss.tools.esb.project.facet.JBossESBFacetInstallationConfig">
- </config-factory>
- </action>
- </project-facet-version>
- <template
- id="template.jboss.esb">
- <label>
- label body text
- </label>
- <fixed
- facet="jboss.esb">
- </fixed>
- <fixed
- facet="jst.java">
- </fixed>
- </template>
- </extension>
- <extension
- id="esbnature"
- name="JBoss ESB Nature"
- point="org.eclipse.core.resources.natures">
- <runtime>
- <run
-
class="org.jboss.tools.esb.projects.nature.JBossESBProjectNature">
- </run>
- </runtime>
- <requires-nature
- id="org.eclipse.wst.common.project.facet.core.nature">
- </requires-nature>
- </extension>
- <extension
- point="org.eclipse.ui.ide.projectNatureImages">
- <image
- icon="esbproject.image3"
- id="org.jboss.esb.project.esbnature.image"
- natureId="org.jboss.esb.project.esbnature">
- </image>
- </extension>
- <extension
- point="org.eclipse.wst.server.core.moduleTypes">
- <moduleType
- id="jboss.esb"
- name="JBoss ESB Module">
- </moduleType>
- </extension>
- <extension
point="org.eclipse.wst.common.project.facet.ui.wizardPages">
<wizard-pages
- action="jboss.esb.install">
+ action="jst.jboss.esb.install">
<page
class="org.jboss.tools.esb.projects.wizards.pages.ESBFacetInstallationPage">
</page>
@@ -116,18 +37,6 @@
wizardPage="org.jboss.tools.esb.project.ui.templates.HelloWorldTemplateWizardPage">
</templates>
</extension>
- <extension
- point="org.eclipse.wst.common.project.facet.core.runtimes">
- <supported>
- <facet
- id="jboss.esb"
- version="4.2,4.3">
- </facet>
- <runtime-component
- id="org.jboss.ide.eclipse.as.runtime.component"
- version="4.2">
- </runtime-component>
- </supported>
- </extension>
+
</plugin>
Deleted:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java 2008-08-27
00:41:46 UTC (rev 9914)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -1,432 +0,0 @@
-package org.jboss.tools.esb.projects.wizards;
-
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
-import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
-import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
-import org.eclipse.wst.common.project.facet.core.IPreset;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
-import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
-import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
-import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard;
-
-public abstract class AbstractESBProjectCreationWizard extends ModifyFacetedProjectWizard
implements INewWizard, IFacetProjectCreationDataModelProperties {
-
- protected IDataModel model = null;
- private final IFacetedProjectTemplate template;
- private IWizardPage[] beginingPages;
- private IConfigurationElement configurationElement;
-
- public AbstractESBProjectCreationWizard(IDataModel model)
- {
- this.model = ( model == null ? createDataModel() : model );
- this.template = getTemplate();
-
- setWindowTitle("New JBoss ESB Project");
- setFacetedProjectWorkingCopy((IFacetedProjectWorkingCopy)this.model.getProperty(FACETED_PROJECT_WORKING_COPY));
- getFacetedProjectWorkingCopy().setFixedProjectFacets(
this.template.getFixedProjectFacets() );
- setDefaultPageImageDescriptor(getDefaultPageImageDescriptor());
- setShowFacetsSelectionPage( false );
- }
-
- public AbstractESBProjectCreationWizard()
- {
- this( null );
- }
-
- public IDataModel getDataModel() {
- return model;
- }
-
- protected abstract IDataModel createDataModel();
-
- protected abstract ImageDescriptor getDefaultPageImageDescriptor();
-
- protected abstract IFacetedProjectTemplate getTemplate();
-
- /**
- * Returns the first page that shows up before the facets page. If multiple pages are
required,
- * also override {@link #createBeginingPages()}.
- *
- * @return
- */
- protected abstract IWizardPage createFirstPage();
-
- /**
- * Subclasses should override to add more than one page before the facets page. If only
one page
- * is required, then use {@link #createFirstPage()}. The default implementation will
return the
- * result of {@link #createFirstPage()}.
- *
- * @return
- */
- protected IWizardPage[] createBeginingPages() {
- return new IWizardPage[]{createFirstPage()};
- }
-
- public void addPages() {
- beginingPages = createBeginingPages();
- for (int i = 0; i < beginingPages.length; i++) {
- addPage(beginingPages[i]);
- }
-
- super.addPages();
-
- getFacetedProjectWorkingCopy().addListener
- (
- new IFacetedProjectListener()
- {
- public void handleEvent( final IFacetedProjectEvent event )
- {
- facetSelectionChangedEvent();
- }
- },
- IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED
- );
- }
-
- public void createPageControls(Composite container) {
- super.createPageControls(container);
-
- final IPreset preset = this.template.getInitialPreset();
- final IRuntime runtime = (IRuntime) model.getProperty( FACET_RUNTIME );
-
- if( preset == null )
- {
- // If no preset is specified, select the runtime and it's default
- // facets.
-
- setRuntimeAndDefaultFacets( runtime );
- }
- else
- {
- // If preset is specified, select the runtime only if supports all
- // of the facets included in the preset.
-
- getFacetedProjectWorkingCopy().setSelectedPreset( preset.getId() );
-
- boolean supports = false;
-
- if( runtime != null )
- {
- supports = true;
-
- for( Iterator itr = preset.getProjectFacets().iterator(); itr.hasNext();
)
- {
- final IProjectFacetVersion fv = (IProjectFacetVersion) itr.next();
-
- if( ! runtime.supports( fv ) )
- {
- supports = false;
- break;
- }
- }
- }
-
- if( supports )
- {
- getFacetedProjectWorkingCopy().setTargetedRuntimes(
Collections.singleton( runtime ) );
- }
- else
- {
- model.setProperty( FACET_RUNTIME, null );
- }
- }
-
- synchRuntimes();
- }
-
- public IWizardPage[] getPages() {
- final IWizardPage[] base = super.getPages();
- final IWizardPage[] pages = new IWizardPage[base.length + beginingPages.length];
-
- for (int i = 0; i < beginingPages.length; i++) {
- pages[i] = beginingPages[i];
- }
-
- System.arraycopy(base, 0, pages, beginingPages.length, base.length);
-
- return pages;
- }
-
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- }
-
- protected void synchRuntimes()
- {
- final Boolean[] suppressBackEvents = { Boolean.FALSE };
-
- model.addListener(new IDataModelListener() {
- public void propertyChanged(DataModelEvent event) {
- if (IDataModel.VALUE_CHG == event.getFlag() || IDataModel.DEFAULT_CHG ==
event.getFlag()) {
- if (FACET_RUNTIME.equals(event.getPropertyName())) {
- if( ! suppressBackEvents[ 0 ].booleanValue() ) {
- IRuntime runtime = (IRuntime) event.getProperty();
- setRuntimeAndDefaultFacets( runtime );
- }
- }
- }
- }
- });
-
- getFacetedProjectWorkingCopy().addListener
- (
- new IFacetedProjectListener()
- {
- public void handleEvent( final IFacetedProjectEvent event )
- {
- suppressBackEvents[ 0 ] = Boolean.TRUE;
- model.setProperty(FACET_RUNTIME,
getFacetedProjectWorkingCopy().getPrimaryRuntime());
- suppressBackEvents[ 0 ] = Boolean.FALSE;
- }
- },
- IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED
- );
- }
-
- protected void setRuntimeAndDefaultFacets( final IRuntime runtime )
- {
- final IFacetedProjectWorkingCopy dm = getFacetedProjectWorkingCopy();
-
- dm.setTargetedRuntimes( Collections.<IRuntime>emptySet() );
-
- if( runtime != null )
- {
- final Set<IProjectFacetVersion> minFacets = new
HashSet<IProjectFacetVersion>();
-
- try
- {
- for( IProjectFacet f : dm.getFixedProjectFacets() )
- {
- minFacets.add( f.getLatestSupportedVersion( runtime ) );
- }
- }
- catch( CoreException e )
- {
- throw new RuntimeException( e );
- }
-
- dm.setProjectFacets( minFacets );
-
- dm.setTargetedRuntimes( Collections.singleton( runtime ) );
- }
-
- dm.setSelectedPreset( FacetedProjectFramework.DEFAULT_CONFIGURATION_PRESET_ID );
- }
-
- public String getProjectName() {
- return
model.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME);
- }
-
- protected void performFinish(final IProgressMonitor monitor)
-
- throws CoreException
-
- {
- monitor.beginTask("", 10); //$NON-NLS-1$
-
- try {
- super.performFinish(new SubProgressMonitor(monitor, 8));
-
- /* try {
- getFacetProjectNotificationOperation().execute(new NullProgressMonitor(),
null);
- } catch (ExecutionException e) {
- String msg = e.getMessage();
- if( msg == null ) msg = ""; //$NON-NLS-1$
- final IStatus st = new Status( IStatus.ERROR, WSTWebUIPlugin.PLUGIN_ID,
0, msg, e );
- throw new CoreException( st );
- }*/
- } finally {
- monitor.done();
- }
- }
-
- public boolean performFinish() {
- if (super.performFinish() == false) {
- return false;
- }
-
- /* try {
- postPerformFinish();
- } catch (InvocationTargetException e) {
- Logger.logException(e);
- }*/
-
- return true;
- }
-
- /**
- * <p>
- * Override to return the final perspective ID (if any). The final perspective ID can
be
- * hardcoded by the subclass or determined programmatically (possibly using the value of
a field
- * on the Wizard's WTP Operation Data Model).
- * </p>
- * <p>
- * The default implementation returns no perspective id unless overriden by product
definition
- * via the "wtp.project.final.perspective" property.
- * </p>
- *
- * @return Returns the ID of the Perspective which is preferred by this wizard upon
completion.
- */
-
- protected String getFinalPerspectiveID() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * The configuration element is saved to use when the wizard completes in order to
change the
- * current perspective using either (1) the value specified by {@link
#getFinalPerspectiveID()}
- * or (2) the value specified by the finalPerspective attribute in the Wizard's
configuration
- * element.
- * </p>
- *
- * @see
org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
- * java.lang.String, java.lang.Object)
- */
- public final void setInitializationData(IConfigurationElement aConfigurationElement,
String aPropertyName, Object theData) throws CoreException {
- configurationElement = aConfigurationElement;
- doSetInitializeData(aConfigurationElement, aPropertyName, theData);
-
- }
-
- /**
- * <p>
- * Override method for clients that wish to take advantage of the information provided
by
- * {@see #setInitializationData(IConfigurationElement, String, Object)}.
- * </p>
- *
- * @param aConfigurationElement
- * The configuration element provided from the templated method.
- * @param aPropertyName
- * The property name provided from the templated method.
- * @param theData
- * The data provided from the templated method.
- */
- protected void doSetInitializeData(IConfigurationElement aConfigurationElement, String
aPropertyName, Object theData) {
- // Default do nothing
- }
-
- /**
- * <p>
- * Returns the an id component used for Activity filtering.
- * </p>
- *
- * <p>
- * The Plugin ID is determined from the configuration element specified in
- * {@see #setInitializationData(IConfigurationElement, String, Object)}.
- * </p>
- *
- * @return Returns the plugin id associated with this wizard
- */
- public final String getPluginId() {
- return (configurationElement != null) ?
configurationElement.getDeclaringExtension().getNamespace() : ""; //$NON-NLS-1$
- }
-
- /**
- *
- * <p>
- * Invoked after the user has clicked the "Finish" button of the wizard. The
default
- * implementation will attempt to update the final perspective to the value specified
by
- * {@link #getFinalPerspectiveID() }
- * </p>
- *
- * @throws InvocationTargetException
- *
- * @see
org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizard#postPerformFinish()
- */
-/* protected void postPerformFinish() throws InvocationTargetException {
- if (getFinalPerspectiveID() != null && getFinalPerspectiveID().length() > 0)
{
- final IConfigurationElement element = new
DelegateConfigurationElement(configurationElement) {
- public String getAttribute(String aName) {
- if (aName.equals("finalPerspective")) { //$NON-NLS-1$
- return getFinalPerspectiveID();
- }
- return super.getAttribute(aName);
- }
- };
- BasicNewProjectResourceWizard.updatePerspective(element);
- } else
- BasicNewProjectResourceWizard.updatePerspective(configurationElement);
-
- String projName = getProjectName();
- BasicNewResourceWizard.selectAndReveal(ResourcesPlugin.getWorkspace().getRoot().getProject(projName),
WSTWebUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow());
- }*/
-
- /*protected IDataModelOperation getFacetProjectNotificationOperation() {
- return new DataModelPausibleOperationImpl(new AbstractDataModelOperation(this.model) {
- public String getID() {
- return AbstractESBProjectCreationWizard.class.getName();
- }
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws
ExecutionException {
- return AbstractDataModelProvider.OK_STATUS;
- }
- });
- }*/
-
- /**
- * Need to keep the model in sync with the UI. This method will pickup changes coming
from the
- * UI and push them into the model
- */
- protected void facetSelectionChangedEvent() {
- Set actions = getFacetedProjectWorkingCopy().getProjectFacetActions();
- Iterator iterator = actions.iterator();
- Set activeIds = new HashSet();
- while (iterator.hasNext()) {
- IFacetedProject.Action action = (IFacetedProject.Action) iterator.next();
- String id = action.getProjectFacetVersion().getProjectFacet().getId();
- activeIds.add(id);
- }
- // First handle all the actions tracked by IDataModels
- FacetDataModelMap dataModelMap = (FacetDataModelMap) model.getProperty(FACET_DM_MAP);
- iterator = dataModelMap.keySet().iterator();
- while (iterator.hasNext()) {
- String id = (String) iterator.next();
- IDataModel configDM = (IDataModel) dataModelMap.get(id);
- boolean active = activeIds.contains(id);
- configDM.setBooleanProperty(IFacetDataModelProperties.SHOULD_EXECUTE, active);
- activeIds.remove(id);
- }
- // Now handle the actions not tracked by IDataModels
- FacetActionMap actionMap = (FacetActionMap) model.getProperty(FACET_ACTION_MAP);
- actionMap.clear();
- iterator = actions.iterator();
- while (iterator.hasNext()) {
- IFacetedProject.Action action = (IFacetedProject.Action) iterator.next();
- String id = action.getProjectFacetVersion().getProjectFacet().getId();
- if (activeIds.contains(id)) {
- actionMap.add(action);
- }
- }
- model.notifyPropertyChange(FACET_RUNTIME, IDataModel.VALID_VALUES_CHG);
- }
-
-
-
-
-}
Added:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java
(rev 0)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/AbstractESBProjectCreationWizard.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -0,0 +1,432 @@
+package org.jboss.tools.esb.projects.wizards;
+
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
+import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
+import org.eclipse.wst.common.project.facet.core.IPreset;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
+import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard;
+
+public abstract class AbstractESBProjectCreationWizard extends ModifyFacetedProjectWizard
implements INewWizard, IFacetProjectCreationDataModelProperties {
+
+ protected IDataModel model = null;
+ private final IFacetedProjectTemplate template;
+ private IWizardPage[] beginingPages;
+ private IConfigurationElement configurationElement;
+
+ public AbstractESBProjectCreationWizard(IDataModel model)
+ {
+ this.model = ( model == null ? createDataModel() : model );
+ this.template = getTemplate();
+
+ setWindowTitle("New JBoss ESB Project");
+ setFacetedProjectWorkingCopy((IFacetedProjectWorkingCopy)this.model.getProperty(FACETED_PROJECT_WORKING_COPY));
+ getFacetedProjectWorkingCopy().setFixedProjectFacets(
this.template.getFixedProjectFacets() );
+ setDefaultPageImageDescriptor(getDefaultPageImageDescriptor());
+ setShowFacetsSelectionPage( false );
+ }
+
+ public AbstractESBProjectCreationWizard()
+ {
+ this( null );
+ }
+
+ public IDataModel getDataModel() {
+ return model;
+ }
+
+ protected abstract IDataModel createDataModel();
+
+ protected abstract ImageDescriptor getDefaultPageImageDescriptor();
+
+ protected abstract IFacetedProjectTemplate getTemplate();
+
+ /**
+ * Returns the first page that shows up before the facets page. If multiple pages are
required,
+ * also override {@link #createBeginingPages()}.
+ *
+ * @return
+ */
+ protected abstract IWizardPage createFirstPage();
+
+ /**
+ * Subclasses should override to add more than one page before the facets page. If only
one page
+ * is required, then use {@link #createFirstPage()}. The default implementation will
return the
+ * result of {@link #createFirstPage()}.
+ *
+ * @return
+ */
+ protected IWizardPage[] createBeginingPages() {
+ return new IWizardPage[]{createFirstPage()};
+ }
+
+ public void addPages() {
+ beginingPages = createBeginingPages();
+ for (int i = 0; i < beginingPages.length; i++) {
+ addPage(beginingPages[i]);
+ }
+
+ super.addPages();
+
+ getFacetedProjectWorkingCopy().addListener
+ (
+ new IFacetedProjectListener()
+ {
+ public void handleEvent( final IFacetedProjectEvent event )
+ {
+ facetSelectionChangedEvent();
+ }
+ },
+ IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED
+ );
+ }
+
+ public void createPageControls(Composite container) {
+ super.createPageControls(container);
+
+ final IPreset preset = this.template.getInitialPreset();
+ final IRuntime runtime = (IRuntime) model.getProperty( FACET_RUNTIME );
+
+ if( preset == null )
+ {
+ // If no preset is specified, select the runtime and it's default
+ // facets.
+
+ setRuntimeAndDefaultFacets( runtime );
+ }
+ else
+ {
+ // If preset is specified, select the runtime only if supports all
+ // of the facets included in the preset.
+
+ getFacetedProjectWorkingCopy().setSelectedPreset( preset.getId() );
+
+ boolean supports = false;
+
+ if( runtime != null )
+ {
+ supports = true;
+
+ for( Iterator itr = preset.getProjectFacets().iterator(); itr.hasNext();
)
+ {
+ final IProjectFacetVersion fv = (IProjectFacetVersion) itr.next();
+
+ if( ! runtime.supports( fv ) )
+ {
+ supports = false;
+ break;
+ }
+ }
+ }
+
+ if( supports )
+ {
+ getFacetedProjectWorkingCopy().setTargetedRuntimes(
Collections.singleton( runtime ) );
+ }
+ else
+ {
+ model.setProperty( FACET_RUNTIME, null );
+ }
+ }
+
+ synchRuntimes();
+ }
+
+ public IWizardPage[] getPages() {
+ final IWizardPage[] base = super.getPages();
+ final IWizardPage[] pages = new IWizardPage[base.length + beginingPages.length];
+
+ for (int i = 0; i < beginingPages.length; i++) {
+ pages[i] = beginingPages[i];
+ }
+
+ System.arraycopy(base, 0, pages, beginingPages.length, base.length);
+
+ return pages;
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+ protected void synchRuntimes()
+ {
+ final Boolean[] suppressBackEvents = { Boolean.FALSE };
+
+ model.addListener(new IDataModelListener() {
+ public void propertyChanged(DataModelEvent event) {
+ if (IDataModel.VALUE_CHG == event.getFlag() || IDataModel.DEFAULT_CHG ==
event.getFlag()) {
+ if (FACET_RUNTIME.equals(event.getPropertyName())) {
+ if( ! suppressBackEvents[ 0 ].booleanValue() ) {
+ IRuntime runtime = (IRuntime) event.getProperty();
+ setRuntimeAndDefaultFacets( runtime );
+ }
+ }
+ }
+ }
+ });
+
+ getFacetedProjectWorkingCopy().addListener
+ (
+ new IFacetedProjectListener()
+ {
+ public void handleEvent( final IFacetedProjectEvent event )
+ {
+ suppressBackEvents[ 0 ] = Boolean.TRUE;
+ model.setProperty(FACET_RUNTIME,
getFacetedProjectWorkingCopy().getPrimaryRuntime());
+ suppressBackEvents[ 0 ] = Boolean.FALSE;
+ }
+ },
+ IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED
+ );
+ }
+
+ protected void setRuntimeAndDefaultFacets( final IRuntime runtime )
+ {
+ final IFacetedProjectWorkingCopy dm = getFacetedProjectWorkingCopy();
+
+ dm.setTargetedRuntimes( Collections.<IRuntime>emptySet() );
+
+ if( runtime != null )
+ {
+ final Set<IProjectFacetVersion> minFacets = new
HashSet<IProjectFacetVersion>();
+
+ try
+ {
+ for( IProjectFacet f : dm.getFixedProjectFacets() )
+ {
+ minFacets.add( f.getLatestSupportedVersion( runtime ) );
+ }
+ }
+ catch( CoreException e )
+ {
+ throw new RuntimeException( e );
+ }
+
+ dm.setProjectFacets( minFacets );
+
+ dm.setTargetedRuntimes( Collections.singleton( runtime ) );
+ }
+
+ dm.setSelectedPreset( FacetedProjectFramework.DEFAULT_CONFIGURATION_PRESET_ID );
+ }
+
+ public String getProjectName() {
+ return
model.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME);
+ }
+
+ protected void performFinish(final IProgressMonitor monitor)
+
+ throws CoreException
+
+ {
+ monitor.beginTask("", 10); //$NON-NLS-1$
+
+ try {
+ super.performFinish(new SubProgressMonitor(monitor, 8));
+
+ /* try {
+ getFacetProjectNotificationOperation().execute(new NullProgressMonitor(),
null);
+ } catch (ExecutionException e) {
+ String msg = e.getMessage();
+ if( msg == null ) msg = ""; //$NON-NLS-1$
+ final IStatus st = new Status( IStatus.ERROR, WSTWebUIPlugin.PLUGIN_ID,
0, msg, e );
+ throw new CoreException( st );
+ }*/
+ } finally {
+ monitor.done();
+ }
+ }
+
+ public boolean performFinish() {
+ if (super.performFinish() == false) {
+ return false;
+ }
+
+ /* try {
+ postPerformFinish();
+ } catch (InvocationTargetException e) {
+ Logger.logException(e);
+ }*/
+
+ return true;
+ }
+
+ /**
+ * <p>
+ * Override to return the final perspective ID (if any). The final perspective ID can
be
+ * hardcoded by the subclass or determined programmatically (possibly using the value of
a field
+ * on the Wizard's WTP Operation Data Model).
+ * </p>
+ * <p>
+ * The default implementation returns no perspective id unless overriden by product
definition
+ * via the "wtp.project.final.perspective" property.
+ * </p>
+ *
+ * @return Returns the ID of the Perspective which is preferred by this wizard upon
completion.
+ */
+
+ protected String getFinalPerspectiveID() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>
+ * The configuration element is saved to use when the wizard completes in order to
change the
+ * current perspective using either (1) the value specified by {@link
#getFinalPerspectiveID()}
+ * or (2) the value specified by the finalPerspective attribute in the Wizard's
configuration
+ * element.
+ * </p>
+ *
+ * @see
org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
+ * java.lang.String, java.lang.Object)
+ */
+ public final void setInitializationData(IConfigurationElement aConfigurationElement,
String aPropertyName, Object theData) throws CoreException {
+ configurationElement = aConfigurationElement;
+ doSetInitializeData(aConfigurationElement, aPropertyName, theData);
+
+ }
+
+ /**
+ * <p>
+ * Override method for clients that wish to take advantage of the information provided
by
+ * {@see #setInitializationData(IConfigurationElement, String, Object)}.
+ * </p>
+ *
+ * @param aConfigurationElement
+ * The configuration element provided from the templated method.
+ * @param aPropertyName
+ * The property name provided from the templated method.
+ * @param theData
+ * The data provided from the templated method.
+ */
+ protected void doSetInitializeData(IConfigurationElement aConfigurationElement, String
aPropertyName, Object theData) {
+ // Default do nothing
+ }
+
+ /**
+ * <p>
+ * Returns the an id component used for Activity filtering.
+ * </p>
+ *
+ * <p>
+ * The Plugin ID is determined from the configuration element specified in
+ * {@see #setInitializationData(IConfigurationElement, String, Object)}.
+ * </p>
+ *
+ * @return Returns the plugin id associated with this wizard
+ */
+ public final String getPluginId() {
+ return (configurationElement != null) ?
configurationElement.getDeclaringExtension().getNamespace() : ""; //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * <p>
+ * Invoked after the user has clicked the "Finish" button of the wizard. The
default
+ * implementation will attempt to update the final perspective to the value specified
by
+ * {@link #getFinalPerspectiveID() }
+ * </p>
+ *
+ * @throws InvocationTargetException
+ *
+ * @see
org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizard#postPerformFinish()
+ */
+/* protected void postPerformFinish() throws InvocationTargetException {
+ if (getFinalPerspectiveID() != null && getFinalPerspectiveID().length() > 0)
{
+ final IConfigurationElement element = new
DelegateConfigurationElement(configurationElement) {
+ public String getAttribute(String aName) {
+ if (aName.equals("finalPerspective")) { //$NON-NLS-1$
+ return getFinalPerspectiveID();
+ }
+ return super.getAttribute(aName);
+ }
+ };
+ BasicNewProjectResourceWizard.updatePerspective(element);
+ } else
+ BasicNewProjectResourceWizard.updatePerspective(configurationElement);
+
+ String projName = getProjectName();
+ BasicNewResourceWizard.selectAndReveal(ResourcesPlugin.getWorkspace().getRoot().getProject(projName),
WSTWebUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow());
+ }*/
+
+ /*protected IDataModelOperation getFacetProjectNotificationOperation() {
+ return new DataModelPausibleOperationImpl(new AbstractDataModelOperation(this.model) {
+ public String getID() {
+ return AbstractESBProjectCreationWizard.class.getName();
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws
ExecutionException {
+ return AbstractDataModelProvider.OK_STATUS;
+ }
+ });
+ }*/
+
+ /**
+ * Need to keep the model in sync with the UI. This method will pickup changes coming
from the
+ * UI and push them into the model
+ */
+ protected void facetSelectionChangedEvent() {
+ Set actions = getFacetedProjectWorkingCopy().getProjectFacetActions();
+ Iterator iterator = actions.iterator();
+ Set activeIds = new HashSet();
+ while (iterator.hasNext()) {
+ IFacetedProject.Action action = (IFacetedProject.Action) iterator.next();
+ String id = action.getProjectFacetVersion().getProjectFacet().getId();
+ activeIds.add(id);
+ }
+ // First handle all the actions tracked by IDataModels
+ FacetDataModelMap dataModelMap = (FacetDataModelMap) model.getProperty(FACET_DM_MAP);
+ iterator = dataModelMap.keySet().iterator();
+ while (iterator.hasNext()) {
+ String id = (String) iterator.next();
+ IDataModel configDM = (IDataModel) dataModelMap.get(id);
+ boolean active = activeIds.contains(id);
+ configDM.setBooleanProperty(IFacetDataModelProperties.SHOULD_EXECUTE, active);
+ activeIds.remove(id);
+ }
+ // Now handle the actions not tracked by IDataModels
+ FacetActionMap actionMap = (FacetActionMap) model.getProperty(FACET_ACTION_MAP);
+ actionMap.clear();
+ iterator = actions.iterator();
+ while (iterator.hasNext()) {
+ IFacetedProject.Action action = (IFacetedProject.Action) iterator.next();
+ String id = action.getProjectFacetVersion().getProjectFacet().getId();
+ if (activeIds.contains(id)) {
+ actionMap.add(action);
+ }
+ }
+ model.notifyPropertyChange(FACET_RUNTIME, IDataModel.VALID_VALUES_CHG);
+ }
+
+
+
+
+}
Deleted:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java 2008-08-27
00:41:46 UTC (rev 9914)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -1,83 +0,0 @@
-package org.jboss.tools.esb.projects.wizards;
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-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.project.facet.IProductConstants;
-import org.eclipse.wst.project.facet.ProductManager;
-import org.eclipse.wst.web.ui.internal.WSTWebUIPlugin;
-import org.jboss.tools.esb.projects.wizards.pages.AbstractESBWizardPage;
-import org.jboss.tools.esb.projects.wizards.pages.NewESBProjectWizardPage;
-
-public class ESBProjectCreationWizard extends AbstractESBProjectCreationWizard{
-
- protected IDataModel createDataModel() {
- return DataModelFactory.createDataModel(new
JBossESBFacetProjectCreationDataModelProvider());
- }
-
- protected ImageDescriptor getDefaultPageImageDescriptor() {
- return WSTWebUIPlugin.getDefault().getImageDescriptor("newwprj_wiz");
//$NON-NLS-1$
- }
-
- protected IFacetedProjectTemplate getTemplate() {
- return ProjectFacetsManager.getTemplate("template.jboss.esb"); //$NON-NLS-1$
- }
-
- protected IWizardPage createFirstPage() {
- return new AbstractESBWizardPage(model, "first.page"); //$NON-NLS-1$
- }
-
- protected String getFinalPerspectiveID() {
- return
ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_STATICWEB);
- }
-
- protected IWizardPage[] createBeginingPages() {
- return new IWizardPage[]{createFirstPage()/*, new
ESBProjectTemplateWizardPage(this.model, "Templates"),
- new TemplatePackageNameWizardPage(this.model, "Set Package Name")*/};
- }
-
-
- @Override
- public void addPages() {
- new NewESBProjectWizardPage(model, "first.page"); //$NON-NLS-1$
-
- super.addPages();
- }
-
- @Override
- public boolean performFinish() {
-
- boolean rtn = super.performFinish();
- IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(this.getProjectName());
- IFile esbFile = project.getFile("/ESBContent/META-INF/jboss-esb.xml");
-
- IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if(esbFile != null){
- try {
- IDE.openEditor(page, esbFile,
"org.jboss.tools.esb.editor.editors.ESBComposedEditor", true);
- } catch (PartInitException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- return rtn;
- }
-
-
-
-}
-
-
-
Added:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java
(rev 0)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/ESBProjectCreationWizard.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -0,0 +1,83 @@
+package org.jboss.tools.esb.projects.wizards;
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+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.project.facet.IProductConstants;
+import org.eclipse.wst.project.facet.ProductManager;
+import org.eclipse.wst.web.ui.internal.WSTWebUIPlugin;
+import org.jboss.tools.esb.projects.wizards.pages.AbstractESBWizardPage;
+import org.jboss.tools.esb.projects.wizards.pages.NewESBProjectWizardPage;
+
+public class ESBProjectCreationWizard extends AbstractESBProjectCreationWizard{
+
+ protected IDataModel createDataModel() {
+ return DataModelFactory.createDataModel(new
JBossESBFacetProjectCreationDataModelProvider());
+ }
+
+ protected ImageDescriptor getDefaultPageImageDescriptor() {
+ return WSTWebUIPlugin.getDefault().getImageDescriptor("newwprj_wiz");
//$NON-NLS-1$
+ }
+
+ protected IFacetedProjectTemplate getTemplate() {
+ return ProjectFacetsManager.getTemplate("template.jboss.esb"); //$NON-NLS-1$
+ }
+
+ protected IWizardPage createFirstPage() {
+ return new AbstractESBWizardPage(model, "first.page"); //$NON-NLS-1$
+ }
+
+ protected String getFinalPerspectiveID() {
+ return
ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_STATICWEB);
+ }
+
+ protected IWizardPage[] createBeginingPages() {
+ return new IWizardPage[]{createFirstPage()/*, new
ESBProjectTemplateWizardPage(this.model, "Templates"),
+ new TemplatePackageNameWizardPage(this.model, "Set Package Name")*/};
+ }
+
+/*
+ @Override
+ public void addPages() {
+ new NewESBProjectWizardPage(model, "first.page"); //$NON-NLS-1$
+
+ super.addPages();
+ }*/
+
+ @Override
+ public boolean performFinish() {
+
+ boolean rtn = super.performFinish();
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(this.getProjectName());
+ IFile esbFile = project.getFile("/ESBContent/META-INF/jboss-esb.xml");
+
+ IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if(esbFile != null){
+ try {
+ IDE.openEditor(page, esbFile,
"org.jboss.tools.esb.editor.editors.ESBComposedEditor", true);
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return rtn;
+ }
+
+
+
+}
+
+
+
Deleted:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java 2008-08-27
00:41:46 UTC (rev 9914)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -1,64 +0,0 @@
-package org.jboss.tools.esb.projects.wizards;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
-import org.eclipse.jst.common.project.facet.JavaFacetUtils;
-import
org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider;
-import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.eclipse.wst.project.facet.ProductManager;
-import org.jboss.tools.esb.project.facet.IJBossESBFacetDataModelProperties;
-import org.jboss.tools.esb.utils.ResourceUtils;
-
-public class JBossESBFacetProjectCreationDataModelProvider extends
- FacetProjectCreationDataModelProvider {
-
-
- public void init() {
- super.init();
-
- Collection<IProjectFacet> requiredFacets = new
ArrayList<IProjectFacet>();
- requiredFacets.add(JavaFacetUtils.JAVA_FACET);
- requiredFacets.add(ProjectFacetsManager.getProjectFacet("jboss.esb"));
- setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets);
-
- FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP);
- IDataModel javaFacet = map.getFacetDataModel( JavaFacetUtils.JAVA_FACET.getId()
);
- javaFacet.setProperty(IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME,
"src");
- // If using optimized single root structure, set the output folder to "<content
folder>/WEB-INF/classes"
- /*if (ProductManager.shouldUseSingleRootStructure())
- javaFacet.setProperty(IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME,
webRoot+"/"+J2EEConstants.WEB_INF_CLASSES); //$NON-NLS-1$
-*/
- }
-
- public Object getDefaultProperty(String propertyName) {
- if (IFacetDataModelProperties.FACET_ID.equals(propertyName)) {
- return "jboss.esb";
- }
- else if (IJBossESBFacetDataModelProperties.DEFAULT_LOCATION.equals(propertyName)){
- return ResourcesPlugin.getWorkspace().getRoot().getFullPath();
- }
- else if(IJBossESBFacetDataModelProperties.USER_DEFINED_LOCATION.equals(propertyName)){
- return true;
- }
- else if(IJBossESBFacetDataModelProperties.FACET_PROJECT_NAME.equals(propertyName)){
- return "";
- }
- return super.getDefaultProperty(propertyName);
- }
-
- @Override
- public IStatus validate(String propertyName) {
- if(FACET_PROJECT_NAME.equals(propertyName)){
- String projectName = model.getStringProperty(FACET_PROJECT_NAME);
- return ResourceUtils.validateName(projectName);
- }
- return super.validate(propertyName);
- }
-}
Added:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java
(rev 0)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/JBossESBFacetProjectCreationDataModelProvider.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -0,0 +1,64 @@
+package org.jboss.tools.esb.projects.wizards;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+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.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.project.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.project.facet.JBossESBFacetInstallationConfig;
+import org.jboss.tools.esb.utils.ESBProjectUtil;
+
+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
JBossESBFacetInstallationConfig());
+ map.add(esbFacet);
+
+ javaFacet.setProperty(
+ IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME,
+ esbFacet
+ .getStringProperty(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER));
+
+
+ }
+
+ public Object getDefaultProperty(String propertyName) {
+ if (IFacetDataModelProperties.FACET_ID.equals(propertyName)) {
+ return "jst.jboss.esb";
+ }
+ else if (IJBossESBFacetDataModelProperties.DEFAULT_LOCATION.equals(propertyName)){
+ return ResourcesPlugin.getWorkspace().getRoot().getFullPath();
+ }
+ else if(IJBossESBFacetDataModelProperties.USER_DEFINED_LOCATION.equals(propertyName)){
+ return true;
+ }
+ else if(IJBossESBFacetDataModelProperties.FACET_PROJECT_NAME.equals(propertyName)){
+ return "";
+ }
+
+ return super.getDefaultProperty(propertyName);
+ }
+
+ @Override
+ public IStatus validate(String propertyName) {
+ if(FACET_PROJECT_NAME.equals(propertyName)){
+ String projectName = model.getStringProperty(FACET_PROJECT_NAME);
+ return ESBProjectUtil.validateName(projectName);
+ }
+ return super.validate(propertyName);
+ }
+
+
+}
Modified:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/AbstractESBWizardPage.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/AbstractESBWizardPage.java 2008-08-27
00:41:46 UTC (rev 9914)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/AbstractESBWizardPage.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -83,7 +83,6 @@
private Text projectNameField;
private Text locationPathField;
private Button browseButton;
- private boolean isValidating = false;
private boolean hasValidPrjLocation = true;
private boolean hasValidPrjName = false;
@@ -108,6 +107,7 @@
}
protected void validatePage() {
+
}
@@ -117,7 +117,11 @@
}
public void propertyChanged(DataModelEvent event) {
- setPageErrorMesage();
+ if(FACET_PROJECT_NAME.equals(event.getPropertyName())
+ || PROJECT_LOCATION.equals(event.getPropertyName())
+ || USE_DEFAULT_LOCATION.equals(event.getPropertyName())){
+ setPageErrorMesage();
+ }
}
private void setPageErrorMesage(){
@@ -156,6 +160,8 @@
createServerTargetComposite(top);
createPrimaryFacetComposite(top);
+ refreshRuntimeCombo(serverTargetCombo, null);
+
setControl(top);
}
@@ -180,27 +186,39 @@
newServerTargetButton.setText("N&ew...");
newServerTargetButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
- NewRuntimeWizard wizard = new NewRuntimeWizard();
- WizardDialog dialog = new
WizardDialog(Display.getCurrent().getActiveShell(),wizard);
-
- boolean isOK = dialog.open() ==
WizardDialog.OK;//ServerUIUtil.showNewRuntimeWizard(Display.getCurrent().getActiveShell(),
null, null);
+
+ Set<IProjectFacetVersion> facetVersions = new
HashSet<IProjectFacetVersion>();
+ facetVersions.add(getPrimaryFacetVersion());
+ Set<IRuntime> preAddition = RuntimeManager.getRuntimes(facetVersions);
+ boolean isOK =
ServerUIUtil.showNewRuntimeWizard(Display.getCurrent().getActiveShell(),
getModuleTypeID(), null);
if(isOK){
- Object obj = wizard.getTaskModel().getObject("runtime");
- if(obj instanceof IRuntime){
- IRuntime newRuntime = (IRuntime)obj;
- refreshRuntimeCombo(FACET_RUNTIME, DataModelEvent.VALUE_CHG, serverTargetCombo,
newRuntime);
- }
+ Set<IRuntime> postAddition = RuntimeManager.getRuntimes(facetVersions);
+ IRuntime newAddition = getNewAddition(preAddition, postAddition);
+ model.setProperty(FACET_RUNTIME, newAddition);
+ refreshRuntimeCombo(serverTargetCombo, newAddition);
}
}
});
//Control[] deps = new Control[]{newServerTargetButton};
//synchHelper.synchCombo(serverTargetCombo, FACET_RUNTIME, deps);
- refreshRuntimeCombo(FACET_RUNTIME, DataModelEvent.VALUE_CHG, serverTargetCombo, null);
if (serverTargetCombo.getSelectionIndex() == -1 &&
serverTargetCombo.getVisibleItemCount() != 0)
serverTargetCombo.select(0);
}
+ private IRuntime getNewAddition(Set<IRuntime> preAddition, Set<IRuntime>
postAddition){
+ IRuntime runtime = null;
+ Iterator<IRuntime> runtimes = postAddition.iterator();
+ while(runtimes.hasNext()){
+ runtime = runtimes.next();
+ if(!preAddition.contains(runtime)){
+ return runtime;
+ }
+ }
+
+ return runtime;
+ }
+
protected void createPrimaryFacetComposite(Composite top) {
primaryProjectFacet = ProjectFacetsManager.getProjectFacet( getModuleTypeID() );
if (primaryProjectFacet.getVersions().size() <= 1){
@@ -301,9 +319,9 @@
model.setStringProperty(FACET_PROJECT_NAME, projectNameField.getText());
}
});
+ projectNameField.setFocus();
-
// project specification group
Group projectGroup = new Group(parent, SWT.NONE);
layout = new GridLayout();
@@ -421,7 +439,7 @@
}
public String getModuleTypeID(){
- return "jboss.esb";
+ return "jst.jboss.esb";
}
protected void updatePrimaryVersions(){
@@ -451,34 +469,26 @@
}
- protected void refreshRuntimeCombo(String propertyName, int flag, Combo combo, IRuntime
newRuntime) {
- int index = -1;
-
- for(IRuntime runtime:RuntimeManager.getRuntimes()){
- index++;
+ protected void refreshRuntimeCombo(Combo combo, IRuntime newRuntime) {
+ for(IRuntime runtime: RuntimeManager.getRuntimes(primaryProjectFacet.getVersions())){
combo.add(runtime.getName());
- combo.setData(Integer.toString(index), runtime);
- if(newRuntime != null && runtime.getName().equals(newRuntime.getName())){
- combo.select(index);
- }
-
+ //combo.setData(Integer.toString(index), descriptor.getPropertyDescription());
}
combo.add("<None>");
- if(combo.getSelectionIndex() < 0){
- combo.select(combo.getItemCount() - 1);
-
+ if(newRuntime != null){
+ combo.setText(newRuntime.getName());
}
+ else{
+ combo.setText("<None>");
+ }
}
private void saveRuntimeToProject(){
- String selectedRuntime = Integer.toString(serverTargetCombo.getSelectionIndex());
- Object obj = serverTargetCombo.getData(selectedRuntime);
-
- model.setProperty(FACET_RUNTIME, obj);
+ IRuntime selectedRunime = RuntimeManager.getRuntime(serverTargetCombo.getText());
+ model.setProperty(FACET_RUNTIME, selectedRunime);
}
-
protected void handlePrimaryFacetVersionSelectedEvent()
Modified:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/ESBFacetInstallationPage.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/ESBFacetInstallationPage.java 2008-08-27
00:41:46 UTC (rev 9914)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/projects/wizards/pages/ESBFacetInstallationPage.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -1,34 +1,53 @@
package org.jboss.tools.esb.projects.wizards.pages;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
+import org.eclipse.jst.common.project.facet.JavaFacetUtils;
+import org.eclipse.jst.common.project.facet.core.JavaFacet;
+import org.eclipse.jst.common.project.facet.core.internal.JavaFacetUtil;
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.Control;
+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.componentcore.datamodel.properties.IFacetInstallDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
-import org.eclipse.wst.common.project.facet.ui.IWizardContext;
-import org.eclipse.wst.web.internal.ResourceHandler;
-import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage;
-import org.eclipse.wst.web.ui.internal.wizards.IWstWebUIContextIds;
+import org.jboss.tools.esb.JBossESBPlugin;
+import org.jboss.tools.esb.project.classpath.JBossRuntime;
+import org.jboss.tools.esb.project.classpath.JBossRuntimeManager;
import org.jboss.tools.esb.project.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.project.preference.controls.JBossRuntimeListFieldEditor;
+import org.jboss.tools.esb.project.utils.StatusUtils;
+import org.jboss.tools.esb.utils.ESBProjectUtil;
public class ESBFacetInstallationPage extends AbstractFacetWizardPage implements
IFacetWizardPage, IJBossESBFacetDataModelProperties {
private Label configFolderLabel;
private Text configFolder;
private Label contextRootLabel;
- private Text contextRoot;
+ private Text contentFolder;
private IDataModel model;
+ private boolean hasValidContentFolder = true;
+ private boolean hasValidSrc = true;
+ private boolean hasRuntime = true;
+ private Combo cmbRuntimes;
public ESBFacetInstallationPage() {
super( "simpleweb.facet.install.page"); //$NON-NLS-1$
@@ -64,10 +83,19 @@
this.contextRootLabel.setText("Content Directory");
this.contextRootLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.contextRoot = new Text(prjGroup, SWT.BORDER);
- this.contextRoot.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.contextRoot.setData("label", this.contextRootLabel); //$NON-NLS-1$
- this.contextRoot.setText("ESBContent");
+ 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("esbcontent");
+ 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();
+ }
+ });
//synchHelper.synchText(contextRoot, CONTEXT_ROOT, new Control[]{contextRootLabel});
configFolderLabel = new Label(prjGroup, SWT.NONE);
@@ -78,45 +106,194 @@
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);
+ }
+ changePageStatus();
+ }
+
+ });
}
+
private void createRuntimeGroup(Composite parent){
Group runtimeGroup = new Group(parent, SWT.BORDER);
- runtimeGroup.setText("ESB Runtime");
+ runtimeGroup.setText("JBoss ESB Runtime");
runtimeGroup.setLayout(new GridLayout(4, false));
runtimeGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
- Button btnServerSupplied = new Button(runtimeGroup, SWT.RADIO);
+ /* Button btnServerSupplied = new Button(runtimeGroup, SWT.RADIO);
GridData gd = new GridData();
gd.horizontalSpan = 1;
- btnServerSupplied.setLayoutData(gd);
+ btnServerSupplied.setLayoutData(gd);*/
- Label lblServerSupplied = new Label(runtimeGroup, SWT.NONE);
+ /*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);
+ Button btnUserSupplied = new Button(runtimeGroup, SWT.RADIO);*/
- Combo cmbRuntimes = new Combo(runtimeGroup, SWT.READ_ONLY);
+ 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");
Copied:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ESBProjectUtil.java
(from rev 9764,
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ResourceUtils.java)
===================================================================
--- workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ESBProjectUtil.java
(rev 0)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ESBProjectUtil.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -0,0 +1,104 @@
+package org.jboss.tools.esb.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.internal.resources.Resource;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.project.classpath.JBossRuntime;
+import org.jboss.tools.esb.project.classpath.JBossRuntimeManager;
+
+public class ESBProjectUtil {
+
+
+ public static IStatus validateName(String name) {
+ IStatus status = validateProjectName(name);
+ if (!status.isOK())
+ return status;
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ if (project.exists()) {
+ return createErrorStatus("A project already exists with this name.");
+ }
+ if (!isPlatformCaseSensitive()) {
+ // now look for a matching case variant in the tree
+ IResource variant = ((Resource)
project).findExistingResourceVariant(project.getFullPath());
+ if (variant != null) {
+ return createErrorStatus("A project already exists with this name.");
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ public static IStatus validateProjectName(String projectName) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IStatus status = workspace.validateName(projectName, IResource.PROJECT);
+ if (!status.isOK())
+ return status;
+ if (projectName.endsWith(" ")) //$NON-NLS-1$
+ return createErrorStatus("Project names cannot end with white space.");
+ return Status.OK_STATUS;
+ }
+
+ public static boolean isPlatformCaseSensitive() {
+ return Platform.OS_MACOSX.equals(Platform.getOS()) ? false : new
+ java.io.File("a").compareTo(new java.io.File("A")) != 0;
//$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ public static IStatus createErrorStatus(String msg){
+ IStatus status = new Status(IStatus.ERROR, "org.jboss.tools.esb.project.ui",
msg);
+ return status;
+ }
+
+ public static String getDuplicateJars(IDataModel model, String jbwsName) throws
JavaModelException{
+ List<String> allExistingJars = new ArrayList<String>();
+ List<String> runtimeJars = new ArrayList<String>();
+
+ JBossRuntime jbws = JBossRuntimeManager.getInstance().findRuntimeByName(jbwsName);
+ if(jbws.isUserConfigClasspath()){
+ runtimeJars.addAll(jbws.getLibraries());
+ }else{
+ runtimeJars.addAll(JBossRuntimeManager.getInstance().getAllRuntimeJars(jbws));
+ }
+
+ String prjName =
model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName);
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ for(IClasspathEntry entry: entries){
+ if(entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER){
+ IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(),
javaProject);
+ for(IClasspathEntry containedEntry: container.getClasspathEntries()){
+ allExistingJars.add(containedEntry.getPath().toOSString());
+ }
+ }else if(entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY){
+ allExistingJars.add(entry.getPath().toOSString());
+ }
+ }
+
+ for(String jarName: runtimeJars){
+ if(allExistingJars.contains(jarName)){
+ return jarName;
+ }
+ }
+
+ return "";
+
+ }
+
+
+}
Deleted:
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ResourceUtils.java
===================================================================
---
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ResourceUtils.java 2008-08-27
00:41:46 UTC (rev 9914)
+++
workspace/Denny/org.jboss.tools.esb/src/org/jboss/tools/esb/utils/ResourceUtils.java 2008-08-27
07:56:48 UTC (rev 9915)
@@ -1,54 +0,0 @@
-package org.jboss.tools.esb.utils;
-
-import org.eclipse.core.internal.resources.Resource;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler;
-import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages;
-import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-public class ResourceUtils {
-
- public static IStatus validateName(String name) {
- IStatus status = validateProjectName(name);
- if (!status.isOK())
- return status;
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- if (project.exists()) {
- return createErrorStatus("A project already exists with this name.");
- }
- if (!isPlatformCaseSensitive()) {
- // now look for a matching case variant in the tree
- IResource variant = ((Resource)
project).findExistingResourceVariant(project.getFullPath());
- if (variant != null) {
- return createErrorStatus("A project already exists with this name.");
- }
- }
- return Status.OK_STATUS;
- }
-
- public static IStatus validateProjectName(String projectName) {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IStatus status = workspace.validateName(projectName, IResource.PROJECT);
- if (!status.isOK())
- return status;
- if (projectName.endsWith(" ")) //$NON-NLS-1$
- return createErrorStatus("Project names cannot end with white space.");
- return Status.OK_STATUS;
- }
-
- public static boolean isPlatformCaseSensitive() {
- return Platform.OS_MACOSX.equals(Platform.getOS()) ? false : new
- java.io.File("a").compareTo(new java.io.File("A")) != 0;
//$NON-NLS-1$//$NON-NLS-2$
- }
-
- public static IStatus createErrorStatus(String msg){
- IStatus status = new Status(IStatus.ERROR, "org.jboss.tools.esb.project.ui",
msg);
- return status;
- }
-}