[jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/types ...
Robert Stryker
rob.stryker at jboss.com
Mon Apr 16 13:34:43 EDT 2007
User: rawb
Date: 07/04/16 13:34:43
Added: core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/types
IPackageType.java AbstractPackageType.java
JARPackageType.java
Log:
Complete rewrite of the the two plugins leading to a cleaner, leaner project.
Revision Changes Path
1.4 +0 -0 jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/types/IPackageType.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: IPackageType.java
===================================================================
RCS file: IPackageType.java
diff -N IPackageType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IPackageType.java 16 Apr 2007 17:34:43 -0000 1.4
@@ -0,0 +1,60 @@
+package org.jboss.ide.eclipse.packages.core.model.types;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.packages.core.model.IPackage;
+
+/**
+ * This interface represents a package type (i.e. JAR,WAR,SAR etc).
+ *
+ * A package type's main focus right now is to provide a default "template" Package for a given Project, making it easier
+ * for users and adopters to automatically adapt projects into a deployable package type.
+ *
+ * @author Marshall
+ */
+public interface IPackageType {
+
+ /**
+ * Represents full support for a project
+ */
+ public static final int SUPPORT_FULL = 0;
+
+ /**
+ * Represents no support for a project
+ */
+ public static final int SUPPORT_NONE = 1;
+
+ /**
+ * Represents conditional support for a project
+ */
+ public static final int SUPPORT_CONDITIONAL = 2;
+
+ /**
+ * @return The ID for this PackageType, i.e. "jar", "war" etc
+ */
+ public String getId();
+
+ /**
+ * @return The label for this PackageType (usually shown in UI)
+ */
+ public String getLabel();
+
+ /**
+ * This will create a "default" packaging configuration for this project using this package type.
+ *
+ * If the passed-in project does not support this package type, a null IPackage should be returned.
+ *
+ * @param project The project to create the packages configuration for
+ * @return The top level package that was created
+ */
+ public IPackage createDefaultConfiguration(IProject project, IProgressMonitor monitor);
+
+ /**
+ * This will return the type of support this package type has for the passed in project.
+ * The type of support can be FULL (should be no problems), NONE (this project is not supported),
+ * or CONDITIONAL (there might be some user input needed before the project supports this package type)
+ * @param project The project to check
+ * @return The support type this package type has for the project
+ */
+ public int getSupportFor (IProject project);
+}
1.6 +0 -0 jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/types/AbstractPackageType.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractPackageType.java
===================================================================
RCS file: AbstractPackageType.java
diff -N AbstractPackageType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AbstractPackageType.java 16 Apr 2007 17:34:43 -0000 1.6
@@ -0,0 +1,52 @@
+/**
+ * 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.packages.core.model.types;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.packages.core.model.IPackage;
+
+/**
+ *
+ * @author rob.stryker at jboss.com
+ */
+public abstract class AbstractPackageType implements IPackageType, IExecutableExtension {
+
+ private IConfigurationElement element;
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ if( element == null ) element = config;
+ }
+ public String getId() {
+ return element.getAttribute("id");
+ }
+
+ public String getLabel() {
+ return element.getAttribute("label");
+ }
+
+ public abstract int getSupportFor(IProject project);
+ public abstract IPackage createDefaultConfiguration(IProject project, IProgressMonitor monitor);
+
+}
1.11 +9 -11 jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/types/JARPackageType.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JARPackageType.java
===================================================================
RCS file: JARPackageType.java
diff -N JARPackageType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ JARPackageType.java 16 Apr 2007 17:34:43 -0000 1.11
@@ -0,0 +1,81 @@
+package org.jboss.ide.eclipse.packages.core.model.types;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.ide.eclipse.packages.core.Trace;
+import org.jboss.ide.eclipse.packages.core.model.IPackage;
+import org.jboss.ide.eclipse.packages.core.model.IPackageFileSet;
+import org.jboss.ide.eclipse.packages.core.model.internal.PackageFileSetImpl;
+import org.jboss.ide.eclipse.packages.core.model.internal.PackageImpl;
+
+/**
+ * The default JAR package type will simply jar-up all the classes in a java project's output directory, and place it in the top-level of the project.
+ * The name of the resulting JAR will be the project's name followed by a ".jar" extension.
+ * @author Marshall
+ */
+public class JARPackageType extends AbstractPackageType {
+
+ public static final String TYPE_ID = "jar";
+ public IPackage createDefaultConfiguration(IProject project, IProgressMonitor monitor) {
+ //IPackageType t = this;
+ Assert.isNotNull(project);
+
+ IJavaProject javaProject = JavaCore.create(project);
+ Assert.isNotNull(javaProject);
+
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Creating default JAR configuration for java project \"" + project.getName() + "\"", 2);
+
+ IPath outputPath;
+ try {
+ outputPath = javaProject.getOutputLocation();
+ } catch (JavaModelException e) {
+ Trace.trace(JARPackageType.class, e);
+ return null;
+ }
+
+ outputPath = outputPath.removeFirstSegments(1);
+ IContainer outputContainer = project.getFolder(outputPath);
+
+ IPackage jar = new PackageImpl();
+
+ jar.setDestinationPath(project.getLocation(), true);
+ jar.setExploded(false);
+ jar.setName(project.getName() + ".jar");
+ //jar.setPackageType(this);
+
+ IPackageFileSet classes = new PackageFileSetImpl();
+ classes.setIncludesPattern("**/*");
+ classes.setSourcePath(outputContainer.getLocation());
+
+ jar.addChild(classes);
+
+ monitor.worked(1);
+ monitor.done();
+
+ return jar;
+ }
+
+ public int getSupportFor(IProject project) {
+
+ try {
+ if (project.hasNature(JavaCore.NATURE_ID))
+ {
+ return IPackageType.SUPPORT_FULL;
+ }
+ } catch (CoreException e) {
+ Trace.trace(getClass(), e);
+ }
+
+ return IPackageType.SUPPORT_NONE;
+ }
+}
More information about the jboss-cvs-commits
mailing list