Author: mculpepper(a)jboss.com
Date: 2007-05-21 19:53:17 -0400 (Mon, 21 May 2007)
New Revision: 2045
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/types/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/types/WorkspaceJARArchiveType.java
Log:
all code with references to org.eclipse.core.resources (anything other than
.runtime) has been moved into src/eclipse
Copied:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java
(from rev 2039,
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java)
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java 2007-05-21
23:53:17 UTC (rev 2045)
@@ -0,0 +1,80 @@
+/*
+ * 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.core;
+
+
+import org.eclipse.core.runtime.Plugin;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ * @author rstryker
+ *
+ */public class ArchivesCorePlugin extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.ide.eclipse.archives.core";
+
+ // The shared instance
+ private static ArchivesCorePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ArchivesCorePlugin() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ // Load the workspace version of ArchivesCore
+ ArchivesCore core = new WorkspaceArchivesCore();
+
+ // force JBossXB initialization
+ XMLBinding.init();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#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 ArchivesCorePlugin getDefault() {
+ return plugin;
+ }
+
+}
Copied:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
(from rev 2039,
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java)
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2007-05-21
23:53:17 UTC (rev 2045)
@@ -0,0 +1,187 @@
+package org.jboss.ide.eclipse.archives.core.build;
+
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.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.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.events.EventManager;
+import org.jboss.ide.eclipse.archives.core.model.other.IArchiveModelListener;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
+
+/**
+ * This class responds to model change events.
+ * It is given a delta as to what nodes are added, removed, or changed.
+ * It then keeps the output file for the top level archive in sync with
+ * the changes to the model.
+ *
+ * If the automatic builder is not enabled for this project, the listener
+ * does nothing.
+ *
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ModelChangeListener implements IArchiveModelListener {
+
+ /**
+ * This is the entry point for model change events.
+ * It immediately passes the delta to be handled.
+ */
+ public void modelChanged(IArchiveNodeDelta delta) {
+ // if we're not building, get out
+ if(
!ArchivesCore.getInstance().getPreferenceManager().isBuilderEnabled(delta.getPostNode().getProjectPath()))
+ return;
+
+ try {
+ handle(delta);
+ } catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This can handle any type of node / delta, not just
+ * root elements. If the node is added or removed, it
+ * will handle those segments and return without checking
+ * the children at all. IT is the responsibility of the add
+ * and remove methods to go through the children.
+ *
+ * Otherwise, it will simply handle attribute children and then
+ * move on to the children.
+ *
+ * @param delta
+ */
+ private void handle(IArchiveNodeDelta delta) {
+ if( (delta.getKind() & IArchiveNodeDelta.REMOVED) != 0 ) {
+ nodeRemoved(delta.getPreNode());
+ return;
+ } else if( (delta.getKind() & IArchiveNodeDelta.ADDED) != 0 ) {
+ nodeAdded(delta.getPostNode());
+ return;
+ } else if( (delta.getKind() & IArchiveNodeDelta.ATTRIBUTE_CHANGED) != 0) {
+ boolean shouldHandleChildren = handleAttributeChange(delta);
+ if( shouldHandleChildren ) {
+ IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
+ for( int i = 0; i < children.length; i++ ) {
+ handle(children[i]);
+ }
+ }
+ } else if( descendentChanged(delta.getKind()) ) {
+ IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
+ for( int i = 0; i < children.length; i++ ) {
+ handle(children[i]);
+ }
+ }
+ }
+ protected boolean descendentChanged(int kind) {
+ return (kind & IArchiveNodeDelta.DESCENDENT_CHANGED) != 0 ||
+ (kind & IArchiveNodeDelta.CHILD_ADDED) != 0 ||
+ (kind & IArchiveNodeDelta.CHILD_REMOVED) != 0;
+ }
+
+ /**
+ * Handle changes in this node
+ * @param delta
+ * @return Whether or not the caller should also handle the children
+ */
+ private boolean handleAttributeChange(IArchiveNodeDelta delta) {
+ switch( delta.getPostNode().getNodeType()) {
+ case IArchiveNode.TYPE_ARCHIVE_FOLDER:
+ return handleFolderAttributeChanged(delta);
+ case IArchiveNode.TYPE_ARCHIVE_FILESET:
+ return handleFilesetAttributeChanged(delta);
+ case IArchiveNode.TYPE_ARCHIVE:
+ return handlePackageAttributeChanged(delta);
+ }
+ return false;
+ }
+
+ private boolean handleFolderAttributeChanged(IArchiveNodeDelta delta) {
+ nodeRemoved(delta.getPreNode());
+ nodeAdded(delta.getPostNode());
+ return false;
+ }
+
+ private boolean handleFilesetAttributeChanged(IArchiveNodeDelta delta) {
+ nodeRemoved(delta.getPreNode());
+ nodeAdded(delta.getPostNode());
+ return false;
+ }
+
+ private boolean handlePackageAttributeChanged(IArchiveNodeDelta delta) {
+ nodeRemoved(delta.getPreNode());
+ nodeAdded(delta.getPostNode());
+ return false;
+ }
+
+
+
+
+ private void nodeAdded(IArchiveNode added) {
+ if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ // create the package
+ ModelTruezipBridge.createFile(added);
+ } else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
+ // create hte folder
+ ModelTruezipBridge.createFile(added);
+ }
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(added);
+ for( int i = 0; i < filesets.length; i++ ) {
+ ModelTruezipBridge.fullFilesetBuild(filesets[i]);
+ IPath[] paths = filesets[i].findMatchingPaths();
+ EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], paths);
+ }
+ refreshLocal(added);
+ }
+
+
+ private void nodeRemoved(IArchiveNode removed) {
+ if( removed.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ ModelTruezipBridge.deleteArchive((IArchive)removed);
+ refreshLocal(removed);
+ return;
+ } else if( removed.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ){
+ IArchiveFileSet[] filesets =
ModelUtil.findAllDescendentFilesets(((IArchiveFolder)removed));
+ for( int i = 0; i < filesets.length; i++ ) {
+ IPath[] removedPaths =
ModelTruezipBridge.fullFilesetRemove(((IArchiveFileSet)removed), false);
+ EventManager.filesRemoved(removedPaths, ((IArchiveFileSet)removed));
+ }
+ refreshLocal(removed);
+ return;
+ }
+
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(removed);
+ for( int i = 0; i < filesets.length; i++ ) {
+ IPath[] removedPaths =
ModelTruezipBridge.fullFilesetRemove(((IArchiveFileSet)removed), false);
+ EventManager.filesRemoved(removedPaths, ((IArchiveFileSet)removed));
+ }
+ refreshLocal(removed);
+ }
+
+
+ // refresh the file tree structure
+ private void refreshLocal(IArchiveNode node) {
+ IArchive pack = node.getRootArchive();
+ if( pack != null && pack.isDestinationInWorkspace() ) {
+ // refresh the root package node
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource res = root.getContainerForLocation(pack.getDestinationPath());
+ if( res != null ) {
+ try {
+ res.getParent().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ }
+ }
+ }
+
+ }
+}
Copied:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
(from rev 2039,
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java)
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java 2007-05-21
23:53:17 UTC (rev 2045)
@@ -0,0 +1,88 @@
+/*
+ * 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.core.model.other.internal;
+
+import java.util.Collection;
+import java.util.Hashtable;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.archives.core.Trace;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.core.model.other.IExtensionManager;
+
+/**
+ * This class will be responsible for loading extension points in the core.
+ *
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class WorkspaceExtensionManager implements IExtensionManager {
+ public static final String ARCHIVE_TYPES_EXTENSION_ID =
"org.jboss.ide.eclipse.archives.core.archiveTypes";
+
+ private IExtension[] findExtension (String extensionId) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(extensionId);
+ return extensionPoint.getExtensions();
+ }
+
+ private static Hashtable archiveTypes;
+ private void loadPackageTypes () {
+ archiveTypes = new Hashtable();
+ IExtension[] extensions = findExtension(ARCHIVE_TYPES_EXTENSION_ID);
+
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement elements[] = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ try {
+ Object executable = elements[j].createExecutableExtension("class");
+ IArchiveType type = (IArchiveType)executable;
+ archiveTypes.put(type.getId(), type);
+ } catch (InvalidRegistryObjectException e) {
+ Trace.trace(WorkspaceExtensionManager.class, e);
+ } catch( CoreException e ) {
+ Trace.trace(WorkspaceExtensionManager.class, e);
+ }
+ }
+ }
+ }
+
+ public IArchiveType getArchiveType (String packageType) {
+ if (archiveTypes == null)
+ loadPackageTypes();
+ return (IArchiveType)archiveTypes.get(packageType);
+ }
+
+ public IArchiveType[] getArchiveTypes() {
+ if( archiveTypes == null )
+ loadPackageTypes();
+ Collection c = archiveTypes.values();
+ return (IArchiveType[]) c.toArray(new IArchiveType[c.size()]);
+ }
+
+
+}
Copied:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
(from rev 2039,
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java)
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java 2007-05-21
23:53:17 UTC (rev 2045)
@@ -0,0 +1,126 @@
+/*
+ * 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.core.model.other.internal;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.other.IPreferenceManager;
+import org.osgi.service.prefs.BackingStoreException;
+
+
+/**
+ * Sets default preferences for the plugin.
+ * By default, the builder is enabled for all projects with archives.
+ *
+ * @author rstryker
+ *
+ */
+public class WorkspacePreferenceManager extends AbstractPreferenceInitializer implements
IPreferenceManager {
+ public static final String AUTOMATIC_BUILDER_ENABLED =
"org.jboss.ide.eclipse.archives.core.automaticBuilderEnabled";
+ public static final String PROJECT_SPECIFIC_PREFS =
"org.jboss.ide.eclipse.archives.core.projectSpecificPreferencesEnabled";
+
+ private static IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ private static IResource getResource(IPath path) {
+ if( path != null && workspaceRoot.getLocation().isPrefixOf(path) ) {
+ String relative =
path.toOSString().substring(workspaceRoot.getLocation().toOSString().length()+1);
+ return workspaceRoot.getProject(relative);
+ }
+
+ return null;
+ }
+
+ public boolean isBuilderEnabled(IPath path) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
AUTOMATIC_BUILDER_ENABLED);
+ IResource res = getResource(path);
+ if( res != null && areProjectSpecificPrefsEnabled(res)) {
+ try {
+ if( res.getPersistentProperty(name) != null) {
+ return Boolean.parseBoolean(res.getPersistentProperty(name));
+ }
+ } catch( CoreException ce ) {}
+ }
+ return new
InstanceScope().getNode(ArchivesCorePlugin.PLUGIN_ID).getBoolean(AUTOMATIC_BUILDER_ENABLED,
true);
+ }
+
+ public void setBuilderEnabled(IPath path, boolean value) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
AUTOMATIC_BUILDER_ENABLED);
+ IResource resource = getResource(path);
+ // if the resource is null or the resource has no preference val, use global val
+ try {
+ if( resource != null && resource.getPersistentProperty(name) != null) {
+ resource.setPersistentProperty(name, new Boolean(value).toString());
+ return;
+ }
+ } catch( CoreException ce ) {}
+ IEclipsePreferences prefs = new InstanceScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(AUTOMATIC_BUILDER_ENABLED, value);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(AUTOMATIC_BUILDER_ENABLED, true);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+
+ public boolean areProjectSpecificPrefsEnabled(IPath path) {
+ return areProjectSpecificPrefsEnabled(getResource(path));
+ }
+ public boolean areProjectSpecificPrefsEnabled(IResource resource) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
PROJECT_SPECIFIC_PREFS);
+ try {
+ if( resource != null && resource.getPersistentProperty(name) != null) {
+ return Boolean.parseBoolean(resource.getPersistentProperty(name));
+ }
+ } catch( CoreException ce ) {}
+ return false;
+ }
+
+ public void setProjectSpecificPrefsEnabled(IPath path, boolean value) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
PROJECT_SPECIFIC_PREFS);
+ IResource resource = getResource(path);
+ try {
+ if( resource != null) {
+ resource.setPersistentProperty(name, new Boolean(value).toString());
+ return;
+ }
+ } catch( CoreException ce ) {}
+ }
+}
Copied:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
(from rev 2039,
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java)
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java 2007-05-21
23:53:17 UTC (rev 2045)
@@ -0,0 +1,40 @@
+package org.jboss.ide.eclipse.archives.core.model.other.internal;
+
+import java.net.URL;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.other.IRuntimeVariables;
+
+public class WorkspaceVariables implements IRuntimeVariables {
+
+ public URL getBindingLog4j() {
+ return getClass().getClassLoader().getResource("log4j.xml");
+ }
+
+ public URL getBindingSchema() {
+ return getClass().getClassLoader().getResource("packages.xsd");
+ }
+
+ public IPath getProjectPath (String projectName) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ if (project.exists() && project.isAccessible())
+ {
+ IPath location = project.getRawLocation();
+ if (location == null) return project.getLocation();
+
+ return location;
+ }
+
+ return null;
+ }
+
+ public boolean isDebugging(String option) {
+ return ArchivesCorePlugin.getDefault().isDebugging()
+ && "true".equalsIgnoreCase(Platform.getDebugOption(option));
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/types/WorkspaceJARArchiveType.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/types/WorkspaceJARArchiveType.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/types/WorkspaceJARArchiveType.java 2007-05-21
23:53:17 UTC (rev 2045)
@@ -0,0 +1,76 @@
+package org.jboss.ide.eclipse.archives.core.model.types;
+
+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.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.Trace;
+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.internal.ArchiveFileSetImpl;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveImpl;
+
+/**
+ * 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";
+
+ 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("Creating default JAR configuration for java project
\"" + project.getName() + "\"", 2);
+
+ IPath outputPath;
+ try {
+ outputPath = javaProject.getOutputLocation();
+ } catch (JavaModelException e) {
+ Trace.trace(WorkspaceJARArchiveType.class, 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");
+ jar.setArchiveType(this);
+
+ IArchiveFileSet classes = new ArchiveFileSetImpl();
+ classes.setIncludesPattern("**/*");
+ classes.setSourcePath(outputContainer.getFullPath());
+ classes.setInWorkspace(true);
+
+ jar.addChild(classes);
+
+ monitor.worked(1);
+ monitor.done();
+
+ return jar;
+ }
+
+ // do nothing
+ public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel,
IProgressMonitor monitor) {
+ return null;
+ }
+}