Author: scabanovich
Date: 2007-10-15 08:18:25 -0400 (Mon, 15 Oct 2007)
New Revision: 4176
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/resources/meta/jsfcapabilities.meta
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/CapabilityPerformer.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/LibrariesPerformer.java
Log:
JBIDE-1017
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/resources/meta/jsfcapabilities.meta
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/resources/meta/jsfcapabilities.meta 2007-10-15
11:34:21 UTC (rev 4175)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/resources/meta/jsfcapabilities.meta 2007-10-15
12:18:25 UTC (rev 4176)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE XModelEntityGroup PUBLIC "-//Red Hat, Inc.//DTD Meta 1.0//EN"
"meta.dtd">
+<!DOCTYPE XModelEntityGroup PUBLIC "-//Red Hat, Inc.//DTD Meta 1.0//EN"
+ "meta.dtd">
<XModelEntityGroup>
<VERSION DEPENDS="Model:1.0" MODULE="Struts Editor"
VERSION="1.0"/>
<MAPPINGS/>
@@ -19,11 +20,9 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="capabilities list"
loader="ElementType" name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute default="Capabilities" name="name">
- <Constraint/>
<Editor name="AccessibleJava"/>
</XModelAttribute>
</XModelAttributes>
@@ -59,6 +58,7 @@
<XModelEntity ImplementingClass="%Custom%"
XMLSUBPATH="capability" name="JSFCapability">
<XChildrenEntities>
<XChildEntity name="JSFLibraryReference"/>
+ <XChildEntity name="JSFConflictingLibraryReference"/>
<XChildEntity name="JSFFileAddition"/>
</XChildrenEntities>
<XEntityRenderer>
@@ -68,12 +68,10 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="jsf capability" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute PROPERTIES="id=true" name="name"
xmlname="name">
<Constraint loader="Text"/>
- <Editor/>
</XModelAttribute>
</XModelAttributes>
<XActionItem kind="list">
@@ -123,6 +121,52 @@
</XActionItem>
<XDependencies/>
</XModelEntity>
+ <XModelEntity ImplementingClass="%Custom%"
+ XMLSUBPATH="conflicting-library"
name="JSFConflictingLibraryReference">
+ <XChildrenEntities/>
+ <XEntityRenderer>
+ <ICONS>
+ <ICON info="main.jsf.application" type="main"/>
+ </ICONS>
+ </XEntityRenderer>
+ <XModelAttributes>
+ <XModelAttribute default="library" loader="ElementType"
name="element type">
+ <Editor name="Uneditable"/>
+ </XModelAttribute>
+ <XModelAttribute PROPERTIES="id=true" name="name"
xmlname="name">
+ <Constraint loader="ListString"/>
+ <Editor name="LibrarySetList"/>
+ </XModelAttribute>
+ </XModelAttributes>
+ <XActionItem kind="list">
+ <XActionItem kind="list" name="EditActions">
+ <XActionItem HandlerClassName="%Edit%" ICON="action.empty"
+ PROPERTIES="validator.edit=true" WizardClassName="%Default%"
+ displayName="Edit" kind="action" name="Edit">
+ <EntityData EntityName="JSFLibraryReference">
+ <AttributeData AttributeName="name"/>
+ </EntityData>
+ </XActionItem>
+ </XActionItem>
+ <XActionItem ICON="action.copy" displayName="Copy"
kind="list" name="CopyActions">
+ <XActionItem BaseActionName="Cut" HandlerClassName="%Cut%"
+ ICON="action.cut" displayName="Cut" kind="action"
name="Cut"/>
+ <XActionItem BaseActionName="Copy" HandlerClassName="%Copy%"
+ ICON="action.copy" displayName="Copy" kind="action"
name="Copy"/>
+ <XActionItem BaseActionName="Paste"
HandlerClassName="%Paste%"
+ ICON="action.paste" displayName="Paste" kind="action"
name="Paste"/>
+ </XActionItem>
+ <XActionItem ICON="action.delete" displayName="Delete"
kind="list" name="DeleteActions">
+ <XActionItem BaseActionName="Delete"
HandlerClassName="%Delete%"
+ ICON="action.delete" displayName="Delete"
kind="action" name="Delete"/>
+ </XActionItem>
+ <XActionItem ICON="action.empty" kind="list"
name="Properties">
+ <XActionItem HandlerClassName="%Properties%"
ICON="action.empty"
+ displayName="Properties..." kind="action"
name="Properties"/>
+ </XActionItem>
+ </XActionItem>
+ <XDependencies/>
+ </XModelEntity>
<XModelEntity ImplementingClass="%Custom%"
XMLSUBPATH="file-addition" name="JSFFileAddition">
<XChildrenEntities/>
<XEntityRenderer>
@@ -132,27 +176,13 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="config file addition"
loader="ElementType" name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
- <XModelAttribute PROPERTIES="id=true" name="label"
xmlname="label">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
- <XModelAttribute name="file name" xmlname="file-name">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
- <XModelAttribute name="x-path" xmlname="x-path">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
- <XModelAttribute name="preferred position" visibility="false"
xmlname="preferred-position">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
+ <XModelAttribute PROPERTIES="id=true" name="label"
xmlname="label"/>
+ <XModelAttribute name="file name" xmlname="file-name"/>
+ <XModelAttribute name="x-path" xmlname="x-path"/>
+ <XModelAttribute name="preferred position" visibility="false"
xmlname="preferred-position"/>
<XModelAttribute PROPERTIES="greedy=always" name="text"
xmlname="CDATA">
- <Constraint/>
<Editor name="Note"/>
</XModelAttribute>
</XModelAttributes>
@@ -197,7 +227,6 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="library" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute PROPERTIES="id=true" name="name"
xmlname="name">
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java 2007-10-15
11:34:21 UTC (rev 4175)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java 2007-10-15
12:18:25 UTC (rev 4176)
@@ -76,6 +76,7 @@
public static String CLOSE;
public static String PROJECT_ALREADY_HAS_SOME_OF_LIBRARIES_INCLUDED;
public static String PROJECT_ALREADY_HAS_SOME_OF_LIBRARIES_INCLUDED_2;
+ public static String PROJECT_HAS_COFLICTING_LIBRARIES;
public static String CONTINUE;
public static String OVERWRITE;
public static String CANNOT_LOAD_JSF_CAPABILITIES;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties 2007-10-15
11:34:21 UTC (rev 4175)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties 2007-10-15
12:18:25 UTC (rev 4176)
@@ -53,6 +53,7 @@
CLOSE = Close
PROJECT_ALREADY_HAS_SOME_OF_LIBRARIES_INCLUDED = The project already has some of
libraries included into the capability ({0}). Existing files will be overwritten and any
new files will be added.
PROJECT_ALREADY_HAS_SOME_OF_LIBRARIES_INCLUDED_2 = The project already has some of
libraries included into the capability ({0} and {1} more). Existing files will be
overwritten and any new files will be added.
+PROJECT_HAS_COFLICTING_LIBRARIES = The project has conflicting library {0}. Do you want
to replace it with selected libraries?
CONTINUE = Continue
OVERWRITE = Overwrite
CANNOT_LOAD_JSF_CAPABILITIES = Cannot load JSF Capabilities
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/CapabilityPerformer.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/CapabilityPerformer.java 2007-10-15
11:34:21 UTC (rev 4175)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/CapabilityPerformer.java 2007-10-15
12:18:25 UTC (rev 4176)
@@ -35,7 +35,7 @@
public void init(XModel model, XModelObject capability) {
this.model = model;
this.capability = capability;
- librariesPerformer.init(model,
capability.getChildren("JSFLibraryReference"));
+ librariesPerformer.init(model, capability.getChildren("JSFLibraryReference"),
capability.getChildren("JSFConflictingLibraryReference"));
fileAdditionsPerformer.init(model, capability);
}
@@ -43,7 +43,7 @@
if(!isSelected()) return true;
context.monitor.worked(1);
context.monitor.subTask(getDisplayName());
- if(!librariesPerformer.check()) return false;
+ if(!librariesPerformer.check(context)) return false;
if(!fileAdditionsPerformer.check()) return false;
if(!fileAdditionsPerformer.execute(context)) return true;
librariesPerformer.execute(context);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/LibrariesPerformer.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/LibrariesPerformer.java 2007-10-15
11:34:21 UTC (rev 4175)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/LibrariesPerformer.java 2007-10-15
12:18:25 UTC (rev 4176)
@@ -14,6 +14,8 @@
import java.util.*;
import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
@@ -22,6 +24,7 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.messages.JSFUIMessages;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.project.helpers.*;
@@ -32,6 +35,7 @@
IContainer libResource;
JarPerformer[] jarPerformers;
+ IFile[] conflictingFiles;
public LibrariesPerformer() {}
@@ -43,7 +47,7 @@
return jarPerformers;
}
- public void init(XModel model, XModelObject[] libraryReferences) {
+ public void init(XModel model, XModelObject[] libraryReferences, XModelObject[]
conflictingLibraryReferences) {
this.model = model;
lib = model.getByPath("FileSystems/lib");
if(lib == null) {
@@ -78,14 +82,39 @@
}
}
jarPerformers = l2.toArray(new JarPerformer[0]);
+
+ conflictingFiles = null;
+ IContainer r = (IContainer)lib.getAdapter(IResource.class);
+ if(conflictingLibraryReferences != null && lib != null && r != null) {
+ ArrayList<IFile> cfjs = new ArrayList<IFile>();
+ for (int i = 0; i < conflictingLibraryReferences.length; i++) {
+ String name = conflictingLibraryReferences[i].getAttributeValue("name");
+ IFile f = r.getFile(new Path(name));
+ if(f.exists()) cfjs.add(f);
+ }
+ conflictingFiles = cfjs.toArray(new IFile[0]);
+ }
}
- public boolean check() {
+ public boolean check(PerformerContext context) {
if(!isSelected()) return true;
if(libResource == null) return false;
+ ServiceDialog d = model.getService();
+
+ if(conflictingFiles != null && conflictingFiles.length > 0) {
+ String message = NLS.bind(JSFUIMessages.PROJECT_HAS_COFLICTING_LIBRARIES,
conflictingFiles[0].getName() );
+ int q = d.showDialog(JSFUIMessages.WARNING, message, new String[]{JSFUIMessages.YES,
JSFUIMessages.NO, JSFUIMessages.CANCEL}, null, ServiceDialog.WARNING);
+ if(q == 2) {
+ context.monitor.setCanceled(true);
+ return false;
+ }
+ if(q == 1) {
+ return false;
+ }
+ }
+
String[] existing = getExistingJars();
if(existing.length == 0) return true;
- ServiceDialog d = model.getService();
String message;
if(existing.length > 1)
message = NLS.bind(JSFUIMessages.PROJECT_ALREADY_HAS_SOME_OF_LIBRARIES_INCLUDED_2,
existing[0], "" + (existing.length-1) );
@@ -177,6 +206,18 @@
//ignore
}
}
+
+ if(conflictingFiles != null) {
+ for (int i = 0; i < conflictingFiles.length; i++) {
+ try {
+ conflictingFiles[i].delete(true, context.monitor);
+ context.changeList.add(capability + ": Removed " +
conflictingFiles[i].getName() + " from WEB-INF/lib");
+ } catch (CoreException ce) {
+ JSFModelPlugin.getPluginLog().logError(ce);
+ }
+ }
+ }
+
context.monitor.worked(1);
return true;
}