Author: rob.stryker(a)jboss.com
Date: 2009-04-10 06:06:23 -0400 (Fri, 10 Apr 2009)
New Revision: 14652
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.classpath
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.project
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.settings/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.settings/org.eclipse.jdt.core.prefs
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/META-INF/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/META-INF/MANIFEST.MF
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/build.properties
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/plugin.xml
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ArchiveJDTIntegrationPlugin.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/ArchiveLibFileSetImpl.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/DeltaLibFileset.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/IArchiveLibFileSet.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/LibFileSetNodeProvider.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/WorkspaceJARArchiveType.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/JDTArchivesActionProvider.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetInfoWizardPage.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetWizard.java
Log:
JBIDE-122 - separating out JDT dependency into its own plugin
Added: trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.classpath
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.classpath
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.classpath 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.project
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.project
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.project 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.ide.eclipse.archives.jdt.integration</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/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/.settings/org.eclipse.jdt.core.prefs 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,7 @@
+#Fri Apr 10 13:28:04 CST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/META-INF/MANIFEST.MF
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/META-INF/MANIFEST.MF 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Archives JDT Integration Plug-in
+Bundle-SymbolicName: org.jboss.ide.eclipse.archives.jdt.integration;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator:
org.jboss.ide.eclipse.archives.jdt.integration.ArchiveJDTIntegrationPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jdt.core;bundle-version="3.4.4",
+ org.eclipse.jdt.ui;bundle-version="3.4.2",
+ org.eclipse.core.resources;bundle-version="3.4.2",
+ org.jboss.ide.eclipse.archives.core;bundle-version="2.0.0",
+ org.jboss.ide.eclipse.archives.ui;bundle-version="1.0.0",
+ org.eclipse.ui.navigator;bundle-version="3.3.102"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.jboss.ide.eclipse.archives.jdt.integration.model,
+ org.jboss.ide.eclipse.archives.jdt.integration.ui
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/build.properties
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/build.properties
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/build.properties 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/plugin.xml
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/plugin.xml
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/plugin.xml 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.jboss.ide.eclipse.archives.core.nodeProvider">
+ <provider
+
class="org.jboss.ide.eclipse.archives.jdt.integration.model.LibFileSetNodeProvider">
+ </provider>
+ </extension>
+ <extension
+ point="org.jboss.ide.eclipse.archives.core.archiveTypes">
+ <packageType
+
class="org.jboss.ide.eclipse.archives.jdt.integration.model.WorkspaceJARArchiveType"
+ id="jar"
+ label="JAR"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <actionProvider
+
class="org.jboss.ide.eclipse.archives.jdt.integration.ui.JDTArchivesActionProvider"
+
id="org.jboss.ide.eclipse.archives.jdt.integration.ui.ArchivesActionProvider"
+ priority="highest">
+ <enablement>
+ <instanceof
+ value="java.lang.Object">
+ </instanceof>
+ </enablement>
+ </actionProvider>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewerActionBinding
+
viewerId="org.jboss.ide.eclipse.archives.ui.ProjectArchivesView">
+ <includes>
+ <actionExtension
+
pattern="org.jboss.ide.eclipse.archives.jdt.integration.ui.ArchivesActionProvider">
+ </actionExtension>
+ </includes>
+ </viewerActionBinding>
+ </extension>
+</plugin>
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ArchiveJDTIntegrationPlugin.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ArchiveJDTIntegrationPlugin.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ArchiveJDTIntegrationPlugin.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,76 @@
+package org.jboss.ide.eclipse.archives.jdt.integration;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.ide.eclipse.archives.jdt.integration.model.IArchiveLibFileSet;
+import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ArchiveJDTIntegrationPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.ide.eclipse.archives.jdt.integration";
+
+ // The shared instance
+ private static ArchiveJDTIntegrationPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ArchiveJDTIntegrationPlugin() {
+ }
+
+ /*
+ * (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;
+ addProvider();
+ }
+
+ private ILabelProvider labelProvider;
+ protected void addProvider() {
+ labelProvider =
+ new LabelProvider() {
+ public Image getImage(Object element) {
+ if( element instanceof IArchiveLibFileSet)
+ return
JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_LIBRARY);
+ return null;
+ }
+ public String getText(Object element) {
+ if( element instanceof IArchiveLibFileSet)
+ return ((IArchiveLibFileSet)element).getId();
+ return null;
+ }
+ };
+ ExtensionManager.addLabelProvider(labelProvider);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ ExtensionManager.removeLabelProvider(labelProvider);
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ArchiveJDTIntegrationPlugin getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/ArchiveLibFileSetImpl.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/ArchiveLibFileSetImpl.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/ArchiveLibFileSetImpl.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.archives.jdt.integration.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.UserLibrary;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbLibFileSet;
+
+/**
+ * An implementation for filesets
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class ArchiveLibFileSetImpl extends ArchiveNodeImpl implements
+ IArchiveLibFileSet {
+
+ private IClasspathEntry[] entries = null;
+ private FileWrapper[] wrappers = null;
+ public ArchiveLibFileSetImpl() {
+ this(new XbLibFileSet());
+ }
+
+ public ArchiveLibFileSetImpl (XbLibFileSet delegate) {
+ super(delegate);
+ }
+
+ public String getId() {
+ return getFileSetDelegate().getId();
+ }
+
+ public void setId(String id) {
+ getFileSetDelegate().setId(id);
+ resetScanner();
+ }
+
+ /*
+ * @see IArchiveFileSet#matchesPath(IPath)
+ */
+ public boolean matchesPath(IPath globalPath) {
+ return matchesPath(globalPath, false);
+ }
+
+ /*
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#matchesPath(org.eclipse.core.runtime.IPath,
boolean)
+ */
+ public boolean matchesPath(IPath path, boolean inWorkspace) {
+ //prime();
+ return false;
+ }
+
+ /*
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#getMatches(org.eclipse.core.runtime.IPath)
+ */
+ public FileWrapper[] getMatches(IPath path) {
+ prime();
+ ArrayList<FileWrapper> temp = new ArrayList<FileWrapper>();
+ for( int i = 0; i < wrappers.length; i++ )
+ if( wrappers[i].getWrapperPath().equals(path))
+ temp.add(wrappers[i]);
+ return (FileWrapper[]) temp.toArray(new FileWrapper[temp.size()]);
+ }
+
+ /*
+ * @see IArchiveFileSet#findMatchingPaths()
+ */
+ public synchronized FileWrapper[] findMatchingPaths () {
+ prime();
+ return wrappers == null ? new FileWrapper[]{} : wrappers;
+ }
+
+ private synchronized void prime() {
+ if( entries == null ) {
+ UserLibrary lib =
JavaModelManager.getUserLibraryManager().getUserLibrary(getFileSetDelegate().getId());
+ if( lib != null ) {
+ entries = lib.getEntries();
+ ArrayList<FileWrapper> list = new ArrayList<FileWrapper>();
+ FileWrapper fw;
+ for( int i = 0; i < entries.length; i++ ) {
+ fw = new FileWrapper(entries[i].getPath().toFile(),
+ entries[i].getPath(), getRootArchiveRelativePath(),
+ entries[i].getPath().lastSegment());
+ list.add(fw);
+ }
+ wrappers = (FileWrapper[]) list.toArray(new FileWrapper[list.size()]);
+ } else {
+ entries = new IClasspathEntry[]{};
+ wrappers = new FileWrapper[]{};
+ }
+ }
+ }
+
+ /*
+ * @see IArchiveNode#getNodeType()
+ */
+ public int getNodeType() {
+ return TYPE_ARCHIVE_FILESET;
+ }
+
+ /*
+ * filesets have no path of their own
+ * and should not be the parents of any other node
+ * so the parent is their base location
+ * @see IArchiveNode#getRootArchiveRelativePath()
+ */
+ public IPath getRootArchiveRelativePath() {
+ return getParent().getRootArchiveRelativePath();
+ }
+
+ /*
+ * @see IArchiveFileSet#resetScanner()
+ */
+ public void resetScanner() {
+ entries = null;
+ wrappers = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#validateChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public boolean validateModel() {
+ return getAllChildren().length == 0 ? true : false;
+ }
+
+ /*
+ * @see org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#canBuild()
+ */
+ public boolean canBuild() {
+ return super.canBuild();
+ }
+
+ protected XbLibFileSet getFileSetDelegate () {
+ return (XbLibFileSet)nodeDelegate;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("{id="); //$NON-NLS-1$
+ sb.append(getFileSetDelegate().getId());
+ return sb.toString();
+ }
+
+}
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/DeltaLibFileset.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/DeltaLibFileset.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/DeltaLibFileset.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,27 @@
+package org.jboss.ide.eclipse.archives.jdt.integration.model;
+
+import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbLibFileSet;
+
+public class DeltaLibFileset extends ArchiveLibFileSetImpl {
+ // everything goes through the delegate or the parent. Simple
+ private IArchiveNodeDelta parentDelta;
+ private IArchiveNode impl;
+ public DeltaLibFileset(XbLibFileSet fileset, IArchiveNodeDelta parentDelta, IArchiveNode
impl){
+ super(fileset);
+ this.parentDelta = parentDelta;
+ this.impl = impl;
+ }
+ public IArchiveNode getParent() {
+ return parentDelta == null ? null : parentDelta.getPreNode();
+ }
+ public IPath getProjectPath() {
+ return impl.getProjectPath();
+ }
+ public IArchiveModelRootNode getModelRootNode() {
+ return impl.getModelRootNode();
+ }
+}
\ No newline at end of file
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/IArchiveLibFileSet.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/IArchiveLibFileSet.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/IArchiveLibFileSet.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.archives.jdt.integration.model;
+
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+
+
+public interface IArchiveLibFileSet extends IArchiveFileSet {
+ public static final String ATTRIBUTE_PREFIX =
"org.jboss.ide.eclipse.archives.core.model.IArchiveLibFileSet."; //$NON-NLS-1$
+ public static final String ID_ATTRIBUTE = ATTRIBUTE_PREFIX + "id";
//$NON-NLS-1$
+ public void setId(String id);
+ public String getId();
+}
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/LibFileSetNodeProvider.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/LibFileSetNodeProvider.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/LibFileSetNodeProvider.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,51 @@
+package org.jboss.ide.eclipse.archives.jdt.integration.model;
+
+import java.util.HashMap;
+
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveDeltaPreNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbLibFileSet;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNode;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.INodeProvider;
+
+public class LibFileSetNodeProvider implements INodeProvider {
+
+ public boolean canCreateNode(XbPackageNode node) {
+ return (node instanceof XbLibFileSet);
+ }
+
+ public IArchiveNode createNode(XbPackageNode node) {
+ if (node instanceof XbLibFileSet) {
+ return new ArchiveLibFileSetImpl((XbLibFileSet)node);
+ }
+ return null;
+ }
+
+ public boolean canCreateDelta(IArchiveNode node) {
+ return (node instanceof ArchiveLibFileSetImpl);
+ }
+
+ public IArchiveNode createDelta(IArchiveNodeDelta parentDelta,
+ IArchiveNode postChange, HashMap attributeChanges,
+ HashMap propertyChanges) {
+ if( postChange instanceof ArchiveLibFileSetImpl ) {
+ XbLibFileSet fs = createLibFileset((ArchiveLibFileSetImpl)postChange,
attributeChanges, propertyChanges);
+ return new DeltaLibFileset(fs, parentDelta, postChange);
+ }
+ return null;
+ }
+
+ protected static XbLibFileSet createLibFileset(ArchiveLibFileSetImpl postChange,HashMap
attributeChanges, HashMap propertyChanges ) {
+ XbLibFileSet fs = new XbLibFileSet((XbLibFileSet)postChange.getNodeDelegate());
+ if( attributeChanges.containsKey(IArchiveLibFileSet.ID_ATTRIBUTE))
+ fs.setId(ArchiveDeltaPreNodeFactory.getBeforeString(attributeChanges,
IArchiveLibFileSet.ID_ATTRIBUTE));
+ ArchiveDeltaPreNodeFactory.undoPropertyChanges(fs, propertyChanges);
+ return fs;
+ }
+
+ public static ArchiveLibFileSetImpl createLibFileset() {
+ return new ArchiveLibFileSetImpl();
+ }
+
+}
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/WorkspaceJARArchiveType.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/WorkspaceJARArchiveType.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/model/WorkspaceJARArchiveType.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.archives.jdt.integration.model;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+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.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.ArchivesCoreMessages;
+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.IArchiveStandardFileSet;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveImpl;
+import org.jboss.ide.eclipse.archives.core.model.types.AbstractArchiveType;
+
+/**
+ * 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 WorkspaceJARArchiveType extends AbstractArchiveType {
+
+ public static final String TYPE_ID = "jar"; //$NON-NLS-1$
+
+ public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor)
{
+ //IPackageType t = this;
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ Assert.isNotNull(project);
+
+ IJavaProject javaProject = JavaCore.create(project);
+ Assert.isNotNull(javaProject);
+
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask(ArchivesCore.bind(ArchivesCoreMessages.CreatingDefaultJarConfig,
project.getName()), 2);
+
+ IPath outputPath;
+ try {
+ outputPath = javaProject.getOutputLocation();
+ } catch (JavaModelException e) {
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, e.getMessage(), e);
+ return null;
+ }
+
+ outputPath = outputPath.removeFirstSegments(1);
+ IContainer outputContainer = project.getFolder(outputPath);
+
+ IArchive jar = new ArchiveImpl();
+
+ jar.setDestinationPath(project.getLocation());
+ jar.setInWorkspace(true);
+ jar.setExploded(false);
+ jar.setName(project.getName() + ".jar"); //$NON-NLS-1$
+ jar.setArchiveType(this);
+
+ IArchiveStandardFileSet classes = new ArchiveFileSetImpl();
+ classes.setIncludesPattern("**/*"); //$NON-NLS-1$
+ classes.setRawSourcePath(outputContainer.getFullPath().toString());
+ classes.setInWorkspace(true);
+
+ try {
+ jar.addChild(classes);
+ } catch( ArchivesModelException ame ) {
+ }
+
+ monitor.worked(1);
+ monitor.done();
+
+ return jar;
+ }
+
+ // do nothing
+ public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel,
IProgressMonitor monitor) {
+ return null;
+ }
+}
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/JDTArchivesActionProvider.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/JDTArchivesActionProvider.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/JDTArchivesActionProvider.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,120 @@
+package org.jboss.ide.eclipse.archives.jdt.integration.ui;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.INamedContainerArchiveNode;
+import org.jboss.ide.eclipse.archives.jdt.integration.model.IArchiveLibFileSet;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesActionProvider;
+import org.jboss.ide.eclipse.archives.ui.wizards.FilesetWizard;
+
+public class JDTArchivesActionProvider extends CommonActionProvider {
+ private ICommonViewerSite site;
+ private Action newLibFilesetAction, editLibFilesetAction, deleteAction;
+
+ public JDTArchivesActionProvider() {
+ }
+
+ public void init(ICommonActionExtensionSite aSite) {
+ site = aSite.getViewSite();
+ createActions();
+ }
+
+ protected void createActions() {
+ newLibFilesetAction = new Action(
+ ArchivesUIMessages.ProjectPackagesView_newLibFilesetAction_label,
+ JavaUI.getSharedImages().getImageDescriptor(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_LIBRARY))
{
+ public void run() {
+ createLibFileset();
+ }
+ };
+
+ editLibFilesetAction = new Action(
+ ArchivesUIMessages.ProjectPackagesView_editFilesetAction_label,
+ JavaUI.getSharedImages().getImageDescriptor(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_LIBRARY))
{
+ public void run() {
+ editAction();
+ }
+ };
+
+ deleteAction = new Action
(ArchivesUIMessages.ProjectPackagesView_deleteFilesetAction_label,
platformDescriptor(ISharedImages.IMG_TOOL_DELETE)) {
+ public void run () {
+ deleteSelectedNode();
+ }
+ };
+
+ }
+
+ public void fillContextMenu(IMenuManager manager) {
+ IArchiveNode node = getSelectedNode();
+ if( node instanceof INamedContainerArchiveNode )
+ manager.insertBefore(ArchivesActionProvider.END_ADD_CHILD_SEPARATOR_ID,
newLibFilesetAction);
+ if( node instanceof IArchiveLibFileSet) {
+ manager.insertAfter(ArchivesActionProvider.END_ADD_CHILD_SEPARATOR_ID, deleteAction);
+ manager.insertAfter(ArchivesActionProvider.END_ADD_CHILD_SEPARATOR_ID,
editLibFilesetAction);
+ }
+ }
+
+
+ private void deleteSelectedNode () {
+ IArchiveNode node = getSelectedNode();
+ if (node != null) {
+ final IArchiveNode parent = (IArchiveNode) node.getParent();
+ parent.removeChild(node);
+ SaveArchivesJob job = new SaveArchivesJob(parent.getProjectPath());
+ job.schedule();
+ }
+ }
+
+
+ private void createLibFileset() {
+ IArchiveNode selected = getSelectedNode();
+ WizardDialog dialog = new WizardDialog(site.getShell(),
+ new LibFilesetWizard(null, selected));
+ dialog.open();
+ }
+
+ private void editAction() {
+ IArchiveNode node = getSelectedNode();
+ if (node != null) {
+ IArchiveLibFileSet fileset = (IArchiveLibFileSet) node;
+ WizardDialog dialog = new WizardDialog(site.getShell(), new LibFilesetWizard(fileset,
node.getParent()));
+ dialog.open();
+ }
+ }
+
+ private IArchiveNode getSelectedNode() {
+ Object selected = getSelectedObject();
+ if (selected instanceof IArchiveNode)
+ return ((IArchiveNode) selected);
+ return null;
+ }
+
+ private Object getSelectedObject() {
+ IStructuredSelection selection = getSelection();
+ if (selection != null && !selection.isEmpty())
+ return selection.getFirstElement();
+ return null;
+ }
+
+ private IStructuredSelection getSelection() {
+ return (IStructuredSelection) site.getSelectionProvider()
+ .getSelection();
+ }
+
+ private ImageDescriptor platformDescriptor(String desc) {
+ return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(desc);
+ }
+
+}
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetInfoWizardPage.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetInfoWizardPage.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetInfoWizardPage.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.archives.jdt.integration.ui;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
+import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElementAttribute;
+import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListLabelProvider;
+import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPUserLibraryElement;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.jdt.integration.model.IArchiveLibFileSet;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+
+/**
+ *
+ * @author "Rob Stryker" <rob.stryker(a)redhat.com>
+ *
+ */
+public class LibFilesetInfoWizardPage extends WizardPage {
+
+ private IArchiveNode parentNode;
+ private IArchiveLibFileSet fileset;
+ private String projectName, id;
+ private Composite mainComposite;
+ private TreeViewer viewer;
+ private ArrayList elements;
+ public LibFilesetInfoWizardPage (Shell parent, IArchiveLibFileSet fileset, IArchiveNode
parentNode) {
+ super(ArchivesUIMessages.LibFilesetInfoWizardPage_new_title,
ArchivesUIMessages.LibFilesetInfoWizardPage_new_title, null);
+
+ if (fileset == null) {
+ setTitle(ArchivesUIMessages.LibFilesetInfoWizardPage_new_title);
+ setMessage(ArchivesUIMessages.LibFilesetInfoWizardPage_new_message);
+ } else {
+ setTitle(ArchivesUIMessages.LibFilesetInfoWizardPage_edit_title);
+ setMessage(ArchivesUIMessages.LibFilesetInfoWizardPage_edit_message);
+ }
+
+ this.fileset = fileset;
+ this.parentNode = parentNode;
+ projectName = parentNode.getProjectName();
+ }
+
+ public void createControl (Composite parent) {
+ mainComposite = new Composite(parent, SWT.NONE);
+ mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ mainComposite.setLayout(new FillLayout());
+ viewer = new TreeViewer(mainComposite, SWT.BORDER | SWT.SINGLE);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(new CPListLabelProvider());
+ elements= getElementList(createPlaceholderProject());
+ viewer.setInput(new Object());
+ addListener();
+ setControl(mainComposite);
+ }
+
+ protected void addListener() {
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ if( getFirstElement() instanceof CPUserLibraryElement ) {
+ id = ((CPUserLibraryElement)getFirstElement()).getName();
+ }
+ validate();
+ }
+ });
+ }
+
+ protected Object getFirstElement() {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ return sel.getFirstElement();
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+ public Object[] getChildren(Object element) {
+ if (element instanceof CPUserLibraryElement) {
+ CPUserLibraryElement elem= (CPUserLibraryElement) element;
+ return elem.getChildren();
+ }
+ return new Object[]{};
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof CPListElementAttribute) {
+ return ((CPListElementAttribute) element).getParent();
+ } else if (element instanceof CPListElement) {
+ return ((CPListElement) element).getParentContainer();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+ public Object[] getElements(Object inputElement) {
+ return (Object[]) elements.toArray(new Object[elements.size()]);
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ }
+ };
+ }
+
+
+ protected ArrayList getElementList(IJavaProject fDummyProject) {
+ String[] names= JavaCore.getUserLibraryNames();
+ ArrayList elements = new ArrayList();
+ for (int i= 0; i < names.length; i++) {
+ IPath path= new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(names[i]);
+ try {
+ IClasspathContainer container= JavaCore.getClasspathContainer(path, fDummyProject);
+ elements.add(new CPUserLibraryElement(names[i], container, fDummyProject));
+ } catch (JavaModelException e) {
+ }
+ }
+ return elements;
+ }
+ private static IJavaProject createPlaceholderProject() {
+ String name= "####internal"; //$NON-NLS-1$
+ IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+ while (true) {
+ IProject project= root.getProject(name);
+ if (!project.exists()) {
+ return JavaCore.create(project);
+ }
+ name += '1';
+ }
+ }
+
+ private FormData createFormData(Object topStart, int topOffset, Object bottomStart, int
bottomOffset,
+ Object leftStart, int leftOffset, Object rightStart, int rightOffset) {
+ FormData data = new FormData();
+
+ if( topStart != null ) {
+ data.top = topStart instanceof Control ? new FormAttachment((Control)topStart,
topOffset) :
+ new FormAttachment(((Integer)topStart).intValue(), topOffset);
+ }
+
+ if( bottomStart != null ) {
+ data.bottom = bottomStart instanceof Control ? new
FormAttachment((Control)bottomStart, bottomOffset) :
+ new FormAttachment(((Integer)bottomStart).intValue(), bottomOffset);
+ }
+
+ if( leftStart != null ) {
+ data.left = leftStart instanceof Control ? new FormAttachment((Control)leftStart,
leftOffset) :
+ new FormAttachment(((Integer)leftStart).intValue(), leftOffset);
+ }
+
+ if( rightStart != null ) {
+ data.right = rightStart instanceof Control ? new FormAttachment((Control)rightStart,
rightOffset) :
+ new FormAttachment(((Integer)rightStart).intValue(), rightOffset);
+ }
+
+ return data;
+ }
+
+
+
+
+ private boolean validate () {
+ if( !( getFirstElement() instanceof CPUserLibraryElement )) {
+ setPageComplete(false);
+ return false;
+ }
+ setPageComplete(true);
+ return true;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ private void fillDefaults () {
+ if (fileset != null) {
+ id = fileset.getId();
+ } else {
+ id = null;
+ }
+
+ }
+
+ protected double getDescriptorVersion() {
+ return parentNode.getModelRootNode().getDescriptorVersion();
+ }
+}
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetWizard.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetWizard.java
(rev 0)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.jdt.integration/src/org/jboss/ide/eclipse/archives/jdt/integration/ui/LibFilesetWizard.java 2009-04-10
10:06:23 UTC (rev 14652)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.archives.jdt.integration.ui;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.Wizard;
+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.IArchiveNode;
+import org.jboss.ide.eclipse.archives.jdt.integration.model.IArchiveLibFileSet;
+import org.jboss.ide.eclipse.archives.jdt.integration.model.LibFileSetNodeProvider;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
+
+/**
+ *
+ * @author "Rob Stryker" <rob.stryker(a)redhat.com>
+ *
+ */
+public class LibFilesetWizard extends Wizard {
+
+ private LibFilesetInfoWizardPage page1;
+ private IArchiveLibFileSet fileset;
+ private IArchiveNode parentNode;
+
+ public LibFilesetWizard(IArchiveLibFileSet fileset, IArchiveNode parentNode) {
+ this.fileset = fileset;
+ this.parentNode = parentNode;
+ setWindowTitle(ArchivesUIMessages.LibFilesetWizard);
+ }
+
+ public boolean performFinish() {
+ final boolean createFileset = this.fileset == null;
+
+ if (createFileset)
+ this.fileset = LibFileSetNodeProvider.createLibFileset();
+ fillFilesetFromPage(fileset);
+ try {
+ getContainer().run(true, false, new IRunnableWithProgress () {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
+ if (createFileset)
+ parentNode.addChild(fileset);
+ try {
+ ArchivesModel.instance().save(fileset.getProjectPath(), monitor);
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID,
ArchivesUIMessages.ErrorCompletingWizard, ame);
+ PackagesUIPlugin.getDefault().getLog().log(status);
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ } catch (InterruptedException e) {
+ } catch(Exception e) {}
+ return true;
+ }
+
+ private void fillFilesetFromPage (IArchiveLibFileSet fileset) {
+ fileset.setId(page1.getId());
+ }
+
+ public void addPages() {
+ page1 = new LibFilesetInfoWizardPage(getShell(), fileset, parentNode);
+ addPage(page1);
+ }
+}