JBoss Tools SVN: r8753 - trunk/ws/tests.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-06-13 04:32:06 -0400 (Fri, 13 Jun 2008)
New Revision: 8753
Added:
trunk/ws/tests/org.jboss.tools.ws.core.test/
Log:
JBIDE-2323: new a plugin for unit test of org.jboss.tools.ws.ore
17 years, 10 months
JBoss Tools SVN: r8752 - in trunk/ws/plugins: org.jboss.tools.ws.creation.ui and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-06-13 03:17:43 -0400 (Fri, 13 Jun 2008)
New Revision: 8752
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/startup/
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/startup/SetDefaultWebServiceServerRuntime.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
Log:
JBIDE-2335: Move the set default Web Service runtime code to a start up extension
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java 2008-06-13 06:35:28 UTC (rev 8751)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java 2008-06-13 07:17:43 UTC (rev 8752)
@@ -39,8 +39,6 @@
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin.getInstance().getPluginPreferences().setDefault("PREFERENCE_SERVER", "org.eclipse.jst.server.generic.jboss42");
- org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin.getInstance().getPluginPreferences().setDefault("PREFERENCE_RUNTIME", "org.jboss.tools.ws.creation.jbossWebServiceRT");
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2008-06-13 06:35:28 UTC (rev 8751)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2008-06-13 07:17:43 UTC (rev 8752)
@@ -63,5 +63,11 @@
</page>
</wizard-pages>
</extension>
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.jboss.tools.ws.creation.ui.startup.SetDefaultWebServiceServerRuntime">
+ </startup>
+ </extension>
</plugin>
Added: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/startup/SetDefaultWebServiceServerRuntime.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/startup/SetDefaultWebServiceServerRuntime.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/startup/SetDefaultWebServiceServerRuntime.java 2008-06-13 07:17:43 UTC (rev 8752)
@@ -0,0 +1,13 @@
+package org.jboss.tools.ws.creation.ui.startup;
+
+import org.eclipse.ui.IStartup;
+
+public class SetDefaultWebServiceServerRuntime implements IStartup {
+
+ public void earlyStartup() {
+ org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin.getInstance().getPluginPreferences().setDefault("PREFERENCE_SERVER", "org.eclipse.jst.server.generic.jboss42");
+ org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin.getInstance().getPluginPreferences().setDefault("PREFERENCE_RUNTIME", "org.jboss.tools.ws.creation.jbossWebServiceRT");
+
+ }
+
+}
17 years, 10 months
JBoss Tools SVN: r8751 - trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-06-13 02:35:28 -0400 (Fri, 13 Jun 2008)
New Revision: 8751
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
Log:
enable seam 2.0 for seam ui tests
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2008-06-13 06:08:38 UTC (rev 8750)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2008-06-13 06:35:28 UTC (rev 8751)
@@ -73,9 +73,7 @@
protected static final String SEAM_2_0 = "Seam 2.0.0";
protected static final String SEAM_1_2_HOME = "jbosstools.test.seam.1.2.1.eap.home";
- protected static final String SEAM_2_0_HOME = "jbosstools.test.seam.2.0.0.home";
- protected static final String SEAM_1_2_HOME_DEFAULT = "F:/jbdevstudio-ga/jboss-eap/seam";
- protected static final String SEAM_2_0_HOME_DEFAULT = "E:/Java/JBoss/Seam/jboss-seam-2.0.1.GA";
+ protected static final String SEAM_2_0_HOME = "jbosstools.test.seam.2.0.1.GA.home";
private static final String SEAM_ACTION_COMPONENT_NAME = "TestAction";
private static final String SEAM_FORM_COMPONENT_NAME = "TestForm";
@@ -272,12 +270,15 @@
protected File getSeamHomeFolder(String seamRTName) {
+ File seamHome = null;
if (SEAM_1_2.equals(seamRTName)) {
- return new File(System.getProperty(SEAM_1_2_HOME, SEAM_1_2_HOME_DEFAULT));
+ seamHome = new File(System.getProperty(SEAM_1_2_HOME));
+
} else if (SEAM_2_0.equals(seamRTName)) {
- return new File(System.getProperty(SEAM_2_0_HOME, SEAM_2_0_HOME_DEFAULT));
+ seamHome = new File(System.getProperty(SEAM_2_0_HOME));
}
- return null;
+
+ return seamHome;
}
protected SeamVersion getSeamRTVersion(String seamRTName) {
17 years, 10 months
JBoss Tools SVN: r8750 - in trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core: utils and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-06-13 02:08:38 -0400 (Fri, 13 Jun 2008)
New Revision: 8750
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
Log:
JBIDE-2262: if user choose server supplied jBoss ws runtime, get runtime location from project target runtime
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-06-13 03:24:13 UTC (rev 8749)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-06-13 06:08:38 UTC (rev 8750)
@@ -15,8 +15,9 @@
Error_Read_Binding_File=Exception occurred while reading binding file
Error_Message_Failed_To_Generate_Code=Failed to Generate code, please read the log for more details
Error_Message_Failed_to_Generate_Implementation=Failed to generate implementation class
-Error_Message_Command_File_Not_Found=The command file:{0} does not exist, please check the JBoss Web Service runtime setting to make sure the location of JBoss Web Service runtime is valid.
+Error_Message_Command_File_Not_Found=The command file: "{0}" does not exist, please check the JBoss Web Service runtime setting to make sure the location of JBoss Web Service runtime is valid.
Error_Message_Execute_Command=Exception occurred while execute JBossWS tool command
+Error_Message_No_Runtime_Specified=No JBoss Web Service runtime has been specified.
Separator_Java=/
Error_Implemetation_Code_Generation=Exception occurred while generating implementation class
@@ -38,3 +39,4 @@
JBossWSFacetInstallPage_ServerSuppliedJBossWS=Server Supplied JBossWS Runtime
JBossWSFacetInstallPage_Deploy=Deploy
JBossWSFacetInstallPage_New=New...
+
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2008-06-13 03:24:13 UTC (rev 8749)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2008-06-13 06:08:38 UTC (rev 8750)
@@ -56,6 +56,8 @@
public static String Client_Sample_Class_Name;
public static String Error_Create_Client_Sample;
public static String WebEndpoint;
+
+ public static String Error_Message_No_Runtime_Specified;
private JBossWSCreationCoreMessages() {
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-06-13 03:24:13 UTC (rev 8749)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-06-13 06:08:38 UTC (rev 8750)
@@ -41,10 +41,8 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jst.ws.internal.common.J2EEUtils;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.eclipse.wst.common.project.facet.core.internal.FacetedProject;
-import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
+import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.tools.ws.core.JbossWSCorePlugin;
import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
@@ -52,6 +50,7 @@
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
import org.jboss.tools.ws.core.utils.StatusUtils;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
public class JBossWSCreationUtils {
@@ -283,27 +282,10 @@
}
public static String getJbossWSRuntimeLocation(IProject project) throws CoreException{
-
- //if users select server as its jbossws runtime, then get runtime location from project target runtime
String isServerSupplied = project.getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
- if(IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED.equals(isServerSupplied)){
- IFacetedProject facetedPrj = ProjectFacetsManager.create( project );
- IRuntime prjRuntime = facetedPrj.getPrimaryRuntime();
- // TODO get runtime location from specified project target runtime
- prjRuntime.getRuntimeComponents().get(0).getProperties();
-
- //if no target runtime specified, get runtime location from default jbossws runtime from jbossws preference
- if(prjRuntime == null){
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance().getDefaultRuntime();
- if(jbws != null){
- return jbws.getHomeDir();
- }else{
- throw new CoreException(StatusUtils.errorStatus("No JBoss Web Service runtime has been specified."));
- }
-
- }
- }else{
+ if(isServerSupplied != null &&
+ !IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED.equals(isServerSupplied)){
String jbwsRuntimeName = project.getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance().findRuntimeByName(jbwsRuntimeName);
if(jbws != null){
@@ -313,8 +295,55 @@
return jbwsHomeDir;
}
}
+ //if users select server as its jbossws runtime, then get runtime location from project target runtime
+ else{
+ IFacetedProject facetedPrj = ProjectFacetsManager.create(project);
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime prjFacetRuntime = facetedPrj.getPrimaryRuntime();
+
+ IRuntime serverRuntime = getRuntime(prjFacetRuntime);
+
+ if(serverRuntime != null){
+ String runtimeTypeName = serverRuntime.getRuntimeType().getName();
+ if(runtimeTypeName == null){
+ runtimeTypeName = "";
+ }
+ if(runtimeTypeName.toUpperCase().indexOf("JBOSS") >= 0){
+ return serverRuntime.getLocation().removeLastSegments(1).toOSString();
+ }
+ }
+
+ //if no target runtime has been specified, get runtime location from default jbossws runtime
+ if(prjFacetRuntime == null){
+ JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance().getDefaultRuntime();
+ if(jbws != null){
+ return jbws.getHomeDir();
+ }else{
+ throw new CoreException(StatusUtils.errorStatus(JBossWSCreationCoreMessages.Error_Message_No_Runtime_Specified));
+ }
+
+ }
+
+ }
return "";
}
+ public static IRuntime getRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime) {
+ if (runtime == null)
+ throw new IllegalArgumentException();
+
+ String id = runtime.getProperty("id");
+ if (id == null)
+ return null;
+
+ org.eclipse.wst.server.core.IRuntime[] runtimes = ServerCore.getRuntimes();
+ int size = runtimes.length;
+ for (int i = 0; i < size; i++) {
+ if (id.equals(runtimes[i].getId()))
+ return runtimes[i];
+ }
+
+ return null;
+ }
+
}
17 years, 10 months
JBoss Tools SVN: r8749 - in trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui: preferences and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-06-12 23:24:13 -0400 (Thu, 12 Jun 2008)
New Revision: 8749
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java
Log:
JBIDE-2261: add runtime version
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties 2008-06-13 03:24:05 UTC (rev 8748)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties 2008-06-13 03:24:13 UTC (rev 8749)
@@ -10,6 +10,7 @@
Error_JBossWS_Basic_Editor_Support=Editor supports only grid layout
Error_JBossWS_Basic_Editor_Different=Parent for label is different
JBossWS_Runtime_List_Field_Editor_Name=Name
+JBossWS_Runtime_List_Field_Editor_Version=Version
JBossWS_Runtime_List_Field_Editor_Path=Path
JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be=inputElement must be
JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List=an instance of List<JBossWSRuntime>.
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java 2008-06-13 03:24:05 UTC (rev 8748)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java 2008-06-13 03:24:13 UTC (rev 8749)
@@ -37,6 +37,7 @@
public static String Error_JBossWS_Basic_Editor_Support;
public static String Error_JBossWS_Basic_Editor_Different;
public static String JBossWS_Runtime_List_Field_Editor_Name;
+ public static String JBossWS_Runtime_List_Field_Editor_Version;
public static String JBossWS_Runtime_List_Field_Editor_Path;
public static String JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be;
public static String JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List;
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-13 03:24:05 UTC (rev 8748)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-13 03:24:13 UTC (rev 8749)
@@ -200,11 +200,15 @@
TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
tc2.setWidth(TC_NAME_WIDTH);
tc2.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name);
-
+
TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
- tc3.setWidth(TC_PATH_WIDTH);
- tc3.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
+ tc3.setWidth(TC_VERSION_WIDTH);
+ tc3.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version);
+ TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc4.setWidth(TC_PATH_WIDTH);
+ tc4.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
+
tableView.setContentProvider(new IStructuredContentProvider() {
@SuppressWarnings("unchecked")
@@ -231,7 +235,8 @@
private static final int TC_DEFAULT_NUMBER = 0;
private static final int TC_NAME_NUMBER = 1;
- private static final int TC_PATH_NUMBER = 2;
+ private static final int TC_VERSION_NUMBER = 2;
+ private static final int TC_PATH_NUMBER = 3;
public void addListener(ILabelProviderListener listener) {
}
@@ -258,6 +263,9 @@
if (columnIndex == TC_NAME_NUMBER) {
return rt.getName();
}
+ if (columnIndex == TC_VERSION_NUMBER) {
+ return rt.getVersion().toString();
+ }
if (columnIndex == TC_PATH_NUMBER) {
return rt.getHomeDir();
}
@@ -399,9 +407,9 @@
PropertyChangeListener {
private static final String SRT_NAME = "name";
+ private static final String SRT_VERSION = "version";
private static final String SRT_HOMEDIR = "homeDir";
- private static final String SRT_DEFAULT = "defaultClasspath";
-
+
private static final int GL_PARENT_COLUMNS = 1;
private static final int GL_CONTENT_COLUMNS = 3;
@@ -410,6 +418,10 @@
IFieldEditor name = createTextEditor(SRT_NAME,
JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name2, ""); //$NON-NLS-1$
+ IFieldEditor version = createTextEditor(SRT_VERSION,
+ JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version, ""); //$NON-NLS-1$
+
+
IFieldEditor homeDir = createBrowseFolderEditor(
SRT_HOMEDIR,
JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Home_Folder,
@@ -445,6 +457,7 @@
root.setLayout(gl);
name.doFillIntoGrid(root);
name.addPropertyChangeListener(this);
+ version.doFillIntoGrid(root);
homeDir.doFillIntoGrid(root);
homeDir.addPropertyChangeListener(this);
@@ -557,6 +570,7 @@
public JbossWSRuntime getRuntime() {
JbossWSRuntime newRt = new JbossWSRuntime();
newRt.setName(name.getValueAsString());
+ newRt.setVersion(version.getValueAsString());
newRt.setHomeDir(homeDir.getValueAsString());
JbossWSRuntime rt = (JbossWSRuntime)jars.getValue();
newRt.setLibraries(rt.getLibraries());
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java 2008-06-13 03:24:05 UTC (rev 8748)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java 2008-06-13 03:24:13 UTC (rev 8749)
@@ -13,9 +13,7 @@
import java.io.File;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
17 years, 10 months
JBoss Tools SVN: r8748 - in trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core: facet/delegate and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-06-12 23:24:05 -0400 (Thu, 12 Jun 2008)
New Revision: 8748
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java
Log:
JBIDE-2261: add runtime version
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java 2008-06-12 22:23:39 UTC (rev 8747)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java 2008-06-13 03:24:05 UTC (rev 8748)
@@ -22,6 +22,8 @@
String name = null;
String homeDir = null;
+
+ String version = null;
boolean defaultRt = false;
@@ -110,4 +112,12 @@
this.userConfigClasspath = userConfigClasspath;
}
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java 2008-06-12 22:23:39 UTC (rev 8747)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java 2008-06-13 03:24:05 UTC (rev 8748)
@@ -2,7 +2,6 @@
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -26,6 +25,7 @@
private static final String FIELD_SEPARATOR = "|";
private static final String DEFAULT = "default";
private static final String HOME_DIR = "homeDir";
+ private static final String VERSION = "version";
private static final String NAME = "name";
private static final String USER_CONFIG_CLASSPATH = "userConfig";
private static final String LIBRARY = "libraries";
@@ -59,6 +59,8 @@
rt.setName(value);
} else if (HOME_DIR.equals(name)) {
rt.setHomeDir(value);
+ } else if (VERSION.equals(name)) {
+ rt.setVersion(value);
} else if (DEFAULT.equals(name)) {
rt.setDefault(Boolean.parseBoolean(value));
}else if(USER_CONFIG_CLASSPATH.equals(name)){
@@ -116,6 +118,9 @@
for (int i = 0; i < runtimes.length; i++) {
buffer.append(NAME).append(FIELD_SEPARATOR);
buffer.append(runtimes[i].getName());
+ buffer.append(FIELD_SEPARATOR).append(VERSION).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getVersion());
buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
FIELD_SEPARATOR);
buffer.append(runtimes[i].getHomeDir());
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java 2008-06-12 22:23:39 UTC (rev 8747)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java 2008-06-13 03:24:05 UTC (rev 8748)
@@ -150,7 +150,7 @@
*/
public void save() {
JbossWSCorePlugin.getDefault().getPreferenceStore().setValue(
- "jbosswsruntimelocation", converter.getString(runtimes));
+ JbossWSCoreMessages.WS_Location, converter.getString(runtimes));
IPreferenceStore store = JbossWSCorePlugin.getDefault()
.getPreferenceStore();
if (store instanceof IPersistentPreferenceStore) {
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java 2008-06-12 22:23:39 UTC (rev 8747)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java 2008-06-13 03:24:05 UTC (rev 8748)
@@ -24,7 +24,8 @@
*
* @return set of property names
*/
- public Set getPropertyNames() {
+ @SuppressWarnings("unchecked")
+ public Set<String> getPropertyNames() {
Set<String> names = super.getPropertyNames();
names.add(JBOSS_WS_DEPLOY);
17 years, 10 months
JBoss Tools SVN: r8747 - in branches/jbosstools-2.1.x/core/plugins: org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-06-12 18:23:39 -0400 (Thu, 12 Jun 2008)
New Revision: 8747
Modified:
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
Log:
JBIDE-2324 on 2.1.x branch
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,98 +1,107 @@
-/*
- * 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 java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-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.IArchiveModel;
-import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
-
-/**
- * Update the model if someone changes the packaging file by hand
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class WorkspaceChangeListener implements IResourceChangeListener {
-
- public void resourceChanged(IResourceChangeEvent event) {
- final Set<IProject> projects = new TreeSet<IProject>();
-
- IResourceDelta delta = event.getDelta();
- try {
- if(delta!=null) {
- delta.accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- if( delta.getResource() != null && delta.getResource().getLocation() != null &&
- delta.getResource().getLocation().lastSegment().equals(IArchiveModel.DEFAULT_PACKAGES_FILE)) {
- projects.add(delta.getResource().getProject());
- }
- return true;
- }
- });
- }
- } catch( CoreException ce ) {
- }
- Iterator<IProject> i = projects.iterator();
- while(i.hasNext()) {
- final IProject p = i.next();
- try {
- if( p.getSessionProperty(new QualifiedName(ArchivesCorePlugin.PLUGIN_ID, "localname")) == null ) {
- try {
- ArchivesModel.instance().registerProject(p.getLocation(), new NullProgressMonitor());
- new Job("Refresh Project: " + p.getName()) {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- p.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- } catch( CoreException e ) {
- IStatus status = new Status(IStatus.WARNING, ArchivesCorePlugin.PLUGIN_ID, "Could not refresh project " + p.getName(), e);
- return status;
- }
- return Status.OK_STATUS;
- }
- }.schedule();
- } catch( ArchivesModelException ame ) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, "Could not register project " + p.getName(), ame);
- }
- }
- } catch( CoreException ce ) {
- }
- }
- }
-
-}
+/*
+ * 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 java.util.Comparator;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+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.IArchiveModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
+
+/**
+ * Update the model if someone changes the packaging file by hand
+ * @author Rob Stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public class WorkspaceChangeListener implements IResourceChangeListener {
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ Comparator c = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ if( o1 instanceof IProject && o2 instanceof IProject)
+ return ((IProject)o1).getLocation().toOSString().compareTo(
+ ((IProject)o2).getLocation().toOSString());
+ return 0;
+ }
+ };
+ final Set<IProject> projects = new TreeSet<IProject>(c);
+
+ IResourceDelta delta = event.getDelta();
+ try {
+ if(delta!=null) {
+ delta.accept(new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ if( delta.getResource() != null && delta.getResource().getLocation() != null &&
+ delta.getResource().getLocation().lastSegment().equals(IArchiveModel.DEFAULT_PACKAGES_FILE)) {
+ projects.add(delta.getResource().getProject());
+ }
+ return true;
+ }
+ });
+ }
+ } catch( CoreException ce ) {
+ }
+ Iterator<IProject> i = projects.iterator();
+ while(i.hasNext()) {
+ final IProject p = i.next();
+ try {
+ if( p.getSessionProperty(new QualifiedName(ArchivesCorePlugin.PLUGIN_ID, "localname")) == null ) {
+ try {
+ ArchivesModel.instance().registerProject(p.getLocation(), new NullProgressMonitor());
+ new Job("Refresh Project: " + p.getName()) {
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ p.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch( CoreException e ) {
+ IStatus status = new Status(IStatus.WARNING, ArchivesCorePlugin.PLUGIN_ID, "Could not refresh project " + p.getName(), e);
+ return status;
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ } catch( ArchivesModelException ame ) {
+ ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, "Could not register project " + p.getName(), ame);
+ }
+ }
+ } catch( CoreException ce ) {
+ }
+ }
+ }
+
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,182 +1,184 @@
-/*
- * 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.build;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IPath;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.EventManager;
-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.IArchiveModelRootNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
-import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
-
-/**
- * This delegate will either build from the model completely
- * (if the builder has been given a full build request) or
- * incrementally update the changed files in
- * **ANY AND ALL** filesets that they match, regardless of project.
- *
- * @author Rob Stryker (rob.stryker(a)redhat.com)
- *
- */
-public class ArchiveBuildDelegate {
-
- public ArchiveBuildDelegate() {
- }
-
-
- /**
- * A full project build has been requested.
- * @param project The project containing the archive model
- */
- public void fullProjectBuild(IPath project) {
- EventManager.cleanProjectBuild(project);
- EventManager.startedBuild(project);
-
- IArchiveModelRootNode root = ArchivesModel.instance().getRoot(project);
- if( root == null ) return;
- IArchiveNode[] nodes = root.getChildren(IArchiveNode.TYPE_ARCHIVE);
- for( int i = 0; i < nodes.length; i++ ) {
- fullArchiveBuild(((IArchive)nodes[i]));
- }
-
- EventManager.finishedBuild(project);
- }
-
- /**
- * Builds an archive entirely, overwriting whatever was in the output destination.
- * @param pkg The archive to build
- */
- public void fullArchiveBuild(IArchive pkg) {
- EventManager.cleanArchiveBuild(pkg);
- EventManager.startedBuildingArchive(pkg);
-
- ModelTruezipBridge.deleteArchive(pkg);
- if( !pkg.getGlobalDestinationPath().toFile().exists() ) {
- pkg.getGlobalDestinationPath().toFile().mkdirs();
- }
- ModelTruezipBridge.createFile(pkg);
-
- // force create all folders
- IArchiveFolder[] folders = ModelUtil.findAllDescendentFolders(pkg);
- for( int i = 0; i < folders.length; i++ ) {
- ModelTruezipBridge.createFile(folders[i]);
- }
-
- // build the filesets
- IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(pkg);
- for( int i = 0; i < filesets.length; i++ ) {
- fullFilesetBuild(filesets[i], pkg);
- }
-
- EventManager.finishedBuildingArchive(pkg);
- }
-
- /**
- * Build the given fileset
- * @param fileset The fileset to match
- * @param topLevel The top level archive that the fileset belongs to
- */
- protected void fullFilesetBuild(IArchiveFileSet fileset, IArchive topLevel) {
- EventManager.startedCollectingFileSet(fileset);
-
- // reset the scanner. It *is* a full build afterall
- fileset.resetScanner();
- IPath[] paths = fileset.findMatchingPaths();
- ModelTruezipBridge.fullFilesetBuild(fileset);
-
- EventManager.filesUpdated(topLevel, fileset, paths);
- EventManager.finishedCollectingFileSet(fileset);
- }
-
-
-
-
- /**
- * Incremental Build!!
- * Parameters are instances of changed IPath objects.
- * Will search the entire model for matching filesets.
- *
- * @param addedChanged Set of changed / added resources
- * @param setRemoved Set of removed resources
- */
- public void projectIncrementalBuild(Set<IPath> addedChanged, Set<IPath> removed) {
- incrementalBuild(null, addedChanged, removed);
- }
-
- /**
- * Incremental build.
- * Parameters are instance sof changed IPath objects
- * Will search only the given node for matching descendent filesets
- * @param archive An archive to limit the scope to, or null if the entire default model
- * @param addedChanged A list of added or changed resource paths
- * @param removed A list of removed resource paths
- */
- public void incrementalBuild(IArchive archive, Set<IPath> addedChanged, Set<IPath> removed) {
-
- // find any and all filesets that match each file
- Iterator<IPath> i = addedChanged.iterator();
- IPath path;
- IArchiveFileSet[] matchingFilesets;
- ArrayList<IArchive> topPackagesChanged = new ArrayList<IArchive>();
- while(i.hasNext()) {
- path = i.next();
- matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
- localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- ModelTruezipBridge.copyFiles(matchingFilesets, new IPath[] { path }, false);
- EventManager.fileUpdated(path, matchingFilesets);
- }
-
- i = removed.iterator();
- while(i.hasNext()) {
- path = ((IPath)i.next());
- matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
- localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- ModelTruezipBridge.deleteFiles(matchingFilesets, new IPath[] { path }, false);
- EventManager.fileRemoved(path, matchingFilesets);
- }
-
- TrueZipUtil.sync();
-
- Iterator<IArchive> i2 = topPackagesChanged.iterator();
- while(i2.hasNext()) {
- EventManager.finishedBuildingArchive(i2.next());
- }
- }
-
- private void localFireAffectedTopLevelPackages(ArrayList<IArchive> affected, IArchiveFileSet[] filesets) {
- for( int i = 0; i < filesets.length; i++ ) {
- if( !affected.contains(filesets[i].getRootArchive())) {
- affected.add(filesets[i].getRootArchive());
- EventManager.startedBuildingArchive(filesets[i].getRootArchive());
- }
- }
- }
-}
+/*
+ * 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.build;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.EventManager;
+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.IArchiveModelRootNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
+import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
+
+/**
+ * This delegate will either build from the model completely
+ * (if the builder has been given a full build request) or
+ * incrementally update the changed files in
+ * **ANY AND ALL** filesets that they match, regardless of project.
+ *
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ArchiveBuildDelegate {
+
+ public ArchiveBuildDelegate() {
+ }
+
+
+ /**
+ * A full project build has been requested.
+ * @param project The project containing the archive model
+ */
+ public void fullProjectBuild(IPath project) {
+ EventManager.cleanProjectBuild(project);
+ EventManager.startedBuild(project);
+
+ IArchiveModelRootNode root = ArchivesModel.instance().getRoot(project);
+ if( root == null ) return;
+ IArchiveNode[] nodes = root.getChildren(IArchiveNode.TYPE_ARCHIVE);
+ for( int i = 0; i < nodes.length; i++ ) {
+ fullArchiveBuild(((IArchive)nodes[i]));
+ }
+
+ EventManager.finishedBuild(project);
+ }
+
+ /**
+ * Builds an archive entirely, overwriting whatever was in the output destination.
+ * @param pkg The archive to build
+ */
+ public void fullArchiveBuild(IArchive pkg) {
+ EventManager.cleanArchiveBuild(pkg);
+ EventManager.startedBuildingArchive(pkg);
+
+ ModelTruezipBridge.deleteArchive(pkg);
+ if( !pkg.getGlobalDestinationPath().toFile().exists() ) {
+ pkg.getGlobalDestinationPath().toFile().mkdirs();
+ }
+ ModelTruezipBridge.createFile(pkg);
+
+ // force create all folders
+ IArchiveFolder[] folders = ModelUtil.findAllDescendentFolders(pkg);
+ for( int i = 0; i < folders.length; i++ ) {
+ ModelTruezipBridge.createFile(folders[i]);
+ }
+
+ // build the filesets
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(pkg);
+ for( int i = 0; i < filesets.length; i++ ) {
+ fullFilesetBuild(filesets[i], pkg);
+ }
+
+ EventManager.finishedBuildingArchive(pkg);
+ }
+
+ /**
+ * Build the given fileset
+ * @param fileset The fileset to match
+ * @param topLevel The top level archive that the fileset belongs to
+ */
+ protected void fullFilesetBuild(IArchiveFileSet fileset, IArchive topLevel) {
+ EventManager.startedCollectingFileSet(fileset);
+
+ // reset the scanner. It *is* a full build afterall
+ fileset.resetScanner();
+ IPath[] paths = fileset.findMatchingPaths();
+ ModelTruezipBridge.fullFilesetBuild(fileset);
+
+ EventManager.filesUpdated(topLevel, fileset, paths);
+ EventManager.finishedCollectingFileSet(fileset);
+ }
+
+
+
+
+ /**
+ * Incremental Build!!
+ * Parameters are instances of changed IPath objects.
+ * Will search the entire model for matching filesets.
+ *
+ * @param addedChanged Set of changed / added resources
+ * @param setRemoved Set of removed resources
+ */
+ public void projectIncrementalBuild(Set<IPath> addedChanged, Set<IPath> removed) {
+ incrementalBuild(null, addedChanged, removed);
+ }
+
+ /**
+ * Incremental build.
+ * Parameters are instance sof changed IPath objects
+ * Will search only the given node for matching descendent filesets
+ * @param archive An archive to limit the scope to, or null if the entire default model
+ * @param addedChanged A list of added or changed resource paths
+ * @param removed A list of removed resource paths
+ */
+ public void incrementalBuild(IArchive archive, Set<IPath> addedChanged, Set<IPath> removed) {
+
+ // find any and all filesets that match each file
+ Iterator<IPath> i = addedChanged.iterator();
+ IPath path;
+ IArchiveFileSet[] matchingFilesets;
+ ArrayList<IArchive> topPackagesChanged = new ArrayList<IArchive>();
+ while(i.hasNext()) {
+ path = i.next();
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
+ localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
+ ModelTruezipBridge.copyFiles(matchingFilesets, new IPath[] { path }, false);
+ EventManager.fileUpdated(path, matchingFilesets);
+ }
+
+ i = removed.iterator();
+ while(i.hasNext()) {
+ path = ((IPath)i.next());
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
+ localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
+ ModelTruezipBridge.deleteFiles(matchingFilesets, new IPath[] { path }, false);
+ EventManager.fileRemoved(path, matchingFilesets);
+ }
+
+ TrueZipUtil.sync();
+
+ Iterator<IArchive> i2 = topPackagesChanged.iterator();
+ while(i2.hasNext()) {
+ EventManager.finishedBuildingArchive(i2.next());
+ }
+ }
+
+ private void localFireAffectedTopLevelPackages(ArrayList<IArchive> affected, IArchiveFileSet[] filesets) {
+ for( int i = 0; i < filesets.length; i++ ) {
+ if( !affected.contains(filesets[i].getRootArchive())) {
+ affected.add(filesets[i].getRootArchive());
+ EventManager.startedBuildingArchive(filesets[i].getRootArchive());
+ }
+ }
+ }
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,222 +1,239 @@
-/**
- * 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.build;
-
-import org.eclipse.core.runtime.IPath;
-import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.model.EventManager;
-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.IArchiveModelListener;
-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.IArchivesLogger;
-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 ) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, "Error updating model changes", e);
- }
- }
-
- /**
- * 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( isTopLevelArchive(delta.getPostNode()))
- EventManager.startedBuildingArchive((IArchive)delta.getPostNode());
-
- if( (delta.getKind() & (IArchiveNodeDelta.NODE_REGISTERED | IArchiveNodeDelta.UNKNOWN_CHANGE)) != 0 ) {
- nodeRemoved(delta.getPreNode());
- nodeAdded(delta.getPostNode());
- } if( (delta.getKind() & IArchiveNodeDelta.REMOVED) != 0 ) {
- nodeRemoved(delta.getPreNode());
- } else if( (delta.getKind() & IArchiveNodeDelta.ADDED) != 0 ) {
- nodeAdded(delta.getPostNode());
- } 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]);
- }
- }
-
- if( isTopLevelArchive(delta.getPostNode()))
- EventManager.finishedBuildingArchive((IArchive)delta.getPostNode());
-
- }
- protected boolean descendentChanged(int kind) {
- return (kind & IArchiveNodeDelta.DESCENDENT_CHANGED) != 0 ||
- (kind & IArchiveNodeDelta.CHILD_ADDED) != 0 ||
- (kind & IArchiveNodeDelta.CHILD_REMOVED) != 0;
- }
- protected boolean isTopLevelArchive(IArchiveNode node) {
- if( node != null && node instanceof IArchive && ((IArchive)node).isTopLevel())
- return true;
- return false;
- }
- /**
- * 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;
- }
-
-
- /*
- * These three methods will need to be optimized eventually. Because right now they suck
- */
- 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 == null ) return;
-
- if( added.getNodeType() == IArchiveNode.TYPE_MODEL_ROOT) {
- IArchiveNode[] archives = ((IArchiveModelRootNode)added).getChildren(IArchiveNode.TYPE_ARCHIVE);
- for( int i = 0; i < archives.length; i++ ) {
- nodeAdded(archives[i]);
- }
- } else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- // create the package
- ModelTruezipBridge.createFile(added);
- } else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
- // create the 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);
- }
- postChange(added);
- }
-
-
- private void nodeRemoved(IArchiveNode removed) {
- if( removed == null ) return;
- if( removed.getNodeType() == IArchiveNode.TYPE_MODEL_ROOT ) {
- // remove all top level items
- IArchiveNode[] kids = removed.getChildren(IArchiveNode.TYPE_ARCHIVE);
- for( int i = 0; i < kids.length; i++ ) {
- nodeRemoved(kids[i]);
- }
- postChange(removed);
- return;
- } else if( removed.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- ModelTruezipBridge.deleteArchive((IArchive)removed);
- postChange(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(filesets[i], false);
- EventManager.filesRemoved(removedPaths, ((IArchiveFileSet)filesets[i]));
- }
- postChange(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));
- }
- postChange(removed);
- }
-
-
- protected void postChange(IArchiveNode node) {
- }
-}
+/**
+ * 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.build;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.EventManager;
+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.IArchiveModelListener;
+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.IArchivesLogger;
+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 ) {
+ ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, "Error updating model changes", e);
+ }
+ }
+
+ /**
+ * 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( isTopLevelArchive(delta.getPostNode())) {
+ EventManager.startedBuildingArchive((IArchive)delta.getPostNode());
+ }
+
+ if( (delta.getKind() & (IArchiveNodeDelta.NODE_REGISTERED | IArchiveNodeDelta.UNKNOWN_CHANGE)) != 0 ) {
+ nodeRemoved(delta.getPreNode());
+ nodeAdded(delta.getPostNode());
+ } if( (delta.getKind() & IArchiveNodeDelta.REMOVED) != 0 ) {
+ nodeRemoved(delta.getPreNode());
+ } else if( (delta.getKind() & IArchiveNodeDelta.ADDED) != 0 ) {
+ nodeAdded(delta.getPostNode());
+ } 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]);
+ }
+ }
+
+ if( isTopLevelArchive(delta.getPostNode()))
+ EventManager.finishedBuildingArchive((IArchive)delta.getPostNode());
+
+ }
+ protected boolean descendentChanged(int kind) {
+ return (kind & IArchiveNodeDelta.DESCENDENT_CHANGED) != 0 ||
+ (kind & IArchiveNodeDelta.CHILD_ADDED) != 0 ||
+ (kind & IArchiveNodeDelta.CHILD_REMOVED) != 0;
+ }
+ protected boolean isTopLevelArchive(IArchiveNode node) {
+ if( node != null && node instanceof IArchive && ((IArchive)node).isTopLevel())
+ return true;
+ return false;
+ }
+ /**
+ * 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;
+ }
+
+
+ /*
+ * These three methods will need to be optimized eventually. Because right now they suck
+ */
+ 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 == null ) return;
+
+ if( added.getNodeType() == IArchiveNode.TYPE_MODEL_ROOT) {
+ IArchiveNode[] archives = ((IArchiveModelRootNode)added).getChildren(IArchiveNode.TYPE_ARCHIVE);
+ for( int i = 0; i < archives.length; i++ ) {
+ nodeAdded(archives[i]);
+ }
+ } else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ // create the package
+ if( ((IArchive)added).isTopLevel() && !added.canBuild() ) {
+ logCannotBuildError((IArchive)added);
+ return;
+ }
+ ModelTruezipBridge.createFile(added);
+ } else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
+ // create the 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);
+ }
+ postChange(added);
+ }
+
+
+ private void nodeRemoved(IArchiveNode removed) {
+ if( removed == null ) return;
+ if( removed.getNodeType() == IArchiveNode.TYPE_MODEL_ROOT ) {
+ // remove all top level items
+ IArchiveNode[] kids = removed.getChildren(IArchiveNode.TYPE_ARCHIVE);
+ for( int i = 0; i < kids.length; i++ ) {
+ nodeRemoved(kids[i]);
+ }
+ postChange(removed);
+ return;
+ } else if( removed.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ if( ((IArchive)removed).isTopLevel() && !removed.canBuild() ) {
+ logCannotBuildError((IArchive)removed);
+ return;
+ }
+ ModelTruezipBridge.deleteArchive((IArchive)removed);
+ postChange(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(filesets[i], false);
+ EventManager.filesRemoved(removedPaths, ((IArchiveFileSet)filesets[i]));
+ }
+ postChange(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));
+ }
+ postChange(removed);
+ }
+
+
+ protected void postChange(IArchiveNode node) {
+ }
+
+ protected void logCannotBuildError(IArchive archive) {
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING,
+ "Cannot Build archive \"" + archive.getName() +
+ "\" due to a problem in the archive's configuration.", null);
+ return;
+ }
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,87 +1,90 @@
-/*
- * 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;
-
-import org.apache.tools.ant.DirectoryScanner;
-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.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-
-/**
- * Utility methods and entry points for model-related APIs
- * @author Rob Stryker (rob.stryker(a)redhat.com)
- *
- */
-public class ArchivesModelCore {
-
- /**
- * Builds all of a project's packages. Note that this does not call any builders before or after the package builder (i.e. the JDT builder).
- * If you are looking to run all the builders on a project use project.build()
- * @param project The project to build
- * @param buildType FULL_BUILD, INCREMENTAL_BUILD, CLEAN_BUILD, etc
- * @param monitor A progress monitor
- */
- public static void buildProject (IPath project, IProgressMonitor monitor) {
- if (monitor == null) monitor = new NullProgressMonitor();
- new ArchiveBuildDelegate().fullProjectBuild(project);
- }
-
- /**
- * Build the passed-in package.
- * @param pkg The package to build
- */
- public static void buildArchive (IArchive pkg, IProgressMonitor monitor) {
- if (monitor == null) monitor = new NullProgressMonitor();
- new ArchiveBuildDelegate().fullArchiveBuild(pkg);
- }
-
- public static boolean packageFileExists (IPath project) {
- return project.append(IArchiveModel.DEFAULT_PACKAGES_FILE).toFile().exists();
- }
-
- public static boolean projectRegistered(IPath project) {
- return ArchivesModel.instance().getRoot(project) == null ? false : true;
- }
-
- public static IPath[] findMatchingPaths(IPath root, String includes, String excludes) {
- try {
- if(root==null) return new IPath[0];
-
- DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(root, includes, excludes, true);
- String[] files = scanner.getIncludedFiles();
- IPath[] paths = new IPath[files.length];
- for( int i = 0; i < files.length; i++ ) {
- paths[i] = new Path(files[i]);
- }
- return paths;
- } catch( IllegalStateException ise ) {
- ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Error creating directory scanner", ise);
- return new IPath[]{};
- }
- }
-
-}
+/*
+ * 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;
+
+import org.apache.tools.ant.DirectoryScanner;
+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.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+
+/**
+ * Utility methods and entry points for model-related APIs
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ArchivesModelCore {
+
+ /**
+ * Builds all of a project's packages. Note that this does not call any builders before or after the package builder (i.e. the JDT builder).
+ * If you are looking to run all the builders on a project use project.build()
+ * @param project The project to build
+ * @param buildType FULL_BUILD, INCREMENTAL_BUILD, CLEAN_BUILD, etc
+ * @param monitor A progress monitor
+ */
+ public static void buildProject (IPath project, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+ new ArchiveBuildDelegate().fullProjectBuild(project);
+ }
+
+ /**
+ * Build the passed-in package.
+ * @param pkg The package to build
+ */
+ public static void buildArchive (IArchive pkg, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+ new ArchiveBuildDelegate().fullArchiveBuild(pkg);
+ }
+
+ public static boolean packageFileExists (IPath project) {
+ return project.append(IArchiveModel.DEFAULT_PACKAGES_FILE).toFile().exists();
+ }
+
+ public static boolean projectRegistered(IPath project) {
+ return ArchivesModel.instance().getRoot(project) == null ? false : true;
+ }
+
+ public static IPath[] findMatchingPaths(IPath root, String includes, String excludes) {
+ try {
+ if(root==null) return new IPath[0];
+
+ DirectoryScanner scanner =
+ DirectoryScannerFactory.createDirectoryScanner(root, includes, excludes, true);
+
+ if( scanner == null )
+ return new IPath[] {};
+
+ String[] files = scanner.getIncludedFiles();
+ IPath[] paths = new IPath[files.length];
+ for( int i = 0; i < files.length; i++ ) {
+ paths[i] = new Path(files[i]);
+ }
+ return paths;
+ } catch( IllegalStateException ise ) {
+ return new IPath[]{};
+ }
+ }
+
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,65 +1,67 @@
-/**
- * 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;
-
-import java.io.File;
-
-import org.apache.tools.ant.DirectoryScanner;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Utility methods to create scanners for matching
- * @author rob.stryker(a)jboss.com
- */
-public class DirectoryScannerFactory {
-
- public static DirectoryScannerExtension createDirectoryScanner (IPath filesystemFolder, String includes, String excludes, boolean scan) {
- if (includes == null) includes = "";
- if (excludes == null) excludes = "";
-
- DirectoryScannerExtension scanner = new DirectoryScannerExtension();
- String excludesList[] = excludes.split(" ?, ?");
- String includesList[] = includes.split(" ?, ?");
-
- File basedir = filesystemFolder.toFile();
- scanner.setBasedir(basedir);
- scanner.setExcludes(excludesList);
- scanner.setIncludes(includesList);
- if (scan) {
- scanner.scan();
- }
-
- return scanner;
- }
-
- /**
- * Exposes the isIncluded method so that entire scans do not need to occur
- * to find matches.
- *
- * Overwrites
- */
- public static class DirectoryScannerExtension extends DirectoryScanner {
- public boolean isUltimatelyIncluded(String name) {
- return super.isIncluded(name) && !super.isExcluded(name);
- }
- }
-}
+/**
+ * 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;
+
+import java.io.File;
+
+import org.apache.tools.ant.DirectoryScanner;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Utility methods to create scanners for matching
+ * @author rob.stryker(a)jboss.com
+ */
+public class DirectoryScannerFactory {
+
+ public static DirectoryScannerExtension createDirectoryScanner (IPath filesystemFolder, String includes, String excludes, boolean scan) {
+ if (includes == null) includes = "";
+ if (excludes == null) excludes = "";
+ if( filesystemFolder == null )
+ return null;
+
+ DirectoryScannerExtension scanner = new DirectoryScannerExtension();
+ String excludesList[] = excludes.split(" ?, ?");
+ String includesList[] = includes.split(" ?, ?");
+
+ File basedir = filesystemFolder.toFile();
+ scanner.setBasedir(basedir);
+ scanner.setExcludes(excludesList);
+ scanner.setIncludes(includesList);
+ if (scan) {
+ scanner.scan();
+ }
+
+ return scanner;
+ }
+
+ /**
+ * Exposes the isIncluded method so that entire scans do not need to occur
+ * to find matches.
+ *
+ * Overwrites
+ */
+ public static class DirectoryScannerExtension extends DirectoryScanner {
+ public boolean isUltimatelyIncluded(String name) {
+ return super.isIncluded(name) && !super.isExcluded(name);
+ }
+ }
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,191 +1,197 @@
-/*
- * 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;
-
-import org.eclipse.core.runtime.IPath;
-
-/**
- * The super type of all package nodes (IPackage, IPackageFileSet, IPackageFolder)
- *
- * Each node in a package may have arbitrary properties that can be reflected upon by other plug-ins
- *
- * @author <a href="marshall(a)jboss.org">Marshall Culpepper</a>
- * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
- * @version $Revision: 1929 $
- */
-public interface IArchiveNode {
- /**
- * The node type that represents the model
- */
- public static final int TYPE_MODEL_ROOT = -1;
-
- /**
- * The node type that represents an IArchive
- */
- public static final int TYPE_ARCHIVE = 0;
-
- /**
- * The node type that represents an IArchiveReference
- */
- public static final int TYPE_ARCHIVE_REFERENCE = 1;
-
- /**
- * The node type that represents an IArchiveFileSet
- */
- public static final int TYPE_ARCHIVE_FILESET = 2;
-
- /**
- * The node type that represents an IActionFolder
- */
- public static final int TYPE_ARCHIVE_FOLDER = 3;
-
- /**
- * The node type that represents an IArchiveAction
- */
- public static final int TYPE_ARCHIVE_ACTION = 4;
-
-
- /**
- * @return The parent of this package node, or null if this node is top level
- */
- public IArchiveNode getParent();
-
- /**
- * Set the parent of this package node
- * @param parent The new parent of this node
- */
- public void setParent(IArchiveNode parent);
-
- /**
- * @param type TYPE_PACKAGE, TYPE_PACKAGE_FILESET, or TYPE_PACKAGE_FOLDER
- * @return An array of child nodes of the passed in type
- */
- public IArchiveNode[] getChildren(int type);
-
- /**
- * @return An array of all children nodes
- */
- public IArchiveNode[] getAllChildren();
-
- /**
- * @return Whether or not this node has children
- */
- public boolean hasChildren();
-
- /**
- * @param child A possible child node
- * @return Whether or not the passed-in node is a child of this node
- */
- public boolean hasChild(IArchiveNode child);
-
- /**
- * @return The type of this package node
- */
- public int getNodeType();
-
- /**
- * @param property The name of the property to fetch
- * @return The value of the specified property
- */
- public String getProperty(String property);
-
- /**
- * Set a property on this package node
- * @param property The name of the property to set
- * @param value The new value of the property
- */
- public void setProperty(String property, String value);
-
- /**
- * @return The project that this node is defined in (not necessarily the project where this is based if this is a fileset)
- */
- public IPath getProjectPath();
-
- /**
- * Recursively visit the package node tree below this node with the passed-in package node visitor.
- * @param visitor A package node visitor
- * @return Whether or not the entire sub-tree was visited
- */
- public boolean accept(IArchiveNodeVisitor visitor);
-
- /**
- * Recursively visit the package node tree below this node with the passed-in package node visitor, using depth-first ordering
- * @param visitor A package node visitor
- * @return Whether or not the entire sub-tree was visited
- */
- public boolean accept(IArchiveNodeVisitor visitor, boolean depthFirst);
-
- /**
- * Add a child node to this node
- * @param child The child to add
- */
- public void addChild(IArchiveNode child) throws ArchivesModelException;
-
- /**
- * Remove a child node from this node
- * @param child The child to remove
- */
- public void removeChild(IArchiveNode child);
-
- /**
- * Get the highest parent that is not null.
- * @return
- */
- public IArchiveNode getRoot();
-
- /**
- * Get the model this node is attached to, or null if none
- * @return
- */
- public IArchiveModelRootNode getModelRootNode();
-
- /**
- * Get the path relative to the root archive,
- * or null if not applicable.
- * @return
- */
- public IPath getRootArchiveRelativePath();
-
- /**
- * Get the root top-level package for this node
- * @return
- */
- public IArchive getRootArchive();
-
- /**
- * Get the current delta
- * @return
- */
- public IArchiveNodeDelta getDelta();
-
- /**
- * Clear the current delta
- * @return
- */
- public void clearDelta();
-
- /**
- * Validating the model
- * @return true if it's ok, false if it should fail
- */
- public boolean validateModel();
-}
+/*
+ * 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;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * The super type of all package nodes (IPackage, IPackageFileSet, IPackageFolder)
+ *
+ * Each node in a package may have arbitrary properties that can be reflected upon by other plug-ins
+ *
+ * @author <a href="marshall(a)jboss.org">Marshall Culpepper</a>
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ * @version $Revision: 1929 $
+ */
+public interface IArchiveNode {
+ /**
+ * The node type that represents the model
+ */
+ public static final int TYPE_MODEL_ROOT = -1;
+
+ /**
+ * The node type that represents an IArchive
+ */
+ public static final int TYPE_ARCHIVE = 0;
+
+ /**
+ * The node type that represents an IArchiveReference
+ */
+ public static final int TYPE_ARCHIVE_REFERENCE = 1;
+
+ /**
+ * The node type that represents an IArchiveFileSet
+ */
+ public static final int TYPE_ARCHIVE_FILESET = 2;
+
+ /**
+ * The node type that represents an IActionFolder
+ */
+ public static final int TYPE_ARCHIVE_FOLDER = 3;
+
+ /**
+ * The node type that represents an IArchiveAction
+ */
+ public static final int TYPE_ARCHIVE_ACTION = 4;
+
+
+ /**
+ * @return The parent of this package node, or null if this node is top level
+ */
+ public IArchiveNode getParent();
+
+ /**
+ * Set the parent of this package node
+ * @param parent The new parent of this node
+ */
+ public void setParent(IArchiveNode parent);
+
+ /**
+ * @param type TYPE_PACKAGE, TYPE_PACKAGE_FILESET, or TYPE_PACKAGE_FOLDER
+ * @return An array of child nodes of the passed in type
+ */
+ public IArchiveNode[] getChildren(int type);
+
+ /**
+ * @return An array of all children nodes
+ */
+ public IArchiveNode[] getAllChildren();
+
+ /**
+ * @return Whether or not this node has children
+ */
+ public boolean hasChildren();
+
+ /**
+ * @param child A possible child node
+ * @return Whether or not the passed-in node is a child of this node
+ */
+ public boolean hasChild(IArchiveNode child);
+
+ /**
+ * @return The type of this package node
+ */
+ public int getNodeType();
+
+ /**
+ * @param property The name of the property to fetch
+ * @return The value of the specified property
+ */
+ public String getProperty(String property);
+
+ /**
+ * Set a property on this package node
+ * @param property The name of the property to set
+ * @param value The new value of the property
+ */
+ public void setProperty(String property, String value);
+
+ /**
+ * @return The project that this node is defined in (not necessarily the project where this is based if this is a fileset)
+ */
+ public IPath getProjectPath();
+
+ /**
+ * Recursively visit the package node tree below this node with the passed-in package node visitor.
+ * @param visitor A package node visitor
+ * @return Whether or not the entire sub-tree was visited
+ */
+ public boolean accept(IArchiveNodeVisitor visitor);
+
+ /**
+ * Recursively visit the package node tree below this node with the passed-in package node visitor, using depth-first ordering
+ * @param visitor A package node visitor
+ * @return Whether or not the entire sub-tree was visited
+ */
+ public boolean accept(IArchiveNodeVisitor visitor, boolean depthFirst);
+
+ /**
+ * Add a child node to this node
+ * @param child The child to add
+ */
+ public void addChild(IArchiveNode child) throws ArchivesModelException;
+
+ /**
+ * Remove a child node from this node
+ * @param child The child to remove
+ */
+ public void removeChild(IArchiveNode child);
+
+ /**
+ * Get the highest parent that is not null.
+ * @return
+ */
+ public IArchiveNode getRoot();
+
+ /**
+ * Get the model this node is attached to, or null if none
+ * @return
+ */
+ public IArchiveModelRootNode getModelRootNode();
+
+ /**
+ * Get the path relative to the root archive,
+ * or null if not applicable.
+ * @return
+ */
+ public IPath getRootArchiveRelativePath();
+
+ /**
+ * Get the root top-level package for this node
+ * @return
+ */
+ public IArchive getRootArchive();
+
+ /**
+ * Get the current delta
+ * @return
+ */
+ public IArchiveNodeDelta getDelta();
+
+ /**
+ * Clear the current delta
+ * @return
+ */
+ public void clearDelta();
+
+ /**
+ * Validating the model
+ * @return true if it's ok, false if it should fail
+ */
+ public boolean validateModel();
+
+ /**
+ * Are all of the fields here accessible to be built?
+ * @throws AssertionFailedException with what's wrong
+ */
+ public boolean canBuild();
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,293 +1,294 @@
-/*
- * 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.internal;
-
-import java.util.ArrayList;
-
-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.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-
-/**
- * An implementation for filesets
- * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
- *
- */
-public class ArchiveFileSetImpl extends ArchiveNodeImpl implements
- IArchiveFileSet {
-
- private DirectoryScannerExtension scanner;
- private ArrayList<IPath> matchingPaths;
- private boolean rescanRequired = true;
-
- public ArchiveFileSetImpl() {
- this(new XbFileSet());
- }
-
- public ArchiveFileSetImpl (XbFileSet delegate) {
- super(delegate);
- }
-
- /*
- * @see IArchiveFileSet#findMatchingPaths()
- */
- public synchronized IPath[] findMatchingPaths () {
- getScanner(); // ensure up to date
- return matchingPaths == null ? new IPath[0] : matchingPaths.toArray(new IPath[matchingPaths.size()]);
- }
-
- /*
- * @see IArchiveFileSet#getExcludesPattern()
- */
- public String getExcludesPattern() {
- return getFileSetDelegate().getExcludes();
- }
-
- /*
- * @see IArchiveFileSet#isInWorkspace()
- */
- public boolean isInWorkspace() {
- return getFileSetDelegate().isInWorkspace();
- }
-
- /*
- * @see IArchiveFileSet#getIncludesPattern()
- */
- public String getIncludesPattern() {
- return getFileSetDelegate().getIncludes();
- }
-
- /*
- * @see IArchiveFileSet#getGlobalSourcePath()
- */
- public IPath getGlobalSourcePath() {
- IPath ret;
- String path = getFileSetDelegate().getDir();
- if (path == null || path.equals(".") || path.equals("")) {
- ret = getProjectPath();
- } else if( isInWorkspace()){
- ret = ModelUtil.workspacePathToAbsolutePath(new Path(path));
- } else {
- ret = new Path(path);
- }
-
- if( ret == null ) {
- String message = "Error in fileset: " + toString() + "; No global source path found.";
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_WARN, message, new Exception(message));
- }
-
- return ret;
- }
-
- /*
- * @see IArchiveFileSet#getSourcePath()
- */
- public IPath getSourcePath() {
- return getFileSetDelegate().getDir() == null ?
- null : new Path(getFileSetDelegate().getDir());
- }
-
- /*
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#isFlattened()
- */
- public boolean isFlattened() {
- return getFileSetDelegate().isFlattened();
- }
-
- /*
- * @see IArchiveFileSet#matchesPath(IPath)
- */
- public boolean matchesPath(IPath path) {
- return matchesPath(getScanner(), path);
- }
-
- private boolean matchesPath(DirectoryScannerExtension scanner, IPath path) {
- IPath global = getGlobalSourcePath();
- if( global != null ) {
- if( global.isPrefixOf(path)) {
- String s = path.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
- return scanner.isUltimatelyIncluded(s);
- }
- }
- return false;
- }
-
- /*
- * Will re-scan if required, or use cached scanner
- * @return
- */
- private synchronized DirectoryScannerExtension getScanner() {
- if( scanner == null || rescanRequired) {
- rescanRequired = false;
-
- try {
- // new scanner
- scanner = DirectoryScannerFactory.createDirectoryScanner(
- getGlobalSourcePath(), getIncludesPattern(), getExcludesPattern(), true);
-
- // cache the paths
- ArrayList<IPath> paths = new ArrayList<IPath>();
- IPath sp = getGlobalSourcePath();
- String matched[] = scanner.getIncludedFiles();
- for (int i = 0; i < matched.length; i++) {
- IPath path = sp.append(new Path(matched[i]));
- paths.add(path);
- }
- matchingPaths = paths;
- } catch( IllegalStateException ise ) {
- ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Could not create directory scanner", ise);
- }
- }
- return scanner;
- }
-
- /*
- * @see IArchiveNode#getNodeType()
- */
- public int getNodeType() {
- return TYPE_ARCHIVE_FILESET;
- }
-
- /*
- * @see IArchiveFileSet#setExcludesPattern(String)
- */
- public void setExcludesPattern(String excludes) {
- attributeChanged(EXCLUDES_ATTRIBUTE, getExcludesPattern(), excludes);
- getFileSetDelegate().setExcludes(excludes);
- rescanRequired = true;
- }
-
- /*
- * @see IArchiveFileSet#setIncludesPattern(String)
- */
- public void setIncludesPattern(String includes) {
- attributeChanged(INCLUDES_ATTRIBUTE, getIncludesPattern(), includes);
- getFileSetDelegate().setIncludes(includes);
- rescanRequired = true;
- }
-
- /*
- * @see IArchiveFileSet#setInWorkspace(boolean)
- */
- public void setInWorkspace(boolean isInWorkspace) {
- attributeChanged(IN_WORKSPACE_ATTRIBUTE, new Boolean(isInWorkspace()), new Boolean(isInWorkspace));
- getFileSetDelegate().setInWorkspace(isInWorkspace);
- rescanRequired = true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#setFlattened(boolean)
- */
- public void setFlattened(boolean flat) {
- attributeChanged(FLATTENED_ATTRIBUTE, new Boolean(isFlattened()), new Boolean(flat));
- getFileSetDelegate().setFlattened(flat);
- //TODO: rescanRequired = true;
- }
-
- /*
- * @see IArchiveFileSet#setSourcePath(IPath, boolean)
- */
- public void setSourcePath (IPath path) {
- Assert.isNotNull(path);
- IPath src = getSourcePath();
- attributeChanged(SOURCE_PATH_ATTRIBUTE, src == null ? null : src.toString(), path == null ? null : path.toString());
- getFileSetDelegate().setDir(path.toString());
- rescanRequired = true;
- }
-
- protected XbFileSet getFileSetDelegate () {
- return (XbFileSet)nodeDelegate;
- }
-
-
- /*
- * 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#getRootArchiveRelativePath(IPath)
- */
- public IPath getRootArchiveRelativePath(IPath inputFile) {
- if( matchesPath(inputFile)) {
- return getParent().getRootArchiveRelativePath().append(getPathRelativeToParent(inputFile));
- }
- return null;
- }
- /*
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#getPathRelativeToParent(org.eclipse.core.runtime.IPath)
- */
- public IPath getPathRelativeToParent(IPath inputFile) {
- String s;
- if( isFlattened() )
- s = inputFile.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
- else
- s = inputFile.lastSegment();
- return new Path(s);
- }
-
-
- /*
- * @see IArchiveFileSet#resetScanner()
- */
- public void resetScanner() {
- rescanRequired = true;
- }
-
- /*
- * (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;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("{dir=");
- sb.append(getFileSetDelegate().getDir());
- sb.append(",includes=");
- sb.append(getFileSetDelegate().getIncludes());
- sb.append(",excludes=");
- sb.append(getFileSetDelegate().getExcludes());
- sb.append(",inWorkspace=");
- sb.append(getFileSetDelegate().isInWorkspace());
- sb.append(",flatten=");
- sb.append(getFileSetDelegate().isFlattened());
- return sb.toString();
- }
-
-}
+/*
+ * 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.internal;
+
+import java.util.ArrayList;
+
+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.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+
+/**
+ * An implementation for filesets
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class ArchiveFileSetImpl extends ArchiveNodeImpl implements
+ IArchiveFileSet {
+
+ private DirectoryScannerExtension scanner;
+ private ArrayList<IPath> matchingPaths;
+ private boolean rescanRequired = true;
+
+ public ArchiveFileSetImpl() {
+ this(new XbFileSet());
+ }
+
+ public ArchiveFileSetImpl (XbFileSet delegate) {
+ super(delegate);
+ }
+
+ /*
+ * @see IArchiveFileSet#findMatchingPaths()
+ */
+ public synchronized IPath[] findMatchingPaths () {
+ getScanner(); // ensure up to date
+ return matchingPaths == null ? new IPath[0] : matchingPaths.toArray(new IPath[matchingPaths.size()]);
+ }
+
+ /*
+ * @see IArchiveFileSet#getExcludesPattern()
+ */
+ public String getExcludesPattern() {
+ return getFileSetDelegate().getExcludes();
+ }
+
+ /*
+ * @see IArchiveFileSet#isInWorkspace()
+ */
+ public boolean isInWorkspace() {
+ return getFileSetDelegate().isInWorkspace();
+ }
+
+ /*
+ * @see IArchiveFileSet#getIncludesPattern()
+ */
+ public String getIncludesPattern() {
+ return getFileSetDelegate().getIncludes();
+ }
+
+ /*
+ * @see IArchiveFileSet#getGlobalSourcePath()
+ */
+ public IPath getGlobalSourcePath() {
+ IPath ret;
+ String path = getFileSetDelegate().getDir();
+ if (path == null || path.equals(".") || path.equals("")) {
+ ret = getProjectPath();
+ } else if( isInWorkspace()){
+ ret = ModelUtil.workspacePathToAbsolutePath(new Path(path));
+ } else {
+ ret = new Path(path);
+ }
+ return ret;
+ }
+
+ /*
+ * @see IArchiveFileSet#getSourcePath()
+ */
+ public IPath getSourcePath() {
+ return getFileSetDelegate().getDir() == null ?
+ null : new Path(getFileSetDelegate().getDir());
+ }
+
+ /*
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#isFlattened()
+ */
+ public boolean isFlattened() {
+ return getFileSetDelegate().isFlattened();
+ }
+
+ /*
+ * @see IArchiveFileSet#matchesPath(IPath)
+ */
+ public boolean matchesPath(IPath path) {
+ return matchesPath(getScanner(), path);
+ }
+
+ private boolean matchesPath(DirectoryScannerExtension scanner, IPath path) {
+ IPath global = getGlobalSourcePath();
+ if( global != null ) {
+ if( global.isPrefixOf(path)) {
+ String s = path.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
+ return scanner.isUltimatelyIncluded(s);
+ }
+ }
+ return false;
+ }
+
+ /*
+ * Will re-scan if required, or use cached scanner
+ * @return
+ */
+ private synchronized DirectoryScannerExtension getScanner() {
+ if( scanner == null || rescanRequired) {
+ rescanRequired = false;
+
+ try {
+ // new scanner
+ scanner = DirectoryScannerFactory.createDirectoryScanner(
+ getGlobalSourcePath(), getIncludesPattern(), getExcludesPattern(), true);
+
+ ArrayList<IPath> paths = new ArrayList<IPath>();
+ if( scanner != null ) {
+ // cache the paths
+ IPath sp = getGlobalSourcePath();
+ String matched[] = scanner.getIncludedFiles();
+ for (int i = 0; i < matched.length; i++) {
+ IPath path = sp.append(new Path(matched[i]));
+ paths.add(path);
+ }
+ }
+ matchingPaths = paths;
+ } catch( IllegalStateException ise ) {
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Could not create directory scanner", ise);
+ }
+ }
+ return scanner;
+ }
+
+ /*
+ * @see IArchiveNode#getNodeType()
+ */
+ public int getNodeType() {
+ return TYPE_ARCHIVE_FILESET;
+ }
+
+ /*
+ * @see IArchiveFileSet#setExcludesPattern(String)
+ */
+ public void setExcludesPattern(String excludes) {
+ attributeChanged(EXCLUDES_ATTRIBUTE, getExcludesPattern(), excludes);
+ getFileSetDelegate().setExcludes(excludes);
+ rescanRequired = true;
+ }
+
+ /*
+ * @see IArchiveFileSet#setIncludesPattern(String)
+ */
+ public void setIncludesPattern(String includes) {
+ attributeChanged(INCLUDES_ATTRIBUTE, getIncludesPattern(), includes);
+ getFileSetDelegate().setIncludes(includes);
+ rescanRequired = true;
+ }
+
+ /*
+ * @see IArchiveFileSet#setInWorkspace(boolean)
+ */
+ public void setInWorkspace(boolean isInWorkspace) {
+ attributeChanged(IN_WORKSPACE_ATTRIBUTE, new Boolean(isInWorkspace()), new Boolean(isInWorkspace));
+ getFileSetDelegate().setInWorkspace(isInWorkspace);
+ rescanRequired = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#setFlattened(boolean)
+ */
+ public void setFlattened(boolean flat) {
+ attributeChanged(FLATTENED_ATTRIBUTE, new Boolean(isFlattened()), new Boolean(flat));
+ getFileSetDelegate().setFlattened(flat);
+ //TODO: rescanRequired = true;
+ }
+
+ /*
+ * @see IArchiveFileSet#setSourcePath(IPath, boolean)
+ */
+ public void setSourcePath (IPath path) {
+ Assert.isNotNull(path);
+ IPath src = getSourcePath();
+ attributeChanged(SOURCE_PATH_ATTRIBUTE, src == null ? null : src.toString(), path == null ? null : path.toString());
+ getFileSetDelegate().setDir(path.toString());
+ rescanRequired = true;
+ }
+
+ protected XbFileSet getFileSetDelegate () {
+ return (XbFileSet)nodeDelegate;
+ }
+
+
+ /*
+ * 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#getRootArchiveRelativePath(IPath)
+ */
+ public IPath getRootArchiveRelativePath(IPath inputFile) {
+ if( matchesPath(inputFile)) {
+ return getParent().getRootArchiveRelativePath().append(getPathRelativeToParent(inputFile));
+ }
+ return null;
+ }
+ /*
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#getPathRelativeToParent(org.eclipse.core.runtime.IPath)
+ */
+ public IPath getPathRelativeToParent(IPath inputFile) {
+ String s;
+ if( isFlattened() )
+ s = inputFile.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
+ else
+ s = inputFile.lastSegment();
+ return new Path(s);
+ }
+
+
+ /*
+ * @see IArchiveFileSet#resetScanner()
+ */
+ public void resetScanner() {
+ rescanRequired = true;
+ }
+
+ /*
+ * (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;
+ }
+
+ public boolean canBuild() {
+ return getGlobalSourcePath() != null
+ && super.canBuild();
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("{dir=");
+ sb.append(getFileSetDelegate().getDir());
+ sb.append(",includes=");
+ sb.append(getFileSetDelegate().getIncludes());
+ sb.append(",excludes=");
+ sb.append(getFileSetDelegate().getExcludes());
+ sb.append(",inWorkspace=");
+ sb.append(getFileSetDelegate().isInWorkspace());
+ sb.append(",flatten=");
+ sb.append(getFileSetDelegate().isFlattened());
+ return sb.toString();
+ }
+
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,272 +1,276 @@
-/*
- * 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.internal;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-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.IArchiveAction;
-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.INamedContainerArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-
-/**
- * An archive
- *
- * @author Rob stryker
- */
-public class ArchiveImpl extends ArchiveNodeImpl implements IArchive {
-
- private XbPackage packageDelegate;
-
- public ArchiveImpl() {
- this(new XbPackage());
- }
- public ArchiveImpl(XbPackage delegate) {
- super(delegate);
- this.packageDelegate = delegate;
- }
-
- /*
- * @see IArchiveNode#getNodeType()
- */
- public int getNodeType() {
- return TYPE_ARCHIVE;
- }
-
- /*
- * @see IArchive#isDestinationInWorkspace()
- */
- public boolean isDestinationInWorkspace() {
- return packageDelegate.isInWorkspace();
- }
-
- /*
- * @see IArchive#getDestinationPath()
- */
- public IPath getGlobalDestinationPath () {
- if (!isTopLevel() || packageDelegate.getToDir() == null || packageDelegate.getToDir().equals(""))
- return Path.EMPTY;
- if( packageDelegate.getToDir().equals("."))
- return getProjectPath() == null ? Path.EMPTY : getProjectPath();
-
- if (isDestinationInWorkspace()) {
- return ModelUtil.workspacePathToAbsolutePath(new Path(packageDelegate.getToDir()));
- } else
- return new Path(packageDelegate.getToDir());
- }
-
- public IPath getDestinationPath() {
- if( !isTopLevel() )
- return Path.EMPTY;
- return packageDelegate.getToDir() == null ? Path.EMPTY : new Path(packageDelegate.getToDir());
- }
-
- /*
- * @see IArchive#getArchiveFilePath()
- */
- public IPath getArchiveFilePath() {
- return getGlobalDestinationPath().append(getName());
- }
-
- /*
- * @see IArchive#getFileSets()
- */
- public IArchiveFileSet[] getFileSets() {
- IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FILESET);
- IArchiveFileSet filesets[] = new IArchiveFileSet[nodes.length];
- System.arraycopy(nodes, 0, filesets, 0, nodes.length);
- return filesets;
- }
-
- /*
- * @see IArchive#getFolders()
- */
- public IArchiveFolder[] getFolders() {
- IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FOLDER);
- IArchiveFolder folders[] = new IArchiveFolder[nodes.length];
- System.arraycopy(nodes, 0, folders, 0, nodes.length);
- return folders;
- }
-
- /*
- * @see IArchive#getArchives()
- */
- public IArchive[] getArchives() {
- IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE);
- IArchive pkgs[] = new IArchive[nodes.length];
- System.arraycopy(nodes, 0, pkgs, 0, nodes.length);
- return pkgs;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getActions()
- */
- public IArchiveAction[] getActions() {
- IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_ACTION);
- IArchiveAction actions[] = new IArchiveAction[nodes.length];
- System.arraycopy(nodes, 0, actions, 0, nodes.length);
- return actions;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getPreActions()
- */
- public IArchiveAction[] getPreActions() {
- return new IArchiveAction[0]; // TODO
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getPostActions()
- */
- public IArchiveAction[] getPostActions() {
- return new IArchiveAction[0]; // TODO
- }
-
- /*
- * @see IArchive#getName()
- */
- public String getName() {
- return packageDelegate.getName();
- }
-
- /*
- * @see IArchive#getArchiveType()
- */
- public IArchiveType getArchiveType() {
- return ArchivesCore.getInstance().getExtensionManager().getArchiveType(packageDelegate.getPackageType());
- }
-
- /*
- * @see IArchive#isExploded()
- */
- public boolean isExploded() {
- return packageDelegate.isExploded();
- }
-
- /*
- * @see IArchive#isTopLevel()
- */
- public boolean isTopLevel() {
- return (packageDelegate.getParent() == null ||
- packageDelegate.getParent() instanceof XbPackages);
- }
-
- /*
- * @see IArchive#setDestinationPath(IPath, boolean)
- */
- public void setDestinationPath(IPath path) {
- IPath destPath = getDestinationPath();
- attributeChanged(DESTINATION_ATTRIBUTE, destPath == null ? null : destPath.toString(), path == null ? null : path.toString());
- packageDelegate.setToDir(path.toString());
- }
-
- /*
- * @see IArchive#setInWorkspace(boolean)
- */
- public void setInWorkspace(boolean inWorkspace) {
- attributeChanged(IN_WORKSPACE_ATTRIBUTE, new Boolean(isDestinationInWorkspace()), new Boolean(inWorkspace));
- packageDelegate.setInWorkspace(inWorkspace);
- }
-
- /*
- * @see IArchive#setExploded(boolean)
- */
- public void setExploded(boolean exploded) {
- attributeChanged(EXPLODED_ATTRIBUTE, new Boolean(isExploded()), new Boolean(exploded));
- packageDelegate.setExploded(exploded);
- }
-
- /*
- * @see IArchive#setName(String)
- */
- public void setName(String name) {
- attributeChanged(NAME_ATTRIBUTE, getName(), name);
- packageDelegate.setName(name);
- }
-
- /*
- * @see IArchive#setArchiveType(IArchiveType)
- */
- public void setArchiveType(IArchiveType type) {
- attributeChanged(PACKAGE_TYPE_ATTRIBUTE, getArchiveTypeId(), type == null ? null : type.getId());
- packageDelegate.setPackageType(type.getId());
- }
-
- /*
- * @see IArchive#setArchiveType(String)
- */
- public void setArchiveType(String type) {
- attributeChanged(PACKAGE_TYPE_ATTRIBUTE, getArchiveTypeId(), type);
- packageDelegate.setPackageType(type);
- }
-
- public String toString() {
- return getName();
- }
-
- /*
- * @see IArchive#getArchiveTypeId()
- */
- public String getArchiveTypeId() {
- return packageDelegate.getPackageType();
- }
-
- /*
- * @see IArchiveNode#getRootArchiveRelativePath()
- */
- public IPath getRootArchiveRelativePath() {
- if( getParent() == null || getParent().getRootArchiveRelativePath() == null )
- return new Path(getName());
- return getParent().getRootArchiveRelativePath().append(getName());
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#validateChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
- */
- public boolean validateModel() {
- ArrayList<String> list = new ArrayList<String>();
- IArchiveNode[] children = getAllChildren();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i] instanceof INamedContainerArchiveNode) {
- if( list.contains(((INamedContainerArchiveNode)children[i]).getName()))
- return false;
- else
- list.add(((INamedContainerArchiveNode)children[i]).getName());
- }
- }
- return super.validateModel();
- }
-
-}
+/*
+ * 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.internal;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+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.IArchiveAction;
+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.INamedContainerArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+
+/**
+ * An archive
+ *
+ * @author Rob stryker
+ */
+public class ArchiveImpl extends ArchiveNodeImpl implements IArchive {
+
+ private XbPackage packageDelegate;
+
+ public ArchiveImpl() {
+ this(new XbPackage());
+ }
+ public ArchiveImpl(XbPackage delegate) {
+ super(delegate);
+ this.packageDelegate = delegate;
+ }
+
+ /*
+ * @see IArchiveNode#getNodeType()
+ */
+ public int getNodeType() {
+ return TYPE_ARCHIVE;
+ }
+
+ /*
+ * @see IArchive#isDestinationInWorkspace()
+ */
+ public boolean isDestinationInWorkspace() {
+ return packageDelegate.isInWorkspace();
+ }
+
+ /*
+ * @see IArchive#getDestinationPath()
+ */
+ public IPath getGlobalDestinationPath () {
+ if (!isTopLevel() || packageDelegate.getToDir() == null || packageDelegate.getToDir().equals(""))
+ return Path.EMPTY;
+ if( packageDelegate.getToDir().equals("."))
+ return getProjectPath() == null ? Path.EMPTY : getProjectPath();
+
+ if (isDestinationInWorkspace()) {
+ return ModelUtil.workspacePathToAbsolutePath(new Path(packageDelegate.getToDir()));
+ } else
+ return new Path(packageDelegate.getToDir());
+ }
+
+ public IPath getDestinationPath() {
+ if( !isTopLevel() )
+ return Path.EMPTY;
+ return packageDelegate.getToDir() == null ? Path.EMPTY : new Path(packageDelegate.getToDir());
+ }
+
+ /*
+ * @see IArchive#getArchiveFilePath()
+ */
+ public IPath getArchiveFilePath() {
+ return getGlobalDestinationPath().append(getName());
+ }
+
+ /*
+ * @see IArchive#getFileSets()
+ */
+ public IArchiveFileSet[] getFileSets() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FILESET);
+ IArchiveFileSet filesets[] = new IArchiveFileSet[nodes.length];
+ System.arraycopy(nodes, 0, filesets, 0, nodes.length);
+ return filesets;
+ }
+
+ /*
+ * @see IArchive#getFolders()
+ */
+ public IArchiveFolder[] getFolders() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FOLDER);
+ IArchiveFolder folders[] = new IArchiveFolder[nodes.length];
+ System.arraycopy(nodes, 0, folders, 0, nodes.length);
+ return folders;
+ }
+
+ /*
+ * @see IArchive#getArchives()
+ */
+ public IArchive[] getArchives() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE);
+ IArchive pkgs[] = new IArchive[nodes.length];
+ System.arraycopy(nodes, 0, pkgs, 0, nodes.length);
+ return pkgs;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getActions()
+ */
+ public IArchiveAction[] getActions() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_ACTION);
+ IArchiveAction actions[] = new IArchiveAction[nodes.length];
+ System.arraycopy(nodes, 0, actions, 0, nodes.length);
+ return actions;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getPreActions()
+ */
+ public IArchiveAction[] getPreActions() {
+ return new IArchiveAction[0]; // TODO
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getPostActions()
+ */
+ public IArchiveAction[] getPostActions() {
+ return new IArchiveAction[0]; // TODO
+ }
+
+ /*
+ * @see IArchive#getName()
+ */
+ public String getName() {
+ return packageDelegate.getName();
+ }
+
+ /*
+ * @see IArchive#getArchiveType()
+ */
+ public IArchiveType getArchiveType() {
+ return ArchivesCore.getInstance().getExtensionManager().getArchiveType(packageDelegate.getPackageType());
+ }
+
+ /*
+ * @see IArchive#isExploded()
+ */
+ public boolean isExploded() {
+ return packageDelegate.isExploded();
+ }
+
+ /*
+ * @see IArchive#isTopLevel()
+ */
+ public boolean isTopLevel() {
+ return (packageDelegate.getParent() == null ||
+ packageDelegate.getParent() instanceof XbPackages);
+ }
+
+ /*
+ * @see IArchive#setDestinationPath(IPath, boolean)
+ */
+ public void setDestinationPath(IPath path) {
+ IPath destPath = getDestinationPath();
+ attributeChanged(DESTINATION_ATTRIBUTE, destPath == null ? null : destPath.toString(), path == null ? null : path.toString());
+ packageDelegate.setToDir(path.toString());
+ }
+
+ /*
+ * @see IArchive#setInWorkspace(boolean)
+ */
+ public void setInWorkspace(boolean inWorkspace) {
+ attributeChanged(IN_WORKSPACE_ATTRIBUTE, new Boolean(isDestinationInWorkspace()), new Boolean(inWorkspace));
+ packageDelegate.setInWorkspace(inWorkspace);
+ }
+
+ /*
+ * @see IArchive#setExploded(boolean)
+ */
+ public void setExploded(boolean exploded) {
+ attributeChanged(EXPLODED_ATTRIBUTE, new Boolean(isExploded()), new Boolean(exploded));
+ packageDelegate.setExploded(exploded);
+ }
+
+ /*
+ * @see IArchive#setName(String)
+ */
+ public void setName(String name) {
+ attributeChanged(NAME_ATTRIBUTE, getName(), name);
+ packageDelegate.setName(name);
+ }
+
+ /*
+ * @see IArchive#setArchiveType(IArchiveType)
+ */
+ public void setArchiveType(IArchiveType type) {
+ attributeChanged(PACKAGE_TYPE_ATTRIBUTE, getArchiveTypeId(), type == null ? null : type.getId());
+ packageDelegate.setPackageType(type.getId());
+ }
+
+ /*
+ * @see IArchive#setArchiveType(String)
+ */
+ public void setArchiveType(String type) {
+ attributeChanged(PACKAGE_TYPE_ATTRIBUTE, getArchiveTypeId(), type);
+ packageDelegate.setPackageType(type);
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ /*
+ * @see IArchive#getArchiveTypeId()
+ */
+ public String getArchiveTypeId() {
+ return packageDelegate.getPackageType();
+ }
+
+ /*
+ * @see IArchiveNode#getRootArchiveRelativePath()
+ */
+ public IPath getRootArchiveRelativePath() {
+ if( getParent() == null || getParent().getRootArchiveRelativePath() == null )
+ return new Path(getName());
+ return getParent().getRootArchiveRelativePath().append(getName());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#validateChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public boolean validateModel() {
+ ArrayList<String> list = new ArrayList<String>();
+ IArchiveNode[] children = getAllChildren();
+ for( int i = 0; i < children.length; i++ ) {
+ if( children[i] instanceof INamedContainerArchiveNode) {
+ if( list.contains(((INamedContainerArchiveNode)children[i]).getName()))
+ return false;
+ else
+ list.add(((INamedContainerArchiveNode)children[i]).getName());
+ }
+ }
+ return super.validateModel();
+ }
+
+ public boolean canBuild() {
+ return getGlobalDestinationPath() != null
+ && super.canBuild();
+ }
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,400 +1,416 @@
-/*
- * 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.internal;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-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.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.IArchiveNodeVisitor;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeDeltaImpl.NodeDelta;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNode;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNodeWithProperties;
-
-/**
- * Abstract superclass implementation for archive node types
- * @author rob.stryker <rob.stryker(a)redhat.com>
- *
- */
-public abstract class ArchiveNodeImpl implements IArchiveNode {
-
- protected XbPackageNodeWithProperties nodeDelegate;
- protected IArchiveNode parent;
- protected ArrayList<ArchiveNodeImpl> children;
-
- // cached data for deltas
- protected HashMap<String, NodeDelta> attributeChanges;
- protected HashMap<String, NodeDelta> propertyChanges;
- protected HashMap<IArchiveNode, Integer> childChanges;
-
-
- public ArchiveNodeImpl (XbPackageNodeWithProperties delegate) {
- nodeDelegate = delegate;
- children = new ArrayList<ArchiveNodeImpl>();
-
- // for deltas
- attributeChanges = new HashMap<String, NodeDelta>();
- propertyChanges = new HashMap<String, NodeDelta>();
- childChanges = new HashMap<IArchiveNode, Integer>();
- }
-
- public XbPackageNode getNodeDelegate() {
- return nodeDelegate;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRoot()
- */
- public IArchiveNode getRoot() {
- return parent == null ? this : parent.getRoot();
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getModel()
- */
- public IArchiveModelRootNode getModelRootNode() {
- Object root = getRoot();
- return root instanceof IArchiveModelRootNode ? (IArchiveModelRootNode)root : null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRootArchive()
- */
- public IArchive getRootArchive() {
- IArchiveNode parent = this.parent;
- IArchive topArchives = null;
-
- if( getNodeType() == IArchiveNode.TYPE_ARCHIVE ) topArchives = (IArchive)this;
- while( parent != null ) {
- if( parent.getNodeType() == IArchiveNode.TYPE_ARCHIVE )
- topArchives = (IArchive)parent;
- parent = parent.getParent();
- }
- return topArchives;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getAllChildren()
- */
- public IArchiveNode[] getAllChildren () {
- return children.toArray(new IArchiveNode[children.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getChildren(int)
- */
- public IArchiveNode[] getChildren(int type) {
- ArrayList<IArchiveNode> typedChildren = new ArrayList<IArchiveNode>();
- for (Iterator<ArchiveNodeImpl> iter = children.iterator(); iter.hasNext(); ) {
- IArchiveNode child = iter.next();
- if (child.getNodeType() == type) {
- typedChildren.add(child);
- }
- }
-
- return typedChildren.toArray(new IArchiveNode[typedChildren.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#hasChildren()
- */
- public boolean hasChildren () {
- return nodeDelegate.hasChildren();
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#hasChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
- */
- public boolean hasChild (IArchiveNode child) {
- ArchiveNodeImpl childImpl = (ArchiveNodeImpl)child;
- return nodeDelegate.getAllChildren().contains(childImpl.nodeDelegate);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getParent()
- */
- public IArchiveNode getParent() {
- return parent;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#setParent(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
- */
- public void setParent (IArchiveNode parent) {
- if( getParent() != null && parent != getParent()) {
- getParent().removeChild(this);
- }
-
- this.parent = parent;
- nodeDelegate.setParent(parent == null ? null :
- ((ArchiveNodeImpl)parent).getNodeDelegate());
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getProject()
- */
- public IPath getProjectPath() {
- IArchiveModelRootNode root = getModelRootNode();
- return root == null ? null : root.getProjectPath();
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getProperty(java.lang.String)
- */
- public String getProperty(String property) {
- return getProperties().getProperty(property);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#setProperty(java.lang.String, java.lang.String)
- */
- public void setProperty(String property, String value) {
- if( property == null ) return;
- propertyChanged(property, getProperty(property), value);
- if( value == null ) {
- getProperties().remove(property);
- } else {
- getProperties().setProperty(property, value);
- }
- }
-
- /**
- * @return Get the properties for this object
- */
- protected Properties getProperties() {
- return nodeDelegate.getProperties().getProperties();
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#accept(org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor)
- */
- public boolean accept(IArchiveNodeVisitor visitor) {
- return accept(visitor, false);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#accept(org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor, boolean)
- */
- public boolean accept(IArchiveNodeVisitor visitor, boolean depthFirst) {
- IArchiveNode children[] = getAllChildren();
- boolean keepGoing = true;
-
- if (!depthFirst)
- keepGoing = visitor.visit(this);
-
- if (keepGoing) {
- for (int i = 0; i < children.length; i++) {
- if (keepGoing) {
- keepGoing = children[i].accept(visitor, depthFirst);
- }
- }
- }
-
- if (depthFirst && keepGoing)
- keepGoing = visitor.visit(this);
-
- return keepGoing;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#addChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
- */
- public final void addChild(IArchiveNode node) throws ArchivesModelException {
- addChild(node, true);
- }
-
- /**
- * Add a child with the option to skip adding in the delegate
- * @param child
- * @param addInDelegate
- */
- public final void addChild(IArchiveNode child, boolean addInDelegate) throws ArchivesModelException {
- Assert.isNotNull(child);
- ArchiveNodeImpl childImpl = (ArchiveNodeImpl) child;
- children.add(childImpl);
- childImpl.setParent(this);
- if( addInDelegate )
- nodeDelegate.addChild(childImpl.nodeDelegate);
- childChanges(child, IArchiveNodeDelta.CHILD_ADDED);
- if( !validateModel()) {
- removeChild(child);
- throw new ArchivesModelException("Unable to add child node");
- }
- }
-
- public boolean validateModel() {
- IArchiveNode[] kids = getAllChildren();
- for( int i = 0; i < kids.length; i++ )
- if( !kids[i].validateModel() )
- return false;
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#removeChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
- */
- public void removeChild(IArchiveNode node) {
- Assert.isNotNull(node);
- ArchiveNodeImpl impl = (ArchiveNodeImpl) node;
- boolean removed = false;
- if (nodeDelegate.getAllChildren().contains(impl.nodeDelegate)) {
- nodeDelegate.removeChild(impl.nodeDelegate);
- removed = true;
- }
-
- if (children.contains(node)) {
- children.remove(node);
- removed = true;
- }
- if( removed )
- childChanges(node, IArchiveNodeDelta.CHILD_REMOVED);
- }
-
- /**
- * An attribute has changed. Save the change so it can be represented in a delta
- */
- protected void attributeChanged(String key, Object beforeValue, Object afterValue) {
- int kind = IArchiveNodeDelta.ATTRIBUTE_CHANGED;
- HashMap<String, NodeDelta> map = attributeChanges;
-
- // short circuit if no change has REALLY occurred
- if( beforeValue != null && beforeValue.equals(afterValue)) return;
-
- if( map.containsKey(key)) {
- Object original = map.get(key).getBefore();
- if( original == null && afterValue == null )
- map.remove(key);
- else if( original == null )
- map.put(key, new NodeDelta(original, afterValue, kind));
- else if( original.equals(afterValue))
- // value was changed from x to y, then back to x. Therefore, no change
- map.remove(key);
- else
- // value was changed from x to y to z.
- // Before should remain x, after should become z
- map.put(key, new NodeDelta(original, afterValue, kind));
- } else {
- // added
- map.put(key, new NodeDelta(beforeValue, afterValue, kind));
- }
- }
-
- /**
- * A property has changed. Save the change so it can be represented in a delta
- */
- protected void propertyChanged(String key, Object beforeValue, Object afterValue) {
- HashMap<String, NodeDelta> changeMap = propertyChanges;
- // short circuit if no change has REALLY occurred
- if( beforeValue != null && beforeValue.equals(afterValue)) return;
-
-
- if( changeMap.containsKey(key)) {
- // element has already been added, removed, or changed since last save
- Object original = changeMap.get(key).getBefore();
- if( original == null && afterValue == null )
- changeMap.remove(key);
- else if( original == null )
- changeMap.put(key, new NodeDelta(original, afterValue, IArchiveNodeDelta.PROPERTY_ADDED));
- else if( original.equals(afterValue))
- // value was changed from x to y, then back to x. Therefore, no change
- changeMap.remove(key);
- else if( afterValue == null ) {
- // changed from x to y to null, so removed
- changeMap.put(key, new NodeDelta(original, afterValue, IArchiveNodeDelta.PROPERTY_REMOVED));
- } else {
- // changed from x to y to z, so changed
- changeMap.put(key, new NodeDelta(original, afterValue, IArchiveNodeDelta.PROPERTY_CHANGED));
- }
- } else {
- int kind;
- if( beforeValue == null ) kind = IArchiveNodeDelta.PROPERTY_ADDED;
- else if( afterValue == null ) kind = IArchiveNodeDelta.PROPERTY_REMOVED;
- else kind = IArchiveNodeDelta.PROPERTY_CHANGED;
- changeMap.put(key, new NodeDelta(beforeValue, afterValue, kind));
- }
- }
-
- /**
- * A child has changed. Save the change
- * @param node
- * @param changeType
- */
- protected void childChanges(IArchiveNode node, int changeType) {
- if( childChanges.containsKey(node)) {
- int lastChange = childChanges.get(node).intValue();
- if( lastChange == IArchiveNodeDelta.CHILD_ADDED && changeType == IArchiveNodeDelta.CHILD_REMOVED) {
- childChanges.remove(node);
- } else if( lastChange == IArchiveNodeDelta.CHILD_REMOVED && changeType == IArchiveNodeDelta.CHILD_ADDED) {
- childChanges.remove(node);
- }
- } else {
- childChanges.put(node, new Integer(changeType));
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getDelta()
- */
- public IArchiveNodeDelta getDelta() {
- return new ArchiveNodeDeltaImpl(null, this, (HashMap<String, NodeDelta>)attributeChanges.clone(),
- (HashMap<String, NodeDelta>)propertyChanges.clone(), (HashMap<IArchiveNode, Integer>)childChanges.clone());
- }
-
- /**
- * Forget all past state
- */
- public void clearDelta() {
- attributeChanges.clear();
- propertyChanges.clear();
- childChanges.clear();
-
- // clear children recursively
- IArchiveNode[] children = getAllChildren();
- for( int i = 0; i < children.length; i++ )
- ((ArchiveNodeImpl)children[i]).clearDelta();
- }
-}
+/*
+ * 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.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+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.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.IArchiveNodeVisitor;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeDeltaImpl.NodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNode;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNodeWithProperties;
+
+/**
+ * Abstract superclass implementation for archive node types
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public abstract class ArchiveNodeImpl implements IArchiveNode {
+
+ protected XbPackageNodeWithProperties nodeDelegate;
+ protected IArchiveNode parent;
+ protected ArrayList<ArchiveNodeImpl> children;
+
+ // cached data for deltas
+ protected HashMap<String, NodeDelta> attributeChanges;
+ protected HashMap<String, NodeDelta> propertyChanges;
+ protected HashMap<IArchiveNode, Integer> childChanges;
+
+
+ public ArchiveNodeImpl (XbPackageNodeWithProperties delegate) {
+ nodeDelegate = delegate;
+ children = new ArrayList<ArchiveNodeImpl>();
+
+ // for deltas
+ attributeChanges = new HashMap<String, NodeDelta>();
+ propertyChanges = new HashMap<String, NodeDelta>();
+ childChanges = new HashMap<IArchiveNode, Integer>();
+ }
+
+ public XbPackageNode getNodeDelegate() {
+ return nodeDelegate;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRoot()
+ */
+ public IArchiveNode getRoot() {
+ return parent == null ? this : parent.getRoot();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getModel()
+ */
+ public IArchiveModelRootNode getModelRootNode() {
+ Object root = getRoot();
+ return root instanceof IArchiveModelRootNode ? (IArchiveModelRootNode)root : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRootArchive()
+ */
+ public IArchive getRootArchive() {
+ IArchiveNode parent = this.parent;
+ IArchive topArchives = null;
+
+ if( getNodeType() == IArchiveNode.TYPE_ARCHIVE ) topArchives = (IArchive)this;
+ while( parent != null ) {
+ if( parent.getNodeType() == IArchiveNode.TYPE_ARCHIVE )
+ topArchives = (IArchive)parent;
+ parent = parent.getParent();
+ }
+ return topArchives;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getAllChildren()
+ */
+ public IArchiveNode[] getAllChildren () {
+ return children.toArray(new IArchiveNode[children.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getChildren(int)
+ */
+ public IArchiveNode[] getChildren(int type) {
+ ArrayList<IArchiveNode> typedChildren = new ArrayList<IArchiveNode>();
+ for (Iterator<ArchiveNodeImpl> iter = children.iterator(); iter.hasNext(); ) {
+ IArchiveNode child = iter.next();
+ if (child.getNodeType() == type) {
+ typedChildren.add(child);
+ }
+ }
+
+ return typedChildren.toArray(new IArchiveNode[typedChildren.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#hasChildren()
+ */
+ public boolean hasChildren () {
+ return nodeDelegate.hasChildren();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#hasChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public boolean hasChild (IArchiveNode child) {
+ ArchiveNodeImpl childImpl = (ArchiveNodeImpl)child;
+ return nodeDelegate.getAllChildren().contains(childImpl.nodeDelegate);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getParent()
+ */
+ public IArchiveNode getParent() {
+ return parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#setParent(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public void setParent (IArchiveNode parent) {
+ if( getParent() != null && parent != getParent()) {
+ getParent().removeChild(this);
+ }
+
+ this.parent = parent;
+ nodeDelegate.setParent(parent == null ? null :
+ ((ArchiveNodeImpl)parent).getNodeDelegate());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getProject()
+ */
+ public IPath getProjectPath() {
+ IArchiveModelRootNode root = getModelRootNode();
+ return root == null ? null : root.getProjectPath();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getProperty(java.lang.String)
+ */
+ public String getProperty(String property) {
+ return getProperties().getProperty(property);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#setProperty(java.lang.String, java.lang.String)
+ */
+ public void setProperty(String property, String value) {
+ if( property == null ) return;
+ propertyChanged(property, getProperty(property), value);
+ if( value == null ) {
+ getProperties().remove(property);
+ } else {
+ getProperties().setProperty(property, value);
+ }
+ }
+
+ /**
+ * @return Get the properties for this object
+ */
+ protected Properties getProperties() {
+ return nodeDelegate.getProperties().getProperties();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#accept(org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor)
+ */
+ public boolean accept(IArchiveNodeVisitor visitor) {
+ return accept(visitor, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#accept(org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor, boolean)
+ */
+ public boolean accept(IArchiveNodeVisitor visitor, boolean depthFirst) {
+ IArchiveNode children[] = getAllChildren();
+ boolean keepGoing = true;
+
+ if (!depthFirst)
+ keepGoing = visitor.visit(this);
+
+ if (keepGoing) {
+ for (int i = 0; i < children.length; i++) {
+ if (keepGoing) {
+ keepGoing = children[i].accept(visitor, depthFirst);
+ }
+ }
+ }
+
+ if (depthFirst && keepGoing)
+ keepGoing = visitor.visit(this);
+
+ return keepGoing;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#addChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public final void addChild(IArchiveNode node) throws ArchivesModelException {
+ addChild(node, true);
+ }
+
+ /**
+ * Add a child with the option to skip adding in the delegate
+ * @param child
+ * @param addInDelegate
+ */
+ public final void addChild(IArchiveNode child, boolean addInDelegate) throws ArchivesModelException {
+ Assert.isNotNull(child);
+ ArchiveNodeImpl childImpl = (ArchiveNodeImpl) child;
+ children.add(childImpl);
+ childImpl.setParent(this);
+ if( addInDelegate )
+ nodeDelegate.addChild(childImpl.nodeDelegate);
+ childChanges(child, IArchiveNodeDelta.CHILD_ADDED);
+ if( !validateModel()) {
+ removeChild(child);
+ throw new ArchivesModelException("Unable to add child node");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#validateModel()
+ */
+ public boolean validateModel() {
+ IArchiveNode[] kids = getAllChildren();
+ for( int i = 0; i < kids.length; i++ )
+ if( !kids[i].validateModel() )
+ return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#canBuild()
+ */
+ public boolean canBuild() {
+ IArchiveNode[] kids = getAllChildren();
+ for( int i = 0; i < kids.length; i++ )
+ if( !kids[i].canBuild() )
+ return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#removeChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public void removeChild(IArchiveNode node) {
+ Assert.isNotNull(node);
+ ArchiveNodeImpl impl = (ArchiveNodeImpl) node;
+ boolean removed = false;
+ if (nodeDelegate.getAllChildren().contains(impl.nodeDelegate)) {
+ nodeDelegate.removeChild(impl.nodeDelegate);
+ removed = true;
+ }
+
+ if (children.contains(node)) {
+ children.remove(node);
+ removed = true;
+ }
+ if( removed )
+ childChanges(node, IArchiveNodeDelta.CHILD_REMOVED);
+ }
+
+ /**
+ * An attribute has changed. Save the change so it can be represented in a delta
+ */
+ protected void attributeChanged(String key, Object beforeValue, Object afterValue) {
+ int kind = IArchiveNodeDelta.ATTRIBUTE_CHANGED;
+ HashMap<String, NodeDelta> map = attributeChanges;
+
+ // short circuit if no change has REALLY occurred
+ if( beforeValue != null && beforeValue.equals(afterValue)) return;
+
+ if( map.containsKey(key)) {
+ Object original = map.get(key).getBefore();
+ if( original == null && afterValue == null )
+ map.remove(key);
+ else if( original == null )
+ map.put(key, new NodeDelta(original, afterValue, kind));
+ else if( original.equals(afterValue))
+ // value was changed from x to y, then back to x. Therefore, no change
+ map.remove(key);
+ else
+ // value was changed from x to y to z.
+ // Before should remain x, after should become z
+ map.put(key, new NodeDelta(original, afterValue, kind));
+ } else {
+ // added
+ map.put(key, new NodeDelta(beforeValue, afterValue, kind));
+ }
+ }
+
+ /**
+ * A property has changed. Save the change so it can be represented in a delta
+ */
+ protected void propertyChanged(String key, Object beforeValue, Object afterValue) {
+ HashMap<String, NodeDelta> changeMap = propertyChanges;
+ // short circuit if no change has REALLY occurred
+ if( beforeValue != null && beforeValue.equals(afterValue)) return;
+
+
+ if( changeMap.containsKey(key)) {
+ // element has already been added, removed, or changed since last save
+ Object original = changeMap.get(key).getBefore();
+ if( original == null && afterValue == null )
+ changeMap.remove(key);
+ else if( original == null )
+ changeMap.put(key, new NodeDelta(original, afterValue, IArchiveNodeDelta.PROPERTY_ADDED));
+ else if( original.equals(afterValue))
+ // value was changed from x to y, then back to x. Therefore, no change
+ changeMap.remove(key);
+ else if( afterValue == null ) {
+ // changed from x to y to null, so removed
+ changeMap.put(key, new NodeDelta(original, afterValue, IArchiveNodeDelta.PROPERTY_REMOVED));
+ } else {
+ // changed from x to y to z, so changed
+ changeMap.put(key, new NodeDelta(original, afterValue, IArchiveNodeDelta.PROPERTY_CHANGED));
+ }
+ } else {
+ int kind;
+ if( beforeValue == null ) kind = IArchiveNodeDelta.PROPERTY_ADDED;
+ else if( afterValue == null ) kind = IArchiveNodeDelta.PROPERTY_REMOVED;
+ else kind = IArchiveNodeDelta.PROPERTY_CHANGED;
+ changeMap.put(key, new NodeDelta(beforeValue, afterValue, kind));
+ }
+ }
+
+ /**
+ * A child has changed. Save the change
+ * @param node
+ * @param changeType
+ */
+ protected void childChanges(IArchiveNode node, int changeType) {
+ if( childChanges.containsKey(node)) {
+ int lastChange = childChanges.get(node).intValue();
+ if( lastChange == IArchiveNodeDelta.CHILD_ADDED && changeType == IArchiveNodeDelta.CHILD_REMOVED) {
+ childChanges.remove(node);
+ } else if( lastChange == IArchiveNodeDelta.CHILD_REMOVED && changeType == IArchiveNodeDelta.CHILD_ADDED) {
+ childChanges.remove(node);
+ }
+ } else {
+ childChanges.put(node, new Integer(changeType));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getDelta()
+ */
+ public IArchiveNodeDelta getDelta() {
+ return new ArchiveNodeDeltaImpl(null, this, (HashMap<String, NodeDelta>)attributeChanges.clone(),
+ (HashMap<String, NodeDelta>)propertyChanges.clone(), (HashMap<IArchiveNode, Integer>)childChanges.clone());
+ }
+
+ /**
+ * Forget all past state
+ */
+ public void clearDelta() {
+ attributeChanges.clear();
+ propertyChanges.clear();
+ childChanges.clear();
+
+ // clear children recursively
+ IArchiveNode[] children = getAllChildren();
+ for( int i = 0; i < children.length; i++ )
+ ((ArchiveNodeImpl)children[i]).clearDelta();
+ }
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,264 +1,267 @@
-/**
- * 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.util.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-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.util.ModelUtil;
-
-import de.schlichtherle.io.ArchiveDetector;
-import de.schlichtherle.io.File;
-
-/**
- * This class is meant to bridge between the model
- * and the raw true-zip utility class. It is a higher level
- * API which deals with filesets and packages instead of
- * raw Strings and paths.
- *
- * It will also make sure that a de.schlichtherle.io.File is
- * created with the proper ArchiveDetector for each and every
- * level, rather than the TrueZipUtil class, which not accurately
- * create the proper File type for exploded archives.
- *
- * @author rstryker
- *
- */
-public class ModelTruezipBridge {
- public static void deleteArchive(IArchive archive) {
- final File file = getFile(archive);
- file.deleteAll();
- TrueZipUtil.sync();
- }
-
- public static void cleanFolder(IArchiveFolder folder) {
- cleanFolder(getFile(folder), true);
- }
-
- public static void cleanFolder(java.io.File folder, boolean sync) {
- TrueZipUtil.deleteEmptyChildren(folder);
- if( sync )
- TrueZipUtil.sync();
- }
-
- public static void fullFilesetBuild(IArchiveFileSet fileset) {
- fullFilesetBuild(fileset, true);
- }
- public static void fullFilesetBuild(final IArchiveFileSet fileset, boolean sync) {
- IPath[] paths = fileset.findMatchingPaths();
- copyFiles(fileset, paths, false);
- if( sync )
- TrueZipUtil.sync();
- }
-
- public static void fullFilesetsRemove(IArchiveFileSet[] filesets, boolean sync) {
- for( int i = 0; i < filesets.length; i++ )
- fullFilesetRemove(filesets[i], false);
- if( sync )
- TrueZipUtil.sync();
- }
-
-
- // Let them know which files were removed, for events
- public static IPath[] fullFilesetRemove(final IArchiveFileSet fileset, boolean sync) {
- IPath[] paths = fileset.findMatchingPaths();
- final ArrayList<IPath> list = new ArrayList<IPath>();
- list.addAll(Arrays.asList(paths));
- for( int i = 0; i < paths.length; i++ ) {
- if( !ModelUtil.otherFilesetMatchesPathAndOutputLocation(fileset, paths[i])) {
- // remove
- deleteFiles(fileset, new IPath[] {paths[i]}, false);
- } else {
- list.remove(paths[i]);
- }
- }
-
- // kinda ugly here. delete all empty folders beneath
- cleanFolder(getFile(fileset), false);
-
- // now ensure all mandatory child folders are still there
- fileset.getParent().accept(new IArchiveNodeVisitor() {
- public boolean visit(IArchiveNode node) {
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- createFile(node);
- } else if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- createFile(node);
- }
- return true;
- }
- } );
-
- if( sync )
- TrueZipUtil.sync();
-
- return list.toArray(new IPath[list.size()]);
- }
-
-
- public static void copyFiles(IArchiveFileSet[] filesets, IPath[] paths) {
- copyFiles(filesets, paths, true);
- }
-
- public static void copyFiles(final IArchiveFileSet[] filesets, final IPath[] paths, boolean sync) {
- for( int i = 0; i < filesets.length; i++ ) {
- copyFiles(filesets[i], paths, false);
- }
- if( sync )
- TrueZipUtil.sync();
-
- }
-
- public static void copyFiles(IArchiveFileSet fileset, final IPath[] paths) {
- copyFiles(fileset, paths, true);
- }
- public static void copyFiles(IArchiveFileSet fileset, final IPath[] sourcePaths, boolean sync) {
- final File[] destFiles = getFiles(sourcePaths, fileset);
- for( int i = 0; i < sourcePaths.length; i++ ) {
- TrueZipUtil.copyFile(sourcePaths[i].toOSString(), destFiles[i]);
- }
- if( sync )
- TrueZipUtil.sync();
- }
-
-
- /*
- * Deleting files
- */
- public static void deleteFiles(IArchiveFileSet[] filesets, IPath[] paths ) {
- deleteFiles(filesets, paths, true);
- }
- public static void deleteFiles(final IArchiveFileSet[] filesets, final IPath[] paths, boolean sync ) {
- for( int i = 0; i < filesets.length; i++ ) {
- deleteFiles(filesets[i], paths, false);
- }
- if( sync )
- TrueZipUtil.sync();
- }
-
- public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths ) {
- deleteFiles(fileset, paths, true);
- }
- public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths, boolean sync ) {
- final File[] destFiles = getFiles(paths, fileset);
- for( int i = 0; i < paths.length; i++ ) {
- TrueZipUtil.deleteAll(destFiles[i]);
- }
-
- if( sync )
- TrueZipUtil.sync();
- }
-
-
- /**
- * Creates the file, folder, or archive represented by the node.
- * Does nothing for filesets
- * @param node
- */
- public static void createFile(final IArchiveNode node) {
- createFile(node, true);
- }
- public static void createFile(final IArchiveNode node, boolean sync) {
- File f = getFile(node);
- if( f != null ) {
- f.mkdirs();
- }
- if( sync )
- TrueZipUtil.sync();
- }
-
-
-
- /**
- * Gets all properly-created de.sch destination files for a fileset
- * @param inputFiles
- * @param fs
- * @return
- */
- private static File[] getFiles(IPath[] inputFiles, IArchiveFileSet fs ) {
- String filesetRelative;
- File fsFile = getFile(fs);
- File[] returnFiles = new File[inputFiles.length];
- int fsLength = fs.getGlobalSourcePath().toOSString().length()+1;
- for( int i = 0; i < inputFiles.length; i++ ) {
- if( fs.isFlattened() )
- filesetRelative = inputFiles[i].lastSegment();
- else
- filesetRelative = inputFiles[i].toOSString().substring(fsLength);
- File parentFile;
- if(new Path(filesetRelative).segmentCount() > 1 ) {
- String tmp = new Path(filesetRelative).removeLastSegments(1).toString();
- parentFile = new File(fsFile, tmp, ArchiveDetector.NULL);
- if( parentFile.getEnclArchive() != null )
- parentFile = new File(fsFile, tmp, ArchiveDetector.DEFAULT);
- } else {
- parentFile = fsFile;
- }
- returnFiles[i] = new File(parentFile, new Path(filesetRelative).lastSegment(), ArchiveDetector.DEFAULT);
- }
- return returnFiles;
- }
-
- /**
- * This should go through the tree and create a file that is
- * correctly perceived at each step of the way.
- *
- * To just create a new File would let the Archive Detector have too
- * much control, and *ALL* war's and jars, including exploded ones,
- * would be treated as archives instead of folders.
- * @param node
- * @return
- */
- private static File getFile(IArchiveNode node) {
- if( node == null ) return null;
-
- if( node.getNodeType() == IArchiveNode.TYPE_MODEL_ROOT ) return null;
-
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET)
- return getFile(node.getParent());
-
- File parentFile = getFile(node.getParent());
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE ) {
- IArchive node2 = ((IArchive)node);
- boolean exploded = ((IArchive)node).isExploded();
- ArchiveDetector detector = exploded ? ArchiveDetector.NULL : TrueZipUtil.getJarArchiveDetector();
- if( parentFile == null ) {
- // we're a root archive, and so the destination folder must be a real folder
- IPath p = node2.getGlobalDestinationPath();
- if( p == null ) return null;
- parentFile = new File(p.toOSString(), ArchiveDetector.NULL);
- }
- return new File(parentFile, node2.getName(), detector);
- }
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
- return new File(parentFile, ((IArchiveFolder)node).getName(), ArchiveDetector.NULL);
- }
- return null;
- }
-
-}
+/**
+ * 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.util.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+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.util.ModelUtil;
+
+import de.schlichtherle.io.ArchiveDetector;
+import de.schlichtherle.io.File;
+
+/**
+ * This class is meant to bridge between the model
+ * and the raw true-zip utility class. It is a higher level
+ * API which deals with filesets and packages instead of
+ * raw Strings and paths.
+ *
+ * It will also make sure that a de.schlichtherle.io.File is
+ * created with the proper ArchiveDetector for each and every
+ * level, rather than the TrueZipUtil class, which not accurately
+ * create the proper File type for exploded archives.
+ *
+ * @author rstryker
+ *
+ */
+public class ModelTruezipBridge {
+ public static void deleteArchive(IArchive archive) {
+ final File file = getFile(archive);
+ file.deleteAll();
+ TrueZipUtil.sync();
+ }
+
+ public static void cleanFolder(IArchiveFolder folder) {
+ cleanFolder(getFile(folder), true);
+ }
+
+ public static void cleanFolder(java.io.File folder, boolean sync) {
+ TrueZipUtil.deleteEmptyChildren(folder);
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+ public static void fullFilesetBuild(IArchiveFileSet fileset) {
+ fullFilesetBuild(fileset, true);
+ }
+ public static void fullFilesetBuild(final IArchiveFileSet fileset, boolean sync) {
+ IPath[] paths = fileset.findMatchingPaths();
+ copyFiles(fileset, paths, false);
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+ public static void fullFilesetsRemove(IArchiveFileSet[] filesets, boolean sync) {
+ for( int i = 0; i < filesets.length; i++ )
+ fullFilesetRemove(filesets[i], false);
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+ // Let them know which files were removed, for events
+ public static IPath[] fullFilesetRemove(final IArchiveFileSet fileset, boolean sync) {
+ IPath[] paths = fileset.findMatchingPaths();
+ final ArrayList<IPath> list = new ArrayList<IPath>();
+ list.addAll(Arrays.asList(paths));
+ for( int i = 0; i < paths.length; i++ ) {
+ if( !ModelUtil.otherFilesetMatchesPathAndOutputLocation(fileset, paths[i])) {
+ // remove
+ deleteFiles(fileset, new IPath[] {paths[i]}, false);
+ } else {
+ list.remove(paths[i]);
+ }
+ }
+
+ // kinda ugly here. delete all empty folders beneath
+ cleanFolder(getFile(fileset), false);
+
+ // now ensure all mandatory child folders are still there
+ fileset.getParent().accept(new IArchiveNodeVisitor() {
+ public boolean visit(IArchiveNode node) {
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ createFile(node);
+ } else if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+ createFile(node);
+ }
+ return true;
+ }
+ } );
+
+ if( sync )
+ TrueZipUtil.sync();
+
+ return list.toArray(new IPath[list.size()]);
+ }
+
+
+ public static void copyFiles(IArchiveFileSet[] filesets, IPath[] paths) {
+ copyFiles(filesets, paths, true);
+ }
+
+ public static void copyFiles(final IArchiveFileSet[] filesets, final IPath[] paths, boolean sync) {
+ for( int i = 0; i < filesets.length; i++ ) {
+ copyFiles(filesets[i], paths, false);
+ }
+ if( sync )
+ TrueZipUtil.sync();
+
+ }
+
+ public static void copyFiles(IArchiveFileSet fileset, final IPath[] paths) {
+ copyFiles(fileset, paths, true);
+ }
+ public static void copyFiles(IArchiveFileSet fileset, final IPath[] sourcePaths, boolean sync) {
+ final File[] destFiles = getFiles(sourcePaths, fileset);
+ for( int i = 0; i < sourcePaths.length; i++ ) {
+ TrueZipUtil.copyFile(sourcePaths[i].toOSString(), destFiles[i]);
+ }
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+ /*
+ * Deleting files
+ */
+ public static void deleteFiles(IArchiveFileSet[] filesets, IPath[] paths ) {
+ deleteFiles(filesets, paths, true);
+ }
+ public static void deleteFiles(final IArchiveFileSet[] filesets, final IPath[] paths, boolean sync ) {
+ for( int i = 0; i < filesets.length; i++ ) {
+ deleteFiles(filesets[i], paths, false);
+ }
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+ public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths ) {
+ deleteFiles(fileset, paths, true);
+ }
+ public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths, boolean sync ) {
+ final File[] destFiles = getFiles(paths, fileset);
+ for( int i = 0; i < paths.length; i++ ) {
+ TrueZipUtil.deleteAll(destFiles[i]);
+ }
+
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+ /**
+ * Creates the file, folder, or archive represented by the node.
+ * Does nothing for filesets
+ * @param node
+ */
+ public static void createFile(final IArchiveNode node) {
+ createFile(node, true);
+ }
+ public static void createFile(final IArchiveNode node, boolean sync) {
+ File f = getFile(node);
+ if( f != null ) {
+ f.mkdirs();
+ }
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+
+ /**
+ * Gets all properly-created de.sch destination files for a fileset
+ * @param inputFiles
+ * @param fs
+ * @return
+ */
+ private static File[] getFiles(IPath[] inputFiles, IArchiveFileSet fs ) {
+ String filesetRelative;
+ File fsFile = getFile(fs);
+ if( fsFile == null )
+ return new File[]{};
+
+ File[] returnFiles = new File[inputFiles.length];
+ int fsLength = fs.getGlobalSourcePath().toOSString().length()+1;
+ for( int i = 0; i < inputFiles.length; i++ ) {
+ if( fs.isFlattened() )
+ filesetRelative = inputFiles[i].lastSegment();
+ else
+ filesetRelative = inputFiles[i].toOSString().substring(fsLength);
+ File parentFile;
+ if(new Path(filesetRelative).segmentCount() > 1 ) {
+ String tmp = new Path(filesetRelative).removeLastSegments(1).toString();
+ parentFile = new File(fsFile, tmp, ArchiveDetector.NULL);
+ if( parentFile.getEnclArchive() != null )
+ parentFile = new File(fsFile, tmp, ArchiveDetector.DEFAULT);
+ } else {
+ parentFile = fsFile;
+ }
+ returnFiles[i] = new File(parentFile, new Path(filesetRelative).lastSegment(), ArchiveDetector.DEFAULT);
+ }
+ return returnFiles;
+ }
+
+ /**
+ * This should go through the tree and create a file that is
+ * correctly perceived at each step of the way.
+ *
+ * To just create a new File would let the Archive Detector have too
+ * much control, and *ALL* war's and jars, including exploded ones,
+ * would be treated as archives instead of folders.
+ * @param node
+ * @return
+ */
+ private static File getFile(IArchiveNode node) {
+ if( node == null ) return null;
+
+ if( node.getNodeType() == IArchiveNode.TYPE_MODEL_ROOT ) return null;
+
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET)
+ return getFile(node.getParent());
+
+ File parentFile = getFile(node.getParent());
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE ) {
+ IArchive node2 = ((IArchive)node);
+ boolean exploded = ((IArchive)node).isExploded();
+ ArchiveDetector detector = exploded ? ArchiveDetector.NULL : TrueZipUtil.getJarArchiveDetector();
+ if( parentFile == null ) {
+ // we're a root archive, and so the destination folder must be a real folder
+ IPath p = node2.getGlobalDestinationPath();
+ if( p == null ) return null;
+ parentFile = new File(p.toOSString(), ArchiveDetector.NULL);
+ }
+ return new File(parentFile, node2.getName(), detector);
+ }
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
+ return new File(parentFile, ((IArchiveFolder)node).getName(), ArchiveDetector.NULL);
+ }
+ return null;
+ }
+
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,157 +1,156 @@
-package org.jboss.ide.eclipse.archives.ui.util.composites;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-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.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-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.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.util.DestinationChangeListener;
-
-public abstract class ArchiveNodeDestinationComposite extends Composite {
-
- protected Composite parent;
- protected Label destinationImage;
- protected Text destinationText;
- protected Object nodeDestination;
- protected ArrayList<DestinationChangeListener> listeners;
-
- public ArchiveNodeDestinationComposite(Composite parent, int style, Object destination) {
- super(parent, style);
- this.parent = parent;
- this.nodeDestination = destination;
- this.listeners = new ArrayList<DestinationChangeListener>();
-
- createComposite();
- }
-
- protected void createComposite() {
- setLayout(new FormLayout());
-
- // create widgets
- destinationImage = new Label(this, SWT.NONE);
- destinationText = new Text(this, SWT.BORDER);
- Composite browseComposite = new Composite(this, SWT.NONE);
-
- // set up their layout positioning
- destinationImage.setLayoutData(createFormData(0,5,null, 0, 0, 0, null, 0));
- destinationText.setLayoutData(createFormData(0, 5, null, 0, destinationImage, 5, destinationImage, 205));
-
-
- // set text, add listeners, etc
- destinationText.setEditable(false);
-
- browseComposite.setLayout(new FillLayout());
- browseComposite.setLayoutData(createFormData(0,0,null,0,destinationText,5,100,-5));
- fillBrowseComposite(browseComposite);
-
- // call other functions required for startup
- updateDestinationViewer();
- }
-
- protected abstract void fillBrowseComposite(Composite browseComposite);
-
- 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;
- }
-
- public void setPackageNodeDestination (Object destination) {
- System.out.println("setting destination to " + destination);
- nodeDestination = destination;
- updateDestinationViewer();
- fireDestinationChanged();
- }
-
- protected void updateDestinationViewer () {
- if (nodeDestination == null) return;
- destinationText.setText("");
-
- if (nodeDestination instanceof IArchive) {
- IArchive pkg = (IArchive) nodeDestination;
- String txt = pkg.isTopLevel() ? pkg.getName() : pkg.getRootArchiveRelativePath().toOSString();
- String imgKey = pkg.isExploded() ? ArchivesSharedImages.IMG_PACKAGE_EXPLODED : ArchivesSharedImages.IMG_PACKAGE;
-
- destinationText.setText(txt);
- destinationImage.setImage(ArchivesSharedImages.getImage(imgKey));
- } else if (nodeDestination instanceof IArchiveFolder) {
- IArchiveFolder folder = (IArchiveFolder) nodeDestination;
- destinationText.setText(folder.getRootArchiveRelativePath().toString());
- destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
- } else if (nodeDestination instanceof IProject) {
- IProject project = (IProject) nodeDestination;
- destinationText.setText(project.getName());
- destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT));
- } else if (nodeDestination instanceof IFolder) {
- IFolder folder = (IFolder) nodeDestination;
- destinationText.setText("/" + folder.getProject().getName() + "/" + folder.getProjectRelativePath().toString());
- destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
- }
- }
-
-
- /**
- * The current destination
- * @return
- */
-
- public Object getPackageNodeDestination () {
- return nodeDestination;
- }
-
-
- /*
- * Destination change listeners
- */
-
- public void addDestinationChangeListener (DestinationChangeListener listener) {
- listeners.add(listener);
- }
-
- public void removeDestinationChangeListener (DestinationChangeListener listener) {
- listeners.remove(listener);
- }
-
- private void fireDestinationChanged () {
- for (Iterator<DestinationChangeListener> iter = listeners.iterator(); iter.hasNext(); ) {
- ((DestinationChangeListener) iter.next()).destinationChanged(nodeDestination);
- }
- }
-}
+package org.jboss.ide.eclipse.archives.ui.util.composites;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+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.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+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.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.util.DestinationChangeListener;
+
+public abstract class ArchiveNodeDestinationComposite extends Composite {
+
+ protected Composite parent;
+ protected Label destinationImage;
+ protected Text destinationText;
+ protected Object nodeDestination;
+ protected ArrayList<DestinationChangeListener> listeners;
+
+ public ArchiveNodeDestinationComposite(Composite parent, int style, Object destination) {
+ super(parent, style);
+ this.parent = parent;
+ this.nodeDestination = destination;
+ this.listeners = new ArrayList<DestinationChangeListener>();
+
+ createComposite();
+ }
+
+ protected void createComposite() {
+ setLayout(new FormLayout());
+
+ // create widgets
+ destinationImage = new Label(this, SWT.NONE);
+ destinationText = new Text(this, SWT.BORDER);
+ Composite browseComposite = new Composite(this, SWT.NONE);
+
+ // set up their layout positioning
+ destinationImage.setLayoutData(createFormData(0,5,null, 0, 0, 0, null, 0));
+ destinationText.setLayoutData(createFormData(0, 5, null, 0, destinationImage, 5, destinationImage, 205));
+
+
+ // set text, add listeners, etc
+ destinationText.setEditable(false);
+
+ browseComposite.setLayout(new FillLayout());
+ browseComposite.setLayoutData(createFormData(0,0,null,0,destinationText,5,100,-5));
+ fillBrowseComposite(browseComposite);
+
+ // call other functions required for startup
+ updateDestinationViewer();
+ }
+
+ protected abstract void fillBrowseComposite(Composite browseComposite);
+
+ 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;
+ }
+
+ public void setPackageNodeDestination (Object destination) {
+ nodeDestination = destination;
+ updateDestinationViewer();
+ fireDestinationChanged();
+ }
+
+ protected void updateDestinationViewer () {
+ if (nodeDestination == null) return;
+ destinationText.setText("");
+
+ if (nodeDestination instanceof IArchive) {
+ IArchive pkg = (IArchive) nodeDestination;
+ String txt = pkg.isTopLevel() ? pkg.getName() : pkg.getRootArchiveRelativePath().toOSString();
+ String imgKey = pkg.isExploded() ? ArchivesSharedImages.IMG_PACKAGE_EXPLODED : ArchivesSharedImages.IMG_PACKAGE;
+
+ destinationText.setText(txt);
+ destinationImage.setImage(ArchivesSharedImages.getImage(imgKey));
+ } else if (nodeDestination instanceof IArchiveFolder) {
+ IArchiveFolder folder = (IArchiveFolder) nodeDestination;
+ destinationText.setText(folder.getRootArchiveRelativePath().toString());
+ destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
+ } else if (nodeDestination instanceof IProject) {
+ IProject project = (IProject) nodeDestination;
+ destinationText.setText(project.getName());
+ destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT));
+ } else if (nodeDestination instanceof IFolder) {
+ IFolder folder = (IFolder) nodeDestination;
+ destinationText.setText("/" + folder.getProject().getName() + "/" + folder.getProjectRelativePath().toString());
+ destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
+ }
+ }
+
+
+ /**
+ * The current destination
+ * @return
+ */
+
+ public Object getPackageNodeDestination () {
+ return nodeDestination;
+ }
+
+
+ /*
+ * Destination change listeners
+ */
+
+ public void addDestinationChangeListener (DestinationChangeListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeDestinationChangeListener (DestinationChangeListener listener) {
+ listeners.remove(listener);
+ }
+
+ private void fireDestinationChanged () {
+ for (Iterator<DestinationChangeListener> iter = listeners.iterator(); iter.hasNext(); ) {
+ ((DestinationChangeListener) iter.next()).destinationChanged(nodeDestination);
+ }
+ }
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,373 +1,382 @@
-package org.jboss.ide.eclipse.archives.ui.views;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-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.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.INullSelectionListener;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.ViewPart;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
-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.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
-import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
-import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
-import org.jboss.ide.eclipse.archives.ui.actions.NewArchiveAction;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
-
-public class ProjectArchivesView extends ViewPart implements IArchiveModelListener {
-
- protected static ProjectArchivesView instance;
- public static ProjectArchivesView getInstance() {
- return instance;
- }
-
-
- protected ISelectionListener selectionListener;
- public ProjectArchivesView() {
- instance = this;
- selectionListener = createSelectionListener();
- }
-
- public void init(IViewSite site) throws PartInitException {
- super.init(site);
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);
- ArchivesModel.instance().addModelListener(this);
- }
-
- public void dispose() {
- super.dispose();
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);
- ArchivesModel.instance().removeModelListener(this);
- }
-
-
- protected ISelectionListener createSelectionListener() {
- return new INullSelectionListener() {
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!(selection instanceof IStructuredSelection))
- return;
-
- Object element = ((IStructuredSelection)selection).getFirstElement();
- IProject project = getProject(element);
- if( project != null ) {
- viewSelectionChanged(project);
- } else {
- if( getCurrentProject() != null && !getCurrentProject().exists() ) {
- viewSelectionChanged(null);
- }
- }
- }
-
- public IProject getProject (Object element) {
- if( element instanceof IStructuredSelection)
- element = ((IStructuredSelection)element).getFirstElement();
-
- if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable)element;
- IResource resource = (IResource) adaptable.getAdapter(IResource.class);
- if( resource != null )
- return resource.getProject();
- }
- return null;
- }
-
- };
- }
-
-
- // parts
- private PageBook book;
- private IProject project;
- private ArchivesContentProvider contentProvider = new ArchivesContentProvider();
- private ArchivesLabelProvider labelProvider = new ArchivesLabelProvider();
- private Composite emptyComposite, viewerComposite, loadingPackagesComposite, noSelectionComposite;
- private IProgressMonitor loadingProgress;
- private TreeViewer packageViewer;
- private ArchivesMenuHandler menuHandler;
- public void createPartControl(Composite parent) {
- book = new PageBook(parent, SWT.NONE);
- addEmptyComposite(book);
- addLoadingComposite(book);
- addViewerComposite(book);
- addNoSelectionComposite(book);
- book.showPage(noSelectionComposite);
- menuHandler = new ArchivesMenuHandler(packageViewer);
- }
-
- protected void addNoSelectionComposite(PageBook book) {
- noSelectionComposite = new Composite(book, SWT.NONE);
- noSelectionComposite.setLayout(new FillLayout());
- Label label = new Label(noSelectionComposite, SWT.NONE);
- label.setText(ArchivesUIMessages.ProjectPackagesView_noProjectSelectedMessage);
- }
- protected void addEmptyComposite(PageBook book) {
- emptyComposite = new Composite(book, SWT.NONE);
- emptyComposite.setLayout(new FormLayout());
- Label l = new Label(emptyComposite, SWT.NONE);
- l.setText(ArchivesUIMessages.ProjectPackagesView_createPackagesMessage);
-
- Composite actionsComposite = new Composite(emptyComposite, SWT.NONE);
-
-
- FormData lData = new FormData();
- lData.left = new FormAttachment(0,5);
- lData.top = new FormAttachment(0,5);
- l.setLayoutData(lData);
-
- FormData actionsData = new FormData();
- actionsData.left = new FormAttachment(0,5);
- actionsData.top = new FormAttachment(l,5);
- actionsData.bottom = new FormAttachment(100,-5);
-
- actionsComposite.setLayoutData(actionsData);
-
- actionsComposite.setLayout(new GridLayout(1, false));
- addNewPackageActions(actionsComposite);
-
- }
-
-
- private void addNewPackageActions (Composite composite) {
- NewArchiveAction[] actions = ExtensionManager.findNewArchiveActions();
- for (int i = 0; i < actions.length; i++) {
- final NewArchiveAction action = actions[i];
-
- Composite linkComposite = new Composite(composite, SWT.NONE);
- linkComposite.setLayout(createGridLayoutWithNoMargins(2));
- linkComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- new Label(linkComposite, SWT.NONE).setImage(action.getIcon());
-
- Link actionLink = new Link(linkComposite, SWT.NONE);
- actionLink.setText("<a href=\"create\">" + action.getLabel() + "</a>");
- actionLink.addSelectionListener(new SelectionListener () {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- action.getAction().run(null);
- }
- });
- }
- }
-
- private GridLayout createGridLayoutWithNoMargins (int columns) {
- GridLayout layout = new GridLayout(columns, false);
- layout.marginBottom = layout.marginHeight = layout.marginLeft = 0;
- layout.marginRight = layout.marginTop = layout.marginWidth = 0;
-
- return layout;
- }
-
- protected void addLoadingComposite(PageBook book) {
- loadingPackagesComposite = new Composite(book, SWT.NONE);
- loadingPackagesComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
- loadingProgress = new ProgressMonitorPart(loadingPackagesComposite, null);
-
- }
- protected void addViewerComposite(PageBook book) {
- viewerComposite = new Composite(book, SWT.NONE);
- viewerComposite.setLayout(new FillLayout());
- packageViewer = new TreeViewer(viewerComposite, SWT.NONE);
- packageViewer.setContentProvider(contentProvider);
- packageViewer.setLabelProvider(labelProvider);
- }
-
-
- public void setFocus() {
- }
- public void viewSelectionChanged(IProject project) {
- if( project == null ) {
- this.project = null;
- packageViewer.setInput(null);
- book.showPage(noSelectionComposite);
- return;
- }
-
- IArchiveModelRootNode node = (IArchiveModelRootNode) packageViewer.getInput();
- if (node != null)
- {
- IPath projectPath = node.getProjectPath();
-
- if( project.getLocation().equals(projectPath))
- return;
- }
-
- if( !project.isAccessible() ) {
- book.showPage(noSelectionComposite);
- } else if( ArchivesModelCore.packageFileExists(project.getLocation()) ) {
- if( ArchivesModelCore.projectRegistered(project.getLocation()))
- book.showPage(viewerComposite);
- else {
- this.project = project;
- book.showPage(loadingPackagesComposite);
- if( PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS, project, true)) {
- registerProjects(getAllProjectsWithPackages(), this.project);
- } else {
- registerProjects(new IProject[] {this.project}, this.project);
- }
- return;
- }
- } else {
- book.showPage(emptyComposite);
- }
-
- this.project = project;
- packageViewer.setInput(ArchivesModel.instance().getRoot(project.getLocation()));
- }
-
- public IProject getCurrentProject() {
- return project;
- }
-
- /**
- * Registers the projects if and only if a file exists already
- * @param projects
- * @param projectToShow
- */
- protected void registerProjects(final IProject[] projects, final IProject projectToShow) {
- for( int i = 0; i < projects.length; i++ ) {
- try {
- ArchivesModel.instance().registerProject(projects[i].getLocation(), loadingProgress);
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, ame.getMessage(), ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
- }
- }
- getSite().getShell().getDisplay().asyncExec(new Runnable () {
- public void run () {
- book.showPage(viewerComposite);
- packageViewer.setInput(ArchivesModel.instance().getRoot(projectToShow.getLocation()));
- }
- });
- }
-
- public IProject[] getAllProjectsWithPackages() {
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList list = new ArrayList();
- for( int i = 0; i < projects2.length; i++ ) {
- if( projects2[i].isAccessible() && ArchivesModelCore.packageFileExists(projects2[i].getLocation())) {
- list.add(projects2[i]);
- }
- }
- return (IProject[]) list.toArray(new IProject[list.size()]);
- }
- public IStructuredSelection getSelection() {
- return (IStructuredSelection)packageViewer.getSelection();
- }
-
-
- public void modelChanged(IArchiveNodeDelta delta) {
- boolean update = true;
- try {
- if( project == null ) return;
- if( delta.getPostNode() == null && delta.getPreNode() == null ) return;
- if( delta.getPreNode() == null ) update = delta.getPostNode().getProjectPath().equals(project.getLocation());
- else if( delta.getPostNode() == null ) update = delta.getPreNode().getProjectPath().equals(project.getLocation());
- else update = delta.getPreNode().getProjectPath().equals(project.getLocation()) || delta.getPostNode().getProjectPath().equals(project);
- } catch( Exception e ) {}
-
- if( !update ) return;
-
- final IArchiveNode[] topChanges;
- if( delta.getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
- topChanges = getChanges(delta);
- else if( delta.getKind() == IArchiveNodeDelta.NO_CHANGE)
- topChanges = new IArchiveNode[]{};
- else
- topChanges = new IArchiveNode[]{delta.getPostNode()};
-
- // now go through and refresh them
- getSite().getShell().getDisplay().asyncExec(new Runnable () {
- public void run () {
- for( int i = 0; i < topChanges.length; i++ ) {
- if( topChanges.length == 1 && topChanges[0] instanceof IArchiveModelRootNode) {
- // we have a changed IArchiveModelNode. Something's different
- IArchiveModelRootNode inputModel = (IArchiveModelRootNode) packageViewer.getInput();
- IArchiveModelRootNode newModel = (IArchiveModelRootNode)topChanges[0];
- if( inputModel == null || (inputModel.getProjectPath().equals(newModel.getProjectPath()) && inputModel != newModel)) {
- // they have the same path but are different objects.
- // Model was probably reloaded from disk and could be completely different
- book.showPage(viewerComposite);
- packageViewer.setInput(newModel);
- packageViewer.expandAll();
- return;
- } else {
- packageViewer.refresh();
- return;
- }
- } else {
- // just refresh whatever is the top changed element (archive probably)
- packageViewer.refresh(topChanges[i]);
- packageViewer.expandToLevel(topChanges[i], 1);
- }
- }
- }
- });
-
- }
- protected IArchiveNode[] getChanges(IArchiveNodeDelta delta) {
-
- IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
- ArrayList list = new ArrayList();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i].getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
- list.addAll(Arrays.asList(getChanges(children[i])));
- else
- list.add(children[i].getPostNode());
- }
- return (IArchiveNode[]) list.toArray(new IArchiveNode[list.size()]);
- }
-
- public void refreshViewer(final Object node) {
- getSite().getShell().getDisplay().asyncExec(new Runnable () {
- public void run () {
- if( node == null ) {
- Object[] els = packageViewer.getExpandedElements();
- packageViewer.refresh();
- packageViewer.setExpandedElements(els);
- } else {
- packageViewer.refresh(node);
- }
- }
- });
- }
-}
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+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.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+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.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.INullSelectionListener;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.ViewPart;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
+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.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
+import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
+import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
+import org.jboss.ide.eclipse.archives.ui.actions.NewArchiveAction;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
+
+public class ProjectArchivesView extends ViewPart implements IArchiveModelListener {
+
+ protected static ProjectArchivesView instance;
+ public static ProjectArchivesView getInstance() {
+ return instance;
+ }
+
+
+ protected ISelectionListener selectionListener;
+ public ProjectArchivesView() {
+ instance = this;
+ selectionListener = createSelectionListener();
+ }
+
+ public void init(IViewSite site) throws PartInitException {
+ super.init(site);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);
+ ArchivesModel.instance().addModelListener(this);
+ }
+
+ public void dispose() {
+ super.dispose();
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);
+ ArchivesModel.instance().removeModelListener(this);
+ }
+
+
+ protected ISelectionListener createSelectionListener() {
+ return new INullSelectionListener() {
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (!(selection instanceof IStructuredSelection))
+ return;
+
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ IProject project = getProject(element);
+ if( project != null ) {
+ viewSelectionChanged(project);
+ } else {
+ if( getCurrentProject() != null && !getCurrentProject().exists() ) {
+ viewSelectionChanged(null);
+ }
+ }
+ }
+
+ public IProject getProject (Object element) {
+ if( element instanceof IStructuredSelection)
+ element = ((IStructuredSelection)element).getFirstElement();
+
+ if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable)element;
+ IResource resource = (IResource) adaptable.getAdapter(IResource.class);
+ if( resource != null )
+ return resource.getProject();
+ }
+ return null;
+ }
+
+ };
+ }
+
+
+ // parts
+ private PageBook book;
+ private IProject project;
+ private ArchivesContentProvider contentProvider = new ArchivesContentProvider();
+ private ArchivesLabelProvider labelProvider = new ArchivesLabelProvider();
+ private Composite emptyComposite, viewerComposite, loadingPackagesComposite, noSelectionComposite;
+ private IProgressMonitor loadingProgress;
+ private TreeViewer packageViewer;
+ private ArchivesMenuHandler menuHandler;
+ public void createPartControl(Composite parent) {
+ book = new PageBook(parent, SWT.NONE);
+ addEmptyComposite(book);
+ addLoadingComposite(book);
+ addViewerComposite(book);
+ addNoSelectionComposite(book);
+ book.showPage(noSelectionComposite);
+ menuHandler = new ArchivesMenuHandler(packageViewer);
+ }
+
+ protected void addNoSelectionComposite(PageBook book) {
+ noSelectionComposite = new Composite(book, SWT.NONE);
+ noSelectionComposite.setLayout(new FillLayout());
+ Label label = new Label(noSelectionComposite, SWT.NONE);
+ label.setText(ArchivesUIMessages.ProjectPackagesView_noProjectSelectedMessage);
+ }
+ protected void addEmptyComposite(PageBook book) {
+ emptyComposite = new Composite(book, SWT.NONE);
+ emptyComposite.setLayout(new FormLayout());
+ Label l = new Label(emptyComposite, SWT.NONE);
+ l.setText(ArchivesUIMessages.ProjectPackagesView_createPackagesMessage);
+
+ Composite actionsComposite = new Composite(emptyComposite, SWT.NONE);
+
+
+ FormData lData = new FormData();
+ lData.left = new FormAttachment(0,5);
+ lData.top = new FormAttachment(0,5);
+ l.setLayoutData(lData);
+
+ FormData actionsData = new FormData();
+ actionsData.left = new FormAttachment(0,5);
+ actionsData.top = new FormAttachment(l,5);
+ actionsData.bottom = new FormAttachment(100,-5);
+
+ actionsComposite.setLayoutData(actionsData);
+
+ actionsComposite.setLayout(new GridLayout(1, false));
+ addNewPackageActions(actionsComposite);
+
+ }
+
+
+ private void addNewPackageActions (Composite composite) {
+ NewArchiveAction[] actions = ExtensionManager.findNewArchiveActions();
+ for (int i = 0; i < actions.length; i++) {
+ final NewArchiveAction action = actions[i];
+
+ Composite linkComposite = new Composite(composite, SWT.NONE);
+ linkComposite.setLayout(createGridLayoutWithNoMargins(2));
+ linkComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ new Label(linkComposite, SWT.NONE).setImage(action.getIcon());
+
+ Link actionLink = new Link(linkComposite, SWT.NONE);
+ actionLink.setText("<a href=\"create\">" + action.getLabel() + "</a>");
+ actionLink.addSelectionListener(new SelectionListener () {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ action.getAction().run(null);
+ }
+ });
+ }
+ }
+
+ private GridLayout createGridLayoutWithNoMargins (int columns) {
+ GridLayout layout = new GridLayout(columns, false);
+ layout.marginBottom = layout.marginHeight = layout.marginLeft = 0;
+ layout.marginRight = layout.marginTop = layout.marginWidth = 0;
+
+ return layout;
+ }
+
+ protected void addLoadingComposite(PageBook book) {
+ loadingPackagesComposite = new Composite(book, SWT.NONE);
+ loadingPackagesComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
+ loadingProgress = new ProgressMonitorPart(loadingPackagesComposite, null);
+
+ }
+ protected void addViewerComposite(PageBook book) {
+ viewerComposite = new Composite(book, SWT.NONE);
+ viewerComposite.setLayout(new FillLayout());
+ packageViewer = new TreeViewer(viewerComposite, SWT.NONE);
+ packageViewer.setContentProvider(contentProvider);
+ packageViewer.setLabelProvider(labelProvider);
+ }
+
+
+ public void setFocus() {
+ }
+ public void viewSelectionChanged(IProject project) {
+ if( project == null ) {
+ this.project = null;
+ packageViewer.setInput(null);
+ book.showPage(noSelectionComposite);
+ return;
+ }
+
+ IArchiveModelRootNode node = (IArchiveModelRootNode) packageViewer.getInput();
+ if (node != null)
+ {
+ IPath projectPath = node.getProjectPath();
+
+ if( project.getLocation().equals(projectPath))
+ return;
+ }
+
+ if( !project.isAccessible() ) {
+ book.showPage(noSelectionComposite);
+ } else if( ArchivesModelCore.packageFileExists(project.getLocation()) ) {
+ if( ArchivesModelCore.projectRegistered(project.getLocation()))
+ book.showPage(viewerComposite);
+ else {
+ this.project = project;
+ book.showPage(loadingPackagesComposite);
+ if( PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS, project, true)) {
+ registerProjects(getAllProjectsWithPackages(), this.project);
+ } else {
+ registerProjects(new IProject[] {this.project}, this.project);
+ }
+ return;
+ }
+ } else {
+ book.showPage(emptyComposite);
+ }
+
+ this.project = project;
+ packageViewer.setInput(ArchivesModel.instance().getRoot(project.getLocation()));
+ }
+
+ public IProject getCurrentProject() {
+ return project;
+ }
+
+ /**
+ * Registers the projects if and only if a file exists already
+ * @param projects
+ * @param projectToShow
+ */
+ protected void registerProjects(final IProject[] projects, final IProject projectToShow) {
+ new Job("Register Project Archives") {
+ protected IStatus run(IProgressMonitor monitor) {
+ // register the projects
+ for( int i = 0; i < projects.length; i++ ) {
+ try {
+ ArchivesModel.instance().registerProject(projects[i].getLocation(), loadingProgress);
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, ame.getMessage(), ame);
+ return status;
+ }
+ }
+
+ // then refresh the view (if no errors)
+ getSite().getShell().getDisplay().asyncExec(new Runnable () {
+ public void run () {
+ book.showPage(viewerComposite);
+ packageViewer.setInput(ArchivesModel.instance().getRoot(projectToShow.getLocation()));
+ }
+ });
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+
+ public IProject[] getAllProjectsWithPackages() {
+ IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ ArrayList<IProject> list = new ArrayList<IProject>();
+ for( int i = 0; i < projects2.length; i++ ) {
+ if( projects2[i].isAccessible() && ArchivesModelCore.packageFileExists(projects2[i].getLocation())) {
+ list.add(projects2[i]);
+ }
+ }
+ return list.toArray(new IProject[list.size()]);
+ }
+ public IStructuredSelection getSelection() {
+ return (IStructuredSelection)packageViewer.getSelection();
+ }
+
+
+ public void modelChanged(IArchiveNodeDelta delta) {
+ boolean update = true;
+ try {
+ if( project == null ) return;
+ if( delta.getPostNode() == null && delta.getPreNode() == null ) return;
+ if( delta.getPreNode() == null ) update = delta.getPostNode().getProjectPath().equals(project.getLocation());
+ else if( delta.getPostNode() == null ) update = delta.getPreNode().getProjectPath().equals(project.getLocation());
+ else update = delta.getPreNode().getProjectPath().equals(project.getLocation()) || delta.getPostNode().getProjectPath().equals(project);
+ } catch( Exception e ) {}
+
+ if( !update ) return;
+
+ final IArchiveNode[] topChanges;
+ if( delta.getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
+ topChanges = getChanges(delta);
+ else if( delta.getKind() == IArchiveNodeDelta.NO_CHANGE)
+ topChanges = new IArchiveNode[]{};
+ else
+ topChanges = new IArchiveNode[]{delta.getPostNode()};
+
+ // now go through and refresh them
+ getSite().getShell().getDisplay().asyncExec(new Runnable () {
+ public void run () {
+ for( int i = 0; i < topChanges.length; i++ ) {
+ if( topChanges.length == 1 && topChanges[0] instanceof IArchiveModelRootNode) {
+ // we have a changed IArchiveModelNode. Something's different
+ IArchiveModelRootNode inputModel = (IArchiveModelRootNode) packageViewer.getInput();
+ IArchiveModelRootNode newModel = (IArchiveModelRootNode)topChanges[0];
+ if( inputModel == null || (inputModel.getProjectPath().equals(newModel.getProjectPath()) && inputModel != newModel)) {
+ // they have the same path but are different objects.
+ // Model was probably reloaded from disk and could be completely different
+ book.showPage(viewerComposite);
+ packageViewer.setInput(newModel);
+ packageViewer.expandAll();
+ return;
+ } else {
+ packageViewer.refresh();
+ return;
+ }
+ } else {
+ // just refresh whatever is the top changed element (archive probably)
+ packageViewer.refresh(topChanges[i]);
+ packageViewer.expandToLevel(topChanges[i], 1);
+ }
+ }
+ }
+ });
+
+ }
+ protected IArchiveNode[] getChanges(IArchiveNodeDelta delta) {
+
+ IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
+ ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
+ for( int i = 0; i < children.length; i++ ) {
+ if( children[i].getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
+ list.addAll(Arrays.asList(getChanges(children[i])));
+ else
+ list.add(children[i].getPostNode());
+ }
+ return list.toArray(new IArchiveNode[list.size()]);
+ }
+
+ public void refreshViewer(final Object node) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable () {
+ public void run () {
+ if( node == null ) {
+ Object[] els = packageViewer.getExpandedElements();
+ packageViewer.refresh();
+ packageViewer.setExpandedElements(els);
+ } else {
+ packageViewer.refresh(node);
+ }
+ }
+ });
+ }
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2008-06-12 22:15:26 UTC (rev 8746)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2008-06-12 22:23:39 UTC (rev 8747)
@@ -1,294 +1,295 @@
-package org.jboss.ide.eclipse.archives.ui.wizards.pages;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-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.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.util.DestinationChangeListener;
-import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveDestinationComposite;
-import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
-import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
-import org.jboss.ide.eclipse.archives.ui.wizards.WizardWithNotification;
-
-public class ArchiveInfoWizardPage extends WizardPageWithNotification {
-
- private AbstractArchiveWizard wizard;
- private Text packageNameText;
- private Button compressedButton;
- private Button explodedButton;
- private String packageName;
- private boolean packageExploded;
- private ArchiveDestinationComposite destinationComposite;
- private IArchive archive;
-
- public ArchiveInfoWizardPage (AbstractArchiveWizard wizard, IArchive existingPackage) {
- super (ArchivesUIMessages.PackageInfoWizardPage_title, ArchivesUIMessages.PackageInfoWizardPage_title, wizard.getImageDescriptor());
- setWizard(wizard);
- this.archive = existingPackage;
- }
-
- public void createControl(Composite parent) {
- setMessage(ArchivesUIMessages.PackageInfoWizardPage_message);
-
- Composite main = new Composite(parent, SWT.NONE);
- main.setLayout(new GridLayout(1, false));
-
- Group infoGroup = new Group(main, SWT.NONE);
- infoGroup.setLayout(new GridLayout(3, false));
- infoGroup.setText(ArchivesUIMessages.PackageInfoWizardPage_infoGroup_label);
- expand(infoGroup);
-
- new Label(infoGroup, SWT.NONE).setText(ArchivesUIMessages.PackageInfoWizardPage_packageName_label);
- Composite pkgNameComposite = new Composite(infoGroup, SWT.NONE);
- GridLayout pkgNameLayout = new GridLayout(2, false);
- pkgNameLayout.marginHeight = 0;
- pkgNameLayout.marginWidth = 0;
- pkgNameComposite.setLayout(pkgNameLayout);
- pkgNameComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- new Label(pkgNameComposite, SWT.NONE).setImage(ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_PACKAGE));
-
- packageNameText = new Text(pkgNameComposite, SWT.BORDER);
- packageName = wizard.getProject().getName() + "." + wizard.getArchiveExtension();
- packageNameText.setText(packageName);
- packageNameText.setSelection(0, wizard.getProject().getName().length());
- expand(packageNameText);
-
- GridData pkgNameData = new GridData(GridData.FILL_HORIZONTAL);
- pkgNameData.horizontalSpan = 2;
- pkgNameComposite.setLayoutData(pkgNameData);
-
- packageNameText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (validate())
- {
- packageName = packageNameText.getText();
- }
- }
- });
-
- new Label(infoGroup, SWT.NONE).setText(ArchivesUIMessages.PackageInfoWizardPage_destination_label);
-
- GridData destinationTextData = new GridData(GridData.FILL_BOTH);
- destinationTextData.horizontalSpan = 2;
- GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
- buttonData.horizontalSpan = 3;
- buttonData.horizontalAlignment = SWT.END;
-
- Object destination = wizard.getSelectedDestination();
- destinationComposite = new ArchiveDestinationComposite(
- infoGroup, SWT.NONE, destination);
- destinationComposite.addDestinationChangeListener(new DestinationChangeListener () {
- public void destinationChanged(Object newDestination) {
- validate();
- }
- });
- destinationComposite.setLayoutData(destinationTextData);
-
- Group packageTypeGroup = new Group(main, SWT.NONE);
- packageTypeGroup.setLayout(new GridLayout(1, false));
- packageTypeGroup.setText(ArchivesUIMessages.PackageInfoWizardPage_packageTypeGroup_label);
- expand(packageTypeGroup);
-
- packageExploded = false;
- compressedButton = new Button(packageTypeGroup, SWT.RADIO);
- compressedButton.setText(ArchivesUIMessages.PackageInfoWizardPage_compressedButton_label);
- compressedButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- packageExploded = false;
- }
- });
- compressedButton.setSelection(true);
- explodedButton = new Button(packageTypeGroup, SWT.RADIO);
- explodedButton.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- packageExploded = true;
- }
- });
- explodedButton.setText(ArchivesUIMessages.PackageInfoWizardPage_explodedButton_label);
- setControl(main);
-
- fillDefaults();
- validate();
- }
-
- private void fillDefaults ()
- {
- if (archive != null)
- {
- compressedButton.setSelection(!archive.isExploded());
- explodedButton.setSelection(archive.isExploded());
- packageNameText.setText(archive.getName());
- packageName = archive.getName();
-
- if (archive.isTopLevel()) {
-
- // TODO: FIX THIS
- IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(archive.getGlobalDestinationPath());
- if( container != null )
- destinationComposite.setPackageNodeDestination(container);
- else
- destinationComposite.setPackageNodeDestination(archive.getGlobalDestinationPath());
- } else {
- destinationComposite.setPackageNodeDestination(archive.getParent());
- }
-
- if (archive.isExploded()) {
- explodedButton.setEnabled(true);
- } else {
- compressedButton.setEnabled(true);
- }
- }
- }
-
- private boolean validate ()
- {
- if (packageNameText.getText() == null || packageNameText.getText().length() == 0)
- {
- setErrorMessage(ArchivesUIMessages.PackageInfoWizardPage_error_noPackageName);
- setPageComplete(false);
- return false;
- }
- else {
- setErrorMessage(null);
- }
-
- Object destination = getPackageDestination();
- if (destination instanceof IArchiveNode)
- {
- IArchiveNode parentNode = (IArchiveNode) destination;
-
- // verify no child has the same name
- IArchiveNode subPackages[] = parentNode.getChildren(IArchiveNode.TYPE_ARCHIVE);
- for (int i = 0; i < subPackages.length; i++)
- {
- IArchive subPackage = (IArchive) subPackages[i];
- if (subPackage.getName().equals(packageNameText.getText())
- && (!subPackage.equals(this.archive)))
- {
- setErrorMessage(
- ArchivesUIMessages.bind(
- ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
- setPageComplete(false);
- return false;
- }
- }
- } else if (destination instanceof IContainer) {
- IContainer container = (IContainer) destination;
- IArchive[] packages = ModelUtil.getProjectArchives(wizard.getProject().getLocation());
- if (packages != null) {
- for( int i = 0; i < packages.length; i++ ) {
- IArchive pkg = (IArchive) packages[i];
- if (pkg.getName().equals(packageNameText.getText())
- && (pkg.getGlobalDestinationPath() != null && pkg.getGlobalDestinationPath().equals(container.getFullPath()))
- && (!pkg.equals(this.archive)))
- {
- setErrorMessage(
- ArchivesUIMessages.bind(
- ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
- setPageComplete(false);
- return false;
- }
- }
- }
- } else if (destination instanceof IPath) {
- IPath path = (IPath) destination;
- IArchive[] packages = ModelUtil.getProjectArchives(wizard.getProject().getLocation());
- if (packages != null) {
- for( int i = 0; i < packages.length; i++ ) {
- IArchive pkg = (IArchive) packages[i];
- if (pkg.getName().equals(packageNameText.getText())
- && (pkg.getGlobalDestinationPath() != null && pkg.getGlobalDestinationPath().equals(path))
- && (!pkg.equals(this.archive)))
- {
- setErrorMessage(
- ArchivesUIMessages.bind(
- ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
- setPageComplete(false);
- return false;
- }
- }
- } else if (destination == null) {
- setErrorMessage(ArchivesUIMessages.PackageInfoWizardPage_error_noDestination);
- setPageComplete(false);
- return false;
- }
- }
-
- setPageComplete(true);
- return true;
- }
-
-
- public void pageExited(int button) {
- if (button == WizardWithNotification.NEXT || button == WizardWithNotification.FINISH) {
- createPackage();
- }
- }
-
- private void createPackage () {
- Object destContainer = getPackageDestination();
-
-
- if (archive == null) {
- archive = ArchiveNodeFactory.createArchive();
- }
-
- archive.setName(getPackageName());
- archive.setExploded(isPackageExploded());
-
- if (destContainer instanceof IContainer) {
- archive.setDestinationPath(((IContainer)destContainer).getFullPath());
- archive.setInWorkspace(true);
- } else if (destContainer instanceof IPath) {
- archive.setDestinationPath((IPath) destContainer);
- archive.setInWorkspace(false);
- }
- }
-
- private void expand(Control control)
- {
- control.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public boolean isPackageExploded() {
- return packageExploded;
- }
-
- public Object getPackageDestination() {
- return destinationComposite.getPackageNodeDestination();
- }
-
- private void setWizard(AbstractArchiveWizard wizard)
- {
- this.wizard = wizard;
- }
-
- public IArchive getArchive ()
- {
- return archive;
- }
-}
+package org.jboss.ide.eclipse.archives.ui.wizards.pages;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+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.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.util.DestinationChangeListener;
+import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveDestinationComposite;
+import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
+import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
+import org.jboss.ide.eclipse.archives.ui.wizards.WizardWithNotification;
+
+public class ArchiveInfoWizardPage extends WizardPageWithNotification {
+
+ private AbstractArchiveWizard wizard;
+ private Text packageNameText;
+ private Button compressedButton;
+ private Button explodedButton;
+ private String packageName;
+ private boolean packageExploded;
+ private ArchiveDestinationComposite destinationComposite;
+ private IArchive archive;
+
+ public ArchiveInfoWizardPage (AbstractArchiveWizard wizard, IArchive existingPackage) {
+ super (ArchivesUIMessages.PackageInfoWizardPage_title, ArchivesUIMessages.PackageInfoWizardPage_title, wizard.getImageDescriptor());
+ setWizard(wizard);
+ this.archive = existingPackage;
+ }
+
+ public void createControl(Composite parent) {
+ setMessage(ArchivesUIMessages.PackageInfoWizardPage_message);
+
+ Composite main = new Composite(parent, SWT.NONE);
+ main.setLayout(new GridLayout(1, false));
+
+ Group infoGroup = new Group(main, SWT.NONE);
+ infoGroup.setLayout(new GridLayout(3, false));
+ infoGroup.setText(ArchivesUIMessages.PackageInfoWizardPage_infoGroup_label);
+ expand(infoGroup);
+
+ new Label(infoGroup, SWT.NONE).setText(ArchivesUIMessages.PackageInfoWizardPage_packageName_label);
+ Composite pkgNameComposite = new Composite(infoGroup, SWT.NONE);
+ GridLayout pkgNameLayout = new GridLayout(2, false);
+ pkgNameLayout.marginHeight = 0;
+ pkgNameLayout.marginWidth = 0;
+ pkgNameComposite.setLayout(pkgNameLayout);
+ pkgNameComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ new Label(pkgNameComposite, SWT.NONE).setImage(ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_PACKAGE));
+
+ packageNameText = new Text(pkgNameComposite, SWT.BORDER);
+ packageName = wizard.getProject().getName() + "." + wizard.getArchiveExtension();
+ packageNameText.setText(packageName);
+ packageNameText.setSelection(0, wizard.getProject().getName().length());
+ expand(packageNameText);
+
+ GridData pkgNameData = new GridData(GridData.FILL_HORIZONTAL);
+ pkgNameData.horizontalSpan = 2;
+ pkgNameComposite.setLayoutData(pkgNameData);
+
+ packageNameText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (validate())
+ {
+ packageName = packageNameText.getText();
+ }
+ }
+ });
+
+ new Label(infoGroup, SWT.NONE).setText(ArchivesUIMessages.PackageInfoWizardPage_destination_label);
+
+ GridData destinationTextData = new GridData(GridData.FILL_BOTH);
+ destinationTextData.horizontalSpan = 2;
+ GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
+ buttonData.horizontalSpan = 3;
+ buttonData.horizontalAlignment = SWT.END;
+
+ Object destination = wizard.getSelectedDestination();
+ destinationComposite = new ArchiveDestinationComposite(
+ infoGroup, SWT.NONE, destination);
+ destinationComposite.addDestinationChangeListener(new DestinationChangeListener () {
+ public void destinationChanged(Object newDestination) {
+ validate();
+ }
+ });
+ destinationComposite.setLayoutData(destinationTextData);
+
+ Group packageTypeGroup = new Group(main, SWT.NONE);
+ packageTypeGroup.setLayout(new GridLayout(1, false));
+ packageTypeGroup.setText(ArchivesUIMessages.PackageInfoWizardPage_packageTypeGroup_label);
+ expand(packageTypeGroup);
+
+ packageExploded = false;
+ compressedButton = new Button(packageTypeGroup, SWT.RADIO);
+ compressedButton.setText(ArchivesUIMessages.PackageInfoWizardPage_compressedButton_label);
+ compressedButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ packageExploded = false;
+ }
+ });
+ compressedButton.setSelection(true);
+ explodedButton = new Button(packageTypeGroup, SWT.RADIO);
+ explodedButton.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ packageExploded = true;
+ }
+ });
+ explodedButton.setText(ArchivesUIMessages.PackageInfoWizardPage_explodedButton_label);
+ setControl(main);
+
+ fillDefaults();
+ validate();
+ }
+
+ private void fillDefaults ()
+ {
+ if (archive != null)
+ {
+ compressedButton.setSelection(!archive.isExploded());
+ explodedButton.setSelection(archive.isExploded());
+ packageNameText.setText(archive.getName());
+ packageName = archive.getName();
+
+ if (archive.isTopLevel()) {
+
+ // TODO: FIX THIS
+ IPath globalDest = archive.getGlobalDestinationPath();
+ IContainer container = globalDest == null ? null : ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(globalDest);
+ if( container != null )
+ destinationComposite.setPackageNodeDestination(container);
+ else
+ destinationComposite.setPackageNodeDestination(globalDest);
+ } else {
+ destinationComposite.setPackageNodeDestination(archive.getParent());
+ }
+
+ if (archive.isExploded()) {
+ explodedButton.setEnabled(true);
+ } else {
+ compressedButton.setEnabled(true);
+ }
+ }
+ }
+
+ private boolean validate ()
+ {
+ if (packageNameText.getText() == null || packageNameText.getText().length() == 0)
+ {
+ setErrorMessage(ArchivesUIMessages.PackageInfoWizardPage_error_noPackageName);
+ setPageComplete(false);
+ return false;
+ }
+ else {
+ setErrorMessage(null);
+ }
+
+ Object destination = getPackageDestination();
+ if (destination instanceof IArchiveNode)
+ {
+ IArchiveNode parentNode = (IArchiveNode) destination;
+
+ // verify no child has the same name
+ IArchiveNode subPackages[] = parentNode.getChildren(IArchiveNode.TYPE_ARCHIVE);
+ for (int i = 0; i < subPackages.length; i++)
+ {
+ IArchive subPackage = (IArchive) subPackages[i];
+ if (subPackage.getName().equals(packageNameText.getText())
+ && (!subPackage.equals(this.archive)))
+ {
+ setErrorMessage(
+ ArchivesUIMessages.bind(
+ ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
+ setPageComplete(false);
+ return false;
+ }
+ }
+ } else if (destination instanceof IContainer) {
+ IContainer container = (IContainer) destination;
+ IArchive[] packages = ModelUtil.getProjectArchives(wizard.getProject().getLocation());
+ if (packages != null) {
+ for( int i = 0; i < packages.length; i++ ) {
+ IArchive pkg = (IArchive) packages[i];
+ if (pkg.getName().equals(packageNameText.getText())
+ && (pkg.getGlobalDestinationPath() != null && pkg.getGlobalDestinationPath().equals(container.getFullPath()))
+ && (!pkg.equals(this.archive)))
+ {
+ setErrorMessage(
+ ArchivesUIMessages.bind(
+ ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
+ setPageComplete(false);
+ return false;
+ }
+ }
+ }
+ } else if (destination instanceof IPath) {
+ IPath path = (IPath) destination;
+ IArchive[] packages = ModelUtil.getProjectArchives(wizard.getProject().getLocation());
+ if (packages != null) {
+ for( int i = 0; i < packages.length; i++ ) {
+ IArchive pkg = (IArchive) packages[i];
+ if (pkg.getName().equals(packageNameText.getText())
+ && (pkg.getGlobalDestinationPath() != null && pkg.getGlobalDestinationPath().equals(path))
+ && (!pkg.equals(this.archive)))
+ {
+ setErrorMessage(
+ ArchivesUIMessages.bind(
+ ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
+ setPageComplete(false);
+ return false;
+ }
+ }
+ } else if (destination == null) {
+ setErrorMessage(ArchivesUIMessages.PackageInfoWizardPage_error_noDestination);
+ setPageComplete(false);
+ return false;
+ }
+ }
+
+ setPageComplete(true);
+ return true;
+ }
+
+
+ public void pageExited(int button) {
+ if (button == WizardWithNotification.NEXT || button == WizardWithNotification.FINISH) {
+ createPackage();
+ }
+ }
+
+ private void createPackage () {
+ Object destContainer = getPackageDestination();
+
+
+ if (archive == null) {
+ archive = ArchiveNodeFactory.createArchive();
+ }
+
+ archive.setName(getPackageName());
+ archive.setExploded(isPackageExploded());
+
+ if (destContainer instanceof IContainer) {
+ archive.setDestinationPath(((IContainer)destContainer).getFullPath());
+ archive.setInWorkspace(true);
+ } else if (destContainer instanceof IPath) {
+ archive.setDestinationPath((IPath) destContainer);
+ archive.setInWorkspace(false);
+ }
+ }
+
+ private void expand(Control control)
+ {
+ control.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public boolean isPackageExploded() {
+ return packageExploded;
+ }
+
+ public Object getPackageDestination() {
+ return destinationComposite.getPackageNodeDestination();
+ }
+
+ private void setWizard(AbstractArchiveWizard wizard)
+ {
+ this.wizard = wizard;
+ }
+
+ public IArchive getArchive ()
+ {
+ return archive;
+ }
+}
17 years, 10 months
JBoss Tools SVN: r8746 - in trunk/core/plugins: org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-06-12 18:15:26 -0400 (Thu, 12 Jun 2008)
New Revision: 8746
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
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/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
Log:
JBIDE-2324 - many changes that ensure builders won't run unless the archive is verified as sane. Removed many of the errors that were being logged because there would be 40 error-log warnings and errors which was too many. Several NPE's also fixed.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -21,6 +21,7 @@
*/
package org.jboss.ide.eclipse.archives.core;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
@@ -51,7 +52,15 @@
public class WorkspaceChangeListener implements IResourceChangeListener {
public void resourceChanged(IResourceChangeEvent event) {
- final Set<IProject> projects = new TreeSet<IProject>();
+ Comparator c = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ if( o1 instanceof IProject && o2 instanceof IProject)
+ return ((IProject)o1).getLocation().toOSString().compareTo(
+ ((IProject)o2).getLocation().toOSString());
+ return 0;
+ }
+ };
+ final Set<IProject> projects = new TreeSet<IProject>(c);
IResourceDelta delta = event.getDelta();
try {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -26,6 +26,8 @@
import java.util.Set;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.EventManager;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
@@ -76,12 +78,25 @@
* @param pkg The archive to build
*/
public void fullArchiveBuild(IArchive pkg) {
+ if( !pkg.canBuild() ) {
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING,
+ "Cannot Build archive \"" + pkg.getName() +
+ "\" due to a problem in the archive's configuration.", null);
+ return;
+ }
+
EventManager.cleanArchiveBuild(pkg);
EventManager.startedBuildingArchive(pkg);
ModelTruezipBridge.deleteArchive(pkg);
if( !pkg.getGlobalDestinationPath().toFile().exists() ) {
- pkg.getGlobalDestinationPath().toFile().mkdirs();
+ if( !pkg.getGlobalDestinationPath().toFile().mkdirs() ) {
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING,
+ "Cannot Build archive \"" + pkg.getName() +
+ "\". Output location " + pkg.getGlobalDestinationPath() +
+ " is not writeable", null);
+ return;
+ }
}
// Run the pre actions
Modified: 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/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -22,6 +22,7 @@
package org.jboss.ide.eclipse.archives.core.build;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.EventManager;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
@@ -78,9 +79,10 @@
* @param delta
*/
private void handle(IArchiveNodeDelta delta) {
- if( isTopLevelArchive(delta.getPostNode()))
+ if( isTopLevelArchive(delta.getPostNode())) {
EventManager.startedBuildingArchive((IArchive)delta.getPostNode());
-
+ }
+
if( (delta.getKind() & (IArchiveNodeDelta.NODE_REGISTERED | IArchiveNodeDelta.UNKNOWN_CHANGE)) != 0 ) {
nodeRemoved(delta.getPreNode());
nodeAdded(delta.getPostNode());
@@ -169,6 +171,10 @@
}
} else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
// create the package
+ if( ((IArchive)added).isTopLevel() && !added.canBuild() ) {
+ logCannotBuildError((IArchive)added);
+ return;
+ }
ModelTruezipBridge.createFile(added);
} else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
// create the folder
@@ -195,6 +201,10 @@
postChange(removed);
return;
} else if( removed.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ if( ((IArchive)removed).isTopLevel() && !removed.canBuild() ) {
+ logCannotBuildError((IArchive)removed);
+ return;
+ }
ModelTruezipBridge.deleteArchive((IArchive)removed);
postChange(removed);
return;
@@ -219,4 +229,11 @@
protected void postChange(IArchiveNode node) {
}
+
+ protected void logCannotBuildError(IArchive archive) {
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING,
+ "Cannot Build archive \"" + archive.getName() +
+ "\" due to a problem in the archive's configuration.", null);
+ return;
+ }
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -72,6 +72,10 @@
DirectoryScanner scanner =
DirectoryScannerFactory.createDirectoryScanner(root, includes, excludes, true);
+
+ if( scanner == null )
+ return new IPath[] {};
+
String[] files = scanner.getIncludedFiles();
IPath[] paths = new IPath[files.length];
for( int i = 0; i < files.length; i++ ) {
@@ -79,7 +83,6 @@
}
return paths;
} catch( IllegalStateException ise ) {
- ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Error creating directory scanner", ise);
return new IPath[]{};
}
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -35,6 +35,8 @@
public static DirectoryScannerExtension createDirectoryScanner (IPath filesystemFolder, String includes, String excludes, boolean scan) {
if (includes == null) includes = "";
if (excludes == null) excludes = "";
+ if( filesystemFolder == null )
+ return null;
DirectoryScannerExtension scanner = new DirectoryScannerExtension();
String excludesList[] = excludes.split(" ?, ?");
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -188,4 +188,10 @@
* @return true if it's ok, false if it should fail
*/
public boolean validateModel();
+
+ /**
+ * Are all of the fields here accessible to be built?
+ * @throws AssertionFailedException with what's wrong
+ */
+ public boolean canBuild();
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -97,12 +97,6 @@
} else {
ret = new Path(path);
}
-
- if( ret == null ) {
- String message = "Error in fileset: " + toString() + "; No global source path found.";
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_WARN, message, new Exception(message));
- }
-
return ret;
}
@@ -152,13 +146,15 @@
scanner = DirectoryScannerFactory.createDirectoryScanner(
getGlobalSourcePath(), getIncludesPattern(), getExcludesPattern(), true);
- // cache the paths
ArrayList<IPath> paths = new ArrayList<IPath>();
- IPath sp = getGlobalSourcePath();
- String matched[] = scanner.getIncludedFiles();
- for (int i = 0; i < matched.length; i++) {
- IPath path = sp.append(new Path(matched[i]));
- paths.add(path);
+ if( scanner != null ) {
+ // cache the paths
+ IPath sp = getGlobalSourcePath();
+ String matched[] = scanner.getIncludedFiles();
+ for (int i = 0; i < matched.length; i++) {
+ IPath path = sp.append(new Path(matched[i]));
+ paths.add(path);
+ }
}
matchingPaths = paths;
} catch( IllegalStateException ise ) {
@@ -275,6 +271,11 @@
return getAllChildren().length == 0 ? true : false;
}
+ public boolean canBuild() {
+ return getGlobalSourcePath() != null
+ && super.canBuild();
+ }
+
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("{dir=");
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -269,4 +269,8 @@
return super.validateModel();
}
+ public boolean canBuild() {
+ return getGlobalDestinationPath() != null
+ && super.canBuild();
+ }
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -264,6 +264,10 @@
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#validateModel()
+ */
public boolean validateModel() {
IArchiveNode[] kids = getAllChildren();
for( int i = 0; i < kids.length; i++ )
@@ -274,6 +278,18 @@
/*
* (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#canBuild()
+ */
+ public boolean canBuild() {
+ IArchiveNode[] kids = getAllChildren();
+ for( int i = 0; i < kids.length; i++ )
+ if( !kids[i].canBuild() )
+ return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#removeChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
*/
public void removeChild(IArchiveNode node) {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -203,6 +203,9 @@
private static File[] getFiles(IPath[] inputFiles, IArchiveFileSet fs ) {
String filesetRelative;
File fsFile = getFile(fs);
+ if( fsFile == null )
+ return new File[]{};
+
File[] returnFiles = new File[inputFiles.length];
int fsLength = fs.getGlobalSourcePath().toOSString().length()+1;
for( int i = 0; i < inputFiles.length; i++ ) {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -94,7 +94,6 @@
}
public void setPackageNodeDestination (Object destination) {
- System.out.println("setting destination to " + destination);
nodeDestination = destination;
updateDestinationViewer();
fireDestinationChanged();
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -11,6 +11,7 @@
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.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
@@ -264,31 +265,39 @@
* @param projectToShow
*/
protected void registerProjects(final IProject[] projects, final IProject projectToShow) {
- for( int i = 0; i < projects.length; i++ ) {
- try {
- ArchivesModel.instance().registerProject(projects[i].getLocation(), loadingProgress);
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, ame.getMessage(), ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
+ new Job("Register Project Archives") {
+ protected IStatus run(IProgressMonitor monitor) {
+ // register the projects
+ for( int i = 0; i < projects.length; i++ ) {
+ try {
+ ArchivesModel.instance().registerProject(projects[i].getLocation(), loadingProgress);
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, ame.getMessage(), ame);
+ return status;
+ }
+ }
+
+ // then refresh the view (if no errors)
+ getSite().getShell().getDisplay().asyncExec(new Runnable () {
+ public void run () {
+ book.showPage(viewerComposite);
+ packageViewer.setInput(ArchivesModel.instance().getRoot(projectToShow.getLocation()));
+ }
+ });
+ return Status.OK_STATUS;
}
- }
- getSite().getShell().getDisplay().asyncExec(new Runnable () {
- public void run () {
- book.showPage(viewerComposite);
- packageViewer.setInput(ArchivesModel.instance().getRoot(projectToShow.getLocation()));
- }
- });
+ }.schedule();
}
public IProject[] getAllProjectsWithPackages() {
IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList list = new ArrayList();
+ ArrayList<IProject> list = new ArrayList<IProject>();
for( int i = 0; i < projects2.length; i++ ) {
if( projects2[i].isAccessible() && ArchivesModelCore.packageFileExists(projects2[i].getLocation())) {
list.add(projects2[i]);
}
}
- return (IProject[]) list.toArray(new IProject[list.size()]);
+ return list.toArray(new IProject[list.size()]);
}
public IStructuredSelection getSelection() {
return (IStructuredSelection)packageViewer.getSelection();
@@ -347,14 +356,14 @@
protected IArchiveNode[] getChanges(IArchiveNodeDelta delta) {
IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
- ArrayList list = new ArrayList();
+ ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
for( int i = 0; i < children.length; i++ ) {
if( children[i].getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
list.addAll(Arrays.asList(getChanges(children[i])));
else
list.add(children[i].getPostNode());
}
- return (IArchiveNode[]) list.toArray(new IArchiveNode[list.size()]);
+ return list.toArray(new IArchiveNode[list.size()]);
}
public void refreshViewer(final Object node) {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2008-06-12 18:06:17 UTC (rev 8745)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2008-06-12 22:15:26 UTC (rev 8746)
@@ -143,11 +143,12 @@
if (archive.isTopLevel()) {
// TODO: FIX THIS
- IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(archive.getGlobalDestinationPath());
+ IPath globalDest = archive.getGlobalDestinationPath();
+ IContainer container = globalDest == null ? null : ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(globalDest);
if( container != null )
destinationComposite.setPackageNodeDestination(container);
else
- destinationComposite.setPackageNodeDestination(archive.getGlobalDestinationPath());
+ destinationComposite.setPackageNodeDestination(globalDest);
} else {
destinationComposite.setPackageNodeDestination(archive.getParent());
}
17 years, 10 months
JBoss Tools SVN: r8745 - branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-06-12 14:06:17 -0400 (Thu, 12 Jun 2008)
New Revision: 8745
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-2227
Modified: branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
===================================================================
--- branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2008-06-12 15:28:44 UTC (rev 8744)
+++ branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2008-06-12 18:06:17 UTC (rev 8745)
@@ -480,8 +480,13 @@
while (doc.getChar(offset - 1 - backslashCount) == '\\') {
backslashCount++;
}
- if (backslashCount%2 == 0)
- return false;
+ // Added by estherbin
+ // JBIDE-2227
+ if ((backslashCount > 0) && (backslashCount % 2 == 0)) {
+ return false;
+ } else {
+ return true;
+ }
}
if ('{' == doc.getChar(offset) &&
17 years, 10 months
JBoss Tools SVN: r8744 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-06-12 11:28:44 -0400 (Thu, 12 Jun 2008)
New Revision: 8744
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeVisualLinkCreator.java
Log:
Restore not worked junits.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeVisualLinkCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeVisualLinkCreator.java 2008-06-12 10:24:43 UTC (rev 8743)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeVisualLinkCreator.java 2008-06-12 15:28:44 UTC (rev 8744)
@@ -39,10 +39,12 @@
private VpeExpression styleExpr;
private VpeExpression classExpr;
private VpeExpression valueExpr;
+ private VpeExpression dirExpr;
private String styleStr;
private String classStr;
private String valueStr;
+ private String dirStr;
// private Set dependencySet;
@@ -66,7 +68,20 @@
VpePlugin.reportProblem(e);
}
}
+
+
+ final Attr dirAttr = element.getAttributeNode(HTML.ATTR_DIR);
+ if (dirAttr != null) {
+ try {
+ dirStr = dirAttr.getValue();
+ VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(dirStr, caseSensitive);
+ dirExpr = info.getExpression();
+ dependencyMap.setCreator(this, info.getDependencySet());
+ } catch (VpeExpressionBuilderException e) {
+ VpePlugin.reportProblem(e);
+ }
+ }
Attr classAttr = element
.getAttributeNode(VpeTemplateManager.ATTR_TEMPLATE_CLASS);
if (styleAttr != null) {
@@ -97,41 +112,41 @@
}
- public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, nsIDOMElement visualElement,
- Map visualNodeMap) {
+ public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, nsIDOMElement visualElement,
+ Map visualNodeMap) {
- nsIDOMElement a = visualDocument.createElement(HTML.TAG_A);
+ nsIDOMElement a = visualDocument.createElement(HTML.TAG_A);
- VpeCreatorInfo creatorInfo = new VpeCreatorInfo(a);
+ VpeCreatorInfo creatorInfo = new VpeCreatorInfo(a);
- if (styleExpr != null) {
- String style = styleExpr.exec(pageContext, sourceNode)
- .stringValue();
- a.setAttribute(HTML.ATTR_STYLE, style);
- }
+ if (dirExpr != null) {
+ String dir = dirExpr.exec(pageContext, sourceNode).stringValue();
+ a.setAttribute(HTML.ATTR_DIR, dirStr);
+ }
- if (classExpr != null) {
- String classStyle = classExpr.exec(pageContext, sourceNode)
- .stringValue();
- a.setAttribute(HTML.ATTR_CLASS, classStyle);
- }
+ if (styleExpr != null) {
+ String style = styleExpr.exec(pageContext, sourceNode).stringValue();
+ a.setAttribute(HTML.ATTR_STYLE, style);
+ }
- if (valueExpr != null) {
- String value = valueExpr.exec(pageContext, sourceNode)
- .stringValue();
- if (value != null && value.length() > 0) {
- nsIDOMElement span = visualDocument
- .createElement(HTML.TAG_SPAN);
- a.appendChild(span);
- nsIDOMText text = visualDocument.createTextNode(value);
- span.appendChild(text);
- }
- }
+ if (classExpr != null) {
+ String classStyle = classExpr.exec(pageContext, sourceNode).stringValue();
+ a.setAttribute(HTML.ATTR_CLASS, classStyle);
+ }
- return creatorInfo;
- }
+ if (valueExpr != null) {
+ String value = valueExpr.exec(pageContext, sourceNode).stringValue();
+ if (value != null && value.length() > 0) {
+ nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
+ a.appendChild(span);
+ nsIDOMText text = visualDocument.createTextNode(value);
+ span.appendChild(text);
+ }
+ }
+ return creatorInfo;
+ }
+
@Override
public boolean isRecreateAtAttrChange(VpePageContext pageContext,
Element sourceElement, nsIDOMDocument visualDocument,
17 years, 10 months