JBoss Tools SVN: r9880 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-08-25 08:14:59 -0400 (Mon, 25 Aug 2008)
New Revision: 9880
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2682
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java 2008-08-25 09:32:41 UTC (rev 9879)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java 2008-08-25 12:14:59 UTC (rev 9880)
@@ -38,6 +38,8 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
@@ -529,7 +531,9 @@
}
if(v.javaProject!=null) {
- configurationNameText.setText(v.javaProject.getElementName() );
+ ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
+ String uniqName = lm.generateUniqueLaunchConfigurationNameFrom(v.javaProject.getElementName());
+ configurationNameText.setText(uniqName);
projectNameText.setText(v.javaProject.getElementName());
}
if (v.propertyFile!=null) {
15 years, 8 months
JBoss Tools SVN: r9879 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-08-25 05:32:41 -0400 (Mon, 25 Aug 2008)
New Revision: 9879
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/HibernateJptUIPlugin.java
Log:
Copyright added
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/HibernateJptUIPlugin.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/HibernateJptUIPlugin.java 2008-08-25 07:56:09 UTC (rev 9878)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/HibernateJptUIPlugin.java 2008-08-25 09:32:41 UTC (rev 9879)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.hibernate.jpt.ui;
import org.eclipse.ui.plugin.AbstractUIPlugin;
15 years, 8 months
JBoss Tools SVN: r9878 - trunk/jsf/docs/userguide/en/modules.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2008-08-25 03:56:09 -0400 (Mon, 25 Aug 2008)
New Revision: 9878
Modified:
trunk/jsf/docs/userguide/en/modules/palette.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-240 - adding role 'updated' to the section
Modified: trunk/jsf/docs/userguide/en/modules/palette.xml
===================================================================
--- trunk/jsf/docs/userguide/en/modules/palette.xml 2008-08-23 00:25:19 UTC (rev 9877)
+++ trunk/jsf/docs/userguide/en/modules/palette.xml 2008-08-25 07:56:09 UTC (rev 9878)
@@ -556,7 +556,7 @@
</section>
</section>
</section>
- <section id="RichFacesSupport">
+ <section id="RichFacesSupport" role="updated">
<?dbhtml filename="RichFacesSupport.html"?>
<title>RichFaces Support</title>
<para><property>JBoss Developer Studio</property> comes with a tight integration with <ulink
15 years, 8 months
JBoss Tools SVN: r9877 - in trunk/core/plugins: org.jboss.ide.eclipse.archives.webtools and 13 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-22 20:25:19 -0400 (Fri, 22 Aug 2008)
New Revision: 9877
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.classpath
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.project
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/org.eclipse.jdt.core.prefs
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/build.properties
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/EJBJar.gif
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/ear.gif
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/publish.gif
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/publishDetails.gif
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/war.gif
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EarArchiveType.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EjbArchiveType.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/J2EEArchiveType.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/WarArchiveType.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ModulePackageTypeConverter.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagedArtifactAdapter.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/EditPublishAction.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEARAction.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEJBJARAction.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewWARAction.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PreviewPage.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java
Log:
JBIDE-2677 - removing the as.core's dependency on archives by way of addding an extension point for publishers and a new plugin for the archives / publishing integration
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.classpath
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.classpath (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.classpath 2008-08-23 00:25:19 UTC (rev 9877)
@@ -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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.project
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.project (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.project 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.ide.eclipse.archives.webtools</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/core/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/org.eclipse.jdt.core.prefs 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,7 @@
+#Fri Aug 22 17:07:49 EDT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Project Archives Webtools Integration Plug-in
+Bundle-SymbolicName: org.jboss.ide.eclipse.archives.webtools;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.ide.eclipse.archives.core;bundle-version="2.0.0",
+ org.jboss.ide.eclipse.archives.ui;bundle-version="1.0.0",
+ org.eclipse.wst.server.core;bundle-version="1.1.0",
+ org.eclipse.wst.server.ui;bundle-version="1.1.0",
+ org.eclipse.core.resources;bundle-version="3.4.0",
+ org.eclipse.jdt.core;bundle-version="3.4.0",
+ org.eclipse.jst.server.core;bundle-version="1.1.0",
+ org.eclipse.wst.common.modulecore;bundle-version="1.1.200",
+ org.apache.ant;bundle-version="1.7.0",
+ org.jboss.ide.eclipse.as.core;bundle-version="1.0.0",
+ org.eclipse.ui.ide;bundle-version="3.4.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/build.properties
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/build.properties (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/build.properties 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/EJBJar.gif
===================================================================
(Binary files differ)
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/EJBJar.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/ear.gif
===================================================================
(Binary files differ)
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/ear.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/publish.gif
===================================================================
(Binary files differ)
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/publish.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/publishDetails.gif
===================================================================
(Binary files differ)
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/publishDetails.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/war.gif
===================================================================
(Binary files differ)
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/icons/war.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.wst.server.core.moduleTypes">
+ <moduleType
+ id="jboss.package"
+ name="Project Package"/>
+ </extension>
+
+ <extension
+ point="org.jboss.ide.eclipse.archives.core.archiveTypes">
+ <packageType
+ class="org.jboss.ide.eclipse.archives.webtools.archivetypes.WarArchiveType"
+ id="org.jboss.ide.eclipse.as.core.packages.warArchive"
+ label="WAR"/>
+ <packageType
+ class="org.jboss.ide.eclipse.archives.webtools.archivetypes.EjbArchiveType"
+ id="org.jboss.ide.eclipse.as.core.packages.ejbPackageType"
+ label="EJB JAR"/>
+ <packageType
+ class="org.jboss.ide.eclipse.archives.webtools.archivetypes.EarArchiveType"
+ id="org.jboss.ide.eclipse.as.core.packages.earPackageType"
+ label="EAR"/>
+ </extension>
+
+ <!-- Adapters and clients to make stuff 'runnable' on server -->
+ <extension
+ point="org.eclipse.wst.server.core.moduleArtifactAdapters">
+ <moduleArtifactAdapter
+ class="org.jboss.ide.eclipse.archives.webtools.modules.PackagedArtifactAdapter"
+ id="org.jboss.ide.eclipse.as.core.PackagedArtifactAdapter"
+ priority="0">
+ <enablement>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.jdt.core.IJavaProject"/>
+ </or>
+ </enablement>
+ </moduleArtifactAdapter>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.moduleFactories">
+ <moduleFactory
+ class="org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory"
+ id="org.jboss.ide.eclipse.as.core.PackageModuleFactory"
+ projects="true">
+ <moduleType
+ types="jboss.package"
+ versions="1.0"/>
+ </moduleFactory>
+ </extension>
+
+ <extension
+ point="org.jboss.ide.eclipse.archives.ui.nodePopupMenus">
+ <nodeContribution
+ class="org.jboss.ide.eclipse.archives.webtools.ui.PublishAction"
+ icon="icons/publish.gif"
+ id="org.jboss.ide.eclipse.as.ui.publishNodeContextContrib"
+ label="Publish To Server"
+ weight="1"/>
+ <nodeContribution
+ class="org.jboss.ide.eclipse.archives.webtools.ui.EditPublishAction"
+ icon="icons/publishDetails.gif "
+ id="org.jboss.ide.eclipse.as.ui.modifyPublishNodeContextContrib"
+ label="Edit publish settings...">
+ </nodeContribution>
+ </extension>
+ <extension
+ point="org.jboss.ide.eclipse.archives.ui.newArchiveActions">
+ <newPackageAction
+ class="org.jboss.ide.eclipse.archives.webtools.ui.NewWARAction"
+ icon="icons/war.gif"
+ id="org.jboss.ide.eclipse.packages.ui.newWARAction"
+ label="WAR"/>
+ <newPackageAction
+ class="org.jboss.ide.eclipse.archives.webtools.ui.NewEJBJARAction"
+ icon="icons/EJBJar.gif"
+ id="org.jboss.ide.eclipse.packages.ui.newEJBJarAction"
+ label="EJB JAR"/>
+ <newPackageAction
+ class="org.jboss.ide.eclipse.archives.webtools.ui.NewEARAction"
+ icon="icons/ear.gif"
+ id="org.jboss.ide.eclipse.packages.ui.newEARAction"
+ label="EAR"/>
+ </extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishers">
+ <publisher
+ class="org.jboss.ide.eclipse.archives.webtools.modules.PackagesPublisher"
+ priority="5">
+ </publisher>
+ </extension>
+</plugin>
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,52 @@
+package org.jboss.ide.eclipse.archives.webtools;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesBuildListener;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class IntegrationPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.ide.eclipse.archives.webtools";
+
+ // The shared instance
+ private static IntegrationPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public IntegrationPlugin() {
+ }
+
+ /*
+ * (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;
+ ArchivesBuildListener.getInstance();
+ }
+
+ /*
+ * (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 IntegrationPlugin getDefault() {
+ return plugin;
+ }
+
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EarArchiveType.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EarArchiveType.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EarArchiveType.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,118 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.archivetypes;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.server.core.IEnterpriseApplication;
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.webtools.modules.ModulePackageTypeConverter;
+
+/**
+ * @author rob.stryker(a)redhat.com
+ */
+public class EarArchiveType extends J2EEArchiveType {
+ public final static String ID = "org.jboss.ide.eclipse.as.core.packages.earPackageType";
+ public String getAssociatedModuleType() {
+ return "jst.ear";
+ }
+
+ public String getId() {
+ return ID;
+ }
+
+ public String getLabel() {
+ return "EAR";
+ }
+
+
+ public IArchive createDefaultConfiguration(String project, IProgressMonitor monitor) {
+ IModule mod = getModule(project);
+ if( mod != null )
+ return createDefaultConfigFromModule(mod, monitor);
+ else
+ return createDefaultConfiguration2(project, monitor);
+ }
+
+ public IArchive createDefaultConfiguration2(String projectName,
+ IProgressMonitor monitor) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".ear");
+ topLevel.setDestinationPath(new Path(project.getName()));
+ topLevel.setInWorkspace(true);
+
+ fillDefaultConfiguration(projectName, topLevel, monitor);
+ return topLevel;
+ }
+
+ public IArchive createDefaultConfigFromModule(IModule module,
+ IProgressMonitor monitor) {
+ IProject project = module.getProject();
+ IContainer sourceContainer = project.getFolder(EARCONTENT);
+ IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".ear", sourceContainer);
+ topLevel.setDestinationPath(new Path(project.getName()));
+ topLevel.setInWorkspace(true);
+
+ fillDefaultConfiguration(project.getName(), topLevel, monitor);
+ return topLevel;
+ }
+
+ public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel, IProgressMonitor monitor) {
+ try {
+ IModule mod = getModule(projectName);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ if( mod == null ) {
+ // add fileset
+ IArchiveFolder metainf = addFolder(project, topLevel, METAINF);
+ addFileset(project, metainf, new Path(projectName).append(METAINF).toOSString(), null);
+
+ } else {
+ // now add children
+ addFileset(project, topLevel, new Path(project.getName()).append(EARCONTENT).toOSString(), "**/*.*");
+ IEnterpriseApplication earModule = (IEnterpriseApplication)mod.loadAdapter(IEnterpriseApplication.class, monitor);
+ IModule[] childModules = earModule.getModules();
+ for( int i = 0; i < childModules.length; i++ ) {
+ IModule child = childModules[i];
+ IArchiveType type = ModulePackageTypeConverter.getPackageTypeFor(child);
+ IArchive childPack;
+ if( type == null ) {
+ childPack = createGenericIArchive(child.getProject(), null, child.getProject().getName() + ".jar");
+ } else {
+ childPack = type.createDefaultConfiguration(child.getProject().getName(), new NullProgressMonitor());
+ }
+ topLevel.addChild(childPack);
+ }
+ }
+
+ } catch( ArchivesModelException ame) {}
+ return topLevel;
+ }
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EjbArchiveType.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EjbArchiveType.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/EjbArchiveType.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,81 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.archivetypes;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+
+/**
+ *
+ * @author rob.stryker(a)redhat.com
+ */
+public class EjbArchiveType extends J2EEArchiveType {
+
+ public final static String ID = "org.jboss.ide.eclipse.as.core.packages.ejbPackageType";
+ public String getAssociatedModuleType() {
+ return "jst.ejb";
+ }
+
+ public String getId() {
+ return ID;
+ }
+
+ public String getLabel() {
+ return "EJB JAR";
+ }
+
+ public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor) {
+ IProject project = getProject(projectName);
+ IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".jar");
+ return fillDefaultConfiguration(project, topLevel, monitor);
+ }
+
+ public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel, IProgressMonitor monitor) {
+ return fillDefaultConfiguration(getProject(projectName), topLevel, monitor);
+ }
+ public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel, IProgressMonitor monitor) {
+
+ IModule mod = getModule(project.getName());
+
+ if( mod == null ) {
+ // TODO fix me
+ } else {
+ if( mod.getModuleType().getId().equals("jst.ejb") ) {
+ try {
+ IJavaProject proj = JavaCore.create(project);
+ IPath outputLoc = proj.getOutputLocation();
+ addFileset(project, topLevel, outputLoc.toOSString(), null);
+ } catch( JavaModelException jmde) {
+ } catch( ArchivesModelException ame ) {}
+ }
+ }
+ return topLevel;
+ }
+
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/J2EEArchiveType.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/J2EEArchiveType.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/J2EEArchiveType.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,163 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.archivetypes;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public abstract class J2EEArchiveType implements IArchiveType {
+ public static final String METAINF = "META-INF";
+ public static final String WEBINF = "WEB-INF";
+ public static final String CLASSES = "classes";
+ public static final String LIB = "lib";
+ public static final String WEBCONTENT = "WebContent";
+ public static final String EARCONTENT = "EarContent";
+ public static final String EJBMODULE = "ejbModule";
+
+
+ protected boolean isModuleType(IModule module, String moduleTypeId){
+ if(module.getModuleType()!=null && moduleTypeId.equals(module.getModuleType().getId()))
+ return true;
+ return false;
+ }
+
+ protected IModule getModule(String projectName) {
+ IModuleArtifact moduleArtifacts[] = ServerPlugin.getModuleArtifacts(getProject(projectName));
+
+ if (moduleArtifacts != null && moduleArtifacts.length > 0)
+ return moduleArtifacts[0].getModule();
+ else return null;
+ }
+
+ protected IProject getProject(String projectName) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ }
+ // Find the source folder, then create the IPackage appropriately
+ public static IArchive createGenericIArchive(IProject project, String deployDirectory, String packageName) {
+ try {
+ IJavaProject javaProject = JavaCore.create(project);
+ Assert.isNotNull(javaProject);
+
+ IPath sourcePath;
+ try {
+ sourcePath = javaProject.getOutputLocation();
+ } catch (JavaModelException e) {
+ return null;
+ }
+ sourcePath = sourcePath.removeFirstSegments(1);
+ IContainer sourcePathContainer;
+ if( sourcePath.segmentCount() == 0 )
+ sourcePathContainer = project;
+ else
+ sourcePathContainer = project.getFolder(sourcePath);
+ return createGenericIArchive(project, deployDirectory, packageName, sourcePathContainer);
+ } catch( Exception e ) {
+ IntegrationPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, "Unexpected Exception", e));
+ }
+ return null;
+ }
+
+ // Create a detached package with some generic settings
+ public static IArchive createGenericIArchive(IProject project, String deployDirectory, String packageName, IContainer sourceContainer) {
+ IArchive jar = ArchiveNodeFactory.createArchive();
+
+ if( deployDirectory != null ) {
+ jar.setDestinationPath(new Path(deployDirectory));
+ jar.setInWorkspace(ResourcesPlugin.getWorkspace().getRoot().getLocation().isPrefixOf(new Path(deployDirectory)));
+ jar.setExploded(false);
+ } else {
+ jar.setDestinationPath(project.getFullPath());
+ jar.setInWorkspace(true);
+ jar.setExploded(false);
+ }
+ jar.setName(packageName);
+ return jar;
+ }
+
+
+ public static IArchiveFolder addFolder(IProject project,
+ IArchiveNode parent, String name) throws ArchivesModelException {
+ IArchiveFolder folder = ArchiveNodeFactory.createFolder();
+ folder.setName(name);
+ parent.addChild(folder);
+ return folder;
+ }
+ public static IArchiveFileSet addFileset(IProject project, IArchiveNode parent,
+ String sourcePath, String includePattern) throws ArchivesModelException {
+ IArchiveFileSet fs = ArchiveNodeFactory.createFileset();
+ Assert.isNotNull(project);
+ IJavaProject javaProject = JavaCore.create(project);
+ Assert.isNotNull(javaProject);
+
+ IContainer sourceContainer;
+ if( sourcePath != null && !sourcePath.equals("")) {
+ Path p = new Path(sourcePath);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ sourceContainer = p.segmentCount() != 1 ? (IContainer)root.getFolder(p) : root.getProject(p.segment(0));
+ } else {
+ sourceContainer = project;
+ }
+
+ fs.setRawSourcePath(sourceContainer.getFullPath().toString());
+ fs.setInWorkspace(true);
+ fs.setIncludesPattern( includePattern == null ? "**/*" : includePattern );
+ parent.addChild(fs);
+ return fs;
+ }
+
+ public abstract String getAssociatedModuleType();
+
+ /*
+ * Creates a directory scanner for some global path
+ */
+ public static DirectoryScannerExtension createDirectoryScanner (String rawPath, String includes, String excludes, boolean scan) {
+ return DirectoryScannerFactory.createDirectoryScanner(rawPath, null, includes, excludes, null, false, 1, scan);
+ }
+
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/J2EEArchiveType.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/WarArchiveType.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/WarArchiveType.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/WarArchiveType.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,246 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.archivetypes;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+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.jst.server.core.IWebModule;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public class WarArchiveType extends J2EEArchiveType {
+ public static final String WAR_PACKAGE_TYPE = "org.jboss.ide.eclipse.as.core.packages.warPackage";
+
+ public String getAssociatedModuleType() {
+ return "jst.web";
+ }
+
+ public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor) {
+ IModule mod = getModule(projectName);
+ if( mod == null )
+ return createDefaultConfiguration2(projectName, monitor);
+ else
+ return createDefaultConfigFromModule(mod, monitor);
+ }
+
+ protected IArchive createDefaultConfiguration2(String projectName, IProgressMonitor monitor) {
+ IProject project = getProject(projectName);
+ IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".war");
+ return fillDefaultConfiguration(project, topLevel, monitor);
+ }
+
+ public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel, IProgressMonitor monitor) {
+ return fillDefaultConfiguration(getProject(projectName), topLevel, monitor);
+ }
+ public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel, IProgressMonitor monitor) {
+ try {
+ IModule mod = getModule(project.getName());
+ IArchiveFolder webinf = addFolder(project, topLevel, WEBINF);
+ IArchiveFolder lib = addFolder(project, webinf, LIB);
+ IArchiveFolder classes = addFolder(project, webinf, CLASSES);
+ addReferencedProjectsAsLibs(project, lib);
+ addLibFileset(project, lib, true);
+ addClassesFileset(project, classes);
+
+ if( mod == null ) {
+ addWebinfFileset(project, webinf);
+ } else {
+ addWebContentFileset(project, topLevel);
+ }
+ } catch( ArchivesModelException ame) {}
+ return topLevel;
+ }
+
+ // For modules only
+ protected void addWebContentFileset(IProject project, IArchiveNode packageRoot) throws ArchivesModelException {
+ try {
+ IPath projectPath = project.getLocation();
+ DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(), "**/WEB-INF/web.xml", null, true);
+ String[] files = scanner.getIncludedFiles();
+ // just take the first
+ if( files.length > 0 ) {
+ IPath path = new Path(files[0]);
+ path = path.removeLastSegments(2); // remove the file name
+ path = new Path(project.getName()).append(path); // pre-pend project name to make workspace-relative
+ IArchiveFileSet fs = addFileset(project, packageRoot, path.toOSString(), "**/*");
+ //If we have separate file set for libraries, we do not need to duplicate jars.
+ fs.setExcludesPattern("**/WEB-INF/lib/*.jar");
+ }
+ } catch( IllegalStateException ise ) {
+ IStatus status = new Status(IStatus.WARNING, IntegrationPlugin.PLUGIN_ID, "Directory could not be scanned", ise);
+ IntegrationPlugin.getDefault().getLog().log(status);
+ }
+ }
+
+ protected void addClassesFileset(IProject project, IArchiveFolder folder) throws ArchivesModelException {
+ IJavaProject jp = JavaCore.create(project);
+ if( jp != null ) {
+ try {
+ IPath outputLoc = project.getWorkspace().getRoot().getLocation();
+ outputLoc = outputLoc.append(jp.getOutputLocation());
+ addFileset(project, folder, jp.getOutputLocation().toOSString(), "**/*");
+ } catch( JavaModelException jme ) {
+ // no logging
+ }
+ }
+ }
+ protected void addWebinfFileset(IProject project, IArchiveFolder folder) throws ArchivesModelException {
+ try {
+ IPath projectPath = project.getLocation();
+ DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(), "**/web.xml", null, true);
+ String[] files = scanner.getIncludedFiles();
+ // just take the first
+ if( files.length > 0 ) {
+ IPath path = new Path(files[0]);
+ path = path.removeLastSegments(1); // remove the file name
+ path = new Path(project.getName()).append(path); // pre-pend project name to make workspace-relative
+ addFileset(project, folder, path.toOSString(), "**/*");
+ }
+ } catch( IllegalStateException ise ) {
+ IStatus status = new Status(IStatus.WARNING, ArchivesCorePlugin.PLUGIN_ID, "Directory could not be scanned", ise);
+ ArchivesCorePlugin.getDefault().getLog().log(status);
+ }
+ }
+
+ // Lib support
+ protected void addLibFileset(IProject project, IArchiveFolder folder, boolean includeTopLevelJars) throws ArchivesModelException {
+ // Let us find /WEB-INF/lib directory and set it as source for the file set.
+ String sourcePath = null;
+
+ IPath projectPath = project.getLocation();
+ DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(), "**/WEB-INF/web.xml", null, true);
+ String[] files = scanner.getIncludedFiles();
+
+ if(files != null && files.length > 0) {
+ IPath path = new Path(files[0]);
+ path = path.removeLastSegments(1).append("lib");
+ sourcePath = project.getFullPath().append(path).toString();
+ addFileset(project, folder, sourcePath, "*.jar"); // add default jars
+ } else {
+ //having failed to find 'lib' directory, let us make source of the project itself
+ sourcePath = project.getName();
+ DirectoryScanner scanner2 = createDirectoryScanner(projectPath.toString(), "**/*.jar", null, true);
+ String[] files2 = scanner2.getIncludedFiles();
+ IPath p;
+ ArrayList list = new ArrayList();
+ for( int i = 0; i < files2.length; i++ ) {
+ p = project.getFullPath().append(files2[i]).removeLastSegments(1);
+ if( !list.contains(p)) {
+ list.add(p);
+ addFileset(project, folder, p.toString(), "*.jar"); // add default jars
+ }
+ }
+ }
+ }
+ protected void addReferencedProjectsAsLibs(IProject project, IArchiveFolder folder) throws ArchivesModelException {
+ IJavaProject jp = JavaCore.create(project);
+ if( jp != null && jp.exists()) {
+ try {
+ IClasspathEntry[] entries = jp.getRawClasspath();
+ for( int i = 0; i < entries.length; i++ ) {
+ if( entries[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IPath path = entries[i].getPath();
+ IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if( res instanceof IProject ) {
+ createLibFromProject((IProject)res, folder);
+ }
+ }
+ }
+ } catch( JavaModelException jme ) {
+ // no logging
+ }
+ }
+ }
+
+
+ protected void createLibFromProject(IProject project, IArchiveFolder folder) throws ArchivesModelException {
+ IArchive pack = createGenericIArchive(project, null, project.getName() + ".jar");
+ folder.addChild(pack);
+ }
+
+ protected IArchive createDefaultConfigFromModule(IModule mod, IProgressMonitor monitor) {
+ try {
+ IProject project = mod.getProject();
+
+ // create the stub
+ IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".war");
+ topLevel.setDestinationPath(new Path(project.getName()));
+ topLevel.setInWorkspace(true);
+
+ // add lib folder so we can add libraries
+ IArchiveFolder webinf = addFolder(project, topLevel, WEBINF);
+ IArchiveFolder lib = addFolder(project, webinf, LIB);
+ IArchiveFolder classes = addFolder(project, webinf, CLASSES);
+
+
+ IVirtualComponent vc = ComponentCore.createComponent(project);
+ IPath webContentPath = vc.getRootFolder().getUnderlyingFolder().getFullPath();
+ addFileset(project, topLevel, webContentPath.toOSString(), "**/*");
+ addClassesFileset(project, classes);
+
+ // package each child and add to lib folder
+ IWebModule webModule = (IWebModule)mod.loadAdapter(IWebModule.class, monitor);
+ IModule[] childModules = webModule.getModules();
+ for (int i = 0; i < childModules.length; i++) {
+ IModule child = childModules[i];
+ lib.addChild(createGenericIArchive(child.getProject(), null, child.getProject().getName() + ".jar"));
+ }
+ return topLevel;
+ } catch( Exception e ) {
+ IntegrationPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, "Unexpected Exception", e));
+ }
+ return null;
+ }
+
+ public String getId() {
+ return WAR_PACKAGE_TYPE;
+ }
+
+ public String getLabel() {
+ return "WAR";
+ }
+}
\ No newline at end of file
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/archivetypes/WarArchiveType.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,215 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.ModuleFactory;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveBuildListener;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public class ArchivesBuildListener implements IArchiveBuildListener, IArchiveModelListener {
+
+ public static ArchivesBuildListener instance;
+ public static final String DEPLOY_SERVERS = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployServers";
+ public static final String DEPLOY_AFTER_BUILD = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployAfterBuild";
+
+ public static ArchivesBuildListener getInstance() {
+ if( instance == null ) {
+ instance = new ArchivesBuildListener();
+ }
+ return instance;
+ }
+
+ public ArchivesBuildListener() {
+ ArchivesModel.instance().addBuildListener(this);
+ ArchivesModel.instance().addModelListener(this); // ? , ArchivesModel.LIST_FRONT);
+ }
+
+ public void cleanArchive(IArchive pkg) {
+ }
+
+
+ public void finishedBuildingArchive(IArchive pkg) {
+ if( pkg.isTopLevel() && new Boolean(pkg.getProperty(DEPLOY_AFTER_BUILD)).booleanValue()) {
+ publish(pkg);
+ }
+ }
+
+ public void fileRemoved(IArchive topLevelPackage, IArchiveFileSet fileset, IPath filePath) {
+ }
+ public void fileUpdated(IArchive topLevelPackage, IArchiveFileSet fileset, IPath filePath) {
+ }
+
+ // If we're supposed to auto-deploy, get on it
+ protected static void publish(IArchive pkg) {
+ String servers = pkg.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
+ publish(pkg, servers, IServer.PUBLISH_INCREMENTAL);
+ }
+ public static void publish(IArchive pkg, String servers, int publishType) {
+ IModule[] module = getModule(pkg);
+ if( module[0] == null ) return;
+ DeployableServerBehavior[] serverBehaviors = ArchivesBuildListener.getServers(servers);
+ if( serverBehaviors != null ) {
+ for( int i = 0; i < serverBehaviors.length; i++ ) {
+ publish(serverBehaviors[i].getServer(), publishType, module );
+ }
+ }
+ }
+
+ protected static IStatus publish(IServer server, int publishType, IModule[] module ) {
+ try {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(module, new IModule[0], new NullProgressMonitor());
+ IServer saved = copy.save(false, new NullProgressMonitor());
+ saved.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ return new Status(Status.ERROR, IntegrationPlugin.PLUGIN_ID,
+ "Cannot deploy file " + module[0].getName(), ce);
+ }
+ return Status.OK_STATUS;
+
+ }
+ protected static IModule[] getModule(IArchive node) {
+ ModuleFactory factory = ServerPlugin.findModuleFactory("org.jboss.ide.eclipse.as.core.PackageModuleFactory");
+ IModule mod = factory.findModule(PackageModuleFactory.getID(node), new NullProgressMonitor());
+ return new IModule[] { mod };
+ }
+ protected static PackagedModuleDelegate getModuleDelegate(IArchive node) {
+ IModule mod = getModule(node)[0];
+ return (PackagedModuleDelegate)mod.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
+ }
+
+ protected IDeployableServer getDeployableServerFromBehavior(DeployableServerBehavior dsb) {
+ IServer server = dsb.getServer();
+ IDeployableServer ids = (IDeployableServer)server.loadAdapter(IDeployableServer.class, new NullProgressMonitor());
+ return ids;
+ }
+
+ public static DeployableServerBehavior[] getServers(String servers) {
+ if( servers == null || "".equals(servers))
+ return null;
+ ArrayList<DeployableServerBehavior> list = new ArrayList<DeployableServerBehavior>();
+ String[] byId = servers.split(",");
+ for( int i = 0; i < byId.length; i++ ) {
+ IServer server = ServerCore.findServer(byId[i]);
+ if( server != null ) {
+ Object o = server.loadAdapter(DeployableServerBehavior.class, new NullProgressMonitor());
+ if( o != null ) {
+ list.add((DeployableServerBehavior)o);
+ }
+ }
+ }
+ return list.toArray(new DeployableServerBehavior[list.size()]);
+ }
+
+ /*
+ * If a node is changing from exploded to imploded, or vice versa
+ * make sure to delete the pre-existing file or folder on the server.
+ */
+ public void packageBuildTypeChanged(IArchive topLevelPackage, boolean isExploded) {
+ String servers = topLevelPackage.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
+ DeployableServerBehavior[] serverBehaviors = ArchivesBuildListener.getServers(servers);
+ if( serverBehaviors != null ) {
+ IPath sourcePath, destPath;
+ IDeployableServer depServer;
+ for( int i = 0; i < serverBehaviors.length; i++ ) {
+ sourcePath = topLevelPackage.getArchiveFilePath();
+ depServer = getDeployableServerFromBehavior(serverBehaviors[i]);
+ destPath = new Path(depServer.getDeployDirectory()).append(sourcePath.lastSegment());
+ FileUtil.safeDelete(destPath.toFile());
+ FileUtil.fileSafeCopy(sourcePath.toFile(), destPath.toFile());
+ }
+ }
+ }
+
+ public void buildFailed(IArchive pkg, IStatus status) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void finishedBuild(IPath project) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void finishedCollectingFileSet(IArchiveFileSet fileset) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void startedBuild(IPath project) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void startedBuildingArchive(IArchive pkg) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void startedCollectingFileSet(IArchiveFileSet fileset) {
+ // TODO Auto-generated method stub
+ }
+ public void startedBuildingPackage(IArchive pkg) {
+ // TODO Auto-generated method stub
+ }
+
+ public void cleanProject(IPath project) {
+ }
+
+ public void modelChanged(IArchiveNodeDelta delta) {
+ IPath p ;
+ if( delta.getPreNode() == null )
+ p = delta.getPostNode().getProjectPath();
+ else
+ p = delta.getPreNode().getProjectPath();
+
+ ArchivesModelModuleContributor.getInstance().refreshProject(p);
+ }
+
+
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,185 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.IModuleContributor;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
+
+/**
+ *
+ * @author Rob Stryker rob.stryker(a)jboss.com
+ *
+ */
+public class ArchivesModelModuleContributor implements IModuleContributor {
+
+ private static ArchivesModelModuleContributor instance;
+ public static ArchivesModelModuleContributor getInstance() {
+ if( instance == null ) {
+ instance = new ArchivesModelModuleContributor(PackageModuleFactory.getFactory());
+ }
+ return instance;
+ }
+
+ private PackageModuleFactory factory;
+ protected ArrayList<IModule> modules = null;
+ protected HashMap<IPath, ArrayList<IModule>> projectToModules = new HashMap<IPath, ArrayList<IModule>>(5); //IPath to IModule
+ protected HashMap<IModule, Object> moduleDelegates = new HashMap<IModule, Object>(5);
+ protected HashMap<IArchive, IModule> packageToModule = new HashMap<IArchive, IModule>(5);
+
+ private ArchivesModelModuleContributor(PackageModuleFactory factory) {
+ this.factory = factory;
+ }
+
+ public IModule[] getModules() {
+ if( modules == null ) {
+ modules = new ArrayList<IModule>();
+ IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ int size = projects2.length;
+ for (int i = 0; i < size; i++) {
+ if (projects2[i].isAccessible()) {
+
+ if( !ArchivesModel.instance().isProjectRegistered(projects2[i].getLocation())) {
+ if( ArchivesModel.instance().canReregister(projects2[i].getLocation()))
+ // registration should also add this to the factory manually, so do not create the module
+ ArchivesModel.instance().registerProject(projects2[i].getLocation(), new NullProgressMonitor());
+ } else {
+ try {
+ // project is already registered. create the module
+ createModules(projects2[i]);
+ } catch(ArchivesModelException ame) {
+ IStatus status = new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, ame.getMessage(), ame);
+ IntegrationPlugin.getDefault().getLog().log(status);
+ }
+ }
+ }
+ }
+ }
+ return modules.toArray(new IModule[modules.size()]);
+ }
+
+ protected void createModules(IProject project) throws ArchivesModelException {
+ IArchive[] packages = ModelUtil.getProjectArchives(project.getLocation());
+ if( packages != null && packages.length > 0 ) {
+ IModule module;
+ boolean requiresSave = ensureArchivesHaveIDs(project, packages);
+ ArrayList<IModule> mods = new ArrayList<IModule>();
+ for( int i = 0; i < packages.length; i++ ) {
+ module = factory.createModule2(packages[i], project);
+ modules.add(module);
+ Object moduleDelegate = new PackagedModuleDelegate(packages[i]);
+ packageToModule.put(packages[i], module);
+ moduleDelegates.put(module, moduleDelegate);
+ mods.add(module);
+ }
+ projectToModules.put(project.getLocation(), mods);
+ if( requiresSave ) {
+ try {
+ ArchivesModel.instance().save(project.getLocation(),
+ new NullProgressMonitor());
+ } catch( ArchivesModelException ame ) {
+ }
+ }
+ }
+ }
+
+ public boolean containsModule(IModule module) {
+ return moduleDelegates.containsKey(module);
+ }
+
+ public PackagedModuleDelegate getModuleDelegate(IModule module) {
+ return (PackagedModuleDelegate)moduleDelegates.get(module);
+ }
+
+ public void refreshProject(IPath projectLoc) {
+ // prime, make sure all are found
+ if( modules == null )
+ getModules();
+
+ // remove old mods
+ ArrayList<IModule> mods = projectToModules.get(projectLoc);
+ IModule mod;
+ PackagedModuleDelegate delegate;
+ if (mods != null) {
+ for( Iterator<IModule> i = mods.iterator(); i.hasNext();) {
+ mod = (IModule)i.next();
+ if( modules.contains(mod)) {
+ delegate = ((PackagedModuleDelegate)moduleDelegates.get(mod));
+ moduleDelegates.remove(mod);
+ modules.remove(mod);
+ if( delegate != null )
+ packageToModule.remove(delegate.getPackage());
+ }
+ }
+ }
+ try {
+ createModules(findProject(projectLoc));
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, ame.getMessage(), ame);
+ IntegrationPlugin.getDefault().getLog().log(status);
+ }
+ }
+
+ protected IProject findProject(IPath projectLoc) {
+ IProject proj = null;
+ IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ int size = projects2.length;
+ for (int i = 0; i < size; i++) {
+ if( projects2[i].getLocation().equals(projectLoc))
+ proj = projects2[i];
+ }
+ return proj;
+ }
+
+ /**
+ * Set a property so that each module that's here in the factory
+ * has a unique ID other than it's name (which is not unique)
+ * @param archives
+ * @return returns whether a save has occurred
+ */
+ protected boolean ensureArchivesHaveIDs(IProject project, IArchive[] archives) {
+ boolean requiresSave = false;
+ for( int i = 0; i < archives.length; i++ ) {
+ if( PackageModuleFactory.getID(archives[i]) == null ) {
+ requiresSave = true;
+ archives[i].setProperty(PackageModuleFactory.MODULE_ID_PROPERTY_KEY,
+ PackageModuleFactory.getID(archives[i], true));
+ }
+ }
+ return requiresSave;
+ }
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ModulePackageTypeConverter.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ModulePackageTypeConverter.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ModulePackageTypeConverter.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,48 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.webtools.archivetypes.EarArchiveType;
+import org.jboss.ide.eclipse.archives.webtools.archivetypes.EjbArchiveType;
+import org.jboss.ide.eclipse.archives.webtools.archivetypes.WarArchiveType;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public class ModulePackageTypeConverter {
+ public static IArchiveType getPackageTypeFor(IModule module) {
+ String modType = module.getModuleType().getId();
+ if("jst.web".equals(modType)) {
+ return ArchivesCore.getInstance().getExtensionManager().getArchiveType(WarArchiveType.WAR_PACKAGE_TYPE);
+ } else if("jst.ear".equals(modType)) {
+ return ArchivesCore.getInstance().getExtensionManager().getArchiveType(EarArchiveType.ID);
+ } else if("jst.ejb".equals(modType)) {
+ return ArchivesCore.getInstance().getExtensionManager().getArchiveType(EjbArchiveType.ID);
+ }
+
+ return null;
+ }
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ModulePackageTypeConverter.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,412 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.internal.ModuleFactory;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleFolder;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
+import org.eclipse.wst.server.core.util.ModuleFile;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public class PackageModuleFactory extends ModuleFactoryDelegate {
+
+ public static final String FACTORY_TYPE_ID = "org.jboss.ide.eclipse.as.core.PackageModuleFactory";
+ public static final String MODULE_TYPE = "jboss.package";
+ public static final String VERSION = "1.0";
+
+ public static final String MODULE_ID_PROPERTY_KEY = "org.jboss.ide.eclipse.as.core.packages.ModuleIDPropertyKey";
+
+ // the factory delegate and the factory respectively
+ private static PackageModuleFactory factDelegate;
+ private static ModuleFactory factory;
+
+ /**
+ * Find the module factory wrapper WTP provides for us
+ * @return
+ */
+ public static PackageModuleFactory getFactory() {
+ if( factDelegate == null ) {
+ ModuleFactory[] factories = ServerPlugin.getModuleFactories();
+
+ for( int i = 0; i < factories.length; i++ ) {
+ if( factories[i].getId().equals(PackageModuleFactory.FACTORY_TYPE_ID)) {
+ Object o = factories[i].getDelegate(new NullProgressMonitor());
+ if( o instanceof PackageModuleFactory ) {
+ factory = factories[i];
+ factDelegate = (PackageModuleFactory)o;
+ return factDelegate;
+ }
+ }
+ }
+ }
+ return factDelegate;
+ }
+
+ /**
+ * Get the module ID of this IArchive if it exists.
+ * Do not create a new one otherwise
+ * @param pack
+ * @return
+ */
+ public static String getID(IArchive pack) {
+ return getID(pack, false);
+ }
+
+ /**
+ * Get the module ID of this IArchive if it exists.
+ * If create is true, and the ID is not set, set a default ID.
+ * @param pack
+ * @param create
+ * @return
+ */
+ protected static String getID(IArchive pack, boolean create) {
+ String propVal = pack.getProperty(MODULE_ID_PROPERTY_KEY);
+ if( propVal == null && create ) {
+ return "" + new Date().getTime();
+ }
+ return propVal;
+ }
+
+ /**
+ * Return the name of the project in the workspace
+ * @param node
+ * @return
+ */
+ public static String getProjectName(IArchiveNode node) {
+ IPath projPath = node.getProjectPath();
+ if( projPath == null ) return null;
+ IProject[] list = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for( int i = 0; i < list.length; i++ )
+ if( list[i].getLocation().equals(projPath))
+ return list[i].getName();
+ return null;
+ }
+
+ /**
+ * Get the visible name of this module
+ * @param pack
+ * @return
+ */
+ public static String getName(IArchive pack) {
+ return getProjectName(pack) + "/" + pack.getName();
+ }
+
+
+
+ protected ArchivesModelModuleContributor moduleContributor;
+ public PackageModuleFactory() {
+ super();
+ }
+
+ public void initialize() {
+ moduleContributor = ArchivesModelModuleContributor.getInstance();
+ }
+
+ protected IModule createModule2(IArchive pack, IProject project) {
+ return createModule(getID(pack), getName(pack), MODULE_TYPE, VERSION, project);
+ }
+
+ public IModule[] getModules(IProject project) {
+ moduleContributor.refreshProject(project.getLocation());
+ return super.getModules(project);
+ }
+ public IModule[] getModules() {
+ return moduleContributor.getModules();
+ }
+
+ public ModuleDelegate getModuleDelegate(IModule module) {
+ return moduleContributor.getModuleDelegate(module);
+ }
+
+ public static interface IModuleContributor {
+ public IModule[] getModules();
+ public boolean containsModule(IModule module);
+ public PackagedModuleDelegate getModuleDelegate(IModule module);
+ }
+
+ public static interface IExtendedModuleResource extends IModuleResource {
+ public IPath getSourcePath();
+ public IArchiveNode getNode();
+ // deep destination is the full path this resource represents, even if it's inside a jar
+ public IPath getDeepDestination();
+ // the concrete file this resource is part of... so the top most zipped jar or, if all is exploded, the file itself
+ public IPath getConcreteDestFile();
+ }
+
+ public static class DelegateInitVisitor implements IArchiveNodeVisitor {
+
+ private IArchive pack;
+ private HashMap<IArchiveNode, ArchiveContainerResource> members; // node -> imoduleresource
+ private HashMap<IPath, IArchiveNode> pathToNode; // path -> node
+ public DelegateInitVisitor(IArchive pack) {
+ this.pack = pack;
+ reset();
+ }
+ public void reset() {
+ members = new HashMap<IArchiveNode, ArchiveContainerResource>();
+ pathToNode = new HashMap<IPath, IArchiveNode>();
+ }
+ public boolean visit(IArchiveNode node) {
+ int type = node.getNodeType();
+ if( type == IArchiveNode.TYPE_ARCHIVE && ((IArchive)node).isTopLevel()) {
+ IPath rel = ((IArchive)node).getRootArchiveRelativePath();
+ members.put(node, new ArchiveContainerResource(((IArchive)node).getName(), node, rel));
+ pathToNode.put(rel, node);
+ } else if( type == IArchiveNode.TYPE_ARCHIVE || type == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+ String name = type == IArchiveNode.TYPE_ARCHIVE ? ((IArchive)node).getName() : ((IArchiveFolder)node).getName();
+ // if we're any other archive or a folder, create us and add to parent
+ IArchiveNode parent = node.getParent();
+ ArchiveContainerResource parentAsResource = members.get(parent);
+ IPath rel = node.getRootArchiveRelativePath();
+ members.put(node, new ArchiveContainerResource(name, node, rel));
+ pathToNode.put(rel, node);
+ parentAsResource.addChild(members.get(node));
+ } else if( type == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
+ ArchiveContainerResource parentAsResource = members.get(node.getParent());
+ parentAsResource.addFilesetAsChild((IArchiveFileSet)node);
+ }
+
+ return true;
+ }
+
+ public IModuleResource getRootResource() {
+ return members.get(pack);
+ }
+
+ public IModuleResource getResourceForNode(IArchiveNode node) {
+ return members.get(node);
+ }
+ }
+
+ public static class ArchiveContainerResource implements IModuleFolder, IExtendedModuleResource {
+
+ protected IPath moduleRelativePath;
+ protected IPath fsRelative;
+ protected IArchiveNode node;
+ protected String name;
+ private HashMap<IPath, IModuleResource> members;
+
+ // represents source folder on disk. only used if node is fileset
+// private IPath folderGlobalPath = null;
+ public ArchiveContainerResource(String name,IArchiveNode node,IPath moduleRelativePath ) {
+ this.name = name;
+ this.node = node;
+ this.moduleRelativePath = moduleRelativePath;
+ members = new HashMap<IPath, IModuleResource>();
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
+ fsRelative = moduleRelativePath.removeFirstSegments(node.getParent().getRootArchiveRelativePath().segmentCount());
+ }
+ }
+
+ public int hashCode() {
+ return name.hashCode() * 37 + moduleRelativePath.hashCode();
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof IModuleFolder) {
+ IModuleFolder resource = (IModuleFolder) other;
+ return resource.getModuleRelativePath().equals(getModuleRelativePath());
+ }
+ return false;
+ }
+
+ public void addChild(IModuleResource resource) {
+ members.put(resource.getModuleRelativePath(), resource);
+ }
+
+ public void removeChild(IPath moduleRelativePath) {
+ members.remove(moduleRelativePath);
+ }
+ public IModuleResource getChild(IPath path) {
+ return members.get(path);
+ }
+
+ public void addFilesetAsChild(IArchiveFileSet fs) {
+ FileWrapper[] files = fs.findMatchingPaths(); // file-system based source paths
+ for( int i = 0; i < files.length; i++ ) {
+ addFilesetPathAsChild(fs, files[i]);
+ }
+ }
+
+ public void addFilesetPathAsChild(IArchiveFileSet fs, FileWrapper file) {
+ IPath fsRelative = new Path(file.getFilesetRelative());
+ ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), true);
+ ExtendedModuleFile emf = new ExtendedModuleFile(file, fs);
+ parent.addChild(emf);
+ }
+
+ protected ArchiveContainerResource find(IArchiveFileSet fs, IPath fsRelative, boolean create) {
+ ArchiveContainerResource resource = this;
+ ArchiveContainerResource tmpResource;
+ IPath tmpPath = fs.getRootArchiveRelativePath();
+ int count = fsRelative.segmentCount();
+ for( int i = 0; i < count; i++ ) {
+ tmpPath = tmpPath.append(fsRelative.segment(i));
+ tmpResource = (ArchiveContainerResource)resource.getChild(tmpPath);
+ if( tmpResource == null ) {
+ if( !create )
+ return null;
+ tmpResource = new ArchiveContainerResource(tmpPath.lastSegment(), fs, tmpPath);
+ resource.addChild(tmpResource);
+ }
+ resource = tmpResource;
+ }
+ return resource;
+ }
+
+ public IModuleResource[] members() {
+ Collection<IModuleResource> c = members.values();
+ return c.toArray(new IModuleResource[c.size()]);
+ }
+
+ public IPath getModuleRelativePath() {
+ return moduleRelativePath;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+ public IPath getDeepDestination() {
+ IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET
+ ? moduleRelativePath : node.getRootArchiveRelativePath();
+ return PathUtils.getGlobalLocation(node.getRootArchive()).append(tmp);
+ }
+
+ public IPath getConcreteDestFile() {
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET )
+ return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node,fsRelative);
+ else
+ return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node);
+ }
+ public IArchiveNode getNode() {
+ return node;
+ }
+
+ public IPath getSourcePath() {
+ return null;
+ }
+
+ }
+
+ public static class ExtendedModuleFile extends ModuleFile implements IExtendedModuleResource {
+ private FileWrapper wrapper;
+ private IArchiveFileSet node;
+ public ExtendedModuleFile(FileWrapper wrapper, IArchiveFileSet fs) {
+ super(wrapper.getOutputName(), wrapper.getRootArchiveRelative(), wrapper.lastModified());
+ this.node = fs;
+ this.wrapper = wrapper;
+ }
+ public int hashCode() {
+ return getName().hashCode() * 37 + getPath().hashCode();
+ }
+
+ public IPath getPath() { return new Path(wrapper.getAbsolutePath()); }
+ public IArchiveNode getNode() { return node; }
+ public IPath getDeepDestination() {
+ return PathUtils.getGlobalLocation(node.getRootArchive()).append(wrapper.getRootArchiveRelative());
+ }
+ public IPath getSourcePath() {
+ return new Path(this.wrapper.getAbsolutePath());
+ }
+
+ public IPath getConcreteDestFile() {
+ return ModelUtil.getBaseDestinationFile(node, new Path(this.wrapper.getFilesetRelative()));
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof IModuleFile) {
+ IModuleFile resource = (IModuleFile) other;
+ return resource.getModuleRelativePath().equals(getModuleRelativePath());
+ }
+ return false;
+ }
+
+ }
+
+ public static class PackagedModuleDelegate extends ModuleDelegate {
+ private IArchive pack;
+ private IModuleResource rootResource;
+ private DelegateInitVisitor initVisitor;
+ public PackagedModuleDelegate(IArchive pack) {
+ this.pack = pack;
+ initVisitor = new DelegateInitVisitor(pack);
+ }
+
+ public IArchive getPackage() {
+ return pack;
+ }
+ public IModule[] getChildModules() {
+ return new IModule[0];
+ }
+
+ protected void init() {
+ initVisitor.reset();
+ pack.accept(initVisitor);
+ rootResource = initVisitor.getRootResource();
+ }
+
+ public IModuleResource[] members() throws CoreException {
+ init();
+ return new IModuleResource[] { rootResource };
+ }
+
+ public IStatus validate() {
+ return new Status(IStatus.OK, IntegrationPlugin.PLUGIN_ID,
+ 0, "", null);
+ }
+ }
+
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagedArtifactAdapter.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagedArtifactAdapter.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagedArtifactAdapter.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,81 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate;
+/**
+ *
+ * @author Rob Stryker rob.stryker(a)redhat.com
+ *
+ */
+public class PackagedArtifactAdapter extends ModuleArtifactAdapterDelegate {
+
+ public PackagedArtifactAdapter() {
+ }
+
+ public IModuleArtifact getModuleArtifact(Object obj) {
+ if( obj instanceof IJavaProject ) {
+ IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ boolean done = false;
+ String jpName = ((IJavaProject)obj).getElementName();
+ for( int i = 0; i < projects2.length && !done; i++ ) {
+ if( projects2[i].getName().equals(jpName)) {
+ done = true;
+ obj = projects2[i];
+ break;
+ }
+ }
+ }
+
+ if( obj instanceof IProject ) {
+ PackageModuleFactory factory = PackageModuleFactory.getFactory();
+ if( factory != null ) {
+// IModule[] mods = factory.getModulesFromProject((IProject)obj);
+// if( mods != null && mods.length != 0) {
+// return getArtifact(mods);
+// }
+ }
+ }
+ return null;
+ }
+
+ protected IModuleArtifact getArtifact(IModule[] mod) {
+ //return new PackagedArtifact(mod);
+ // TODO Blocking on eclipse bug 174372
+ return null;
+ }
+
+ public class PackagedArtifact implements IModuleArtifact{
+ protected IModule mod;
+ public PackagedArtifact(IModule module) {
+ this.mod = module;
+ }
+ public IModule getModule() {
+ return mod;
+ }
+ }
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagedArtifactAdapter.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,256 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleFolder;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.ExtendedModuleFile;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.IExtendedModuleResource;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
+import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublisherFileUtilListener;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public class PackagesPublisher implements IJBossServerPublisher {
+
+ protected IDeployableServer server;
+ protected IModuleResourceDelta[] delta;
+ protected EventLogTreeItem eventRoot;
+
+ public PackagesPublisher() {
+ }
+
+ public int getPublishState() {
+ return IServer.PUBLISH_STATE_NONE;
+ }
+
+ public boolean accepts(IServer server, IModule[] module) {
+ if( module != null && module.length > 0
+ && "jboss.package".equals(module[0].getModuleType().getId()))
+ return true;
+ return false;
+ }
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor)
+ throws CoreException {
+ this.server = ServerConverter.getDeployableServer(server);
+ eventRoot = log;
+ this.delta = delta;
+
+ try {
+ IModule module2 = module[0];
+ // if it's being removed
+ if( publishType == REMOVE_PUBLISH ) {
+ removeModule(module2, monitor);
+ } else if( publishType == FULL_PUBLISH ) {
+ publishModule(module2, false, monitor);
+ } else if( publishType == INCREMENTAL_PUBLISH ) {
+ publishModule(module2, true, monitor);
+ }
+ }catch(Exception e) {
+ IStatus status = new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, "Error during publish", e);
+ IntegrationPlugin.getDefault().getLog().log(status);
+ }
+ return null;
+ }
+
+ protected void removeModule(IModule module, IProgressMonitor monitor) {
+ IArchive pack = getPackage(module);
+ // remove all of the deployed items
+ if( pack != null ) {
+ IPath sourcePath = pack.getArchiveFilePath();
+ IPath destPath = new Path(server.getDeployDirectory()).append(sourcePath.lastSegment());
+ // remove the entire file or folder
+ PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
+ FileUtil.safeDelete(destPath.toFile(), listener);
+ }
+ }
+
+
+
+ protected void publishModule(IModule module, boolean incremental, IProgressMonitor monitor) {
+ IArchive pack = getPackage(module);
+ IPath sourcePath = pack.getArchiveFilePath();
+ IPath destPathRoot = new Path(server.getDeployDirectory());
+
+ // if destination is deploy directory... no need to re-copy!
+ if( destPathRoot.toOSString().equals(PathUtils.getGlobalLocation(pack).toOSString())) {
+ // fire null publish event
+ return;
+ }
+
+ PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
+ eventRoot.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, countChanges(delta));
+ if( incremental ) {
+ publishFromDelta(module, destPathRoot, sourcePath.removeLastSegments(1), delta, listener);
+ } else {
+ // full publish, copy whole folder or file
+ FileUtil.fileSafeCopy(sourcePath.toFile(), destPathRoot.append(sourcePath.lastSegment()).toFile(), listener);
+ }
+ }
+
+ protected void publishFromDelta(IModule module, IPath destPathRoot, IPath sourcePrefix,
+ IModuleResourceDelta[] delta, PublisherFileUtilListener listener) {
+ ArrayList<IPath> changedFiles = new ArrayList<IPath>();
+ for( int i = 0; i < delta.length; i++ ) {
+ publishFromDeltaHandle(delta[i], destPathRoot, sourcePrefix, changedFiles, listener);
+ }
+ }
+
+ protected int countChanges(IModuleResourceDelta[] deltas) {
+ IModuleResource res;
+ int count = 0;
+ if( deltas == null ) return 0;
+ for( int i = 0; i < deltas.length; i++ ) {
+ res = deltas[i].getModuleResource();
+ if( res != null && res instanceof IModuleFile)
+ count++;
+ count += countChanges(deltas[i].getAffectedChildren());
+ }
+ return count;
+ }
+
+ protected int countConcreteFiles(IModule module) {
+ PackagedModuleDelegate delegate = (PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
+ try {
+ ArrayList list = new ArrayList();
+ countConcreteFiles(delegate.members()[0], list);
+ return list.size();
+ } catch( CoreException ce ) {
+
+ }
+ return -1;
+ }
+ protected void countConcreteFiles(IModuleResource mr, ArrayList list) {
+ if( mr instanceof IExtendedModuleResource) {
+ IExtendedModuleResource emr = ((IExtendedModuleResource)mr);
+ if( mr instanceof IModuleFile ) {
+ IPath p = emr.getConcreteDestFile();
+ if( !list.contains(p))
+ list.add(p);
+ }
+ if( mr instanceof IModuleFolder) {
+ IModuleResource[] children = ((IModuleFolder)mr).members();
+ for( int i = 0; i < children.length; i++ )
+ countConcreteFiles(children[i], list);
+ }
+ }
+ }
+
+ protected void publishFromDeltaHandle(IModuleResourceDelta delta, IPath destRoot,
+ IPath sourcePrefix, ArrayList<IPath> changedFiles, PublisherFileUtilListener listener) {
+ switch( delta.getKind()) {
+ case IModuleResourceDelta.REMOVED:
+ // removed might not be IExtendedModuleResource
+ IModuleResource imr = delta.getModuleResource();
+ if( imr instanceof IExtendedModuleResource) {
+ IExtendedModuleResource emr = ((IExtendedModuleResource)imr);
+ IPath concrete = emr.getConcreteDestFile();
+ if( !changedFiles.contains(concrete)) {
+ IPath destPath = destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
+
+ // file hasnt been updated yet.
+ // But we don't know whether to delete or copy this file.
+ // depends where it is in the tree and what's exploded.
+ changedFiles.add(concrete);
+ IPath concreteRelative = concrete.removeFirstSegments(sourcePrefix.segmentCount()).setDevice(null);
+ IPath emrModRelative = emr.getModuleRelativePath();
+ boolean delete = concreteRelative.equals(emrModRelative);
+
+ if( delete ) {
+ FileUtil.safeDelete(destPath.toFile(), listener);
+ } else {
+ // copy
+ FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
+ }
+ }
+ return;
+ } else {
+ // TODO
+ return;
+ }
+ case IModuleResourceDelta.ADDED:
+ imr = delta.getModuleResource();
+ if( imr instanceof IExtendedModuleResource) {
+ IPath concrete = ((IExtendedModuleResource)imr).getConcreteDestFile();
+ if( !changedFiles.contains(concrete)) {
+ changedFiles.add(concrete);
+ IPath destPath = destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
+ FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
+ }
+ return;
+ } else {
+ // TODO
+ return;
+ }
+ case IModuleResourceDelta.CHANGED:
+ imr = delta.getModuleResource();
+ if( imr instanceof ExtendedModuleFile ) {
+ IPath concrete = ((ExtendedModuleFile)imr).getConcreteDestFile();
+ if( !changedFiles.contains(concrete)) {
+ changedFiles.add(concrete);
+ IPath destPath = destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
+ FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
+ }
+ }
+ break;
+ }
+
+ IModuleResourceDelta[] children = delta.getAffectedChildren();
+ if( children != null ) {
+ for( int i = 0; i < children.length; i++ ) {
+ publishFromDeltaHandle(children[i], destRoot, sourcePrefix, changedFiles, listener);
+ }
+ }
+ }
+
+ protected IArchive getPackage(IModule module) {
+ PackagedModuleDelegate delegate = (PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
+ return delegate == null ? null : delegate.getPackage();
+ }
+
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,220 @@
+package org.jboss.ide.eclipse.archives.webtools.ui;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.ui.internal.ImageResource;
+import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesBuildListener;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+public class ArchivePublishWizard extends Wizard {
+
+ private ArchivePublishWizardPage page;
+ private IArchive pack;
+ public ArchivePublishWizard(IArchive pack) {
+ this.pack = pack;
+ setWindowTitle("Archive Publish Settings");
+ }
+ public boolean performFinish() {
+ boolean alwaysPublish = new Boolean(page.getAlwaysPublish()).booleanValue();
+ pack.setProperty(ArchivesBuildListener.DEPLOY_SERVERS, alwaysPublish ? getServers() : null);
+ pack.setProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD, getAutoDeploy());
+ final IPath p = pack.getProjectPath();
+ new SaveArchivesJob(p).schedule();
+ return true;
+ }
+ public void addPages() {
+ page = new ArchivePublishWizardPage(pack);
+ addPage(page);
+ }
+
+ protected String getServers() {
+ return page.getServers();
+ }
+ protected String getAutoDeploy() {
+ return page.getAutoDeploy();
+ }
+ protected String getAlwaysPublish() {
+ return page.getAlwaysPublish();
+ }
+
+
+ public class ArchivePublishWizardPage extends WizardPage {
+ protected IArchive pack;
+ protected TableViewer viewer;
+ protected Button autoDeploy, alwaysPublish;
+ protected String viewerResult = "";
+ protected String deployResult = Boolean.toString(false);
+ protected String alwaysPublishResult = Boolean.toString(false);
+
+ protected ArchivePublishWizardPage(IArchive pack) {
+ super("Select Server Wizard");
+ setDescription("Select the server to publish the archive to.");
+ setTitle("Publish archive to a server");
+ this.pack = pack;
+ }
+
+ public void createControl(Composite parent) {
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ mainComposite.setLayout(new FormLayout());
+ mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fillComposite(mainComposite);
+ addListeners();
+ setControl(mainComposite);
+ getContainer().updateTitleBar();
+ setPackageDefaults();
+ }
+
+ protected void setPackageDefaults() {
+ String servers = pack.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
+ viewerResult = servers;
+ String deployAfterBuild = pack.getProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD);
+ if( servers != null ) {
+ alwaysPublish.setSelection(true);
+ alwaysPublishSelected();
+ boolean depAfterBld = !(deployAfterBuild == null || new Boolean(deployAfterBuild).booleanValue() == false);
+ autoDeploy.setSelection(depAfterBld);
+ autoDeploySelected();
+
+ IDeployableServer[] depServers = ServerConverter.getAllDeployableServers();
+ String[] serverList = servers.split(",");
+ final ArrayList<IDeployableServer> selected = new ArrayList<IDeployableServer>();
+ for(int i = 0; i < serverList.length; i++ ) {
+ for( int j = 0; j < depServers.length; j++ ) {
+ if( serverList[i].equals(depServers[j].getServer().getId()))
+ selected.add(depServers[j]);
+ }
+ }
+ viewer.setSelection(new StructuredSelection(selected.toArray()));
+ }
+ }
+
+ protected void fillComposite(Composite mainComposite) {
+ viewer = new TableViewer(mainComposite);
+ FormData viewerData = new FormData();
+ viewerData.left = new FormAttachment(15,0);
+ viewerData.right = new FormAttachment(85,0);
+ viewerData.top = new FormAttachment(0,10);
+ viewerData.bottom = new FormAttachment(80,0);
+ viewer.getTable().setLayoutData(viewerData);
+
+ this.alwaysPublish = new Button(mainComposite, SWT.CHECK);
+ FormData always = new FormData();
+ always.left = new FormAttachment(15,0);
+ always.top = new FormAttachment(viewer.getTable(), 5);
+ alwaysPublish.setLayoutData(always);
+ alwaysPublish.setText("Always publish to these servers");
+
+ autoDeploy = new Button(mainComposite, SWT.CHECK);
+ FormData add = new FormData();
+ add.left = new FormAttachment(15,0);
+ add.top = new FormAttachment(alwaysPublish, 5);
+ autoDeploy.setLayoutData(add);
+ autoDeploy.setText("Auto-deploy to selected servers after builds");
+ }
+
+ protected void addListeners() {
+ autoDeploy.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ autoDeploySelected();
+ }
+ });
+ viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ viewerSelected();
+ }
+ } );
+
+ alwaysPublish.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ alwaysPublishSelected();
+ }
+ });
+
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.setLabelProvider(new ArchivePublishLabelProvider());
+ viewer.setInput(ServerConverter.getAllDeployableServers());
+ autoDeploy.setEnabled(false);
+ }
+
+ protected void autoDeploySelected() {
+ deployResult = Boolean.toString(autoDeploy.getSelection() && autoDeploy.getEnabled());
+ }
+
+ protected void alwaysPublishSelected() {
+ autoDeploy.setEnabled(alwaysPublish.getSelection());
+ deployResult = Boolean.toString(autoDeploy.getSelection() && autoDeploy.getEnabled());
+ alwaysPublishResult = Boolean.toString(alwaysPublish.getSelection());
+ }
+
+ protected void viewerSelected() {
+ ISelection sel = viewer.getSelection();
+ if( sel instanceof IStructuredSelection ) {
+ IStructuredSelection sel2 = (IStructuredSelection)sel;
+ Object[] os = sel2.toArray();
+ String tmp = "";
+ for( int i = 0; i < os.length; i++ ) {
+ tmp += ((IDeployableServer)os[i]).getServer().getId() + ",";
+ }
+ viewerResult = tmp;
+ }
+ }
+ protected String getServers() {
+ return viewerResult;
+ }
+ protected String getAutoDeploy() {
+ return deployResult;
+ }
+ protected String getAlwaysPublish() {
+ return alwaysPublishResult;
+ }
+ }
+
+ protected class ArchivePublishLabelProvider extends LabelProvider {
+ public Image getImage(Object element) {
+ if( element instanceof IDeployableServer ) {
+ IServerType type = ((IDeployableServer)element).getServer().getServerType();
+ return ImageResource.getImage(type.getId());
+ }
+ return null;
+ }
+ public String getText(Object element) {
+ if( element instanceof IDeployableServer ) {
+ return ((IDeployableServer)element).getServer().getName();
+ }
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+
+ }
+}
\ No newline at end of file
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/EditPublishAction.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/EditPublishAction.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/EditPublishAction.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,22 @@
+package org.jboss.ide.eclipse.archives.webtools.ui;
+
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.actions.INodeActionDelegate;
+
+public class EditPublishAction implements INodeActionDelegate {
+
+ public boolean isEnabledFor(IArchiveNode node) {
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE)
+ return true;
+ return false;
+ }
+
+ public void run(IArchiveNode node) {
+ ArchivePublishWizard wiz = new ArchivePublishWizard((IArchive)node);
+ new WizardDialog(new Shell(), wiz).open();
+ }
+
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEARAction.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEARAction.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEARAction.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,108 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.ui;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
+import org.jboss.ide.eclipse.archives.webtools.archivetypes.EarArchiveType;
+
+public class NewEARAction implements IActionDelegate {
+
+ private IStructuredSelection selection;
+ public void run() {
+ AbstractArchiveWizard wizard = new NewEARWizard();
+ wizard.init(PlatformUI.getWorkbench(), selection);
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.open();
+ }
+
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if( selection instanceof IStructuredSelection)
+ this.selection = (IStructuredSelection)selection;
+ }
+
+ public void init(IViewPart view) {
+ }
+
+ public static class NewEARWizard extends AbstractArchiveWizard {
+
+ private EARPreviewPage earInfoPage;
+
+ public NewEARWizard () {
+ setWindowTitle("New EAR");
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_EAR);
+ }
+
+ public WizardPage[] createWizardPages() {
+ earInfoPage = new EARPreviewPage(this);
+
+ return new WizardPage[] { earInfoPage };
+ }
+
+ public boolean performFinish(IArchive pkg) {
+ pkg.setArchiveType(ArchivesCore.getInstance().getExtensionManager().getArchiveType(EarArchiveType.ID));
+ return true;
+ }
+
+ public String getArchiveExtension() {
+ return "ear";
+ }
+ }
+
+
+ protected static class EARPreviewPage extends PreviewPage {
+ protected EARPreviewPage(NewEARWizard wiz) {
+ super(wiz, "EAR Preview", "EAR Preview",
+ ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_EAR));
+ }
+ protected void addToPackage() {
+ IArchiveType type = ArchivesCore.getInstance().getExtensionManager().getArchiveType(EarArchiveType.ID);
+ type.fillDefaultConfiguration(wizard.getProject().getName(), wizard.getArchive(), new NullProgressMonitor());
+ }
+
+ protected String getDescriptionMessage() {
+ return "Preview the EAR\n" +
+ "Later, you can customize this structure further.";
+ }
+ }
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEJBJARAction.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEJBJARAction.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEJBJARAction.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,103 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.ui;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
+import org.jboss.ide.eclipse.archives.webtools.archivetypes.EjbArchiveType;
+
+public class NewEJBJARAction implements IActionDelegate {
+ private IStructuredSelection selection;
+ public void run() {
+ AbstractArchiveWizard wizard = new NewEJBWizard();
+ wizard.init(PlatformUI.getWorkbench(), selection);
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.open();
+ }
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if( selection instanceof IStructuredSelection)
+ this.selection = (IStructuredSelection)selection;
+ }
+
+ public static class NewEJBWizard extends AbstractArchiveWizard {
+
+ private EjbJarPreviewPage ejbInfoPage;
+
+ public NewEJBWizard () {
+ setWindowTitle("New EJB JAR");
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_EJB_JAR);
+ }
+
+ public WizardPage[] createWizardPages() {
+ ejbInfoPage = new EjbJarPreviewPage(this);
+
+ return new WizardPage[] { ejbInfoPage };
+ }
+
+ public boolean performFinish(IArchive pkg) {
+ pkg.setArchiveType(ArchivesCore.getInstance().getExtensionManager().getArchiveType(EjbArchiveType.ID));
+ return true;
+ }
+
+ public String getArchiveExtension() {
+ return "jar";
+ }
+ }
+
+
+ protected static class EjbJarPreviewPage extends PreviewPage {
+ protected EjbJarPreviewPage(NewEJBWizard wiz) {
+ super(wiz, "EJB JAR Preview", "EJB JAR Preview",
+ ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_NEW_JAR_WIZARD));
+ }
+ protected void addToPackage() {
+ IArchiveType type = ArchivesCore.getInstance().getExtensionManager().getArchiveType(EjbArchiveType.ID);
+ type.fillDefaultConfiguration(wizard.getProject().getName(), wizard.getArchive(), new NullProgressMonitor());
+ }
+
+ protected String getDescriptionMessage() {
+ return "Preview the EJB JAR \n" +
+ "Later, you can customize this structure further.";
+ }
+ }
+
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewEJBJARAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewWARAction.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewWARAction.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewWARAction.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,103 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.ui;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
+import org.jboss.ide.eclipse.archives.webtools.archivetypes.WarArchiveType;
+
+public class NewWARAction implements IActionDelegate {
+ private IStructuredSelection selection;
+ public void run() {
+ NewWARWizard wizard = new NewWARWizard();
+ wizard.init(PlatformUI.getWorkbench(), selection);
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.open();
+ }
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if( selection instanceof IStructuredSelection)
+ this.selection = (IStructuredSelection)selection;
+ }
+
+
+ public static class NewWARWizard extends AbstractArchiveWizard {
+
+ private WarPreviewPage warInfoPage;
+
+ public NewWARWizard ()
+ {
+ setWindowTitle("New WAR");
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ public WizardPage[] createWizardPages() {
+ warInfoPage = new WarPreviewPage(this);
+
+ return new WizardPage[] { warInfoPage };
+ }
+
+ public boolean performFinish(IArchive pkg) {
+ pkg.setArchiveType(ArchivesCore.getInstance().getExtensionManager().getArchiveType(WarArchiveType.WAR_PACKAGE_TYPE));
+ return true;
+ }
+
+ public String getArchiveExtension() {
+ return "war";
+ }
+ }
+
+ protected static class WarPreviewPage extends PreviewPage {
+ protected WarPreviewPage(NewWARWizard wiz) {
+ super(wiz, "WAR Archive Stub", "WAR Archive Stub",
+ ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_NEW_WAR_WIZARD));
+ }
+ protected void addToPackage() {
+ IArchiveType type = ArchivesCore.getInstance().getExtensionManager().getArchiveType(WarArchiveType.WAR_PACKAGE_TYPE);
+ type.fillDefaultConfiguration(wizard.getProject().getName(), wizard.getArchive(), new NullProgressMonitor());
+ }
+
+ protected String getDescriptionMessage() {
+ return "Below is a stub archive configuration for your project. \n" +
+ "You can customize this structure further after pressing finish.";
+ }
+ }
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/NewWARAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PreviewPage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PreviewPage.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PreviewPage.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,255 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.ui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+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.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProviderDelegate;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
+import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
+import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
+
+public abstract class PreviewPage extends WizardPageWithNotification {
+
+ private Group previewGroup;
+ protected AbstractArchiveWizard wizard;
+ private TreeViewer previewViewer;
+ private boolean hasCreated = false;
+ public PreviewPage (AbstractArchiveWizard wizard, String name, String title, ImageDescriptor descriptor ) {
+ super( name, title, descriptor);
+ this.wizard = wizard;
+ }
+
+ protected abstract String getDescriptionMessage();
+ public void createControl(Composite parent) {
+
+ setMessage(getDescriptionMessage());
+ Composite main = new Composite(parent, SWT.NONE);
+ main.setLayout(new FormLayout());
+
+ layoutGroups(main);
+ fillGroups();
+
+ setControl(main);
+ }
+ protected void layoutGroups(Composite main) {
+ previewGroup = new Group(main, SWT.NONE);
+ previewGroup.setText("Preview");
+ FormData previewData = new FormData();
+ previewData.left = new FormAttachment(0,5);
+ previewData.right = new FormAttachment(100,-5);
+ previewData.top = new FormAttachment(0,5);
+ previewData.bottom = new FormAttachment(100,-5);
+ previewGroup.setLayoutData(previewData);
+ previewGroup.setLayout(new FormLayout());
+ previewViewer = new TreeViewer(previewGroup);
+ previewViewer.setLabelProvider(new ArchivesLabelProvider());
+ previewViewer.setContentProvider(new ArchivesContentProviderDelegate());
+ FormData warPreviewData = new FormData();
+ warPreviewData.left = new FormAttachment(0,5);
+ warPreviewData.right = new FormAttachment(100,-5);
+ warPreviewData.top = new FormAttachment(0,5);
+ warPreviewData.bottom = new FormAttachment(100,-5);
+ previewViewer.getTree().setLayoutData(warPreviewData);
+
+ }
+
+ protected void fillGroups() {
+ }
+ public boolean isPageComplete() {
+ return hasCreated;
+ }
+ public void pageEntered(int button) {
+ if( !hasCreated ) {
+ addToPackage();
+ hasCreated = true;
+ }
+ fillWidgets(wizard.getArchive());
+
+ // if it's already a module type project, hide the meta inf stuff
+ IModuleArtifact moduleArtifacts[] = ServerPlugin.getModuleArtifacts(wizard.getProject());
+ if( moduleArtifacts != null && moduleArtifacts.length > 0) {
+ FormData d = (FormData)previewGroup.getLayoutData();
+ d.top = new FormAttachment(0,5);
+ previewGroup.setLayoutData(d);
+ ((Composite)getControl()).layout();
+ }
+ getWizard().getContainer().updateButtons();
+ }
+
+ protected abstract void addToPackage();
+ protected void fillWidgets(IArchive pkg) {
+ previewViewer.setInput(pkg);
+ previewViewer.expandAll();
+ }
+
+ protected IArchiveFolder getFolder(IArchive pkg, String folderName) {
+ IArchiveFolder result = null;
+ IArchiveFolder[] folders = pkg.getFolders();
+ for( int i = 0; i < folders.length; i++ ) {
+ if( folders[i].getName().equals(folderName)) {
+ result = folders[i];
+ break;
+ }
+ }
+ return result;
+ }
+
+ public void pageExited(int button) {}
+
+
+
+
+ // stuff that can be extracted
+ public static class WorkspaceFolderSelectionDialog extends ElementTreeSelectionDialog {
+
+ public WorkspaceFolderSelectionDialog(Shell parent, boolean allowMultiple, String selectedPaths) {
+ super(parent, new FolderLabelProvider(), new FolderContentProvider());
+ setAllowMultiple(allowMultiple);
+ setupDestinationList();
+ setupInitialSelections(selectedPaths);
+ }
+
+ private void setupDestinationList () {
+ List projects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
+ setInput(projects);
+ }
+ private void setupInitialSelections(String initialSelection) {
+ ArrayList resources = new ArrayList();
+ String[] paths = initialSelection.split(",");
+ // find IResources
+ IResource res;
+ for( int i = 0; i < paths.length; i++ ) {
+ res = ResourcesPlugin.getWorkspace().getRoot().findMember(paths[i]);
+ resources.add(res);
+ }
+ setInitialSelections((IResource[]) resources.toArray(new IResource[resources.size()]));
+ }
+
+ private static class FolderContentProvider implements ITreeContentProvider {
+ private static final Object[] NO_CHILDREN = new Object[0];
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IContainer) {
+ IContainer container = (IContainer) parentElement;
+ try {
+ IResource members[] = container.members();
+ List folders = new ArrayList();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i].getType() == IResource.FOLDER) folders.add(members[i]);
+ }
+ return folders.toArray();
+ } catch (CoreException e) {
+ // ignore
+ }
+ }
+ return NO_CHILDREN;
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof IContainer) {
+ return ((IContainer) element).getParent();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ Object[] results = getChildren(element);
+ return results != null && results.length > 0;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof Collection)
+ return ((Collection)inputElement).toArray();
+
+ return NO_CHILDREN;
+ }
+
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ }
+
+ public static class FolderLabelProvider implements ILabelProvider {
+ public FolderLabelProvider () {}
+ public Image getImage(Object element) {
+ if (element instanceof IProject) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);
+ } else if (element instanceof IFolder) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof IContainer) {
+ return ((IContainer)element).getName();
+ }
+ return "";
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ }
+ }
+
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PreviewPage.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java 2008-08-23 00:25:19 UTC (rev 9877)
@@ -0,0 +1,89 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.webtools.ui;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.actions.INodeActionDelegate;
+import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesBuildListener;
+
+public class PublishAction implements INodeActionDelegate {
+
+
+ public PublishAction() {
+ }
+
+ public void run (IArchiveNode node) {
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE
+ && ((IArchive)node).isTopLevel()) {
+ final IArchive pkg = (IArchive)node;
+ String servers = node.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
+ if( servers == null || "".equals(servers) || anyServerDoesntExist(servers)){
+ servers = showSelectServersDialog(pkg);
+ }
+ final String servers2 = servers;
+ if( servers != null ) {
+ Job j = new Job("Build Archive") {
+ protected IStatus run(IProgressMonitor monitor) {
+ ArchivesBuildListener.publish(pkg, servers2, IServer.PUBLISH_FULL);
+ return Status.OK_STATUS;
+ } };
+ j.schedule();
+ }
+ }
+ }
+
+ protected boolean anyServerDoesntExist(String servers) {
+ String[] asArray = servers.split(",");
+ for( int i = 0; i < asArray.length; i++ )
+ if( ServerCore.findServer(asArray[i]) == null )
+ return true;
+ return false;
+ }
+ public boolean isEnabledFor(IArchiveNode node) {
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE ) {
+ IArchive pkg = (IArchive) node;
+ if (pkg.isTopLevel()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected String showSelectServersDialog(IArchive node) {
+ ArchivePublishWizard wiz = new ArchivePublishWizard(node);
+ int result = new WizardDialog(new Shell(), wiz).open();
+ if( result == Window.OK) {
+ return wiz.getServers();
+ }
+ return null;
+ }
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java
___________________________________________________________________
Name: svn:executable
+ *
15 years, 8 months
JBoss Tools SVN: r9876 - in trunk: as/plugins/org.jboss.ide.eclipse.as.core/META-INF and 11 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-22 20:24:20 -0400 (Fri, 22 Aug 2008)
New Revision: 9876
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/packages/
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml
Log:
JBIDE-2677 - removing the as.core's dependency on archives by way of addding an extension point for publishers and a new plugin for the archives / publishing integration
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2008-08-23 00:24:20 UTC (rev 9876)
@@ -18,13 +18,11 @@
org.eclipse.wst.common.project.facet.core,
org.eclipse.jst.common.project.facet.core,
org.eclipse.wst.xml.core,
- org.jboss.ide.eclipse.archives.core,
org.apache.ant,
org.eclipse.jst.server.tomcat.core,
org.eclipse.wst.web
Eclipse-LazyStart: true
Export-Package: org.jboss.ide.eclipse.as.core,
- org.jboss.ide.eclipse.as.core.extensions.archives,
org.jboss.ide.eclipse.as.core.extensions.descriptors,
org.jboss.ide.eclipse.as.core.extensions.events,
org.jboss.ide.eclipse.as.core.extensions.jmx,
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -23,6 +23,8 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -31,6 +33,9 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
@@ -57,6 +62,8 @@
/** The map of pollerID -> PollerObject */
private HashMap<String, IPollerFailureHandler> pollerFailureHandlers;
+ private ArrayList<PublisherWrapper> publishers;
+
/** The method used to load / instantiate the pollers */
public void loadPollers() {
pollers = new HashMap<String, ServerStatePollerType>();
@@ -142,4 +149,53 @@
}
return null;
}
+
+
+ public IJBossServerPublisher getPublisher(IServer server, IModule[] module) {
+ if( publishers == null )
+ loadPublishers();
+ Iterator i = publishers.iterator();
+ PublisherWrapper wrapper;
+ while(i.hasNext()) {
+ wrapper = (PublisherWrapper)i.next();
+ if( wrapper.publisher.accepts(server, module))
+ return wrapper.publisher;
+ }
+ return null;
+ }
+
+ private void loadPublishers() {
+ ArrayList<PublisherWrapper> publishers = new ArrayList<PublisherWrapper>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID, "publishers");
+ for( int i = 0; i < cf.length; i++ ) {
+ try {
+ Object clazz = cf[i].createExecutableExtension("class");
+ String priority = cf[i].getAttribute("priority");
+ int p = -1;
+ try {
+ p = Integer.parseInt(priority);
+ } catch( NumberFormatException nfe) {}
+ publishers.add(new PublisherWrapper(p, (IJBossServerPublisher)clazz));
+ } catch( CoreException e ) {
+ } catch( ClassCastException cce ) {
+ }
+ }
+ this.publishers = publishers;
+ Comparator<PublisherWrapper> comparator = new Comparator<PublisherWrapper>() {
+ public int compare(PublisherWrapper o1, PublisherWrapper o2) {
+ return o2.priority - o1.priority;
+ }
+ };
+ Collections.sort(this.publishers, comparator);
+ }
+
+ private class PublisherWrapper {
+ private int priority;
+ private IJBossServerPublisher publisher;
+ private PublisherWrapper(int priority, IJBossServerPublisher publisher) {
+ this.priority = priority;
+ this.publisher = publisher;
+ }
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -30,7 +30,6 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
-import org.jboss.ide.eclipse.as.core.modules.ArchivesBuildListener;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.osgi.framework.BundleContext;
@@ -73,7 +72,6 @@
super.start(context);
// Start the array of models that need to be started
- ArchivesBuildListener.getInstance();
XPathModel.getDefault();
UnitedServerListenerManager.getDefault();
}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,118 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.server.core.IEnterpriseApplication;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
-import org.jboss.ide.eclipse.as.core.modules.ModulePackageTypeConverter;
-
-/**
- * @author rob.stryker(a)redhat.com
- */
-public class EarArchiveType extends J2EEArchiveType {
- public final static String ID = "org.jboss.ide.eclipse.as.core.packages.earPackageType";
- public String getAssociatedModuleType() {
- return "jst.ear";
- }
-
- public String getId() {
- return ID;
- }
-
- public String getLabel() {
- return "EAR";
- }
-
-
- public IArchive createDefaultConfiguration(String project, IProgressMonitor monitor) {
- IModule mod = getModule(project);
- if( mod != null )
- return createDefaultConfigFromModule(mod, monitor);
- else
- return createDefaultConfiguration2(project, monitor);
- }
-
- public IArchive createDefaultConfiguration2(String projectName,
- IProgressMonitor monitor) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".ear");
- topLevel.setDestinationPath(new Path(project.getName()));
- topLevel.setInWorkspace(true);
-
- fillDefaultConfiguration(projectName, topLevel, monitor);
- return topLevel;
- }
-
- public IArchive createDefaultConfigFromModule(IModule module,
- IProgressMonitor monitor) {
- IProject project = module.getProject();
- IContainer sourceContainer = project.getFolder(EARCONTENT);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".ear", sourceContainer);
- topLevel.setDestinationPath(new Path(project.getName()));
- topLevel.setInWorkspace(true);
-
- fillDefaultConfiguration(project.getName(), topLevel, monitor);
- return topLevel;
- }
-
- public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel, IProgressMonitor monitor) {
- try {
- IModule mod = getModule(projectName);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-
- if( mod == null ) {
- // add fileset
- IArchiveFolder metainf = addFolder(project, topLevel, METAINF);
- addFileset(project, metainf, new Path(projectName).append(METAINF).toOSString(), null);
-
- } else {
- // now add children
- addFileset(project, topLevel, new Path(project.getName()).append(EARCONTENT).toOSString(), "**/*.*");
- IEnterpriseApplication earModule = (IEnterpriseApplication)mod.loadAdapter(IEnterpriseApplication.class, monitor);
- IModule[] childModules = earModule.getModules();
- for( int i = 0; i < childModules.length; i++ ) {
- IModule child = childModules[i];
- IArchiveType type = ModulePackageTypeConverter.getPackageTypeFor(child);
- IArchive childPack;
- if( type == null ) {
- childPack = createGenericIArchive(child.getProject(), null, child.getProject().getName() + ".jar");
- } else {
- childPack = type.createDefaultConfiguration(child.getProject().getName(), new NullProgressMonitor());
- }
- topLevel.addChild(childPack);
- }
- }
-
- } catch( ArchivesModelException ame) {}
- return topLevel;
- }
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,81 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-
-/**
- *
- * @author rob.stryker(a)redhat.com
- */
-public class EjbArchiveType extends J2EEArchiveType {
-
- public final static String ID = "org.jboss.ide.eclipse.as.core.packages.ejbPackageType";
- public String getAssociatedModuleType() {
- return "jst.ejb";
- }
-
- public String getId() {
- return ID;
- }
-
- public String getLabel() {
- return "EJB JAR";
- }
-
- public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor) {
- IProject project = getProject(projectName);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".jar");
- return fillDefaultConfiguration(project, topLevel, monitor);
- }
-
- public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel, IProgressMonitor monitor) {
- return fillDefaultConfiguration(getProject(projectName), topLevel, monitor);
- }
- public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel, IProgressMonitor monitor) {
-
- IModule mod = getModule(project.getName());
-
- if( mod == null ) {
- // TODO fix me
- } else {
- if( mod.getModuleType().getId().equals("jst.ejb") ) {
- try {
- IJavaProject proj = JavaCore.create(project);
- IPath outputLoc = proj.getOutputLocation();
- addFileset(project, topLevel, outputLoc.toOSString(), null);
- } catch( JavaModelException jmde) {
- } catch( ArchivesModelException ame ) {}
- }
- }
- return topLevel;
- }
-
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,163 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public abstract class J2EEArchiveType implements IArchiveType {
- public static final String METAINF = "META-INF";
- public static final String WEBINF = "WEB-INF";
- public static final String CLASSES = "classes";
- public static final String LIB = "lib";
- public static final String WEBCONTENT = "WebContent";
- public static final String EARCONTENT = "EarContent";
- public static final String EJBMODULE = "ejbModule";
-
-
- protected boolean isModuleType(IModule module, String moduleTypeId){
- if(module.getModuleType()!=null && moduleTypeId.equals(module.getModuleType().getId()))
- return true;
- return false;
- }
-
- protected IModule getModule(String projectName) {
- IModuleArtifact moduleArtifacts[] = ServerPlugin.getModuleArtifacts(getProject(projectName));
-
- if (moduleArtifacts != null && moduleArtifacts.length > 0)
- return moduleArtifacts[0].getModule();
- else return null;
- }
-
- protected IProject getProject(String projectName) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
- // Find the source folder, then create the IPackage appropriately
- public static IArchive createGenericIArchive(IProject project, String deployDirectory, String packageName) {
- try {
- IJavaProject javaProject = JavaCore.create(project);
- Assert.isNotNull(javaProject);
-
- IPath sourcePath;
- try {
- sourcePath = javaProject.getOutputLocation();
- } catch (JavaModelException e) {
- return null;
- }
- sourcePath = sourcePath.removeFirstSegments(1);
- IContainer sourcePathContainer;
- if( sourcePath.segmentCount() == 0 )
- sourcePathContainer = project;
- else
- sourcePathContainer = project.getFolder(sourcePath);
- return createGenericIArchive(project, deployDirectory, packageName, sourcePathContainer);
- } catch( Exception e ) {
- JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Unexpected Exception", e));
- }
- return null;
- }
-
- // Create a detached package with some generic settings
- public static IArchive createGenericIArchive(IProject project, String deployDirectory, String packageName, IContainer sourceContainer) {
- IArchive jar = ArchiveNodeFactory.createArchive();
-
- if( deployDirectory != null ) {
- jar.setDestinationPath(new Path(deployDirectory));
- jar.setInWorkspace(ResourcesPlugin.getWorkspace().getRoot().getLocation().isPrefixOf(new Path(deployDirectory)));
- jar.setExploded(false);
- } else {
- jar.setDestinationPath(project.getFullPath());
- jar.setInWorkspace(true);
- jar.setExploded(false);
- }
- jar.setName(packageName);
- return jar;
- }
-
-
- public static IArchiveFolder addFolder(IProject project,
- IArchiveNode parent, String name) throws ArchivesModelException {
- IArchiveFolder folder = ArchiveNodeFactory.createFolder();
- folder.setName(name);
- parent.addChild(folder);
- return folder;
- }
- public static IArchiveFileSet addFileset(IProject project, IArchiveNode parent,
- String sourcePath, String includePattern) throws ArchivesModelException {
- IArchiveFileSet fs = ArchiveNodeFactory.createFileset();
- Assert.isNotNull(project);
- IJavaProject javaProject = JavaCore.create(project);
- Assert.isNotNull(javaProject);
-
- IContainer sourceContainer;
- if( sourcePath != null && !sourcePath.equals("")) {
- Path p = new Path(sourcePath);
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- sourceContainer = p.segmentCount() != 1 ? (IContainer)root.getFolder(p) : root.getProject(p.segment(0));
- } else {
- sourceContainer = project;
- }
-
- fs.setRawSourcePath(sourceContainer.getFullPath().toString());
- fs.setInWorkspace(true);
- fs.setIncludesPattern( includePattern == null ? "**/*" : includePattern );
- parent.addChild(fs);
- return fs;
- }
-
- public abstract String getAssociatedModuleType();
-
- /*
- * Creates a directory scanner for some global path
- */
- public static DirectoryScannerExtension createDirectoryScanner (String rawPath, String includes, String excludes, boolean scan) {
- return DirectoryScannerFactory.createDirectoryScanner(rawPath, null, includes, excludes, null, false, 1, scan);
- }
-
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,246 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-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.jst.server.core.IWebModule;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
-import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class WarArchiveType extends J2EEArchiveType {
- public static final String WAR_PACKAGE_TYPE = "org.jboss.ide.eclipse.as.core.packages.warPackage";
-
- public String getAssociatedModuleType() {
- return "jst.web";
- }
-
- public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor) {
- IModule mod = getModule(projectName);
- if( mod == null )
- return createDefaultConfiguration2(projectName, monitor);
- else
- return createDefaultConfigFromModule(mod, monitor);
- }
-
- protected IArchive createDefaultConfiguration2(String projectName, IProgressMonitor monitor) {
- IProject project = getProject(projectName);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".war");
- return fillDefaultConfiguration(project, topLevel, monitor);
- }
-
- public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel, IProgressMonitor monitor) {
- return fillDefaultConfiguration(getProject(projectName), topLevel, monitor);
- }
- public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel, IProgressMonitor monitor) {
- try {
- IModule mod = getModule(project.getName());
- IArchiveFolder webinf = addFolder(project, topLevel, WEBINF);
- IArchiveFolder lib = addFolder(project, webinf, LIB);
- IArchiveFolder classes = addFolder(project, webinf, CLASSES);
- addReferencedProjectsAsLibs(project, lib);
- addLibFileset(project, lib, true);
- addClassesFileset(project, classes);
-
- if( mod == null ) {
- addWebinfFileset(project, webinf);
- } else {
- addWebContentFileset(project, topLevel);
- }
- } catch( ArchivesModelException ame) {}
- return topLevel;
- }
-
- // For modules only
- protected void addWebContentFileset(IProject project, IArchiveNode packageRoot) throws ArchivesModelException {
- try {
- IPath projectPath = project.getLocation();
- DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(), "**/WEB-INF/web.xml", null, true);
- String[] files = scanner.getIncludedFiles();
- // just take the first
- if( files.length > 0 ) {
- IPath path = new Path(files[0]);
- path = path.removeLastSegments(2); // remove the file name
- path = new Path(project.getName()).append(path); // pre-pend project name to make workspace-relative
- IArchiveFileSet fs = addFileset(project, packageRoot, path.toOSString(), "**/*");
- //If we have separate file set for libraries, we do not need to duplicate jars.
- fs.setExcludesPattern("**/WEB-INF/lib/*.jar");
- }
- } catch( IllegalStateException ise ) {
- IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, "Directory could not be scanned", ise);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
-
- protected void addClassesFileset(IProject project, IArchiveFolder folder) throws ArchivesModelException {
- IJavaProject jp = JavaCore.create(project);
- if( jp != null ) {
- try {
- IPath outputLoc = project.getWorkspace().getRoot().getLocation();
- outputLoc = outputLoc.append(jp.getOutputLocation());
- addFileset(project, folder, jp.getOutputLocation().toOSString(), "**/*");
- } catch( JavaModelException jme ) {
- // no logging
- }
- }
- }
- protected void addWebinfFileset(IProject project, IArchiveFolder folder) throws ArchivesModelException {
- try {
- IPath projectPath = project.getLocation();
- DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(), "**/web.xml", null, true);
- String[] files = scanner.getIncludedFiles();
- // just take the first
- if( files.length > 0 ) {
- IPath path = new Path(files[0]);
- path = path.removeLastSegments(1); // remove the file name
- path = new Path(project.getName()).append(path); // pre-pend project name to make workspace-relative
- addFileset(project, folder, path.toOSString(), "**/*");
- }
- } catch( IllegalStateException ise ) {
- IStatus status = new Status(IStatus.WARNING, ArchivesCorePlugin.PLUGIN_ID, "Directory could not be scanned", ise);
- ArchivesCorePlugin.getDefault().getLog().log(status);
- }
- }
-
- // Lib support
- protected void addLibFileset(IProject project, IArchiveFolder folder, boolean includeTopLevelJars) throws ArchivesModelException {
- // Let us find /WEB-INF/lib directory and set it as source for the file set.
- String sourcePath = null;
-
- IPath projectPath = project.getLocation();
- DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(), "**/WEB-INF/web.xml", null, true);
- String[] files = scanner.getIncludedFiles();
-
- if(files != null && files.length > 0) {
- IPath path = new Path(files[0]);
- path = path.removeLastSegments(1).append("lib");
- sourcePath = project.getFullPath().append(path).toString();
- addFileset(project, folder, sourcePath, "*.jar"); // add default jars
- } else {
- //having failed to find 'lib' directory, let us make source of the project itself
- sourcePath = project.getName();
- DirectoryScanner scanner2 = createDirectoryScanner(projectPath.toString(), "**/*.jar", null, true);
- String[] files2 = scanner2.getIncludedFiles();
- IPath p;
- ArrayList list = new ArrayList();
- for( int i = 0; i < files2.length; i++ ) {
- p = project.getFullPath().append(files2[i]).removeLastSegments(1);
- if( !list.contains(p)) {
- list.add(p);
- addFileset(project, folder, p.toString(), "*.jar"); // add default jars
- }
- }
- }
- }
- protected void addReferencedProjectsAsLibs(IProject project, IArchiveFolder folder) throws ArchivesModelException {
- IJavaProject jp = JavaCore.create(project);
- if( jp != null && jp.exists()) {
- try {
- IClasspathEntry[] entries = jp.getRawClasspath();
- for( int i = 0; i < entries.length; i++ ) {
- if( entries[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- IPath path = entries[i].getPath();
- IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- if( res instanceof IProject ) {
- createLibFromProject((IProject)res, folder);
- }
- }
- }
- } catch( JavaModelException jme ) {
- // no logging
- }
- }
- }
-
-
- protected void createLibFromProject(IProject project, IArchiveFolder folder) throws ArchivesModelException {
- IArchive pack = createGenericIArchive(project, null, project.getName() + ".jar");
- folder.addChild(pack);
- }
-
- protected IArchive createDefaultConfigFromModule(IModule mod, IProgressMonitor monitor) {
- try {
- IProject project = mod.getProject();
-
- // create the stub
- IArchive topLevel = createGenericIArchive(project, null, project.getName() + ".war");
- topLevel.setDestinationPath(new Path(project.getName()));
- topLevel.setInWorkspace(true);
-
- // add lib folder so we can add libraries
- IArchiveFolder webinf = addFolder(project, topLevel, WEBINF);
- IArchiveFolder lib = addFolder(project, webinf, LIB);
- IArchiveFolder classes = addFolder(project, webinf, CLASSES);
-
-
- IVirtualComponent vc = ComponentCore.createComponent(project);
- IPath webContentPath = vc.getRootFolder().getUnderlyingFolder().getFullPath();
- addFileset(project, topLevel, webContentPath.toOSString(), "**/*");
- addClassesFileset(project, classes);
-
- // package each child and add to lib folder
- IWebModule webModule = (IWebModule)mod.loadAdapter(IWebModule.class, monitor);
- IModule[] childModules = webModule.getModules();
- for (int i = 0; i < childModules.length; i++) {
- IModule child = childModules[i];
- lib.addChild(createGenericIArchive(child.getProject(), null, child.getProject().getName() + ".jar"));
- }
- return topLevel;
- } catch( Exception e ) {
- JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Unexpected Exception", e));
- }
- return null;
- }
-
- public String getId() {
- return WAR_PACKAGE_TYPE;
- }
-
- public String getLabel() {
- return "WAR";
- }
-}
\ No newline at end of file
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,215 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveBuildListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
-import org.jboss.ide.eclipse.as.core.util.FileUtil;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class ArchivesBuildListener implements IArchiveBuildListener, IArchiveModelListener {
-
- public static ArchivesBuildListener instance;
- public static final String DEPLOY_SERVERS = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployServers";
- public static final String DEPLOY_AFTER_BUILD = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployAfterBuild";
-
- public static ArchivesBuildListener getInstance() {
- if( instance == null ) {
- instance = new ArchivesBuildListener();
- }
- return instance;
- }
-
- public ArchivesBuildListener() {
- ArchivesModel.instance().addBuildListener(this);
- ArchivesModel.instance().addModelListener(this); // ? , ArchivesModel.LIST_FRONT);
- }
-
- public void cleanArchive(IArchive pkg) {
- }
-
-
- public void finishedBuildingArchive(IArchive pkg) {
- if( pkg.isTopLevel() && new Boolean(pkg.getProperty(DEPLOY_AFTER_BUILD)).booleanValue()) {
- publish(pkg);
- }
- }
-
- public void fileRemoved(IArchive topLevelPackage, IArchiveFileSet fileset, IPath filePath) {
- }
- public void fileUpdated(IArchive topLevelPackage, IArchiveFileSet fileset, IPath filePath) {
- }
-
- // If we're supposed to auto-deploy, get on it
- protected static void publish(IArchive pkg) {
- String servers = pkg.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
- publish(pkg, servers, IServer.PUBLISH_INCREMENTAL);
- }
- public static void publish(IArchive pkg, String servers, int publishType) {
- IModule[] module = getModule(pkg);
- if( module[0] == null ) return;
- DeployableServerBehavior[] serverBehaviors = ArchivesBuildListener.getServers(servers);
- if( serverBehaviors != null ) {
- for( int i = 0; i < serverBehaviors.length; i++ ) {
- publish(serverBehaviors[i].getServer(), publishType, module );
- }
- }
- }
-
- protected static IStatus publish(IServer server, int publishType, IModule[] module ) {
- try {
- IServerWorkingCopy copy = server.createWorkingCopy();
- copy.modifyModules(module, new IModule[0], new NullProgressMonitor());
- IServer saved = copy.save(false, new NullProgressMonitor());
- saved.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
- } catch( CoreException ce ) {
- return new Status(Status.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "Cannot deploy file " + module[0].getName(), ce);
- }
- return Status.OK_STATUS;
-
- }
- protected static IModule[] getModule(IArchive node) {
- ModuleFactory factory = ServerPlugin.findModuleFactory("org.jboss.ide.eclipse.as.core.PackageModuleFactory");
- IModule mod = factory.findModule(PackageModuleFactory.getID(node), new NullProgressMonitor());
- return new IModule[] { mod };
- }
- protected static PackagedModuleDelegate getModuleDelegate(IArchive node) {
- IModule mod = getModule(node)[0];
- return (PackagedModuleDelegate)mod.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
- }
-
- protected IDeployableServer getDeployableServerFromBehavior(DeployableServerBehavior dsb) {
- IServer server = dsb.getServer();
- IDeployableServer ids = (IDeployableServer)server.loadAdapter(IDeployableServer.class, new NullProgressMonitor());
- return ids;
- }
-
- public static DeployableServerBehavior[] getServers(String servers) {
- if( servers == null || "".equals(servers))
- return null;
- ArrayList<DeployableServerBehavior> list = new ArrayList<DeployableServerBehavior>();
- String[] byId = servers.split(",");
- for( int i = 0; i < byId.length; i++ ) {
- IServer server = ServerCore.findServer(byId[i]);
- if( server != null ) {
- Object o = server.loadAdapter(DeployableServerBehavior.class, new NullProgressMonitor());
- if( o != null ) {
- list.add((DeployableServerBehavior)o);
- }
- }
- }
- return list.toArray(new DeployableServerBehavior[list.size()]);
- }
-
- /*
- * If a node is changing from exploded to imploded, or vice versa
- * make sure to delete the pre-existing file or folder on the server.
- */
- public void packageBuildTypeChanged(IArchive topLevelPackage, boolean isExploded) {
- String servers = topLevelPackage.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
- DeployableServerBehavior[] serverBehaviors = ArchivesBuildListener.getServers(servers);
- if( serverBehaviors != null ) {
- IPath sourcePath, destPath;
- IDeployableServer depServer;
- for( int i = 0; i < serverBehaviors.length; i++ ) {
- sourcePath = topLevelPackage.getArchiveFilePath();
- depServer = getDeployableServerFromBehavior(serverBehaviors[i]);
- destPath = new Path(depServer.getDeployDirectory()).append(sourcePath.lastSegment());
- FileUtil.safeDelete(destPath.toFile());
- FileUtil.fileSafeCopy(sourcePath.toFile(), destPath.toFile());
- }
- }
- }
-
- public void buildFailed(IArchive pkg, IStatus status) {
- // TODO Auto-generated method stub
-
- }
-
- public void finishedBuild(IPath project) {
- // TODO Auto-generated method stub
-
- }
-
- public void finishedCollectingFileSet(IArchiveFileSet fileset) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedBuild(IPath project) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedBuildingArchive(IArchive pkg) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedCollectingFileSet(IArchiveFileSet fileset) {
- // TODO Auto-generated method stub
- }
- public void startedBuildingPackage(IArchive pkg) {
- // TODO Auto-generated method stub
- }
-
- public void cleanProject(IPath project) {
- }
-
- public void modelChanged(IArchiveNodeDelta delta) {
- IPath p ;
- if( delta.getPreNode() == null )
- p = delta.getPostNode().getProjectPath();
- else
- p = delta.getPreNode().getProjectPath();
-
- ArchivesModelModuleContributor.getInstance().refreshProject(p);
- }
-
-
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,185 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.IModuleContributor;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
-
-/**
- *
- * @author Rob Stryker rob.stryker(a)jboss.com
- *
- */
-public class ArchivesModelModuleContributor implements IModuleContributor {
-
- private static ArchivesModelModuleContributor instance;
- public static ArchivesModelModuleContributor getInstance() {
- if( instance == null ) {
- instance = new ArchivesModelModuleContributor(PackageModuleFactory.getFactory());
- }
- return instance;
- }
-
- private PackageModuleFactory factory;
- protected ArrayList<IModule> modules = null;
- protected HashMap<IPath, ArrayList<IModule>> projectToModules = new HashMap<IPath, ArrayList<IModule>>(5); //IPath to IModule
- protected HashMap<IModule, Object> moduleDelegates = new HashMap<IModule, Object>(5);
- protected HashMap<IArchive, IModule> packageToModule = new HashMap<IArchive, IModule>(5);
-
- private ArchivesModelModuleContributor(PackageModuleFactory factory) {
- this.factory = factory;
- }
-
- public IModule[] getModules() {
- if( modules == null ) {
- modules = new ArrayList<IModule>();
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- int size = projects2.length;
- for (int i = 0; i < size; i++) {
- if (projects2[i].isAccessible()) {
-
- if( !ArchivesModel.instance().isProjectRegistered(projects2[i].getLocation())) {
- if( ArchivesModel.instance().canReregister(projects2[i].getLocation()))
- // registration should also add this to the factory manually, so do not create the module
- ArchivesModel.instance().registerProject(projects2[i].getLocation(), new NullProgressMonitor());
- } else {
- try {
- // project is already registered. create the module
- createModules(projects2[i]);
- } catch(ArchivesModelException ame) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ame.getMessage(), ame);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
- }
- }
- }
- return modules.toArray(new IModule[modules.size()]);
- }
-
- protected void createModules(IProject project) throws ArchivesModelException {
- IArchive[] packages = ModelUtil.getProjectArchives(project.getLocation());
- if( packages != null && packages.length > 0 ) {
- IModule module;
- boolean requiresSave = ensureArchivesHaveIDs(project, packages);
- ArrayList<IModule> mods = new ArrayList<IModule>();
- for( int i = 0; i < packages.length; i++ ) {
- module = factory.createModule2(packages[i], project);
- modules.add(module);
- Object moduleDelegate = new PackagedModuleDelegate(packages[i]);
- packageToModule.put(packages[i], module);
- moduleDelegates.put(module, moduleDelegate);
- mods.add(module);
- }
- projectToModules.put(project.getLocation(), mods);
- if( requiresSave ) {
- try {
- ArchivesModel.instance().save(project.getLocation(),
- new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- }
- }
- }
- }
-
- public boolean containsModule(IModule module) {
- return moduleDelegates.containsKey(module);
- }
-
- public PackagedModuleDelegate getModuleDelegate(IModule module) {
- return (PackagedModuleDelegate)moduleDelegates.get(module);
- }
-
- public void refreshProject(IPath projectLoc) {
- // prime, make sure all are found
- if( modules == null )
- getModules();
-
- // remove old mods
- ArrayList<IModule> mods = projectToModules.get(projectLoc);
- IModule mod;
- PackagedModuleDelegate delegate;
- if (mods != null) {
- for( Iterator<IModule> i = mods.iterator(); i.hasNext();) {
- mod = (IModule)i.next();
- if( modules.contains(mod)) {
- delegate = ((PackagedModuleDelegate)moduleDelegates.get(mod));
- moduleDelegates.remove(mod);
- modules.remove(mod);
- if( delegate != null )
- packageToModule.remove(delegate.getPackage());
- }
- }
- }
- try {
- createModules(findProject(projectLoc));
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ame.getMessage(), ame);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
-
- protected IProject findProject(IPath projectLoc) {
- IProject proj = null;
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- int size = projects2.length;
- for (int i = 0; i < size; i++) {
- if( projects2[i].getLocation().equals(projectLoc))
- proj = projects2[i];
- }
- return proj;
- }
-
- /**
- * Set a property so that each module that's here in the factory
- * has a unique ID other than it's name (which is not unique)
- * @param archives
- * @return returns whether a save has occurred
- */
- protected boolean ensureArchivesHaveIDs(IProject project, IArchive[] archives) {
- boolean requiresSave = false;
- for( int i = 0; i < archives.length; i++ ) {
- if( PackageModuleFactory.getID(archives[i]) == null ) {
- requiresSave = true;
- archives[i].setProperty(PackageModuleFactory.MODULE_ID_PROPERTY_KEY,
- PackageModuleFactory.getID(archives[i], true));
- }
- }
- return requiresSave;
- }
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,48 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
-import org.jboss.ide.eclipse.as.core.extensions.archives.EarArchiveType;
-import org.jboss.ide.eclipse.as.core.extensions.archives.EjbArchiveType;
-import org.jboss.ide.eclipse.as.core.extensions.archives.WarArchiveType;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class ModulePackageTypeConverter {
- public static IArchiveType getPackageTypeFor(IModule module) {
- String modType = module.getModuleType().getId();
- if("jst.web".equals(modType)) {
- return ArchivesCore.getInstance().getExtensionManager().getArchiveType(WarArchiveType.WAR_PACKAGE_TYPE);
- } else if("jst.ear".equals(modType)) {
- return ArchivesCore.getInstance().getExtensionManager().getArchiveType(EarArchiveType.ID);
- } else if("jst.ejb".equals(modType)) {
- return ArchivesCore.getInstance().getExtensionManager().getArchiveType(EjbArchiveType.ID);
- }
-
- return null;
- }
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,412 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.eclipse.wst.server.core.model.IModuleFile;
-import org.eclipse.wst.server.core.model.IModuleFolder;
-import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.model.ModuleDelegate;
-import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
-import org.eclipse.wst.server.core.util.ModuleFile;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.archives.core.util.PathUtils;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class PackageModuleFactory extends ModuleFactoryDelegate {
-
- public static final String FACTORY_TYPE_ID = "org.jboss.ide.eclipse.as.core.PackageModuleFactory";
- public static final String MODULE_TYPE = "jboss.package";
- public static final String VERSION = "1.0";
-
- public static final String MODULE_ID_PROPERTY_KEY = "org.jboss.ide.eclipse.as.core.packages.ModuleIDPropertyKey";
-
- // the factory delegate and the factory respectively
- private static PackageModuleFactory factDelegate;
- private static ModuleFactory factory;
-
- /**
- * Find the module factory wrapper WTP provides for us
- * @return
- */
- public static PackageModuleFactory getFactory() {
- if( factDelegate == null ) {
- ModuleFactory[] factories = ServerPlugin.getModuleFactories();
-
- for( int i = 0; i < factories.length; i++ ) {
- if( factories[i].getId().equals(PackageModuleFactory.FACTORY_TYPE_ID)) {
- Object o = factories[i].getDelegate(new NullProgressMonitor());
- if( o instanceof PackageModuleFactory ) {
- factory = factories[i];
- factDelegate = (PackageModuleFactory)o;
- return factDelegate;
- }
- }
- }
- }
- return factDelegate;
- }
-
- /**
- * Get the module ID of this IArchive if it exists.
- * Do not create a new one otherwise
- * @param pack
- * @return
- */
- public static String getID(IArchive pack) {
- return getID(pack, false);
- }
-
- /**
- * Get the module ID of this IArchive if it exists.
- * If create is true, and the ID is not set, set a default ID.
- * @param pack
- * @param create
- * @return
- */
- protected static String getID(IArchive pack, boolean create) {
- String propVal = pack.getProperty(MODULE_ID_PROPERTY_KEY);
- if( propVal == null && create ) {
- return "" + new Date().getTime();
- }
- return propVal;
- }
-
- /**
- * Return the name of the project in the workspace
- * @param node
- * @return
- */
- public static String getProjectName(IArchiveNode node) {
- IPath projPath = node.getProjectPath();
- if( projPath == null ) return null;
- IProject[] list = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for( int i = 0; i < list.length; i++ )
- if( list[i].getLocation().equals(projPath))
- return list[i].getName();
- return null;
- }
-
- /**
- * Get the visible name of this module
- * @param pack
- * @return
- */
- public static String getName(IArchive pack) {
- return getProjectName(pack) + "/" + pack.getName();
- }
-
-
-
- protected ArchivesModelModuleContributor moduleContributor;
- public PackageModuleFactory() {
- super();
- }
-
- public void initialize() {
- moduleContributor = ArchivesModelModuleContributor.getInstance();
- }
-
- protected IModule createModule2(IArchive pack, IProject project) {
- return createModule(getID(pack), getName(pack), MODULE_TYPE, VERSION, project);
- }
-
- public IModule[] getModules(IProject project) {
- moduleContributor.refreshProject(project.getLocation());
- return super.getModules(project);
- }
- public IModule[] getModules() {
- return moduleContributor.getModules();
- }
-
- public ModuleDelegate getModuleDelegate(IModule module) {
- return moduleContributor.getModuleDelegate(module);
- }
-
- public static interface IModuleContributor {
- public IModule[] getModules();
- public boolean containsModule(IModule module);
- public PackagedModuleDelegate getModuleDelegate(IModule module);
- }
-
- public static interface IExtendedModuleResource extends IModuleResource {
- public IPath getSourcePath();
- public IArchiveNode getNode();
- // deep destination is the full path this resource represents, even if it's inside a jar
- public IPath getDeepDestination();
- // the concrete file this resource is part of... so the top most zipped jar or, if all is exploded, the file itself
- public IPath getConcreteDestFile();
- }
-
- public static class DelegateInitVisitor implements IArchiveNodeVisitor {
-
- private IArchive pack;
- private HashMap<IArchiveNode, ArchiveContainerResource> members; // node -> imoduleresource
- private HashMap<IPath, IArchiveNode> pathToNode; // path -> node
- public DelegateInitVisitor(IArchive pack) {
- this.pack = pack;
- reset();
- }
- public void reset() {
- members = new HashMap<IArchiveNode, ArchiveContainerResource>();
- pathToNode = new HashMap<IPath, IArchiveNode>();
- }
- public boolean visit(IArchiveNode node) {
- int type = node.getNodeType();
- if( type == IArchiveNode.TYPE_ARCHIVE && ((IArchive)node).isTopLevel()) {
- IPath rel = ((IArchive)node).getRootArchiveRelativePath();
- members.put(node, new ArchiveContainerResource(((IArchive)node).getName(), node, rel));
- pathToNode.put(rel, node);
- } else if( type == IArchiveNode.TYPE_ARCHIVE || type == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- String name = type == IArchiveNode.TYPE_ARCHIVE ? ((IArchive)node).getName() : ((IArchiveFolder)node).getName();
- // if we're any other archive or a folder, create us and add to parent
- IArchiveNode parent = node.getParent();
- ArchiveContainerResource parentAsResource = members.get(parent);
- IPath rel = node.getRootArchiveRelativePath();
- members.put(node, new ArchiveContainerResource(name, node, rel));
- pathToNode.put(rel, node);
- parentAsResource.addChild(members.get(node));
- } else if( type == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
- ArchiveContainerResource parentAsResource = members.get(node.getParent());
- parentAsResource.addFilesetAsChild((IArchiveFileSet)node);
- }
-
- return true;
- }
-
- public IModuleResource getRootResource() {
- return members.get(pack);
- }
-
- public IModuleResource getResourceForNode(IArchiveNode node) {
- return members.get(node);
- }
- }
-
- public static class ArchiveContainerResource implements IModuleFolder, IExtendedModuleResource {
-
- protected IPath moduleRelativePath;
- protected IPath fsRelative;
- protected IArchiveNode node;
- protected String name;
- private HashMap<IPath, IModuleResource> members;
-
- // represents source folder on disk. only used if node is fileset
-// private IPath folderGlobalPath = null;
- public ArchiveContainerResource(String name,IArchiveNode node,IPath moduleRelativePath ) {
- this.name = name;
- this.node = node;
- this.moduleRelativePath = moduleRelativePath;
- members = new HashMap<IPath, IModuleResource>();
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
- fsRelative = moduleRelativePath.removeFirstSegments(node.getParent().getRootArchiveRelativePath().segmentCount());
- }
- }
-
- public int hashCode() {
- return name.hashCode() * 37 + moduleRelativePath.hashCode();
- }
-
- public boolean equals(Object other) {
- if (other instanceof IModuleFolder) {
- IModuleFolder resource = (IModuleFolder) other;
- return resource.getModuleRelativePath().equals(getModuleRelativePath());
- }
- return false;
- }
-
- public void addChild(IModuleResource resource) {
- members.put(resource.getModuleRelativePath(), resource);
- }
-
- public void removeChild(IPath moduleRelativePath) {
- members.remove(moduleRelativePath);
- }
- public IModuleResource getChild(IPath path) {
- return members.get(path);
- }
-
- public void addFilesetAsChild(IArchiveFileSet fs) {
- FileWrapper[] files = fs.findMatchingPaths(); // file-system based source paths
- for( int i = 0; i < files.length; i++ ) {
- addFilesetPathAsChild(fs, files[i]);
- }
- }
-
- public void addFilesetPathAsChild(IArchiveFileSet fs, FileWrapper file) {
- IPath fsRelative = new Path(file.getFilesetRelative());
- ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), true);
- ExtendedModuleFile emf = new ExtendedModuleFile(file, fs);
- parent.addChild(emf);
- }
-
- protected ArchiveContainerResource find(IArchiveFileSet fs, IPath fsRelative, boolean create) {
- ArchiveContainerResource resource = this;
- ArchiveContainerResource tmpResource;
- IPath tmpPath = fs.getRootArchiveRelativePath();
- int count = fsRelative.segmentCount();
- for( int i = 0; i < count; i++ ) {
- tmpPath = tmpPath.append(fsRelative.segment(i));
- tmpResource = (ArchiveContainerResource)resource.getChild(tmpPath);
- if( tmpResource == null ) {
- if( !create )
- return null;
- tmpResource = new ArchiveContainerResource(tmpPath.lastSegment(), fs, tmpPath);
- resource.addChild(tmpResource);
- }
- resource = tmpResource;
- }
- return resource;
- }
-
- public IModuleResource[] members() {
- Collection<IModuleResource> c = members.values();
- return c.toArray(new IModuleResource[c.size()]);
- }
-
- public IPath getModuleRelativePath() {
- return moduleRelativePath;
- }
-
- public String getName() {
- return name;
- }
-
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- public IPath getDeepDestination() {
- IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET
- ? moduleRelativePath : node.getRootArchiveRelativePath();
- return PathUtils.getGlobalLocation(node.getRootArchive()).append(tmp);
- }
-
- public IPath getConcreteDestFile() {
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET )
- return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node,fsRelative);
- else
- return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node);
- }
- public IArchiveNode getNode() {
- return node;
- }
-
- public IPath getSourcePath() {
- return null;
- }
-
- }
-
- public static class ExtendedModuleFile extends ModuleFile implements IExtendedModuleResource {
- private FileWrapper wrapper;
- private IArchiveFileSet node;
- public ExtendedModuleFile(FileWrapper wrapper, IArchiveFileSet fs) {
- super(wrapper.getOutputName(), wrapper.getRootArchiveRelative(), wrapper.lastModified());
- this.node = fs;
- this.wrapper = wrapper;
- }
- public int hashCode() {
- return getName().hashCode() * 37 + getPath().hashCode();
- }
-
- public IPath getPath() { return new Path(wrapper.getAbsolutePath()); }
- public IArchiveNode getNode() { return node; }
- public IPath getDeepDestination() {
- return PathUtils.getGlobalLocation(node.getRootArchive()).append(wrapper.getRootArchiveRelative());
- }
- public IPath getSourcePath() {
- return new Path(this.wrapper.getAbsolutePath());
- }
-
- public IPath getConcreteDestFile() {
- return ModelUtil.getBaseDestinationFile(node, new Path(this.wrapper.getFilesetRelative()));
- }
-
- public boolean equals(Object other) {
- if (other instanceof IModuleFile) {
- IModuleFile resource = (IModuleFile) other;
- return resource.getModuleRelativePath().equals(getModuleRelativePath());
- }
- return false;
- }
-
- }
-
- public static class PackagedModuleDelegate extends ModuleDelegate {
- private IArchive pack;
- private IModuleResource rootResource;
- private DelegateInitVisitor initVisitor;
- public PackagedModuleDelegate(IArchive pack) {
- this.pack = pack;
- initVisitor = new DelegateInitVisitor(pack);
- }
-
- public IArchive getPackage() {
- return pack;
- }
- public IModule[] getChildModules() {
- return new IModule[0];
- }
-
- protected void init() {
- initVisitor.reset();
- pack.accept(initVisitor);
- rootResource = initVisitor.getRootResource();
- }
-
- public IModuleResource[] members() throws CoreException {
- init();
- return new IModuleResource[] { rootResource };
- }
-
- public IStatus validate() {
- return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID,
- 0, "", null);
- }
- }
-
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,81 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
-import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate;
-/**
- *
- * @author Rob Stryker rob.stryker(a)redhat.com
- *
- */
-public class PackagedArtifactAdapter extends ModuleArtifactAdapterDelegate {
-
- public PackagedArtifactAdapter() {
- }
-
- public IModuleArtifact getModuleArtifact(Object obj) {
- if( obj instanceof IJavaProject ) {
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- boolean done = false;
- String jpName = ((IJavaProject)obj).getElementName();
- for( int i = 0; i < projects2.length && !done; i++ ) {
- if( projects2[i].getName().equals(jpName)) {
- done = true;
- obj = projects2[i];
- break;
- }
- }
- }
-
- if( obj instanceof IProject ) {
- PackageModuleFactory factory = PackageModuleFactory.getFactory();
- if( factory != null ) {
-// IModule[] mods = factory.getModulesFromProject((IProject)obj);
-// if( mods != null && mods.length != 0) {
-// return getArtifact(mods);
-// }
- }
- }
- return null;
- }
-
- protected IModuleArtifact getArtifact(IModule[] mod) {
- //return new PackagedArtifact(mod);
- // TODO Blocking on eclipse bug 174372
- return null;
- }
-
- public class PackagedArtifact implements IModuleArtifact{
- protected IModule mod;
- public PackagedArtifact(IModule module) {
- this.mod = module;
- }
- public IModule getModule() {
- return mod;
- }
- }
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -55,7 +55,6 @@
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
-import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
@@ -227,7 +226,8 @@
private IPath workspaceRelative;
public SingleDeployableModuleDelegate(IPath workspaceRelative) {
this.workspaceRelative = workspaceRelative;
- global = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(workspaceRelative);
+ IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(workspaceRelative);
+ global = res.getLocation();
}
public IModule[] getChildModules() {
return new IModule[0];
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -35,6 +35,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.DeletedModule;
@@ -73,16 +74,8 @@
protected int publishState = IServer.PUBLISH_STATE_NONE;
- public JstPublisher(IDeployableServer server, EventLogTreeItem context) {
- this.server = server;
- eventRoot = context;
+ public JstPublisher() {
}
- public JstPublisher(IServer server, EventLogTreeItem eventContext) {
- this( ServerConverter.getDeployableServer(server), eventContext);
- }
- public void setDelta(IModuleResourceDelta[] delta) {
- this.delta = delta;
- }
protected String getModulePath(IModule[] module ) {
String modulePath = "";
@@ -93,9 +86,14 @@
return modulePath;
}
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor monitor)
- throws CoreException {
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
IStatus status = null;
+ this.server = ServerConverter.getDeployableServer(server);
+ this.eventRoot = log;
+ this.delta = delta;
+
boolean deleted = false;
for( int i = 0; i < module.length; i++ ) {
if( module[i] instanceof DeletedModule )
@@ -103,7 +101,7 @@
}
if (publishType == REMOVE_PUBLISH ) {
- status = unpublish(server, module, monitor);
+ status = unpublish(this.server, module, monitor);
} else {
if( deleted ) {
publishState = IServer.PUBLISH_STATE_UNKNOWN;
@@ -395,4 +393,8 @@
}
return count;
}
+
+ public boolean accepts(IServer server, IModule[] module) {
+ return ModuleCoreNature.isFlexibleProject(module[0].getProject());
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -27,6 +27,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
/**
@@ -38,12 +39,13 @@
public int getPublishState() {
return IServer.PUBLISH_STATE_NONE;
}
-
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor monitor) throws CoreException {
- return null;
+ public boolean accepts(IServer server, IModule[] module) {
+ return true;
}
- public void setDelta(IModuleResourceDelta[] delta) {
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
+ return null;
}
-
}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -1,250 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.publishers;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleFile;
-import org.eclipse.wst.server.core.model.IModuleFolder;
-import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.util.PathUtils;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.ExtendedModuleFile;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.IExtendedModuleResource;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublisherFileUtilListener;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
-import org.jboss.ide.eclipse.as.core.util.FileUtil;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class PackagesPublisher implements IJBossServerPublisher {
-
- protected IDeployableServer server;
- protected IModuleResourceDelta[] delta;
- protected EventLogTreeItem eventRoot;
-
- public PackagesPublisher(IDeployableServer server, EventLogTreeItem eventContext) {
- this.server = server;
- eventRoot = eventContext;
- }
- public PackagesPublisher(IServer server, EventLogTreeItem eventContext) {
- this( ServerConverter.getDeployableServer(server), eventContext);
- }
- public void setDelta(IModuleResourceDelta[] delta) {
- this.delta = delta;
- }
-
-
- public int getPublishState() {
- return IServer.PUBLISH_STATE_NONE;
- }
-
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor monitor) throws CoreException {
- try {
- IModule module2 = module[0];
- // if it's being removed
- if( publishType == REMOVE_PUBLISH ) {
- removeModule(module2, monitor);
- } else if( publishType == FULL_PUBLISH ) {
- publishModule(module2, false, monitor);
- } else if( publishType == INCREMENTAL_PUBLISH ) {
- publishModule(module2, true, monitor);
- }
- }catch(Exception e) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Error during publish", e);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- return null;
- }
-
- protected void removeModule(IModule module, IProgressMonitor monitor) {
- IArchive pack = getPackage(module);
- // remove all of the deployed items
- if( pack != null ) {
- IPath sourcePath = pack.getArchiveFilePath();
- IPath destPath = new Path(server.getDeployDirectory()).append(sourcePath.lastSegment());
- // remove the entire file or folder
- PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
- FileUtil.safeDelete(destPath.toFile(), listener);
- }
- }
-
-
-
- protected void publishModule(IModule module, boolean incremental, IProgressMonitor monitor) {
- IArchive pack = getPackage(module);
- IPath sourcePath = pack.getArchiveFilePath();
- IPath destPathRoot = new Path(server.getDeployDirectory());
-
- // if destination is deploy directory... no need to re-copy!
- if( destPathRoot.toOSString().equals(PathUtils.getGlobalLocation(pack).toOSString())) {
- // fire null publish event
- return;
- }
-
- PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
- eventRoot.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, countChanges(delta));
- if( incremental ) {
- publishFromDelta(module, destPathRoot, sourcePath.removeLastSegments(1), delta, listener);
- } else {
- // full publish, copy whole folder or file
- FileUtil.fileSafeCopy(sourcePath.toFile(), destPathRoot.append(sourcePath.lastSegment()).toFile(), listener);
- }
- }
-
- protected void publishFromDelta(IModule module, IPath destPathRoot, IPath sourcePrefix,
- IModuleResourceDelta[] delta, PublisherFileUtilListener listener) {
- ArrayList<IPath> changedFiles = new ArrayList<IPath>();
- for( int i = 0; i < delta.length; i++ ) {
- publishFromDeltaHandle(delta[i], destPathRoot, sourcePrefix, changedFiles, listener);
- }
- }
-
- protected int countChanges(IModuleResourceDelta[] deltas) {
- IModuleResource res;
- int count = 0;
- if( deltas == null ) return 0;
- for( int i = 0; i < deltas.length; i++ ) {
- res = deltas[i].getModuleResource();
- if( res != null && res instanceof IModuleFile)
- count++;
- count += countChanges(deltas[i].getAffectedChildren());
- }
- return count;
- }
-
- protected int countConcreteFiles(IModule module) {
- PackagedModuleDelegate delegate = (PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
- try {
- ArrayList list = new ArrayList();
- countConcreteFiles(delegate.members()[0], list);
- return list.size();
- } catch( CoreException ce ) {
-
- }
- return -1;
- }
- protected void countConcreteFiles(IModuleResource mr, ArrayList list) {
- if( mr instanceof IExtendedModuleResource) {
- IExtendedModuleResource emr = ((IExtendedModuleResource)mr);
- if( mr instanceof IModuleFile ) {
- IPath p = emr.getConcreteDestFile();
- if( !list.contains(p))
- list.add(p);
- }
- if( mr instanceof IModuleFolder) {
- IModuleResource[] children = ((IModuleFolder)mr).members();
- for( int i = 0; i < children.length; i++ )
- countConcreteFiles(children[i], list);
- }
- }
- }
-
- protected void publishFromDeltaHandle(IModuleResourceDelta delta, IPath destRoot,
- IPath sourcePrefix, ArrayList<IPath> changedFiles, PublisherFileUtilListener listener) {
- switch( delta.getKind()) {
- case IModuleResourceDelta.REMOVED:
- // removed might not be IExtendedModuleResource
- IModuleResource imr = delta.getModuleResource();
- if( imr instanceof IExtendedModuleResource) {
- IExtendedModuleResource emr = ((IExtendedModuleResource)imr);
- IPath concrete = emr.getConcreteDestFile();
- if( !changedFiles.contains(concrete)) {
- IPath destPath = destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
-
- // file hasnt been updated yet.
- // But we don't know whether to delete or copy this file.
- // depends where it is in the tree and what's exploded.
- changedFiles.add(concrete);
- IPath concreteRelative = concrete.removeFirstSegments(sourcePrefix.segmentCount()).setDevice(null);
- IPath emrModRelative = emr.getModuleRelativePath();
- boolean delete = concreteRelative.equals(emrModRelative);
-
- if( delete ) {
- FileUtil.safeDelete(destPath.toFile(), listener);
- } else {
- // copy
- FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
- }
- }
- return;
- } else {
- // TODO
- return;
- }
- case IModuleResourceDelta.ADDED:
- imr = delta.getModuleResource();
- if( imr instanceof IExtendedModuleResource) {
- IPath concrete = ((IExtendedModuleResource)imr).getConcreteDestFile();
- if( !changedFiles.contains(concrete)) {
- changedFiles.add(concrete);
- IPath destPath = destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
- FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
- }
- return;
- } else {
- // TODO
- return;
- }
- case IModuleResourceDelta.CHANGED:
- imr = delta.getModuleResource();
- if( imr instanceof ExtendedModuleFile ) {
- IPath concrete = ((ExtendedModuleFile)imr).getConcreteDestFile();
- if( !changedFiles.contains(concrete)) {
- changedFiles.add(concrete);
- IPath destPath = destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
- FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
- }
- }
- break;
- }
-
- IModuleResourceDelta[] children = delta.getAffectedChildren();
- if( children != null ) {
- for( int i = 0; i < children.length; i++ ) {
- publishFromDeltaHandle(children[i], destRoot, sourcePrefix, changedFiles, listener);
- }
- }
- }
-
- protected IArchive getPackage(IModule module) {
- PackagedModuleDelegate delegate = (PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
- return delegate == null ? null : delegate.getPackage();
- }
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -30,28 +30,38 @@
private IDeployableServer server;
private EventLogTreeItem root;
private int publishState = IServer.PUBLISH_STATE_NONE;
- public SingleFilePublisher(IServer server, EventLogTreeItem root) {
- this.server = ServerConverter.getDeployableServer(server);
- this.root = root;
+ public SingleFilePublisher() {
}
public int getPublishState() {
return publishState;
}
+
+ public boolean accepts(IServer server, IModule[] module) {
+ if( module != null && module.length > 0
+ && module[module.length-1] != null
+ && module[module.length-1].getModuleType().getId().equals("jboss.singlefile"))
+ return true;
+ return false;
+ }
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor monitor)
- throws CoreException {
-
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
+
+ this.server = ServerConverter.getDeployableServer(server);
+ this.root = log;
+
IModule module2 = module[0];
IStatus status = null;
if(publishType == REMOVE_PUBLISH){
- status = unpublish(server, module2, monitor);
+ status = unpublish(this.server, module2, monitor);
} else if( publishType == FULL_PUBLISH ){
// if there's no change, do nothing. Otherwise, on change or add, re-publish
- status = publish(server, module2, true, monitor);
+ status = publish(this.server, module2, true, monitor);
} else if( publishType == INCREMENTAL_PUBLISH ) {
- status = publish(server, module2, false, monitor);
+ status = publish(this.server, module2, false, monitor);
}
root.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, new Integer(1));
return status;
@@ -97,9 +107,6 @@
return null;
}
- public void setDelta(IModuleResourceDelta[] delta) {
- // ignore delta
- }
public static class FileUtilListener implements IFileUtilListener {
protected EventLogTreeItem root;
@@ -128,6 +135,5 @@
EventLogModel.markChanged(root);
}
}
- };
-
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -25,7 +25,9 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
/**
*
@@ -38,8 +40,14 @@
public static final int FULL_PUBLISH = 2;
public static final int REMOVE_PUBLISH = 3;
- public IStatus publishModule(IModule[] module, int publishType,
- IProgressMonitor monitor) throws CoreException;
+ // pre-publish
+ public boolean accepts(IServer server, IModule[] module);
+
+
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException;
+
+ // post publish
public int getPublishState();
- public void setDelta(IModuleResourceDelta[] delta);
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -24,18 +24,13 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory;
-import org.jboss.ide.eclipse.as.core.publishers.JstPublisher;
-import org.jboss.ide.eclipse.as.core.publishers.NullPublisher;
-import org.jboss.ide.eclipse.as.core.publishers.PackagesPublisher;
import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
-import org.jboss.ide.eclipse.as.core.publishers.SingleFilePublisher;
import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublishEvent;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.launch.DeployableLaunchConfiguration;
@@ -92,39 +87,30 @@
int publishType = getPublishType(kind, deltaKind, modulePublishState);
IJBossServerPublisher publisher;
-
if( module.length > 0 && publishType != IJBossServerPublisher.NO_PUBLISH) {
Integer i,j;
i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_MODULE_COUNT);
publishRootEvent.setProperty(PublisherEventLogger.CHANGED_MODULE_COUNT, new Integer(i == null ? 1 : i.intValue()+1));
PublishEvent modulePublishEvent = PublisherEventLogger.createModuleRootEvent(publishRootEvent, module, kind, deltaKind, modulePublishState);
- IModule lastMod = module[module.length -1];
- if( isPackagesTypeModule(lastMod) ) {
- publisher = new PackagesPublisher(getServer(), modulePublishEvent);
- } else if( lastMod.getModuleType().getId().equals("jboss.singlefile")){
- publisher = new SingleFilePublisher(getServer(), modulePublishEvent);
- } else if( lastMod.getProject() != null &&
- ModuleCoreNature.isFlexibleProject(lastMod.getProject())) {
- publisher = new JstPublisher(getServer(), modulePublishEvent);
- } else {
- publisher = new NullPublisher();
+ publisher = ExtensionManager.getDefault().getPublisher(getServer(), module);
+ if( publisher != null ) {
+ try {
+ publisher.publishModule(getServer(), module, publishType,
+ getPublishedResourceDelta(module),
+ modulePublishEvent, monitor);
+ } catch( CoreException ce ) {
+ throw ce;
+ } finally {
+ setModulePublishState(module, publisher.getPublishState());
+ }
+ // add file changed count to top level element
+ i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
+ j = (Integer)modulePublishEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
+ j = j == null ? new Integer(0) : j;
+ int count = (i == null ? 0 : i.intValue()) + j.intValue();
+ publishRootEvent.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, count);
}
- publisher.setDelta(getPublishedResourceDelta(module));
- try {
- publisher.publishModule(module, publishType, monitor);
- } catch( CoreException ce ) {
- throw ce;
- } finally {
- setModulePublishState(module, publisher.getPublishState());
- }
-
- // add file changed count to top level element
- i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
- j = (Integer)modulePublishEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
- j = j == null ? new Integer(0) : j;
- int count = (i == null ? 0 : i.intValue()) + j.intValue();
- publishRootEvent.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, count);
}
}
@@ -141,10 +127,6 @@
return IJBossServerPublisher.NO_PUBLISH;
}
- protected boolean isPackagesTypeModule(IModule module) {
- return module.getModuleType().getId().equals(PackageModuleFactory.MODULE_TYPE);
- }
-
/*
* Change the state of the server
*/
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-08-23 00:24:20 UTC (rev 9876)
@@ -21,15 +21,8 @@
*/
package org.jboss.ide.eclipse.as.core.server.internal;
-import java.io.IOException;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.MBeanInfo;
import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import javax.management.ReflectionException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -41,15 +34,12 @@
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXRunnable;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXSafeRunner;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublishEvent;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.internal.launch.StopLaunchConfiguration;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-08-23 00:24:20 UTC (rev 9876)
@@ -4,6 +4,7 @@
<extension-point id="pollers" name="org.jboss.ide.eclipse.as.core.runtime.server.pollers" schema="schema/pollers.exsd"/>
<extension-point id="pollerFailureHandler" name="org.jboss.ide.eclipse.as.core.runtime.server.pollerFailureHandler" schema="schema/pollerFailureHandler.exsd"/>
+ <extension-point id="publishers" name="org.jboss.ide.eclipse.as.core.publishers" schema="schema/publishers.exsd"/>
<extension
point="org.eclipse.wst.server.core.serverTypes">
@@ -291,14 +292,6 @@
<extension
point="org.eclipse.wst.server.core.moduleFactories">
<moduleFactory
- class="org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory"
- id="org.jboss.ide.eclipse.as.core.PackageModuleFactory"
- projects="true">
- <moduleType
- types="jboss.package"
- versions="1.0"/>
- </moduleFactory>
- <moduleFactory
class="org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory"
id="org.jboss.ide.eclipse.as.core.singledeployablefactory"
projects="false">
@@ -309,26 +302,7 @@
</moduleFactory>
</extension>
-
-
-
- <!-- Adapters and clients to make stuff 'runnable' on server -->
<extension
- point="org.eclipse.wst.server.core.moduleArtifactAdapters">
- <moduleArtifactAdapter
- class="org.jboss.ide.eclipse.as.core.modules.PackagedArtifactAdapter"
- id="org.jboss.ide.eclipse.as.core.PackagedArtifactAdapter"
- priority="0">
- <enablement>
- <or>
- <instanceof value="org.eclipse.core.resources.IProject"/>
- <instanceof value="org.eclipse.jdt.core.IJavaProject"/>
- </or>
- </enablement>
- </moduleArtifactAdapter>
- </extension>
-
- <extension
point="org.eclipse.wst.server.core.launchableAdapters">
<launchableAdapter
class="org.jboss.ide.eclipse.as.core.server.internal.JBossLaunchAdapter"
@@ -482,29 +456,8 @@
</extension>
+
<extension
- point="org.eclipse.wst.server.core.moduleTypes">
- <moduleType
- id="jboss.package"
- name="Project Package"/>
- </extension>
-
- <extension
- point="org.jboss.ide.eclipse.archives.core.archiveTypes">
- <packageType
- class="org.jboss.ide.eclipse.as.core.extensions.archives.WarArchiveType"
- id="org.jboss.ide.eclipse.as.core.packages.warArchive"
- label="WAR"/>
- <packageType
- class="org.jboss.ide.eclipse.as.core.extensions.archives.EjbArchiveType"
- id="org.jboss.ide.eclipse.as.core.packages.ejbPackageType"
- label="EJB JAR"/>
- <packageType
- class="org.jboss.ide.eclipse.as.core.extensions.archives.EarArchiveType"
- id="org.jboss.ide.eclipse.as.core.packages.earPackageType"
- label="EAR"/>
- </extension>
- <extension
point="org.eclipse.jst.j2ee.classpathdep">
<filteredClasspathContainer
containerID="org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer">
@@ -598,4 +551,19 @@
</public>
</catalogContribution>
</extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishers">
+ <publisher
+ class="org.jboss.ide.eclipse.as.core.publishers.JstPublisher"
+ priority="5">
+ </publisher>
+ <publisher
+ class="org.jboss.ide.eclipse.as.core.publishers.SingleFilePublisher"
+ priority="5">
+ </publisher>
+ <publisher
+ class="org.jboss.ide.eclipse.as.core.publishers.NullPublisher"
+ priority="0">
+ </publisher>
+ </extension>
</plugin>
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd 2008-08-23 00:24:20 UTC (rev 9876)
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.ide.eclipse.as.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.ide.eclipse.as.core" id="publishers" name="org.jboss.ide.eclipse.as.core.publishers"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="publisher" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="publisher">
+ <complexType>
+ <attribute name="priority" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-08-23 00:24:20 UTC (rev 9876)
@@ -277,39 +277,6 @@
-->
<extension
- point="org.jboss.ide.eclipse.archives.ui.nodePopupMenus">
- <nodeContribution
- class="org.jboss.ide.eclipse.as.ui.packages.PublishAction"
- icon="icons/publish.gif"
- id="org.jboss.ide.eclipse.as.ui.publishNodeContextContrib"
- label="Publish To Server"
- weight="1"/>
- <nodeContribution
- class="org.jboss.ide.eclipse.as.ui.packages.EditPublishAction"
- icon="icons/publishDetails.gif"
- id="org.jboss.ide.eclipse.as.ui.modifyPublishNodeContextContrib"
- label="Edit publish settings...">
- </nodeContribution>
- </extension>
- <extension
- point="org.jboss.ide.eclipse.archives.ui.newArchiveActions">
- <newPackageAction
- class="org.jboss.ide.eclipse.as.ui.packages.NewWARAction"
- icon="icons/packages/war.gif"
- id="org.jboss.ide.eclipse.packages.ui.newWARAction"
- label="WAR"/>
- <newPackageAction
- class="org.jboss.ide.eclipse.as.ui.packages.NewEJBJARAction"
- icon="icons/packages/EJBJar.gif"
- id="org.jboss.ide.eclipse.packages.ui.newEJBJarAction"
- label="EJB JAR"/>
- <newPackageAction
- class="org.jboss.ide.eclipse.as.ui.packages.NewEARAction"
- icon="icons/packages/ear.gif"
- id="org.jboss.ide.eclipse.packages.ui.newEARAction"
- label="EAR"/>
- </extension>
- <extension
point="org.eclipse.help.contexts">
<contexts
file="InlineDocs/Twiddle/twiddleContext.xml">
Modified: trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml
===================================================================
--- trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml 2008-08-22 20:46:59 UTC (rev 9875)
+++ trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml 2008-08-23 00:24:20 UTC (rev 9876)
@@ -499,4 +499,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.jboss.ide.eclipse.archives.webtools"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
15 years, 8 months
JBoss Tools SVN: r9875 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-22 16:46:59 -0400 (Fri, 22 Aug 2008)
New Revision: 9875
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
Log:
JBIDE-2646 - null checks added
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2008-08-22 20:37:34 UTC (rev 9874)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2008-08-22 20:46:59 UTC (rev 9875)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.dom4j.Document;
import org.dom4j.Node;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
@@ -103,11 +104,13 @@
String[] files = getFilter().getIncludedFiles();
String fileLoc;
ArrayList<XPathFileResult> resultList = new ArrayList<XPathFileResult>();
- List<Node> nodeList;
+ List<Node> nodeList = null;
for( int i = 0; i < files.length; i++ ) {
fileLoc = new Path(baseDir).append(files[i]).toOSString();
- nodeList = getRepository().getDocument(fileLoc).selectNodes(xpathPattern);
- if( nodeList.size() > 0 )
+ Document d = getRepository().getDocument(fileLoc);
+ if( d != null )
+ nodeList = d.selectNodes(xpathPattern);
+ if( nodeList != null && nodeList.size() > 0 )
resultList.add(new XPathFileResult(this, fileLoc, nodeList));
}
results = resultList.toArray(new XPathFileResult[resultList.size()]);
15 years, 8 months
JBoss Tools SVN: r9874 - trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-22 16:37:34 -0400 (Fri, 22 Aug 2008)
New Revision: 9874
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
Log:
JBIDE-2665 - a few more tiny changes to make sure the selection listener was in top shape
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-22 20:30:51 UTC (rev 9873)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-22 20:37:34 UTC (rev 9874)
@@ -72,8 +72,7 @@
if( project != null && project != currentProject ) {
currentProject = project;
if( showProjectRoot()) {
- boolean showAll = PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS);
- if( !showAll || !getCommonViewer().getInput().equals(ResourcesPlugin.getWorkspace().getRoot()))
+ if( !showAllProjects() || !getCommonViewer().getInput().equals(ResourcesPlugin.getWorkspace().getRoot()))
getCommonViewer().setInput(ResourcesPlugin.getWorkspace().getRoot());
} else {
getCommonViewer().setInput(currentProject);
@@ -106,10 +105,15 @@
public IProject getCurrentProject() {
return currentProject;
}
- private boolean showProjectRoot () {
+
+ private boolean showProjectRoot() {
return PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT);
}
-
+
+ private boolean showAllProjects() {
+ return PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS);
+ }
+
public void addBuildActionToSite() {
Action buildAction = new Action("", ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_BUILD_PACKAGES)) {
public void run() {
15 years, 8 months
JBoss Tools SVN: r9873 - trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-22 16:30:51 -0400 (Fri, 22 Aug 2008)
New Revision: 9873
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
Log:
JBIDE-2665 - a few more tiny changes to make sure the selection listener was in top shape
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-22 20:14:53 UTC (rev 9872)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-22 20:30:51 UTC (rev 9873)
@@ -27,6 +27,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProviderDelegate.WrappedProject;
public class ProjectArchivesCommonView extends CommonNavigator {
protected static ProjectArchivesCommonView instance;
@@ -70,10 +71,13 @@
IProject project = getProject(element);
if( project != null && project != currentProject ) {
currentProject = project;
- if( showProjectRoot())
- getCommonViewer().setInput(ResourcesPlugin.getWorkspace().getRoot());
- else
+ if( showProjectRoot()) {
+ boolean showAll = PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS);
+ if( !showAll || !getCommonViewer().getInput().equals(ResourcesPlugin.getWorkspace().getRoot()))
+ getCommonViewer().setInput(ResourcesPlugin.getWorkspace().getRoot());
+ } else {
getCommonViewer().setInput(currentProject);
+ }
}
}
@@ -87,6 +91,12 @@
if( resource != null )
return resource.getProject();
}
+ if( element instanceof WrappedProject )
+ return ((WrappedProject)element).getElement();
+ if( element instanceof IArchiveNode ) {
+ String projName = ((IArchiveNode)element).getProjectName();
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
+ }
return null;
}
15 years, 8 months
JBoss Tools SVN: r9872 - trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-22 16:14:53 -0400 (Fri, 22 Aug 2008)
New Revision: 9872
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
Log:
JBIDE-2665 - reacting to each other, added view's selection action to not re-set the input if the project has not changed.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-22 19:59:25 UTC (rev 9871)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-22 20:14:53 UTC (rev 9872)
@@ -68,7 +68,7 @@
Object element = ((IStructuredSelection)selection).getFirstElement();
IProject project = getProject(element);
- if( project != null ) {
+ if( project != null && project != currentProject ) {
currentProject = project;
if( showProjectRoot())
getCommonViewer().setInput(ResourcesPlugin.getWorkspace().getRoot());
15 years, 8 months
JBoss Tools SVN: r9871 - trunk/as/features/org.jboss.ide.eclipse.as.feature.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-22 15:59:25 -0400 (Fri, 22 Aug 2008)
New Revision: 9871
Modified:
trunk/as/features/org.jboss.ide.eclipse.as.feature/feature.xml
Log:
JBIDE-2661 - firstrun removed
Modified: trunk/as/features/org.jboss.ide.eclipse.as.feature/feature.xml
===================================================================
--- trunk/as/features/org.jboss.ide.eclipse.as.feature/feature.xml 2008-08-22 14:10:39 UTC (rev 9870)
+++ trunk/as/features/org.jboss.ide.eclipse.as.feature/feature.xml 2008-08-22 19:59:25 UTC (rev 9871)
@@ -475,7 +475,6 @@
<import plugin="org.eclipse.jst.ws.axis.creation.ui"/>
<import plugin="org.eclipse.wst.ws"/>
<import plugin="org.eclipse.wst.ws.ui"/>
- <import plugin="org.jboss.ide.eclipse.firstrun"/>
<import plugin="org.jboss.ide.eclipse.archives.core"/>
<import plugin="org.apache.ant"/>
<import plugin="org.jboss.ide.eclipse.archives.ui"/>
15 years, 8 months