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());
}