JBoss Tools SVN: r10369 - in trunk: archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal and 13 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-09-18 20:38:23 -0400 (Thu, 18 Sep 2008)
New Revision: 10369
Added:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntBuildListener.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/AbstractBuildListener.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIBuildListener.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModuleModelListener.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/ArchivesWorkspaceLogger.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveBuildListener.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesLogger.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ExtensionManager.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PackagesUIPlugin.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java
Log:
Archives Error Handling for both Ant and Workspace. Added an ErrorDialog in workspace (with option to hide forever and preference page to restore). Ant errors now print properly. JBIDE-2470 and JBIDE-1426
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -61,14 +61,14 @@
}
};
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 {
// TODO modify to make sure this file is a descriptor in use / registered
- if( delta.getResource() != null && delta.getResource().getLocation() != null &&
+ if( delta.getResource() != null && delta.getResource().getLocation() != null &&
delta.getResource().getLocation().lastSegment().equals(IArchiveModel.DEFAULT_PACKAGES_FILE)) {
projects.add(delta.getResource().getProject());
}
@@ -97,7 +97,7 @@
}
}.schedule();
} catch( ArchivesModelException ame ) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, "Could not register project " + p.getName(), ame);
+ ArchivesCore.getInstance().getLogger().log(IStatus.ERROR, "Could not register project " + p.getName(), ame);
}
}
} catch( CoreException ce ) {
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/ArchivesWorkspaceLogger.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/ArchivesWorkspaceLogger.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/ArchivesWorkspaceLogger.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.ide.eclipse.archives.core.model.other.internal;
import org.eclipse.core.runtime.ILog;
@@ -19,36 +19,27 @@
/**
* @author eskimo
- * Comment:
+ * Comment:
* This could probably be worked into ArchivesCore API
* This specific implementation should belong in an eclipse-specific
- * class.
+ * class.
*/
public class ArchivesWorkspaceLogger implements IArchivesLogger {
/**
- * Copy of ArchiveCorePlugin.PLUGIN_ID to break dependency cycle between
+ * Copy of ArchiveCorePlugin.PLUGIN_ID to break dependency cycle between
* jars in this plug-in
- *
+ *
* @see ArchiveCorePlugin.PLUGIN_ID
*/
public static final String PLUGIN_ID = ArchivesCore.PLUGIN_ID;
-
+
static ILog log = Platform.getLog(Platform.getBundle(PLUGIN_ID));
-
+
public void log(int severity, String message,Throwable t) {
- IStatus status = new Status(convert(severity), PLUGIN_ID, message, t);
+ IStatus status = new Status(severity, PLUGIN_ID, message, t);
+ log(status);
+ }
+ public void log(IStatus status) {
log.log(status);
}
-
- private int convert(int severity) {
- switch( severity ) {
- case IArchivesLogger.MSG_ERR: return IStatus.ERROR;
- case IArchivesLogger.MSG_INFO: return IStatus.INFO;
- case IArchivesLogger.MSG_WARN: return IStatus.WARNING;
- case IArchivesLogger.MSG_DEBUG:
- case IArchivesLogger.MSG_VERBOSE:
- default:
- return IStatus.OK;
- }
- }
}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -27,6 +27,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
@@ -42,7 +43,7 @@
/**
* Sets default preferences for the plugin.
* By default, the builder is enabled for all projects with archives.
- *
+ *
* @author rstryker
*
*/
@@ -63,7 +64,7 @@
}
return null;
}
-
+
public boolean isBuilderEnabled(IPath path) {
QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID, AUTOMATIC_BUILDER_ENABLED);
IResource res = getResource(path);
@@ -76,7 +77,7 @@
}
return new InstanceScope().getNode(ArchivesCorePlugin.PLUGIN_ID).getBoolean(AUTOMATIC_BUILDER_ENABLED, true);
}
-
+
public void setBuilderEnabled(IPath path, boolean value) {
QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID, AUTOMATIC_BUILDER_ENABLED);
IResource resource = getResource(path);
@@ -91,25 +92,25 @@
prefs.putBoolean(AUTOMATIC_BUILDER_ENABLED, value);
try {
prefs.flush();
- } catch (BackingStoreException e) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e.getMessage(), e);
+ } catch (BackingStoreException e) {
+ ArchivesCore.getInstance().getLogger().log(IStatus.ERROR, e.getMessage(), e);
}
}
-
+
public void initializeDefaultPreferences() {
IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
prefs.putBoolean(AUTOMATIC_BUILDER_ENABLED, true);
try {
prefs.flush();
} catch (BackingStoreException e1) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e1.getMessage(), e1);
+ ArchivesCore.getInstance().getLogger().log(IStatus.ERROR, e1.getMessage(), e1);
}
}
-
+
public boolean areProjectSpecificPrefsEnabled(IPath path) {
return areProjectSpecificPrefsEnabled(getResource(path));
}
- public boolean areProjectSpecificPrefsEnabled(IResource resource) {
+ public boolean areProjectSpecificPrefsEnabled(IResource resource) {
QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID, PROJECT_SPECIFIC_PREFS);
try {
if( resource != null && resource.getPersistentProperty(name) != null) {
@@ -118,7 +119,7 @@
} catch( CoreException ce ) {}
return false;
}
-
+
public void setProjectSpecificPrefsEnabled(IPath path, boolean value) {
QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID, PROJECT_SPECIFIC_PREFS);
IResource resource = getResource(path);
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -4,8 +4,8 @@
import org.apache.tools.ant.Task;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.build.ModelChangeListener;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.IActionType;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
@@ -25,21 +25,21 @@
private Task currentTask;
public AntArchivesCore () {
super(STANDALONE);
- ArchivesModel.instance().addModelListener(new ModelChangeListener());
+ ArchivesModel.instance().addBuildListener(new AntBuildListener());
}
-
+
public void setProject(Project p) {
currentProject = p;
}
-
+
public Project getProject() {
return currentProject;
}
-
+
public void setTask(Task t) {
currentTask= t;
}
-
+
public Task getTask() {
return currentTask;
}
@@ -62,7 +62,7 @@
protected IArchivesLogger createLogger() {
return new AntLogger();
}
-
+
protected class AntExtensionManager implements IExtensionManager {
public IActionType getActionType(String id) {
return null;
@@ -84,7 +84,7 @@
}
public String getLabel() {
return id2;
- }
+ }
};
}
@@ -96,7 +96,7 @@
return new IArchiveType[]{};
}
}
-
+
protected class AntPreferences implements IPreferenceManager {
public boolean areProjectSpecificPrefsEnabled(IPath path) {
@@ -116,10 +116,22 @@
}
}
protected class AntLogger implements IArchivesLogger {
+ public void log(IStatus s) {
+ log(s.getSeverity(), s.getMessage(), s.getException());
+ }
public void log(int severity, String message, Throwable throwable) {
- currentProject.log(message, throwable, severity);
- if( throwable != null && severity == IArchivesLogger.MSG_ERR)
+ currentProject.log(message, throwable, convert(severity));
+ if( throwable != null && severity == IStatus.ERROR)
throwable.printStackTrace();
}
+ protected int convert(int severity) {
+ switch(severity) {
+ case IStatus.ERROR: return Project.MSG_ERR;
+ case IStatus.WARNING: return Project.MSG_WARN;
+ case IStatus.INFO: return Project.MSG_INFO;
+ case IStatus.OK: return Project.MSG_VERBOSE;
+ }
+ return Project.MSG_DEBUG;
+ }
}
}
Added: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntBuildListener.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntBuildListener.java (rev 0)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntBuildListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -0,0 +1,19 @@
+package org.jboss.ide.eclipse.archives.core.ant;
+
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.AbstractBuildListener;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+
+public class AntBuildListener extends AbstractBuildListener {
+
+ public void buildFailed(IArchive pkg, IStatus status) {
+ ArchivesCore.getInstance().getLogger().log(status);
+ }
+ public void error(IArchiveNode node, IStatus[] multi) {
+ for( int i = 0; i < multi.length; i++ ) {
+ ArchivesCore.getInstance().getLogger().log(multi[i]);
+ }
+ }
+}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -27,6 +27,7 @@
import org.apache.tools.ant.Task;
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;
@@ -41,13 +42,13 @@
public class GenerateArchivesTask extends Task {
private String projectPath;
-
+
public void init() throws BuildException {
// Force standalone mode
AntArchivesCore standalone = new AntArchivesCore();
ArchivesCore.setInstance(standalone);
}
-
+
protected AntArchivesCore getCore() {
return (AntArchivesCore)ArchivesCore.getInstance();
}
@@ -58,14 +59,14 @@
try {
IPath projectPath = new Path(this.projectPath);
IProgressMonitor monitor = new NullProgressMonitor();
-
+
for (Iterator iter = getProject().getProperties().keySet().iterator(); iter.hasNext(); ) {
String property = (String) iter.next();
if (property.endsWith(".dir")) {
System.setProperty(property, getProject().getProperty(property));
}
}
-
+
// needed so the correct XML binding / TrueZIP jars are loaded
ClassLoader myCL = getClass().getClassLoader();
Thread.currentThread().setContextClassLoader(myCL);
@@ -73,10 +74,10 @@
ArchivesModel.instance().registerProject(projectPath, monitor);
new ArchiveBuildDelegate().fullProjectBuild(projectPath);
} else {
- getCore().getLogger().log(IArchivesLogger.MSG_ERR, "Project \"" + projectPath + "\" does not exist or has no .packages file. Skipping.", null);
+ getCore().getLogger().log(IStatus.ERROR, "Project \"" + projectPath + "\" does not exist or has no .packages file. Skipping.", null);
}
} catch(RuntimeException e ) {
- getCore().getLogger().log(IArchivesLogger.MSG_ERR, "A runtime error has occurred during build.", e);
+ getCore().getLogger().log(IStatus.ERROR, "A runtime error has occurred during build.", e);
}
finally {
Thread.currentThread().setContextClassLoader(original);
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -1,231 +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.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.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.IArchiveModelRootNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.archives.core.util.PathUtils;
-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) {
- if( !pkg.canBuild() ) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR,
- "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);
- IPath dest = PathUtils.getGlobalLocation(pkg);
- if( dest != null && !dest.toFile().exists() ) {
- if( !dest.toFile().mkdirs() ) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR,
- "Cannot Build archive \"" + pkg.getName() +
- "\". Output location " + dest +
- " is not writeable", null);
- return;
- }
- }
-
- // Run the pre actions
- IArchiveAction[] actions = pkg.getActions();
- for( int i = 0; i < actions.length; i++ ) {
- if( actions[i].getTime().equals(IArchiveAction.PRE_BUILD)) {
- actions[i].execute();
- }
- }
-
- 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);
- }
-
- // Run the post actions
- for( int i = 0; i < actions.length; i++ ) {
- if( actions[i].getTime().equals(IArchiveAction.POST_BUILD)) {
- actions[i].execute();
- }
- }
-
- 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();
- FileWrapper[] paths = fileset.findMatchingPaths();
- ModelTruezipBridge.fullFilesetBuild(fileset);
-
- EventManager.filesUpdated(topLevel, fileset, paths);
- EventManager.finishedCollectingFileSet(fileset);
- }
-
- /**
- * 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, boolean workspaceRelative) {
-
- // find any and all filesets that match each file
- Iterator<IPath> i;
- IPath path, globalPath;
- IArchiveFileSet[] matchingFilesets;
- ArrayList<IArchive> topPackagesChanged = new ArrayList<IArchive>();
- ArrayList<IArchiveFileSet> seen = new ArrayList<IArchiveFileSet>();
-
- // Handle the removed files first. Hopefully the fileset hasn't been reset yet
- // or it could make this block of code fail.
- i = removed.iterator();
- while(i.hasNext()) {
- path = ((IPath)i.next());
- globalPath = !workspaceRelative ? path :
- ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
-
- matchingFilesets = ModelUtil.getMatchingFilesets(archive, path, workspaceRelative);
- localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- for( int j = 0; j < matchingFilesets.length; j++ ) {
- ModelTruezipBridge.deleteFiles(matchingFilesets[j], matchingFilesets[j].getMatches(globalPath));
- if( !seen.contains(matchingFilesets[j])) {
- seen.add(matchingFilesets[j]);
- }
- }
- EventManager.fileRemoved(path, matchingFilesets);
- }
-
- // reset all of the filesets that have already matched
- Iterator<IArchiveFileSet> fit = seen.iterator();
- while(fit.hasNext())
- fit.next().resetScanner();
-
- i = addedChanged.iterator();
- while(i.hasNext()) {
- path = i.next();
- globalPath = !workspaceRelative ? path :
- ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
- matchingFilesets = ModelUtil.getMatchingFilesets(archive, path, workspaceRelative);
- localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- for( int j = 0; j < matchingFilesets.length; j++ ) {
- if( !seen.contains(matchingFilesets[j])) {
- seen.add(matchingFilesets[j]);
- matchingFilesets[j].resetScanner();
- }
- ModelTruezipBridge.copyFiles(matchingFilesets[j], matchingFilesets[j].getMatches(globalPath));
- }
- EventManager.fileUpdated(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.Arrays;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+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.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.IArchiveModelRootNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
+import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
+import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
+import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge.FileWrapperStatusPair;
+
+/**
+ * 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 ) {
+ IStatus s = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID, "An error occurred locating the root node for " + project.toOSString(), null);
+ EventManager.error(null, new IStatus[]{s});
+ } else {
+ IArchiveNode[] nodes = root.getChildren(IArchiveNode.TYPE_ARCHIVE);
+ ArrayList<IStatus> errors = new ArrayList<IStatus>();
+ for( int i = 0; i < nodes.length; i++ ) {
+ errors.addAll(Arrays.asList(fullArchiveBuild(((IArchive)nodes[i]), false)));
+ }
+
+ EventManager.finishedBuild(project);
+ EventManager.error(null, errors.toArray(new IStatus[errors.size()]));
+ }
+ }
+
+ /**
+ * Builds an archive entirely, overwriting whatever was in the output destination.
+ * @param pkg The archive to build
+ */
+ public IStatus[] fullArchiveBuild(IArchive pkg) {
+ return fullArchiveBuild(pkg, true);
+ }
+ protected IStatus[] fullArchiveBuild(IArchive pkg, boolean log) {
+ if( !pkg.canBuild() ) {
+ IStatus s = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID,
+ "Cannot Build archive \"" + pkg.getName() +
+ "\" due to a problem in the archive's configuration.", null);
+ if( log )
+ EventManager.error(pkg, new IStatus[]{s});
+ return new IStatus[]{};
+ }
+
+ EventManager.cleanArchiveBuild(pkg);
+ EventManager.startedBuildingArchive(pkg);
+
+ ModelTruezipBridge.deleteArchive(pkg);
+ IPath dest = PathUtils.getGlobalLocation(pkg);
+ if( dest != null && !dest.toFile().exists() ) {
+ if( !dest.toFile().mkdirs() ) {
+ IStatus s = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID,
+ "Cannot Build archive \"" + pkg.getName() +
+ "\". Output location " + dest +
+ " is not writeable", null);
+ if( log )
+ EventManager.error(pkg, new IStatus[]{s});
+ return new IStatus[]{};
+ }
+ }
+
+ ArrayList<IStatus> errors = new ArrayList<IStatus>();
+
+ // Run the pre actions
+ IArchiveAction[] actions = pkg.getActions();
+ for( int i = 0; i < actions.length; i++ ) {
+ if( actions[i].getTime().equals(IArchiveAction.PRE_BUILD)) {
+ actions[i].execute();
+ }
+ }
+
+ if( !ModelTruezipBridge.createFile(pkg) ) {
+ IStatus e = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID, "Error creating output file for node " + pkg.toString());
+ errors.add(e);
+ }
+
+ // force create all folders
+ IArchiveFolder[] folders = ModelUtil.findAllDescendentFolders(pkg);
+ for( int i = 0; i < folders.length; i++ ) {
+ if( !ModelTruezipBridge.createFile(folders[i])) {
+ IStatus e = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID, "Error creating output file for node " + folders[i].toString());
+ errors.add(e);
+ }
+ }
+
+ // build the filesets
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(pkg);
+ for( int i = 0; i < filesets.length; i++ ) {
+ IStatus[] errors2 = fullFilesetBuild(filesets[i], pkg);
+ errors.addAll(Arrays.asList(errors2));
+ }
+
+ // Run the post actions
+ for( int i = 0; i < actions.length; i++ ) {
+ if( actions[i].getTime().equals(IArchiveAction.POST_BUILD)) {
+ actions[i].execute();
+ }
+ }
+
+ EventManager.finishedBuildingArchive(pkg);
+ IStatus[] errors2 = errors.toArray(new IStatus[errors.size()]);
+ if( log )
+ EventManager.error(pkg, errors2 );
+ return errors2;
+ }
+
+ /**
+ * Build the given fileset
+ * @param fileset The fileset to match
+ * @param topLevel The top level archive that the fileset belongs to
+ */
+ protected IStatus[] fullFilesetBuild(IArchiveFileSet fileset, IArchive topLevel) {
+ EventManager.startedCollectingFileSet(fileset);
+
+ // reset the scanner. It *is* a full build afterall
+ fileset.resetScanner();
+ FileWrapper[] paths = fileset.findMatchingPaths();
+
+ FileWrapperStatusPair result = ModelTruezipBridge.fullFilesetBuild(fileset, true);
+
+ EventManager.filesUpdated(topLevel, fileset, paths);
+ EventManager.finishedCollectingFileSet(fileset);
+ return result.s;
+ }
+
+ /**
+ * 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, boolean workspaceRelative) {
+ ArrayList<IStatus> errors = new ArrayList<IStatus>();
+
+ // find any and all filesets that match each file
+ Iterator<IPath> i;
+ IPath path, globalPath;
+ IArchiveFileSet[] matchingFilesets;
+ ArrayList<IArchive> topPackagesChanged = new ArrayList<IArchive>();
+ ArrayList<IArchiveFileSet> seen = new ArrayList<IArchiveFileSet>();
+
+ // Handle the removed files first. Hopefully the fileset hasn't been reset yet
+ // or it could make this block of code fail.
+ i = removed.iterator();
+ while(i.hasNext()) {
+ path = ((IPath)i.next());
+ globalPath = !workspaceRelative ? path :
+ ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
+
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path, workspaceRelative);
+ localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
+ for( int j = 0; j < matchingFilesets.length; j++ ) {
+ IStatus[] errors2 = ModelTruezipBridge.deleteFiles(matchingFilesets[j], matchingFilesets[j].getMatches(globalPath), true);
+ errors.addAll(Arrays.asList(errors2));
+ if( !seen.contains(matchingFilesets[j])) {
+ seen.add(matchingFilesets[j]);
+ }
+ }
+ EventManager.fileRemoved(path, matchingFilesets);
+ }
+
+ // reset all of the filesets that have already matched
+ Iterator<IArchiveFileSet> fit = seen.iterator();
+ while(fit.hasNext())
+ fit.next().resetScanner();
+
+ i = addedChanged.iterator();
+ while(i.hasNext()) {
+ path = i.next();
+ globalPath = !workspaceRelative ? path :
+ ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path, workspaceRelative);
+ localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
+ for( int j = 0; j < matchingFilesets.length; j++ ) {
+ if( !seen.contains(matchingFilesets[j])) {
+ seen.add(matchingFilesets[j]);
+ matchingFilesets[j].resetScanner();
+ }
+ IStatus[] errors2 = ModelTruezipBridge.copyFiles(matchingFilesets[j], matchingFilesets[j].getMatches(globalPath), true);
+ errors.addAll(Arrays.asList(errors2));
+ }
+ EventManager.fileUpdated(path, matchingFilesets);
+ }
+
+
+ TrueZipUtil.sync();
+
+ Iterator<IArchive> i2 = topPackagesChanged.iterator();
+ while(i2.hasNext()) {
+ EventManager.finishedBuildingArchive(i2.next());
+ }
+
+ if( errors.size() > 0 )
+ EventManager.error(null, errors.toArray(new IStatus[errors.size()]));
+ }
+
+ 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: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -1,240 +1,250 @@
-/**
- * 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.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
-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]);
- FileWrapper[] files = filesets[i].findMatchingPaths();
- EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], files);
- }
- 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;
- }
-}
+/**
+ * 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.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
+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.ModelTruezipBridge.FileWrapperStatusPair;
+
+/**
+ * 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(IStatus.ERROR, "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++ ) {
+ FileWrapperStatusPair result = ModelTruezipBridge.fullFilesetBuild(filesets[i], true);
+ FileWrapper[] files = filesets[i].findMatchingPaths();
+ EventManager.error(filesets[i], result.s);
+ EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], files);
+ }
+ 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++ ) {
+ // TODO report IO Errors
+ FileWrapperStatusPair result = ModelTruezipBridge.fullFilesetRemove(filesets[i], false);
+ EventManager.filesRemoved(convertToPath(result.f), ((IArchiveFileSet)filesets[i]));
+ }
+ postChange(removed);
+ return;
+ }
+
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(removed);
+ for( int i = 0; i < filesets.length; i++ ) {
+ FileWrapperStatusPair result = ModelTruezipBridge.fullFilesetRemove(
+ ((IArchiveFileSet)removed), false);
+ EventManager.filesRemoved(convertToPath(result.f), ((IArchiveFileSet)removed));
+ }
+ postChange(removed);
+ }
+
+ protected IPath[] convertToPath(FileWrapper[] wrappers) {
+ IPath[] paths = new IPath[wrappers.length];
+ for( int i = 0; i < wrappers.length; i++ ) {
+ paths[i] = wrappers[i].getWrapperPath();
+ }
+ return paths;
+ }
+ 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;
+ }
+}
Added: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/AbstractBuildListener.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/AbstractBuildListener.java (rev 0)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/AbstractBuildListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -0,0 +1,33 @@
+package org.jboss.ide.eclipse.archives.core.model;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+
+public class AbstractBuildListener implements IArchiveBuildListener {
+ public void buildFailed(IArchive pkg, IStatus status) {
+ }
+ public void cleanArchive(IArchive pkg) {
+ }
+ public void cleanProject(IPath project) {
+ }
+ public void error(IArchiveNode node, IStatus[] multi) {
+ }
+ public void fileRemoved(IArchive topLevelArchive, IArchiveFileSet fileset,
+ IPath filePath) {
+ }
+ public void fileUpdated(IArchive topLevelArchive, IArchiveFileSet fileset,
+ IPath filePath) {
+ }
+ public void finishedBuild(IPath project) {
+ }
+ public void finishedBuildingArchive(IArchive pkg) {
+ }
+ public void finishedCollectingFileSet(IArchiveFileSet fileset) {
+ }
+ public void startedBuild(IPath project) {
+ }
+ public void startedBuildingArchive(IArchive pkg) {
+ }
+ public void startedCollectingFileSet(IArchiveFileSet fileset) {
+ }
+}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -25,8 +25,11 @@
import java.util.Collection;
import java.util.HashMap;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+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.internal.ArchiveModelNode;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding;
@@ -37,21 +40,21 @@
/**
* The root model which keeps track of registered projects
* and what archives / model nodes they contain.
- *
+ *
* @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
*/
public class ArchivesModel implements IArchiveModel {
-
+
/**
* Singleton instance
*/
protected static IArchiveModel instance;
public static IArchiveModel instance() {
- if( instance == null )
+ if( instance == null )
instance = new ArchivesModel();
return instance;
}
-
+
private HashMap<IPath, XbPackages> xbPackages; // maps an IPath (of a project) to XbPackages
private HashMap<IPath, ArchiveModelNode> archivesRoot; // maps an IPath (of a project) to PackageModelNode, aka root
private ArrayList<IArchiveBuildListener> buildListeners;
@@ -62,16 +65,16 @@
buildListeners = new ArrayList<IArchiveBuildListener>();
modelListeners = new ArrayList<IArchiveModelListener>();
}
-
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#addBuildListener(org.jboss.ide.eclipse.archives.core.model.IArchiveBuildListener)
*/
public void addBuildListener(IArchiveBuildListener listener) {
- if( !buildListeners.contains(listener))
+ if( !buildListeners.contains(listener))
buildListeners.add(listener);
}
-
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#removeBuildListener(org.jboss.ide.eclipse.archives.core.model.IArchiveBuildListener)
@@ -79,7 +82,7 @@
public void removeBuildListener(IArchiveBuildListener listener) {
buildListeners.remove(listener);
}
-
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#getBuildListeners()
@@ -87,13 +90,13 @@
public IArchiveBuildListener[] getBuildListeners() {
return buildListeners.toArray(new IArchiveBuildListener[buildListeners.size()]);
}
-
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#addModelListener(org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener)
*/
public void addModelListener(IArchiveModelListener listener) {
- if( !modelListeners.contains(listener))
+ if( !modelListeners.contains(listener))
modelListeners.add(listener);
}
@@ -102,10 +105,10 @@
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#removeModelListener(org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener)
*/
public void removeModelListener(IArchiveModelListener listener) {
- if( modelListeners.contains(listener))
+ if( modelListeners.contains(listener))
modelListeners.remove(listener);
}
-
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#getModelListeners()
@@ -113,7 +116,7 @@
public IArchiveModelListener[] getModelListeners() {
return modelListeners.toArray(new IArchiveModelListener[modelListeners.size()]);
}
-
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#getModelNodes()
@@ -122,7 +125,7 @@
Collection<ArchiveModelNode> c = archivesRoot.values();
return (IArchiveModelRootNode[]) c.toArray(new IArchiveModelRootNode[c.size()]);
}
-
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveModel#accept(org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor)
@@ -135,39 +138,48 @@
if (keepGoing)
keepGoing = children[i].accept(visitor);
return keepGoing;
- }
+ }
public IArchiveModelRootNode getRoot(IPath project) {
return (archivesRoot.get(project));
}
-
+
@Deprecated
public void save(IPath projectPath, IProgressMonitor monitor) throws ArchivesModelException {
save(getRoot(projectPath), monitor);
}
-
+
@Deprecated
public void save(IArchiveModelRootNode modelNode, IProgressMonitor monitor) throws ArchivesModelException {
modelNode.save(monitor);
}
-
+
public boolean isProjectRegistered(IPath projectPath) {
return projectPath != null && archivesRoot.containsKey(projectPath);
}
-
+
public boolean canReregister(IPath projectPath) {
return canReregister(projectPath, DEFAULT_PACKAGES_FILE);
}
-
+
public boolean canReregister(IPath projectPath, String file) {
- return projectPath != null && file != null && projectPath.append(file).toFile().exists();
+ if( projectPath != null && file != null ) {
+ IPath p = projectPath.append(file);
+ try {
+ String result = ArchivesCore.getInstance().getVFS().performStringSubstitution(p.toString(), null, false);
+ return new Path(result).toFile().exists();
+ } catch( CoreException ce ) {
+ return false;
+ }
+ }
+ return false;
}
-
+
public IArchiveModelRootNode registerProject(IPath projectPath, IProgressMonitor monitor) throws ArchivesModelException {
return registerProject(projectPath, DEFAULT_PACKAGES_FILE, monitor);
}
-
+
public IArchiveModelRootNode registerProject(IPath projectPath, String file, IProgressMonitor monitor) throws ArchivesModelException {
XbPackages packages;
ArchiveModelNode modelNode;
@@ -178,23 +190,23 @@
packages = XMLBinding.unmarshal(packagesFile.toFile(), monitor);
} catch( XbException xbe ) {
// Empty / non-working XML file loaded
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, "Error unmarshalling packages file " + packagesFile, xbe);
+ ArchivesCore.getInstance().getLogger().log(IStatus.ERROR, "Error unmarshalling packages file " + packagesFile, xbe);
return null;
}
} else {
packages = new XbPackages();
packages.setVersion(1.2);
}
-
+
// Fill the model
modelNode = new ArchiveModelNode(projectPath, projectPath.append(file), packages, this);
ModelUtil.fillArchiveModel(packages, modelNode);
modelNode.clearDelta();
-
+
registerProject(modelNode, monitor);
return modelNode;
}
-
+
public void registerProject(IArchiveModelRootNode model, IProgressMonitor monitor) {
ArchivesCore.getInstance().preRegisterProject(model.getProjectPath());
xbPackages.put(model.getProjectPath(), ((ArchiveModelNode)model).getXbPackages());
@@ -202,7 +214,7 @@
model.setModel(this);
fireRegisterProjectEvent((ArchiveModelNode)model);
}
-
+
public void unregisterProject(IPath projectPath, IProgressMonitor monitor) {
IArchiveModelRootNode root = getRoot(projectPath);
xbPackages.remove(projectPath);
@@ -215,15 +227,15 @@
archivesRoot.remove(model.getProjectPath());
fireUnregisterProjectEvent((ArchiveModelNode)model);
}
-
+
protected void fireRegisterProjectEvent(final IArchiveModelRootNode newRoot) {
fireRegistrationEvent(null, newRoot, IArchiveNodeDelta.NODE_REGISTERED);
}
-
+
protected void fireUnregisterProjectEvent(final IArchiveModelRootNode oldRoot) {
fireRegistrationEvent(oldRoot, null, IArchiveNodeDelta.NODE_UNREGISTERED);
}
-
+
protected void fireRegistrationEvent(final IArchiveModelRootNode oldRoot, final IArchiveModelRootNode newRoot, final int type) {
IArchiveNodeDelta delta = new IArchiveNodeDelta() {
public IArchiveNodeDelta[] getAddedChildrenDeltas() {return null;}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -32,16 +32,16 @@
* @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
*/
public class EventManager {
-
+
public static void cleanProjectBuild(IPath project) {
IArchiveBuildListener[] listeners = getBuildListeners();
for( int i = 0; i < listeners.length; i++ ) {
- try {
+ try {
listeners[i].cleanProject(project);
} catch(Exception e ) {logError(e);}
}
}
-
+
public static void cleanArchiveBuild(IArchive archive) {
IArchiveBuildListener[] listeners = getBuildListeners(archive);
for( int i = 0; i < listeners.length; i++ ) {
@@ -50,7 +50,7 @@
} catch(Exception e ) {logError(e);}
}
}
-
+
public static void startedBuild(IPath project) {
IArchiveBuildListener[] listeners = getBuildListeners();
for( int i = 0; i < listeners.length; i++ ) {
@@ -87,8 +87,8 @@
}
}
-
-
+
+
public static void startedCollectingFileSet(IArchiveFileSet fileset) {
IArchiveBuildListener[] listeners = getBuildListeners(fileset);
for( int i = 0; i < listeners.length; i++ ) {
@@ -112,14 +112,14 @@
fileUpdated(topLevelArchive, fileset, new Path(filePath[i].getAbsolutePath()));
}
}
-
+
// one file updated matching multiple filesets
public static void fileUpdated(IPath path, IArchiveFileSet[] matchingFilesets) {
for( int i = 0; i < matchingFilesets.length; i++ ) {
fileUpdated(matchingFilesets[i].getRootArchive(), matchingFilesets[i], path);
}
}
-
+
public static void fileUpdated(IArchive topLevelArchive, IArchiveFileSet fileset, IPath filePath) {
IArchiveBuildListener[] listeners = getBuildListeners(topLevelArchive);
for( int i = 0; i < listeners.length; i++ ) {
@@ -144,7 +144,7 @@
fileRemoved(matchingFilesets[i].getRootArchive(), matchingFilesets[i], path);
}
}
-
+
public static void filesRemoved(IPath[] paths, IArchiveFileSet fileset) {
for( int i = 0; i < paths.length; i++ ) {
fileRemoved(fileset.getRootArchive(), fileset, paths[i]);
@@ -160,13 +160,23 @@
}
}
+ public static void error(IArchiveNode node, IStatus[] errors) {
+ if( errors != null && errors.length > 0 ) {
+ IArchiveBuildListener[] listeners = getBuildListeners(node);
+ for( int i = 0; i < listeners.length; i++ ) {
+ try {
+ listeners[i].error(node, errors);
+ } catch(Exception e ) {logError(e);}
+ }
+ }
+ }
-
+
/**
* Fire events dealing with model changes
* @param delta
*/
-
+
public static void fireDelta(IArchiveNodeDelta delta) {
IArchiveNode node = delta.getPostNode() == null ? delta.getPreNode() : delta.getPostNode();
IArchiveModelListener[] listeners = getModelListeners(node);
@@ -176,7 +186,7 @@
} catch(Exception e ) {logError(e);} }
}
-
+
private static IArchiveModelListener[] getModelListeners(IArchiveNode node) {
IArchiveModelRootNode model = node.getModelRootNode();
if( model != null && model.getModel() != null ) {
@@ -184,12 +194,14 @@
}
return new IArchiveModelListener[]{};
}
-
+
// get workspace default ones
private static IArchiveBuildListener[] getBuildListeners() {
return ArchivesModel.instance().getBuildListeners();
}
private static IArchiveBuildListener[] getBuildListeners(IArchiveNode node) {
+ if( node == null )
+ return getBuildListeners();
IArchiveModelRootNode model = node.getModelRootNode();
if( model != null && model.getModel() != null ) {
return model.getModel().getBuildListeners();
@@ -201,9 +213,9 @@
e.printStackTrace();
try {
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_WARN, "Archives Listener error in " + trace[1].getMethodName(), e);
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Archives Listener error in " + trace[1].getMethodName(), e);
} catch( Exception f ) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_WARN, "Archives Listener error", e);
+ ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Archives Listener error", e);
}
}
}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveBuildListener.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveBuildListener.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveBuildListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -1,116 +1,121 @@
-/*
- * 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;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * This interface is inteded to be implemented by classes who are
- * interested in receiving callbacks for various IArchive build events
- *
- * @author Marshall
- */
-public interface IArchiveBuildListener {
-
-
- /**
- * A project has started being built by the Archives builder
- * @param project the project being built
- */
- public void startedBuild (IPath project);
-
- /**
- * A project is finished being built by the Archives builder
- * @param project the project being built
- */
- public void finishedBuild (IPath project);
-
- /**
- * The project is going to be rebuilt from scratch and all state should be discarded
- * @param project
- */
- public void cleanProject(IPath project);
-
- /**
- * An Archive has started being built by the Archives builder
- * This can be called from a full build, or from the incremental build
- * if and only if one of the affected files matches a fileset in this archive.
- *
- * @param pkg the Archive being built
- */
- public void startedBuildingArchive (IArchive pkg);
-
- /**
- * An Archive is finished being built by the Archives builder
- * This can be called from a full build, or from the incremental build
- * if and only if one of the affected files matches a fileset in this archive.
- *
- * @param pkg the Archive being built
- */
- public void finishedBuildingArchive (IArchive pkg);
-
- /**
- * The archive is going to be rebuilt from scratch and all state should be discarded
- * @param pkg
- */
- public void cleanArchive(IArchive pkg);
-
-
- /**
- * A fileset has started being collected for copying into a Archive
- * This is *only* used during a FULL BUILD or after a MODEL CHANGE
- * @param fileset the fileset being collected
- */
- public void startedCollectingFileSet (IArchiveFileSet fileset);
-
- /**
- * A fileset has finished being collected for copying into a Archive
- * This is *only* used during a FULL BUILD or after a MODEL CHANGE
- * @param fileset the fileset being collected
- */
- public void finishedCollectingFileSet (IArchiveFileSet fileset);
-
- /**
- * The build for the given project has failed
- * @param pkg The Archive that failed to build
- * @param status The status/exception that occurred
- */
- public void buildFailed (IArchive pkg, IStatus status);
-
- /**
- * A file has been updated, with the given IArchive / IArchiveFileSet context
- * @param topLevelArchive The top level Archive that was updated
- * @param fileset The fileset that matched the updated file
- * @param filePath The path to the file that was copied (filesystem/workspace path)
- */
- public void fileUpdated (IArchive topLevelArchive, IArchiveFileSet fileset, IPath filePath);
-
- /**
- * A file has been removed, with the given IArchive / IArchiveFileSet context
- * @param topLevelArchive The top level Archive that was updated
- * @param fileset The fileset that matched the removed file
- * @param filePath The path to the file that was removed (filesystem/workspace path)
- */
- public void fileRemoved (IArchive topLevelArchive, IArchiveFileSet fileset, IPath filePath);
-
-}
+/*
+ * 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;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * This interface is inteded to be implemented by classes who are
+ * interested in receiving callbacks for various IArchive build events
+ *
+ * @author Marshall
+ */
+public interface IArchiveBuildListener {
+
+
+ /**
+ * A project has started being built by the Archives builder
+ * @param project the project being built
+ */
+ public void startedBuild (IPath project);
+
+ /**
+ * A project is finished being built by the Archives builder
+ * @param project the project being built
+ */
+ public void finishedBuild (IPath project);
+
+ /**
+ * The project is going to be rebuilt from scratch and all state should be discarded
+ * @param project
+ */
+ public void cleanProject(IPath project);
+
+ /**
+ * An Archive has started being built by the Archives builder
+ * This can be called from a full build, or from the incremental build
+ * if and only if one of the affected files matches a fileset in this archive.
+ *
+ * @param pkg the Archive being built
+ */
+ public void startedBuildingArchive (IArchive pkg);
+
+ /**
+ * An Archive is finished being built by the Archives builder
+ * This can be called from a full build, or from the incremental build
+ * if and only if one of the affected files matches a fileset in this archive.
+ *
+ * @param pkg the Archive being built
+ */
+ public void finishedBuildingArchive (IArchive pkg);
+
+ /**
+ * The archive is going to be rebuilt from scratch and all state should be discarded
+ * @param pkg
+ */
+ public void cleanArchive(IArchive pkg);
+
+
+ /**
+ * A fileset has started being collected for copying into a Archive
+ * This is *only* used during a FULL BUILD or after a MODEL CHANGE
+ * @param fileset the fileset being collected
+ */
+ public void startedCollectingFileSet (IArchiveFileSet fileset);
+
+ /**
+ * A fileset has finished being collected for copying into a Archive
+ * This is *only* used during a FULL BUILD or after a MODEL CHANGE
+ * @param fileset the fileset being collected
+ */
+ public void finishedCollectingFileSet (IArchiveFileSet fileset);
+
+ /**
+ * The build for the given project has failed
+ * @param pkg The Archive that failed to build
+ * @param status The status/exception that occurred
+ */
+ public void buildFailed (IArchive pkg, IStatus status);
+
+ /**
+ * A file has been updated, with the given IArchive / IArchiveFileSet context
+ * @param topLevelArchive The top level Archive that was updated
+ * @param fileset The fileset that matched the updated file
+ * @param filePath The path to the file that was copied (filesystem/workspace path)
+ */
+ public void fileUpdated (IArchive topLevelArchive, IArchiveFileSet fileset, IPath filePath);
+
+ /**
+ * A file has been removed, with the given IArchive / IArchiveFileSet context
+ * @param topLevelArchive The top level Archive that was updated
+ * @param fileset The fileset that matched the removed file
+ * @param filePath The path to the file that was removed (filesystem/workspace path)
+ */
+ public void fileRemoved (IArchive topLevelArchive, IArchiveFileSet fileset, IPath filePath);
+
+ /**
+ * An error was happened upon.
+ */
+ public void error(IArchiveNode node, IStatus[] multi);
+
+}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesLogger.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesLogger.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesLogger.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -21,27 +21,13 @@
*/
package org.jboss.ide.eclipse.archives.core.model;
+import org.eclipse.core.runtime.IStatus;
+
/**
* @author rob.stryker <rob.stryker(a)redhat.com>
*
*/
public interface IArchivesLogger {
- /** Message priority of "error". */
- public static final int MSG_ERR = 0;
- /** Message priority of "warning". */
- public static final int MSG_WARN = 1;
- /** Message priority of "information". */
- public static final int MSG_INFO = 2;
- /** Message priority of "verbose". */
- public static final int MSG_VERBOSE = 3;
- /** Message priority of "debug". */
- public static final int MSG_DEBUG = 4;
-
- /**
- * Log a message
- * @param severety
- * @param message
- * @param error
- */
- public void log(int severety, String message,Throwable throwable);
+ public void log(IStatus status);
+ public void log(int severity, String message,Throwable throwable);
}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -38,6 +38,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
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.IArchivesLogger;
@@ -55,20 +56,20 @@
* @author Rob Stryker
*/
public class XMLBinding {
-
+
public static final int NUM_UNMARSHAL_MONITOR_STEPS = 3;
public static final int NUM_MARSHALL_MONITOR_STEPS = 2;
- private static URL schema = XMLBinding.class.getClassLoader().getResource("packages.xsd");
+ private static URL schema = XMLBinding.class.getClassLoader().getResource("packages.xsd");
private static URL log4jxml = XMLBinding.class.getClassLoader().getResource("log4j.xml");
private static SchemaBinding binding;
-
+
private static boolean initialized = false;
-
+
static {
System.setProperty("log4j.configuration", log4jxml.toString());
}
-
+
public static void init ()
{
try {
@@ -77,10 +78,10 @@
stream.close();
initialized = true;
} catch (IOException e) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e.getMessage(), e);
+ ArchivesCore.getInstance().getLogger().log(IStatus.ERROR, e.getMessage(), e);
}
}
-
+
private static void binderSandbox (XbRunnable runnable) throws XbException {
ClassLoader original = Thread.currentThread().getContextClassLoader();
ClassLoader myCL = XMLBinding.class.getClassLoader();
@@ -95,11 +96,11 @@
if( e != null )
throw e;
}
-
+
public static XbPackages unmarshal( String input, IProgressMonitor monitor ) throws XbException {
return unmarshal(new ByteArrayInputStream(input.getBytes()), monitor);
}
-
+
public static XbPackages unmarshal(File file, IProgressMonitor monitor) throws XbException {
try {
FileInputStream fis = new FileInputStream(file);
@@ -110,15 +111,15 @@
throw xbe;
}
}
-
- protected static XbPackages unmarshal (final InputStream in,
+
+ protected static XbPackages unmarshal (final InputStream in,
final IProgressMonitor monitor) throws XbException {
if( !initialized) init();
final XbPackages[] element = new XbPackages[1];
element[0] = null;
XbRunnable runnable = new XbRunnable() {
public void run () throws XbException {
- try {
+ try {
ArchivesUnmarshallerImpl unmarshaller = new ArchivesUnmarshallerImpl();
monitor.worked(1);
binding.setStrictSchema(true);
@@ -127,20 +128,20 @@
unmarshaller.getParser().setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", schema.toExternalForm());
Object xmlObject = unmarshaller.unmarshal(in, binding);
monitor.worked(1);
-
+
element[0] = (XbPackages) xmlObject;
monitor.worked(1);
-
+
} catch (JBossXBException e) {
throw new XbException(e);
}
}
};
-
+
binderSandbox(runnable);
return element[0];
}
-
+
public static String marshall(IArchive topLevelArchive, IProgressMonitor monitor ) throws XbException {
if( topLevelArchive.isTopLevel() && topLevelArchive instanceof ArchiveImpl ) {
XbPackages packs = (XbPackages)((ArchiveImpl)topLevelArchive).getNodeDelegate().getParent();
@@ -150,7 +151,7 @@
}
return null;
}
-
+
public static void marshallToFile(XbPackages element, IPath filePath, IProgressMonitor monitor) throws XbException {
OutputStreamWriter writer = null;
try {
@@ -167,8 +168,8 @@
} catch( IOException ioe) {}
}
}
-
- public static void marshall (final XbPackages element, final Writer writer,
+
+ public static void marshall (final XbPackages element, final Writer writer,
final IProgressMonitor monitor) throws XbException {
if( !initialized) init();
binderSandbox(new XbRunnable() {
@@ -178,7 +179,7 @@
try {
stream = schema.openStream();
monitor.worked(1);
-
+
StrictXercesXSMarshaller marshaller = new StrictXercesXSMarshaller();
marshaller.marshal(new InputStreamReader(stream), new XbPackagesObjectProvider(), element, writer);
monitor.worked(1);
@@ -203,7 +204,7 @@
}
});
}
-
+
public static String serializePackages(XbPackages packages, IProgressMonitor monitor) throws XbException {
try {
StringWriter sw = new StringWriter();
@@ -213,12 +214,12 @@
throw new XbException(e);
}
}
-
-
+
+
public static interface XbRunnable {
public void run() throws XbException;
}
-
+
public static class XbException extends Exception {
private Exception parent;
public XbException(Exception e) {
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -28,6 +28,7 @@
import java.util.List;
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.ArchivesModel;
@@ -76,7 +77,7 @@
final ArrayList<IArchiveFileSet> rets = new ArrayList<IArchiveFileSet>();
IArchiveNodeVisitor visitor = new IArchiveNodeVisitor() {
public boolean visit(IArchiveNode node) {
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET &&
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET &&
((IArchiveFileSet)node).matchesPath(path, inWorkspace)) {
rets.add((IArchiveFileSet)node);
}
@@ -88,7 +89,7 @@
ArchivesModel.instance().accept(visitor);
else
node.accept(visitor);
-
+
return rets.toArray(new IArchiveFileSet[rets.size()]);
}
@@ -111,7 +112,7 @@
ArrayList<IArchiveNode> matches = findAllDescendents(node, IArchiveNode.TYPE_ARCHIVE_FOLDER, false);
return matches.toArray(new IArchiveFolder[matches.size()]);
}
-
+
/**
* Find all nodes of one type that are a child to this one
* @param node
@@ -125,21 +126,21 @@
if( ((node.getNodeType() == type) && !matches.contains(node)) && (includeSelf || node != original))
matches.add(node);
return true;
- }
+ }
});
return matches;
}
-
+
/**
* Do any filesets other than the parameter match this path?
*/
public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, FileWrapper file) {
- return otherFilesetMatchesPathAndOutputLocation(fileset, new Path(file.getAbsolutePath()),
+ return otherFilesetMatchesPathAndOutputLocation(fileset, new Path(file.getAbsolutePath()),
file.getFilesetRelative(), file.getRootArchiveRelative().toString(), null);
}
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, IPath absolute,
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, IPath absolute,
String fsRelative, String rootArchiveRelative, IArchiveNode root) {
IArchiveFileSet[] filesets = ModelUtil.getMatchingFilesets(root, absolute);
if( filesets.length == 0 || (filesets.length == 1 && Arrays.asList(filesets).contains(fileset))) {
@@ -155,7 +156,7 @@
for( int j = 0; j < matches.length; j++ )
relativePathsMatch |= matches[j].getRootArchiveRelative().toString().equals(rootArchiveRelative);
destinationsMatch = fileset.getRootArchive().getArchiveFilePath().equals(filesets[i].getRootArchive().getArchiveFilePath());
-
+
if( relativePathsMatch && destinationsMatch ) {
// the two put the file in the same spot, within the same archive! It's a match!
return true;
@@ -166,7 +167,7 @@
}
/**
- * Get the raw file for this node, specifically,
+ * Get the raw file for this node, specifically,
* the file actually saved as an OS file.
* @param node
* @return
@@ -176,35 +177,35 @@
IPath lastConcrete = null;
for( int i = 0; i < nodes.length; i++ ) {
if( nodes[i] instanceof IArchive) {
- if( lastConcrete == null )
+ if( lastConcrete == null )
lastConcrete = ((IArchive)nodes[i]).getArchiveFilePath();
else
lastConcrete = lastConcrete.append(((IArchive)nodes[i]).getName());
-
+
if( !((IArchive)nodes[i]).isExploded())
return lastConcrete;
} else if( nodes[i] instanceof IArchiveFolder ) {
lastConcrete = lastConcrete.append(((IArchiveFolder)nodes[i]).getName());
}
}
- return lastConcrete;
+ return lastConcrete;
}
-
+
public static IPath getBaseDestinationFile(IArchiveFileSet node, IPath fsRelative) {
IPath last = getBaseDestinationFile(node);
if( fsRelative != null ) {
IArchiveNode[] nodes = getReverseNodeTree(node);
boolean anyZipped = false;
- for( int i = 0; !anyZipped && i < nodes.length; i++ )
+ for( int i = 0; !anyZipped && i < nodes.length; i++ )
if( nodes[i] instanceof IArchive && !((IArchive)nodes[i]).isExploded())
anyZipped = true;
-
+
if(!anyZipped) // none are zipped, we can append this path
last = last.append(fsRelative);
}
return last;
}
-
+
private static IArchiveNode[] getReverseNodeTree(IArchiveNode node) {
ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
while( node != null && !(node instanceof ArchiveModelNode)) {
@@ -216,7 +217,7 @@
return nodes;
}
- public static void fillArchiveModel( XbPackages node, IArchiveModelRootNode modelNode) throws ArchivesModelException {
+ public static void fillArchiveModel( XbPackages node, IArchiveModelRootNode modelNode) throws ArchivesModelException {
for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
XbPackageNode child = (XbPackageNode) iter.next();
ArchiveNodeImpl childImpl = (ArchiveNodeImpl)createPackageNodeImpl(child, modelNode);
@@ -224,10 +225,10 @@
try {
if( modelNode instanceof ArchiveNodeImpl )
((ArchiveNodeImpl)modelNode).addChild(childImpl, false);
- else
+ else
modelNode.addChild(childImpl);
} catch( ArchivesModelException ame ) {
- ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, ame.getMessage(), ame);
+ ArchivesCore.getInstance().getLogger().log(IStatus.ERROR, ame.getMessage(), ame);
}
}
}
@@ -244,7 +245,7 @@
} else if( node instanceof XbAction ) {
nodeImpl = new ArchiveActionImpl((XbAction)node);
}
-
+
for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
XbPackageNode child = (XbPackageNode) iter.next();
ArchiveNodeImpl childImpl = (ArchiveNodeImpl)createPackageNodeImpl(child, nodeImpl);
@@ -254,11 +255,11 @@
}
return nodeImpl;
}
-
+
public static IArchive[] getProjectArchives(IPath project) {
return getProjectArchives(project, ArchivesModel.instance());
}
-
+
public static IArchive[] getProjectArchives(IPath project, IArchiveModel model) {
if( model != null ) {
IArchiveModelRootNode root = model.getRoot(project);
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -25,7 +25,10 @@
import java.util.Arrays;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
@@ -41,162 +44,178 @@
/**
* 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
+ * 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);
- boolean b = file.deleteAll();
- TrueZipUtil.sync();
+ public static class FileWrapperStatusPair {
+ public FileWrapper[] f;
+ public IStatus[] s;
+ public FileWrapperStatusPair(FileWrapper[] files, IStatus[] statuses) {
+ this.f = files;
+ this.s = statuses;
+ }
}
-
- 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) {
+ public static FileWrapperStatusPair fullFilesetBuild(final IArchiveFileSet fileset, boolean sync) {
FileWrapper[] files = fileset.findMatchingPaths();
- copyFiles(fileset, files, false);
+ IStatus[] s = copyFiles(fileset, files, false);
if( sync )
TrueZipUtil.sync();
+ return new FileWrapperStatusPair( files, s );
}
-
- 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) {
+
+ /*
+ * Returns an Object array as follows:
+ * Object[] {
+ * FileWrapper[] removedPaths,
+ * IStatus[] errors
+ * }
+ */
+ public static FileWrapperStatusPair fullFilesetRemove(final IArchiveFileSet fileset, boolean sync) {
FileWrapper[] files = fileset.findMatchingPaths();
+ final ArrayList<IStatus> errors = new ArrayList<IStatus>();
final ArrayList<FileWrapper> list = new ArrayList<FileWrapper>();
list.addAll(Arrays.asList(files));
for( int i = 0; i < files.length; i++ ) {
if( !ModelUtil.otherFilesetMatchesPathAndOutputLocation(fileset, files[i])) {
// remove
- deleteFiles(fileset, new FileWrapper[] {files[i]}, false);
+ errors.addAll(Arrays.asList(deleteFiles(fileset, new FileWrapper[] {files[i]}, false)));
} else {
list.remove(files[i]);
}
}
-
+
// kinda ugly here. delete all empty folders beneath
- cleanFolder(getFile(fileset), false);
-
+ File folder = getFile(fileset);
+ if( !cleanFolder(folder, false) ) {
+ IStatus e = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID, "Error emptying folder " + folder.toString());
+ errors.add(e);
+ }
+
// now ensure all mandatory child folders are still there
fileset.getParent().accept(new IArchiveNodeVisitor() {
public boolean visit(IArchiveNode node) {
+ boolean b = true;
if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- createFile(node);
+ b = createFile(node);
} else if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- createFile(node);
+ b = createFile(node);
}
+ if( !b ) {
+ IStatus e = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID, "Error creating file " + getFile(node).toString());
+ errors.add(e);
+ }
return true;
- }
+ }
} );
-
- if( sync )
+
+ if( sync )
TrueZipUtil.sync();
-
- return list.toArray(new IPath[list.size()]);
+ IStatus[] errorsArr = errors.toArray(new IStatus[errors.size()]);
+ FileWrapper[] files2 = list.toArray(new FileWrapper[list.size()]);
+ return new FileWrapperStatusPair( files2, errorsArr);
}
-
- public static void copyFiles(IArchiveFileSet[] filesets, FileWrapper[] files) {
- copyFiles(filesets, files, true);
+ public static boolean deleteArchive(IArchive archive) {
+ final File file = getFile(archive);
+ boolean b = file.deleteAll();
+ TrueZipUtil.sync();
+ return b;
}
-
- public static void copyFiles(final IArchiveFileSet[] filesets, final FileWrapper[] files, boolean sync) {
+
+ public static boolean cleanFolder(IArchiveFolder folder) {
+ return cleanFolder(getFile(folder), true);
+ }
+
+ public static boolean cleanFolder(java.io.File folder, boolean sync) {
+ boolean b = TrueZipUtil.deleteEmptyChildren(folder);
+ if( sync )
+ TrueZipUtil.sync();
+ return b;
+ }
+
+
+ public static IStatus[] copyFiles(IArchiveFileSet[] filesets, FileWrapper[] files) {
+ return copyFiles(filesets, files, true);
+ }
+
+ public static IStatus[] copyFiles(final IArchiveFileSet[] filesets, final FileWrapper[] files, boolean sync) {
+ ArrayList<IStatus> list = new ArrayList<IStatus>();
for( int i = 0; i < filesets.length; i++ ) {
- copyFiles(filesets[i], files, false);
+ list.addAll(Arrays.asList(copyFiles(filesets[i], files, false)));
}
- if( sync )
+ if( sync )
TrueZipUtil.sync();
-
+ return list.toArray(new IStatus[list.size()]);
}
-
- public static void copyFiles(IArchiveFileSet fileset, final FileWrapper[] files) {
- copyFiles(fileset, files, true);
- }
-
- public static void copyFiles(IArchiveFileSet fileset, final FileWrapper[] files, boolean sync) {
+
+ public static IStatus[] copyFiles(IArchiveFileSet fileset, final FileWrapper[] files, boolean sync) {
+ boolean b = true;
+ ArrayList<IStatus> list = new ArrayList<IStatus>();
final File[] destFiles = getFiles(files, fileset);
for( int i = 0; i < files.length; i++ ) {
- TrueZipUtil.copyFile(files[i].getAbsolutePath(), destFiles[i]);
+ b = TrueZipUtil.copyFile(files[i].getAbsolutePath(), destFiles[i]);
+ if( b == false ) {
+ list.add(new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID, "File copy failed. Source=" + files[i].getAbsolutePath() + ", dest=" + destFiles[i]));
+ }
}
- if( sync )
+ if( sync )
TrueZipUtil.sync();
+ return list.toArray(new IStatus[list.size()]);
}
-
-
+
+
/*
* Deleting files
*/
- public static void deleteFiles(IArchiveFileSet[] filesets, FileWrapper[] files ) {
- deleteFiles(filesets, files, true);
+
+ public static IStatus[] deleteFiles(IArchiveFileSet fileset, final FileWrapper[] paths ) {
+ return deleteFiles(fileset, paths, true);
}
- public static void deleteFiles(final IArchiveFileSet[] filesets, final FileWrapper[] files, boolean sync ) {
- for( int i = 0; i < filesets.length; i++ ) {
- deleteFiles(filesets[i], files, false);
- }
- if( sync )
- TrueZipUtil.sync();
- }
-
- public static void deleteFiles(IArchiveFileSet fileset, final FileWrapper[] paths ) {
- deleteFiles(fileset, paths, true);
- }
- public static void deleteFiles(IArchiveFileSet fileset, final FileWrapper[] files, boolean sync ) {
+ public static IStatus[] deleteFiles(IArchiveFileSet fileset, final FileWrapper[] files, boolean sync ) {
final File[] destFiles = getFiles(files, fileset);
+ ArrayList<IStatus> list = new ArrayList<IStatus>();
for( int i = 0; i < files.length; i++ ) {
- TrueZipUtil.deleteAll(destFiles[i]);
+ if( !TrueZipUtil.deleteAll(destFiles[i]) ) {
+ IStatus e = new Status(IStatus.ERROR, ArchivesCore.PLUGIN_ID, "Error deleting file " + destFiles[i].toString());
+ list.add(e);
+ }
}
-
- if( sync )
+ if( sync )
TrueZipUtil.sync();
+ return list.toArray(new IStatus[list.size()]);
}
-
-
+
+
/**
* 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 boolean createFile(final IArchiveNode node) {
+ return createFile(node, true);
}
- public static void createFile(final IArchiveNode node, boolean sync) {
+ public static boolean createFile(final IArchiveNode node, boolean sync) {
File f = getFile(node);
+ boolean b = true;
if( f != null ) {
- f.mkdirs();
+ b = f.mkdirs();
}
- if( sync )
+ if( sync )
TrueZipUtil.sync();
+ return b;
}
-
-
+
+
/**
* Gets all properly-created de.sch destination files for a fileset
* @param inputFiles
@@ -208,16 +227,16 @@
File fsFile = getFile(fs);
if( fsFile == null )
return new File[]{};
-
+
File[] returnFiles = new File[inputFiles.length];
for( int i = 0; i < inputFiles.length; i++ ) {
if( fs.isFlattened() )
filesetRelative = inputFiles[i].getOutputName();
- else
+ else
filesetRelative = inputFiles[i].getFilesetRelative();
-
+
File parentFile;
- if(new Path(filesetRelative).segmentCount() > 1 ) {
+ 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 )
@@ -225,30 +244,30 @@
} else {
parentFile = fsFile;
}
- returnFiles[i] = new File(parentFile, new Path(filesetRelative).lastSegment(), ArchiveDetector.DEFAULT);
+ 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.
+ * 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);
@@ -267,5 +286,5 @@
}
return null;
}
-
+
}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -1,175 +1,181 @@
-/**
- * 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.io.IOException;
-
-import org.eclipse.core.runtime.IPath;
-
-import de.schlichtherle.io.AbstractArchiveDetector;
-import de.schlichtherle.io.ArchiveDetector;
-import de.schlichtherle.io.ArchiveException;
-import de.schlichtherle.io.archive.spi.ArchiveDriver;
-import de.schlichtherle.io.archive.zip.Zip32Driver;
-
-/**
- * Accesses raw files with the truezip filesystem
- * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
- *
- */
-public class TrueZipUtil {
-
- public static de.schlichtherle.io.File getFile(IPath path) {
- return getFile(path, ArchiveDetector.DEFAULT);
- }
- public static de.schlichtherle.io.File getFile(IPath path, ArchiveDetector detector) {
- return new de.schlichtherle.io.File(path.toOSString(), detector);
- }
-
- public static boolean pathExists(IPath path) {
- return pathExists( getFile(path));
- }
- public static boolean pathExists( de.schlichtherle.io.File file) {
- return file.exists();
- }
-
-
- public static long getTimestamp(IPath path) {
- return getTimestamp( getFile(path));
- }
-
- public static long getTimestamp(de.schlichtherle.io.File file) {
- return file.lastModified();
- }
-
-
- public static void copyFile(String source, IPath dest) throws IOException {
- copyFile(source, getFile(dest));
- }
-
- public static void copyFile(String source, de.schlichtherle.io.File file) {
- file.getParentFile().mkdirs();
- new de.schlichtherle.io.File(source).copyAllTo(file);
- updateParentTimestamps(file);
- }
-
- public static void touchFile(IPath path) {
- de.schlichtherle.io.File f = getFile(path);
- f.setLastModified(System.currentTimeMillis());
- updateParentTimestamps(path);
- }
-
-
- // Delete methods
- public static void deleteAll(IPath path, String fileName) {
- deleteAll(path.append(fileName));
- }
- public static void deleteAll(IPath path) {
- deleteAll(getFile(path));
- }
- public static void deleteAll(de.schlichtherle.io.File file) {
- file.deleteAll();
- }
-
- public static void deleteEmptyChildren(java.io.File file) {
- if( file.isDirectory() ) {
- java.io.File[] children = file.listFiles();
- for( int i = 0; i < children.length; i++ )
- deleteEmptyFolders(children[i]);
- }
- }
- public static void deleteEmptyFolders(java.io.File file ) {
- if( file.isDirectory() ) {
- java.io.File[] children = file.listFiles();
- for( int i = 0; i < children.length; i++ )
- deleteEmptyFolders(children[i]);
- if( file.listFiles().length == 0 )
- file.delete();
- }
- }
-
-
- public static void createFolder(IPath parent, String folderName) {
- new de.schlichtherle.io.File(getFile(parent, ArchiveDetector.DEFAULT), folderName, ArchiveDetector.NULL).mkdirs();
- updateParentTimestamps(parent.append(folderName));
- }
- public static void createFolder(IPath path) {
- createFolder(path.removeLastSegments(1), path.lastSegment());
- }
- public static void createArchive(IPath parent, String folderName) {
- new de.schlichtherle.io.File(getFile(parent, ArchiveDetector.DEFAULT), folderName, getJarArchiveDetector()).mkdirs();
- updateParentTimestamps(parent.append(folderName));
- }
- public static void createArchive(IPath path) {
- createArchive(path.removeLastSegments(1), path.lastSegment());
- }
- public static void umount() {
- try {
- de.schlichtherle.io.File.umount();
- } catch( ArchiveException ae ) {
- }
- }
-
- /**
- * Sync's with file system after executing a runnable
- * @param run Runnable or null
- */
- public static void syncExec(Runnable run) {
- try {
- if( run != null )
- run.run();
- } catch (Exception e ) {}
- umount();
- }
-
- public static void sync() {
- syncExec(null);
- }
-
- public static void updateParentTimestamps(IPath path) {
- updateParentTimestamps(getFile(path));
- }
- public static void updateParentTimestamps(de.schlichtherle.io.File file) {
- long time = System.currentTimeMillis();
- de.schlichtherle.io.File parent = file.getEnclArchive();
- while( parent != null ) {
- parent.setLastModified(time);
- parent = parent.getEnclArchive();
- }
- }
-
-
- private static ArchiveDetector JAR_ARCHIVE_DETECTOR;
- public static ArchiveDetector getJarArchiveDetector() {
- if( JAR_ARCHIVE_DETECTOR == null ) {
- JAR_ARCHIVE_DETECTOR = new JarArchiveDetector();
- }
- return JAR_ARCHIVE_DETECTOR;
- }
-
- public static class JarArchiveDetector extends AbstractArchiveDetector {
- public ArchiveDriver getArchiveDriver(String arg0) {
- return new Zip32Driver();
- }
-
- }
-}
+/**
+ * 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.io.IOException;
+
+import org.eclipse.core.runtime.IPath;
+
+import de.schlichtherle.io.AbstractArchiveDetector;
+import de.schlichtherle.io.ArchiveDetector;
+import de.schlichtherle.io.ArchiveException;
+import de.schlichtherle.io.archive.spi.ArchiveDriver;
+import de.schlichtherle.io.archive.zip.Zip32Driver;
+
+/**
+ * Accesses raw files with the truezip filesystem
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class TrueZipUtil {
+
+ public static de.schlichtherle.io.File getFile(IPath path) {
+ return getFile(path, ArchiveDetector.DEFAULT);
+ }
+ public static de.schlichtherle.io.File getFile(IPath path, ArchiveDetector detector) {
+ return new de.schlichtherle.io.File(path.toOSString(), detector);
+ }
+
+ public static boolean pathExists(IPath path) {
+ return pathExists( getFile(path));
+ }
+ public static boolean pathExists( de.schlichtherle.io.File file) {
+ return file.exists();
+ }
+
+
+ public static long getTimestamp(IPath path) {
+ return getTimestamp( getFile(path));
+ }
+
+ public static long getTimestamp(de.schlichtherle.io.File file) {
+ return file.lastModified();
+ }
+
+
+ public static boolean copyFile(String source, IPath dest) throws IOException {
+ return copyFile(source, getFile(dest));
+ }
+
+ public static boolean copyFile(String source, de.schlichtherle.io.File file) {
+ file.getParentFile().mkdirs();
+ boolean b = new de.schlichtherle.io.File(source).copyAllTo(file);
+ return b && updateParentTimestamps(file);
+ }
+
+ public static boolean touchFile(IPath path) {
+ de.schlichtherle.io.File f = getFile(path);
+ boolean b = f.setLastModified(System.currentTimeMillis());
+ return b && updateParentTimestamps(path);
+ }
+
+
+ // Delete methods
+ public static boolean deleteAll(IPath path, String fileName) {
+ return deleteAll(path.append(fileName));
+ }
+ public static boolean deleteAll(IPath path) {
+ return deleteAll(getFile(path));
+ }
+ public static boolean deleteAll(de.schlichtherle.io.File file) {
+ return file.deleteAll();
+ }
+
+ public static boolean deleteEmptyChildren(java.io.File file) {
+ boolean b = true;
+ if( file.isDirectory() ) {
+ java.io.File[] children = file.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ b &= deleteEmptyFolders(children[i]);
+ }
+ return b;
+ }
+ public static boolean deleteEmptyFolders(java.io.File file ) {
+ boolean b = true;
+ if( file.isDirectory() ) {
+ java.io.File[] children = file.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ b &= deleteEmptyFolders(children[i]);
+ if( file.listFiles().length == 0 )
+ file.delete();
+ }
+ return b;
+ }
+
+
+ public static boolean createFolder(IPath parent, String folderName) {
+ boolean b = new de.schlichtherle.io.File(getFile(parent, ArchiveDetector.DEFAULT), folderName, ArchiveDetector.NULL).mkdirs();
+ return b && updateParentTimestamps(parent.append(folderName));
+ }
+ public static boolean createFolder(IPath path) {
+ return createFolder(path.removeLastSegments(1), path.lastSegment());
+ }
+ public static boolean createArchive(IPath parent, String folderName) {
+ boolean b = new de.schlichtherle.io.File(getFile(parent, ArchiveDetector.DEFAULT), folderName, getJarArchiveDetector()).mkdirs();
+ return b && updateParentTimestamps(parent.append(folderName));
+ }
+ public static boolean createArchive(IPath path) {
+ return createArchive(path.removeLastSegments(1), path.lastSegment());
+ }
+ public static void umount() {
+ try {
+ de.schlichtherle.io.File.umount();
+ } catch( ArchiveException ae ) {
+ }
+ }
+
+ /**
+ * Sync's with file system after executing a runnable
+ * @param run Runnable or null
+ */
+ public static void syncExec(Runnable run) {
+ try {
+ if( run != null )
+ run.run();
+ } catch (Exception e ) {}
+ umount();
+ }
+
+ public static void sync() {
+ syncExec(null);
+ }
+
+ public static boolean updateParentTimestamps(IPath path) {
+ return updateParentTimestamps(getFile(path));
+ }
+ public static boolean updateParentTimestamps(de.schlichtherle.io.File file) {
+ long time = System.currentTimeMillis();
+ de.schlichtherle.io.File parent = file.getEnclArchive();
+ boolean b = true;
+ while( parent != null ) {
+ b &= parent.setLastModified(time);
+ parent = parent.getEnclArchive();
+ }
+ return b;
+ }
+
+
+ private static ArchiveDetector JAR_ARCHIVE_DETECTOR;
+ public static ArchiveDetector getJarArchiveDetector() {
+ if( JAR_ARCHIVE_DETECTOR == null ) {
+ JAR_ARCHIVE_DETECTOR = new JarArchiveDetector();
+ }
+ return JAR_ARCHIVE_DETECTOR;
+ }
+
+ public static class JarArchiveDetector extends AbstractArchiveDetector {
+ public ArchiveDriver getArchiveDriver(String arg0) {
+ return new Zip32Driver();
+ }
+
+ }
+}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2008-09-19 00:38:23 UTC (rev 10369)
@@ -52,7 +52,6 @@
<extension
point="org.eclipse.ui.preferencePages">
<page
- category="org.jboss.ide.eclipse.ui.MainPreferencePage"
class="org.jboss.ide.eclipse.archives.ui.preferences.MainPreferencePage"
id="org.jboss.ide.eclipse.archives.ui.archivesPreferencePage"
name="Packaging Archives"/>
Added: trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIBuildListener.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIBuildListener.java (rev 0)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIBuildListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -0,0 +1,127 @@
+package org.jboss.ide.eclipse.archives.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Image;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.AbstractBuildListener;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+
+public class ArchivesUIBuildListener extends AbstractBuildListener {
+
+ public void error(IArchiveNode node, final IStatus[] multi) {
+ final MultiStatus ms = new MultiStatus(ArchivesCore.PLUGIN_ID, 0, "Error during build", null);
+ for( int i = 0; i < multi.length; i++ ) {
+ ms.add(multi[i]);
+ }
+ if( PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_BUILD_ERROR_DIALOG)) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ ErrorDialog ed = new ErrorDialogWithPreference(new Shell(), "Error building project archives", "Error building project archives", ms, IStatus.ERROR );
+ ed.open();
+ }
+ } );
+ } else {
+ ArchivesCore.getInstance().getLogger().log(ms);
+ }
+ }
+
+ public static class ErrorDialogWithPreference extends ErrorDialog {
+ private Button checkbox;
+ public ErrorDialogWithPreference(Shell parentShell, String dialogTitle,
+ String message, IStatus status, int displayMask) {
+ super(parentShell, dialogTitle, message, status, displayMask);
+ }
+ protected void okPressed() {
+ // save the checkbox selection
+ if( checkbox.getSelection()) {
+ PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_BUILD_ERROR_DIALOG, false);
+ }
+ super.okPressed();
+ }
+ protected Control createMessageArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL));
+ composite.setLayout(new FormLayout());
+
+ // create composite
+ // create image
+ Image image = getImage();
+ if (image != null) {
+ imageLabel = new Label(composite, SWT.NULL);
+ image.setBackground(imageLabel.getBackground());
+ imageLabel.setImage(image);
+ addAccessibleListeners(imageLabel, image);
+ FormData fd = new FormData();
+ fd.left = new FormAttachment(0,5);
+ fd.top = new FormAttachment(0,5);
+ imageLabel.setLayoutData(fd);
+ }
+ // create message
+ if (message != null) {
+ messageLabel = new Label(composite, getMessageLabelStyle());
+ messageLabel.setText(message);
+ FormData fd = new FormData();
+ fd.top = new FormAttachment(0,5);
+ fd.left = image == null ? new FormAttachment(0,5) : new FormAttachment(imageLabel,5);
+ messageLabel.setLayoutData(fd);
+ }
+
+ checkbox = new Button(composite, SWT.CHECK);
+ checkbox.setText("Do not show this message again");
+ FormData fd = new FormData();
+ fd.top = new FormAttachment(messageLabel,5);
+ fd.left = new FormAttachment(0,5);
+ fd.right = new FormAttachment(0,IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+ checkbox.setLayoutData(fd);
+
+ return parent;
+ }
+ private void addAccessibleListeners(Label label, final Image image) {
+ label.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ public void getName(AccessibleEvent event) {
+ final String accessibleMessage = getAccessibleMessageFor(image);
+ if (accessibleMessage == null) {
+ return;
+ }
+ event.result = accessibleMessage;
+ }
+ });
+ }
+ private String getAccessibleMessageFor(Image image) {
+ if (image.equals(getErrorImage())) {
+ return JFaceResources.getString("error");//$NON-NLS-1$
+ }
+
+ if (image.equals(getWarningImage())) {
+ return JFaceResources.getString("warning");//$NON-NLS-1$
+ }
+
+ if (image.equals(getInfoImage())) {
+ return JFaceResources.getString("info");//$NON-NLS-1$
+ }
+
+ if (image.equals(getQuestionImage())) {
+ return JFaceResources.getString("question"); //$NON-NLS-1$
+ }
+
+ return null;
+ }
+ }
+}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ExtensionManager.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ExtensionManager.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ExtensionManager.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -12,7 +12,7 @@
public class ExtensionManager {
public static final String NODE_POPUP_MENUS_EXTENSION_ID = "org.jboss.ide.eclipse.archives.ui.nodePopupMenus";
public static final String NEW_PACKAGE_ACTIONS_EXTENSION_ID = "org.jboss.ide.eclipse.archives.ui.newArchiveActions";
-
+
private NewArchiveAction[] newArchiveActions;
private NodeContribution[] nodeContributions;
public NewArchiveAction[] getNewArchiveActions() {
@@ -25,40 +25,38 @@
nodeContributions = findNodePopupMenuContributions();
return nodeContributions;
}
-
+
public static IExtension[] findExtension (String extensionId) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry.getExtensionPoint(extensionId);
return extensionPoint.getExtensions();
}
-
+
public static NodeContribution[] findNodePopupMenuContributions () {
- ArrayList contributions = new ArrayList();
+ ArrayList<NodeContribution> contributions = new ArrayList<NodeContribution>();
IExtension[] extensions = findExtension(NODE_POPUP_MENUS_EXTENSION_ID);
-
+
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
for (int j = 0; j < elements.length; j++) {
contributions.add(new NodeContribution(elements[j]));
}
}
-
- return (NodeContribution[]) contributions.toArray(new NodeContribution[contributions.size()]);
+
+ return contributions.toArray(new NodeContribution[contributions.size()]);
}
-
+
public static NewArchiveAction[] findNewArchiveActions () {
- ArrayList contributions = new ArrayList();
+ ArrayList<NewArchiveAction> contributions = new ArrayList<NewArchiveAction>();
IExtension[] extensions = findExtension(NEW_PACKAGE_ACTIONS_EXTENSION_ID);
-
- for (int i = 0; i < extensions.length; i++)
- {
+
+ for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++)
- {
+ for (int j = 0; j < elements.length; j++) {
contributions.add(new NewArchiveAction(elements[j]));
}
}
-
- return (NewArchiveAction[]) contributions.toArray(new NewArchiveAction[contributions.size()]);
+
+ return contributions.toArray(new NewArchiveAction[contributions.size()]);
}
}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PackagesUIPlugin.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PackagesUIPlugin.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PackagesUIPlugin.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -2,6 +2,7 @@
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.osgi.framework.BundleContext;
/**
@@ -13,10 +14,10 @@
public static final String PLUGIN_ID = "org.jboss.ide.eclipse.archives.ui";
-
+
// The shared instance
private static PackagesUIPlugin plugin;
-
+
/**
* The constructor
*/
@@ -28,8 +29,11 @@
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
+ private ArchivesUIBuildListener buildListener;
public void start(BundleContext context) throws Exception {
super.start(context);
+ buildListener = new ArchivesUIBuildListener();
+ ArchivesModel.instance().addBuildListener(buildListener);
}
/*
@@ -37,6 +41,7 @@
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
+ ArchivesModel.instance().removeBuildListener(buildListener);
plugin = null;
super.stop(context);
}
@@ -50,8 +55,8 @@
return plugin;
}
-
-
+
+
protected void initializeImageRegistry(ImageRegistry registry) {
ArchivesSharedImages.register(registry);
}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -21,21 +21,23 @@
public static final String PREF_SHOW_FULL_FILESET_ROOT_DIR = "showFullFilesetRootDir";
public static final String PREF_SHOW_PROJECT_ROOT = "showProjectRoot";
public static final String PREF_SHOW_ALL_PROJECTS = "showAllProjects";
+ public static final String PREF_SHOW_BUILD_ERROR_DIALOG = "showBuildErrorDialog";
public static final ArrayList<IArchivesPreferenceListener> listeners = new ArrayList<IArchivesPreferenceListener>();
-
+
public static interface IArchivesPreferenceListener {
public void preferenceChanged(String key, boolean val);
}
-
+
public void initializeDefaultPreferences() {
IEclipsePreferences prefs = new DefaultScope().getNode(PackagesUIPlugin.PLUGIN_ID);
prefs.putBoolean(PREF_SHOW_FULL_FILESET_ROOT_DIR, true);
prefs.putBoolean(PREF_SHOW_PACKAGE_OUTPUT_PATH, true);
prefs.putBoolean(PREF_SHOW_PROJECT_ROOT, true);
prefs.putBoolean(PREF_SHOW_ALL_PROJECTS, false);
+ prefs.putBoolean(PREF_SHOW_BUILD_ERROR_DIALOG, true);
try {
prefs.flush();
- } catch (org.osgi.service.prefs.BackingStoreException e) {
+ } catch (org.osgi.service.prefs.BackingStoreException e) {
e.printStackTrace();
} // swallow
}
@@ -43,7 +45,7 @@
public static void setBoolean(String key, boolean val) {
setBoolean(key, val, null);
}
-
+
public static void setBoolean(String key, boolean val, IAdaptable adaptable) {
QualifiedName name = new QualifiedName(PackagesUIPlugin.PLUGIN_ID, key);
if( adaptable != null ) {
@@ -62,23 +64,23 @@
} catch (org.osgi.service.prefs.BackingStoreException e) { } // swallow
fireChanged(key, val);
}
-
+
protected static void fireChanged(String key, boolean val) {
Iterator<IArchivesPreferenceListener> i = listeners.iterator();
while(i.hasNext()) {
i.next().preferenceChanged(key, val);
}
}
-
+
public static void addListener(IArchivesPreferenceListener listener) {
if( !listeners.contains(listener))
listeners.add(listener);
}
-
+
public static void removeListener(IArchivesPreferenceListener listener) {
listeners.remove(listener);
}
-
+
/**
* Get the global pref value for this key
* @param key
@@ -87,13 +89,13 @@
public static boolean getBoolean(String key) {
return getBoolean(key, null, true);
}
-
+
/**
- *
+ *
* @param key the preference to be gotten
* @param adaptable the project / resource where the pref might be stored
- * @param effective whether or not to get the raw pref value or the effective value
- * (based on whether project specific prefs are turned on)
+ * @param effective whether or not to get the raw pref value or the effective value
+ * (based on whether project specific prefs are turned on)
* @return
*/
public static boolean getBoolean(String key, IAdaptable adaptable, boolean effective) {
@@ -110,6 +112,7 @@
} catch(CoreException ce) {}
}
}
- return new InstanceScope().getNode(PackagesUIPlugin.PLUGIN_ID).getBoolean(key, false);
+ boolean defaultVal = new DefaultScope().getNode(PackagesUIPlugin.PLUGIN_ID).getBoolean(key, false);
+ return new InstanceScope().getNode(PackagesUIPlugin.PLUGIN_ID).getBoolean(key, defaultVal);
}
}
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -27,11 +27,11 @@
private Button showPackageOutputPath, showFullFilesetRootDir;
private Button showProjectRoot, showAllProjects;
- private Button automaticBuilder, overrideButton;
+ private Button automaticBuilder, showErrorDialog, overrideButton;
private Group corePrefGroup, viewPrefGroup;
private Composite overrideComp;
-
-
+
+
public MainPreferencePage() {
super();
setTitle(ArchivesUIMessages.PreferencePageTitle);
@@ -41,20 +41,20 @@
protected Control createContents(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(1, false));
-
+
createOverridePrefs(main);
createCorePrefs(main);
createViewPrefs(main);
fillValues();
return main;
}
-
+
public IPath getResourceLocationIfExists() {
IAdaptable el = getElement();
- return el == null ? null :
+ return el == null ? null :
((IResource)el.getAdapter(IResource.class)).getLocation();
}
-
+
public IPreferenceManager getPrefManager() {
return ArchivesCore.getInstance().getPreferenceManager();
}
@@ -62,7 +62,8 @@
if( getResourceLocationIfExists() != null ) {
overrideButton.setSelection(getPrefManager().areProjectSpecificPrefsEnabled(getResourceLocationIfExists()));
}
- automaticBuilder.setSelection(getPrefManager().isBuilderEnabled(getResourceLocationIfExists()));
+ automaticBuilder.setSelection(getPrefManager().isBuilderEnabled(getResourceLocationIfExists()));
+ showErrorDialog.setSelection(PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_BUILD_ERROR_DIALOG, getElement(), true));
showAllProjects.setSelection(
PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS, getElement(), false));
showPackageOutputPath.setSelection(
@@ -73,21 +74,21 @@
PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT, getElement(), false));
showAllProjects.setEnabled(showProjectRoot.getSelection());
- if (!showProjectRoot.getSelection())
+ if (!showProjectRoot.getSelection())
showAllProjects.setSelection(false);
-
+
if( getElement() != null ) {
setWidgetsEnabled(overrideButton.getSelection());
}
}
-
+
protected void createOverridePrefs(Composite main) {
if( getResourceLocationIfExists() != null ) {
overrideComp = new Composite(main, SWT.NONE);
overrideComp.setLayout(new FillLayout());
overrideButton = new Button(overrideComp, SWT.CHECK);
overrideButton.setText(ArchivesUIMessages.ProjectSpecificSettings);
-
+
overrideButton.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -98,7 +99,7 @@
});
}
}
-
+
protected void setWidgetsEnabled(boolean val) {
showPackageOutputPath.setEnabled(val);
showProjectRoot.setEnabled(val);
@@ -106,61 +107,65 @@
if( showProjectRoot.getSelection())
showAllProjects.setEnabled(val);
automaticBuilder.setEnabled(val);
+ showErrorDialog.setEnabled(val);
}
-
+
protected void createCorePrefs(Composite main) {
corePrefGroup = new Group(main, SWT.NONE);
corePrefGroup.setText(ArchivesUIMessages.CorePreferences);
corePrefGroup.setLayout(new GridLayout(1, false));
- corePrefGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+ corePrefGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
automaticBuilder = new Button(corePrefGroup, SWT.CHECK);
automaticBuilder.setText(ArchivesUIMessages.EnableIncrementalBuilder);
+ showErrorDialog = new Button(corePrefGroup, SWT.CHECK);
+ showErrorDialog.setText("Externalize me");
}
-
+
protected void createViewPrefs(Composite main) {
-
+
viewPrefGroup = new Group(main, SWT.NONE);
viewPrefGroup.setText(ArchivesUIMessages.ProjectPackagesView);
viewPrefGroup.setLayout(new GridLayout(1, false));
viewPrefGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
showPackageOutputPath = new Button(viewPrefGroup, SWT.CHECK);
showPackageOutputPath.setText(ArchivesUIMessages.ShowFullOutputPath);
-
+
showFullFilesetRootDir = new Button(viewPrefGroup, SWT.CHECK);
showFullFilesetRootDir.setText(ArchivesUIMessages.ShowFullRootDirectory);
-
+
showProjectRoot = new Button(viewPrefGroup, SWT.CHECK);
showProjectRoot.setText(ArchivesUIMessages.ShowRootProject);
-
+
showProjectRoot.addSelectionListener(new SelectionListener () {
public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
+ widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
showAllProjects.setEnabled(showProjectRoot.getSelection());
-
+
if (!showProjectRoot.getSelection())
{
showAllProjects.setSelection(false);
}
}
});
-
+
showAllProjects = new Button(viewPrefGroup, SWT.CHECK);
showAllProjects.setText(ArchivesUIMessages.ShowAllProjects);
showAllProjects.setEnabled(showProjectRoot.getSelection());
- if( !showProjectRoot.getSelection() )
+ if( !showProjectRoot.getSelection() )
showAllProjects.setSelection(false);
}
-
+
public void init(IWorkbench workbench) {
}
public void performDefaults() {
automaticBuilder.setSelection(true);
+ showErrorDialog.setSelection(true);
showPackageOutputPath.setSelection(true);
showFullFilesetRootDir.setSelection(true);
showProjectRoot.setSelection(true);
@@ -178,6 +183,7 @@
getPrefManager().setProjectSpecificPrefsEnabled(getResourceLocationIfExists(), overrideButton.getSelection());
}
getPrefManager().setBuilderEnabled(getResourceLocationIfExists(), automaticBuilder.getSelection());
+ PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_BUILD_ERROR_DIALOG, showErrorDialog.getSelection(), getElement());
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_PACKAGE_OUTPUT_PATH, showPackageOutputPath.getSelection(), getElement());
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_FULL_FILESET_ROOT_DIR, showFullFilesetRootDir.getSelection(), getElement());
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT, showProjectRoot.getSelection(), getElement());
Modified: trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java
===================================================================
--- trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -46,9 +46,9 @@
import org.osgi.framework.Bundle;
/**
- * This class will test the individual portions
+ * This class will test the individual portions
* of the build process.
- *
+ *
* @author rob.stryker <rob.stryker(a)redhat.com>
*/
public class ModelTruezipBridgeTest extends ModelTest {
@@ -106,7 +106,7 @@
ModelTruezipBridge.createFile(explodedInExploded);
File eIeF = PathUtils.getGlobalLocation(exploded).append("exploded.war").append("explodedInExploded.jar").toFile();
assertTrue(eIeF.exists());
-
+
// zip inside exploded
IArchive ZipInExploded = createArchive("zipInExploded.jar", "");
ZipInExploded.setExploded(false);
@@ -127,7 +127,7 @@
} catch( AssertionFailedError re ) {
System.out.println("gah");
}
-
+
// zip inside zip
IArchive zipInZip = createArchive("zipInZip.jar", "");
zipInZip.setExploded(false);
@@ -135,7 +135,7 @@
ModelTruezipBridge.createFile(zipInZip);
assertEquals(2, countEntries(zipF));
}
-
+
public void testCreateFileInWorkspace() {
IArchive zipped = createArchive("zipped.war", new Path(proj.getName()).append("outputs").makeAbsolute().toString());
zipped.setInWorkspace(true);
@@ -144,15 +144,15 @@
File zippedF = proj.getLocation().append("outputs").append("zipped.war").toFile();
assertTrue(zippedF.exists());
assertTrue(!zippedF.isDirectory());
-
+
// inner child; zip inside zip
IArchive zipInZip = createArchive("zipInZip.jar", "");
zipInZip.setExploded(false);
zipped.addChild(zipInZip);
ModelTruezipBridge.createFile(zipInZip);
assertEquals(1, countEntries(zippedF));
- }
-
+ }
+
public void testNoSync() {
// zipped
IArchive zipped = createArchive("zipped.war", outputs.toString());
@@ -162,14 +162,14 @@
File zipF = outputs.append("zipped.war").toFile();
assertTrue(zipF.exists());
assertFalse(zipF.isDirectory());
-
+
// zip inside zip
IArchive zipInZip = createArchive("zipInZip.jar", "");
zipInZip.setExploded(false);
zipped.addChild(zipInZip);
ModelTruezipBridge.createFile(zipInZip);
assertEquals(1, countEntries(zipF));
-
+
// zip inside zip2
IArchive zipInZip2 = createArchive("zipInZip2.jar", "");
zipInZip.setExploded(false);
@@ -179,8 +179,8 @@
TrueZipUtil.umount();
assertEquals(2, countEntries(zipF));
}
-
-
+
+
public void testDeleteArchive() {
IArchive zipped = createArchive("zipped.war", new Path(proj.getName()).append("outputs").makeAbsolute().toString());
zipped.setInWorkspace(true);
@@ -189,7 +189,7 @@
File zippedF = proj.getLocation().append("outputs").append("zipped.war").toFile();
assertTrue(zippedF.exists());
assertTrue(!zippedF.isDirectory());
-
+
// inner child; zip inside zip
IArchive zipInZip = createArchive("zipInZip.jar", "");
zipInZip.setExploded(false);
@@ -206,12 +206,12 @@
ModelTruezipBridge.deleteArchive(zipInZip2);
assertEquals(1, countEntries(zippedF));
-
+
ModelTruezipBridge.deleteArchive(zipped);
assertFalse(zippedF.exists());
}
-
-
+
+
/*
* Fileset-related
*/
@@ -227,10 +227,10 @@
IArchiveFileSet fs = createFileSet("**/*.gif", new Path(proj.getName()).makeAbsolute().toString());
fs.setInWorkspace(true);
zipped.addChild(fs);
- ModelTruezipBridge.fullFilesetBuild(fs);
+ ModelTruezipBridge.fullFilesetBuild(fs, true);
assertEquals(19, countEntries(zippedF));
}
-
+
public void testFlattenedFileset() {
IArchive zipped = createArchive("zipped.war", new Path(proj.getName()).append("outputs").makeAbsolute().toString());
zipped.setInWorkspace(true);
@@ -244,17 +244,17 @@
fs.setInWorkspace(true);
fs.setFlattened(true);
zipped.addChild(fs);
- ModelTruezipBridge.fullFilesetBuild(fs);
-
+ ModelTruezipBridge.fullFilesetBuild(fs, true);
+
// should be two less files and 3 less folders created
assertEquals(14, countEntries(zippedF));
}
-
-
+
+
/*
* Utility
*/
-
+
protected int countEntries(File zipF) {
ZipFile zf = null;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -1,7 +1,7 @@
package org.jboss.ide.eclipse.archives.webtools;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesBuildListener;
+import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesModuleModelListener;
import org.osgi.framework.BundleContext;
/**
@@ -28,7 +28,7 @@
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- ArchivesBuildListener.getInstance();
+ ArchivesModuleModelListener.getInstance();
}
/*
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -1,215 +0,0 @@
-/**
- * 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.webtools.modules;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-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.IArchiveBuildListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
-import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
-import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
-import org.jboss.ide.eclipse.as.core.util.FileUtil;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class ArchivesBuildListener implements IArchiveBuildListener, IArchiveModelListener {
-
- public static ArchivesBuildListener instance;
- public static final String DEPLOY_SERVERS = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployServers";
- public static final String DEPLOY_AFTER_BUILD = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployAfterBuild";
-
- public static ArchivesBuildListener getInstance() {
- if( instance == null ) {
- instance = new ArchivesBuildListener();
- }
- return instance;
- }
-
- public ArchivesBuildListener() {
- ArchivesModel.instance().addBuildListener(this);
- ArchivesModel.instance().addModelListener(this); // ? , ArchivesModel.LIST_FRONT);
- }
-
- public void cleanArchive(IArchive pkg) {
- }
-
-
- public void finishedBuildingArchive(IArchive pkg) {
- if( pkg.isTopLevel() && new Boolean(pkg.getProperty(DEPLOY_AFTER_BUILD)).booleanValue()) {
- publish(pkg);
- }
- }
-
- public void fileRemoved(IArchive topLevelPackage, IArchiveFileSet fileset, IPath filePath) {
- }
- public void fileUpdated(IArchive topLevelPackage, IArchiveFileSet fileset, IPath filePath) {
- }
-
- // If we're supposed to auto-deploy, get on it
- protected static void publish(IArchive pkg) {
- String servers = pkg.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
- publish(pkg, servers, IServer.PUBLISH_INCREMENTAL);
- }
- public static void publish(IArchive pkg, String servers, int publishType) {
- IModule[] module = getModule(pkg);
- if( module[0] == null ) return;
- DeployableServerBehavior[] serverBehaviors = ArchivesBuildListener.getServers(servers);
- if( serverBehaviors != null ) {
- for( int i = 0; i < serverBehaviors.length; i++ ) {
- publish(serverBehaviors[i].getServer(), publishType, module );
- }
- }
- }
-
- protected static IStatus publish(IServer server, int publishType, IModule[] module ) {
- try {
- IServerWorkingCopy copy = server.createWorkingCopy();
- copy.modifyModules(module, new IModule[0], new NullProgressMonitor());
- IServer saved = copy.save(false, new NullProgressMonitor());
- saved.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
- } catch( CoreException ce ) {
- return new Status(Status.ERROR, IntegrationPlugin.PLUGIN_ID,
- "Cannot deploy file " + module[0].getName(), ce);
- }
- return Status.OK_STATUS;
-
- }
- protected static IModule[] getModule(IArchive node) {
- ModuleFactory factory = ServerPlugin.findModuleFactory("org.jboss.ide.eclipse.as.core.PackageModuleFactory");
- IModule mod = factory.findModule(PackageModuleFactory.getId(node), new NullProgressMonitor());
- return new IModule[] { mod };
- }
- protected static PackagedModuleDelegate getModuleDelegate(IArchive node) {
- IModule mod = getModule(node)[0];
- return (PackagedModuleDelegate)mod.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
- }
-
- protected IDeployableServer getDeployableServerFromBehavior(DeployableServerBehavior dsb) {
- IServer server = dsb.getServer();
- IDeployableServer ids = (IDeployableServer)server.loadAdapter(IDeployableServer.class, new NullProgressMonitor());
- return ids;
- }
-
- public static DeployableServerBehavior[] getServers(String servers) {
- if( servers == null || "".equals(servers))
- return null;
- ArrayList<DeployableServerBehavior> list = new ArrayList<DeployableServerBehavior>();
- String[] byId = servers.split(",");
- for( int i = 0; i < byId.length; i++ ) {
- IServer server = ServerCore.findServer(byId[i]);
- if( server != null ) {
- Object o = server.loadAdapter(DeployableServerBehavior.class, new NullProgressMonitor());
- if( o != null ) {
- list.add((DeployableServerBehavior)o);
- }
- }
- }
- return list.toArray(new DeployableServerBehavior[list.size()]);
- }
-
- /*
- * If a node is changing from exploded to imploded, or vice versa
- * make sure to delete the pre-existing file or folder on the server.
- */
- public void packageBuildTypeChanged(IArchive topLevelPackage, boolean isExploded) {
- String servers = topLevelPackage.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
- DeployableServerBehavior[] serverBehaviors = ArchivesBuildListener.getServers(servers);
- if( serverBehaviors != null ) {
- IPath sourcePath, destPath;
- IDeployableServer depServer;
- for( int i = 0; i < serverBehaviors.length; i++ ) {
- sourcePath = topLevelPackage.getArchiveFilePath();
- depServer = getDeployableServerFromBehavior(serverBehaviors[i]);
- destPath = new Path(depServer.getDeployDirectory()).append(sourcePath.lastSegment());
- FileUtil.safeDelete(destPath.toFile());
- FileUtil.fileSafeCopy(sourcePath.toFile(), destPath.toFile());
- }
- }
- }
-
- public void buildFailed(IArchive pkg, IStatus status) {
- // TODO Auto-generated method stub
-
- }
-
- public void finishedBuild(IPath project) {
- // TODO Auto-generated method stub
-
- }
-
- public void finishedCollectingFileSet(IArchiveFileSet fileset) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedBuild(IPath project) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedBuildingArchive(IArchive pkg) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedCollectingFileSet(IArchiveFileSet fileset) {
- // TODO Auto-generated method stub
- }
- public void startedBuildingPackage(IArchive pkg) {
- // TODO Auto-generated method stub
- }
-
- public void cleanProject(IPath project) {
- }
-
- public void modelChanged(IArchiveNodeDelta delta) {
- IPath p ;
- if( delta.getPreNode() == null )
- p = delta.getPostNode().getProjectPath();
- else
- p = delta.getPreNode().getProjectPath();
-
- ArchivesModelModuleContributor.getInstance().refreshProject(p);
- }
-
-
-}
Copied: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModuleModelListener.java (from rev 10338, trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java)
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModuleModelListener.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModuleModelListener.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -0,0 +1,167 @@
+/**
+ * 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.webtools.modules;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.ModuleFactory;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.jboss.ide.eclipse.archives.core.model.AbstractBuildListener;
+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.IArchiveModelListener;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public class ArchivesModuleModelListener implements IArchiveModelListener {
+
+ public static ArchivesModuleModelListener instance;
+ public static final String DEPLOY_SERVERS = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployServers";
+ public static final String DEPLOY_AFTER_BUILD = "org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployAfterBuild";
+
+ public static ArchivesModuleModelListener getInstance() {
+ if( instance == null ) {
+ instance = new ArchivesModuleModelListener();
+ }
+ return instance;
+ }
+
+ public ArchivesModuleModelListener() {
+ ArchivesModel.instance().addModelListener(this);
+ }
+
+ public void finishedBuildingArchive(IArchive pkg) {
+ if( pkg.isTopLevel() && new Boolean(pkg.getProperty(DEPLOY_AFTER_BUILD)).booleanValue()) {
+ publish(pkg);
+ }
+ }
+
+ // If we're supposed to auto-deploy, get on it
+ protected static void publish(IArchive pkg) {
+ String servers = pkg.getProperty(ArchivesModuleModelListener.DEPLOY_SERVERS);
+ publish(pkg, servers, IServer.PUBLISH_INCREMENTAL);
+ }
+ public static void publish(IArchive pkg, String servers, int publishType) {
+ IModule[] module = getModule(pkg);
+ if( module[0] == null ) return;
+ DeployableServerBehavior[] serverBehaviors = ArchivesModuleModelListener.getServers(servers);
+ if( serverBehaviors != null ) {
+ for( int i = 0; i < serverBehaviors.length; i++ ) {
+ publish(serverBehaviors[i].getServer(), publishType, module );
+ }
+ }
+ }
+
+ protected static IStatus publish(IServer server, int publishType, IModule[] module ) {
+ try {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(module, new IModule[0], new NullProgressMonitor());
+ IServer saved = copy.save(false, new NullProgressMonitor());
+ saved.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ return new Status(Status.ERROR, IntegrationPlugin.PLUGIN_ID,
+ "Cannot deploy file " + module[0].getName(), ce);
+ }
+ return Status.OK_STATUS;
+
+ }
+ protected static IModule[] getModule(IArchive node) {
+ ModuleFactory factory = ServerPlugin.findModuleFactory("org.jboss.ide.eclipse.as.core.PackageModuleFactory");
+ IModule mod = factory.findModule(PackageModuleFactory.getId(node), new NullProgressMonitor());
+ return new IModule[] { mod };
+ }
+ protected static PackagedModuleDelegate getModuleDelegate(IArchive node) {
+ IModule mod = getModule(node)[0];
+ return (PackagedModuleDelegate)mod.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
+ }
+
+ protected IDeployableServer getDeployableServerFromBehavior(DeployableServerBehavior dsb) {
+ IServer server = dsb.getServer();
+ IDeployableServer ids = (IDeployableServer)server.loadAdapter(IDeployableServer.class, new NullProgressMonitor());
+ return ids;
+ }
+
+ public static DeployableServerBehavior[] getServers(String servers) {
+ if( servers == null || "".equals(servers))
+ return null;
+ ArrayList<DeployableServerBehavior> list = new ArrayList<DeployableServerBehavior>();
+ String[] byId = servers.split(",");
+ for( int i = 0; i < byId.length; i++ ) {
+ IServer server = ServerCore.findServer(byId[i]);
+ if( server != null ) {
+ Object o = server.loadAdapter(DeployableServerBehavior.class, new NullProgressMonitor());
+ if( o != null ) {
+ list.add((DeployableServerBehavior)o);
+ }
+ }
+ }
+ return list.toArray(new DeployableServerBehavior[list.size()]);
+ }
+
+ /*
+ * If a node is changing from exploded to imploded, or vice versa
+ * make sure to delete the pre-existing file or folder on the server.
+ */
+ public void packageBuildTypeChanged(IArchive topLevelPackage, boolean isExploded) {
+ String servers = topLevelPackage.getProperty(ArchivesModuleModelListener.DEPLOY_SERVERS);
+ DeployableServerBehavior[] serverBehaviors = ArchivesModuleModelListener.getServers(servers);
+ if( serverBehaviors != null ) {
+ IPath sourcePath, destPath;
+ IDeployableServer depServer;
+ for( int i = 0; i < serverBehaviors.length; i++ ) {
+ sourcePath = topLevelPackage.getArchiveFilePath();
+ depServer = getDeployableServerFromBehavior(serverBehaviors[i]);
+ destPath = new Path(depServer.getDeployDirectory()).append(sourcePath.lastSegment());
+ FileUtil.safeDelete(destPath.toFile());
+ FileUtil.fileSafeCopy(sourcePath.toFile(), destPath.toFile());
+ }
+ }
+ }
+
+ public void modelChanged(IArchiveNodeDelta delta) {
+ IPath p ;
+ if( delta.getPreNode() == null )
+ p = delta.getPostNode().getProjectPath();
+ else
+ p = delta.getPreNode().getProjectPath();
+
+ ArchivesModelModuleContributor.getInstance().refreshProject(p);
+ }
+}
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModuleModelListener.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mergeinfo
+
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/ArchivePublishWizard.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -27,7 +27,7 @@
import org.eclipse.wst.server.ui.internal.ImageResource;
import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesBuildListener;
+import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesModuleModelListener;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -41,8 +41,8 @@
}
public boolean performFinish() {
boolean alwaysPublish = new Boolean(page.getAlwaysPublish()).booleanValue();
- pack.setProperty(ArchivesBuildListener.DEPLOY_SERVERS, alwaysPublish ? getServers() : null);
- pack.setProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD, getAutoDeploy());
+ pack.setProperty(ArchivesModuleModelListener.DEPLOY_SERVERS, alwaysPublish ? getServers() : null);
+ pack.setProperty(ArchivesModuleModelListener.DEPLOY_AFTER_BUILD, getAutoDeploy());
final IPath p = pack.getProjectPath();
new SaveArchivesJob(p).schedule();
return true;
@@ -91,9 +91,9 @@
}
protected void setPackageDefaults() {
- String servers = pack.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
+ String servers = pack.getProperty(ArchivesModuleModelListener.DEPLOY_SERVERS);
viewerResult = servers;
- String deployAfterBuild = pack.getProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD);
+ String deployAfterBuild = pack.getProperty(ArchivesModuleModelListener.DEPLOY_AFTER_BUILD);
if( servers != null ) {
alwaysPublish.setSelection(true);
alwaysPublishSelected();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java 2008-09-18 22:44:18 UTC (rev 10368)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/PublishAction.java 2008-09-19 00:38:23 UTC (rev 10369)
@@ -33,7 +33,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.ui.actions.INodeActionDelegate;
-import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesBuildListener;
+import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesModuleModelListener;
public class PublishAction implements INodeActionDelegate {
@@ -45,7 +45,7 @@
if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE
&& ((IArchive)node).isTopLevel()) {
final IArchive pkg = (IArchive)node;
- String servers = node.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
+ String servers = node.getProperty(ArchivesModuleModelListener.DEPLOY_SERVERS);
if( servers == null || "".equals(servers) || anyServerDoesntExist(servers)){
servers = showSelectServersDialog(pkg);
}
@@ -53,7 +53,7 @@
if( servers != null ) {
Job j = new Job("Build Archive") {
protected IStatus run(IProgressMonitor monitor) {
- ArchivesBuildListener.publish(pkg, servers2, IServer.PUBLISH_FULL);
+ ArchivesModuleModelListener.publish(pkg, servers2, IServer.PUBLISH_FULL);
return Status.OK_STATUS;
} };
j.schedule();
15 years, 9 months
JBoss Tools SVN: r10368 - trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-09-18 18:44:18 -0400 (Thu, 18 Sep 2008)
New Revision: 10368
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java
Log:
JBIDE-2792 Add runtime support for portal
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java 2008-09-18 22:44:11 UTC (rev 10367)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java 2008-09-18 22:44:18 UTC (rev 10368)
@@ -1,15 +1,23 @@
package org.jboss.tools.portlet.ui.internal.project.facet;
+import java.io.File;
+import java.io.FilenameFilter;
-
import org.eclipse.jface.dialogs.IDialogSettings;
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.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper;
import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
import org.jboss.tools.portlet.core.IPortletConstants;
import org.jboss.tools.portlet.ui.PortletUIActivator;
@@ -22,50 +30,163 @@
private IDialogSettings dialogSettings;
private IDataModel model;
private IDialogSettings jsfSection;
+ private boolean deployJars;
+ private String portletbridgeRuntime;
+ private Text folderText;
+ private DataModelSynchHelper synchHelper;
+ private Button folderButton;
+ private Button deployButton;
public JSFPortletFacetInstallPage() {
super("JSFPortletProjectConfigurationWizardPage");
setTitle("JBoss JSF Portlet Capabilities");
setDescription("Add JBoss JSF Portlet capabilities to this Web Project");
- //ImageDescriptor imageDesc = getDefaultPageImageDescriptor( );
- //if ( imageDesc != null )
- // setImageDescriptor( imageDesc );
+ // ImageDescriptor imageDesc = getDefaultPageImageDescriptor( );
+ // if ( imageDesc != null )
+ // setImageDescriptor( imageDesc );
dialogSettings = PortletUIActivator.getDefault().getDialogSettings();
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(1,false));
-
- final Button btn = new Button(composite,SWT.CHECK);
- btn.setText("Deploy jars to WEB-INF/lib");
jsfSection = dialogSettings.getSection(IPortletConstants.JSF_SECTION);
- boolean deployJars;
if (jsfSection == null) {
- jsfSection = dialogSettings.addNewSection(IPortletConstants.JSF_SECTION);
+ jsfSection = dialogSettings
+ .addNewSection(IPortletConstants.JSF_SECTION);
deployJars = true;
+ portletbridgeRuntime = "";
+ jsfSection.put(IPortletConstants.PORTLET_BRIDGE_RUNTIME,
+ portletbridgeRuntime);
} else {
deployJars = jsfSection.getBoolean(IPortletConstants.DEPLOY_JARS);
+ portletbridgeRuntime = jsfSection
+ .get(IPortletConstants.PORTLET_BRIDGE_RUNTIME);
+ if (portletbridgeRuntime == null) {
+ portletbridgeRuntime = "";
+ jsfSection.put(IPortletConstants.PORTLET_BRIDGE_RUNTIME,
+ portletbridgeRuntime);
+ }
}
- btn.setSelection(deployJars);
- jsfSection.put(IPortletConstants.DEPLOY_JARS, btn.getSelection());
- btn.addSelectionListener(new SelectionAdapter() {
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(3, false));
+ synchHelper = new DataModelSynchHelper(model);
+ addFolderGroup(composite);
+ // createButton(composite);
+ setControl(composite);
+ }
+
+ private void createButton(Composite composite) {
+ deployButton = new Button(composite, SWT.CHECK);
+ deployButton.setText("Deploy jars to WEB-INF/lib");
+ deployButton.setSelection(deployJars);
+ deployButton.addSelectionListener(new SelectionAdapter() {
+
@Override
public void widgetSelected(SelectionEvent e) {
- model.setBooleanProperty(IPortletConstants.DEPLOY_JARS, btn.getSelection());
- jsfSection.put(IPortletConstants.DEPLOY_JARS, btn.getSelection());
+ model.setBooleanProperty(IPortletConstants.DEPLOY_JARS,
+ deployButton.getSelection());
}
-
+
});
- setControl( composite );
}
public void setConfig(Object config) {
this.model = (IDataModel) config;
}
-
+ private void addFolderGroup(Composite composite) {
+ // folder
+ Label folderLabel = new Label(composite, SWT.LEFT);
+ folderLabel.setText("Portletbridge Runtime");
+ folderLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ folderText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ folderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(folderText,
+ IPortletConstants.PORTLET_BRIDGE_RUNTIME, null);
+
+ folderText.setText(portletbridgeRuntime);
+ folderText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validatePortletBridge();
+ }
+
+ });
+
+ folderButton = new Button(composite, SWT.PUSH);
+ folderButton.setText("Browse...");
+ folderButton
+ .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ folderButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleFolderButtonPressed();
+ }
+
+ });
+ validatePortletBridge();
+ }
+
+ private void validatePortletBridge() {
+ String folderString = folderText.getText();
+ folderString = folderString.trim();
+ if (folderString.length() <= 0) {
+ setErrorMessage("Portletbridge Runtime directory is required.");
+ setPageComplete(false);
+ return;
+ }
+ File folder = new File(folderString);
+ if (!folder.exists() || !folder.isDirectory()) {
+ setInvalidPortletbridgeRuntime();
+ return;
+ }
+ String[] fileList = folder.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ if (name.startsWith("portletbridge") || name.endsWith(".jar")) {
+ return true;
+ }
+ return false;
+ }
+
+ });
+ if (fileList.length < 2) {
+ setInvalidPortletbridgeRuntime();
+ return;
+ }
+ portletbridgeRuntime = folderText.getText();
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+
+ private void setInvalidPortletbridgeRuntime() {
+ setErrorMessage("Invalid Portletbridge Runtime directory.");
+ setPageComplete(false);
+ }
+
+ protected void handleFolderButtonPressed() {
+ String lastPath = folderText.getText();
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.MULTI);
+ dialog.setText("Select Portletbridge Runtime");
+ dialog.setFilterPath(lastPath);
+ String res = dialog.open();
+ if (res == null) {
+ return;
+ }
+ String newPath = dialog.getFilterPath();
+ folderText.setText(newPath);
+ }
+
+ @Override
+ public void transferStateToConfig() {
+ super.transferStateToConfig();
+ if (deployButton != null) {
+ jsfSection.put(IPortletConstants.DEPLOY_JARS, deployButton
+ .getSelection());
+ }
+ jsfSection.put(IPortletConstants.PORTLET_BRIDGE_RUNTIME,
+ portletbridgeRuntime);
+ }
+
}
15 years, 9 months
JBoss Tools SVN: r10367 - in trunk/portlet/plugins/org.jboss.tools.portlet.core: resources and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-09-18 18:44:11 -0400 (Thu, 18 Sep 2008)
New Revision: 10367
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java
Removed:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/portlet/1.0/
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java
Log:
JBIDE-2792 Add runtime support for portal
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-09-18 21:36:00 UTC (rev 10366)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-09-18 22:44:11 UTC (rev 10367)
@@ -254,4 +254,9 @@
</catalogContribution>
</extension>
+
+ <extension point="org.eclipse.wst.common.project.facet.core.listeners">
+ <listener class="org.jboss.tools.portlet.core.internal.project.facet.PortletPostInstallListener"
+ eventTypes="POST_INSTALL"/>
+ </extension>
</plugin>
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-09-18 21:36:00 UTC (rev 10366)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-09-18 22:44:11 UTC (rev 10367)
@@ -46,6 +46,8 @@
static final String JBOSS_APP_FILE = "WEB-INF/jboss-app.xml";
static final String DEPLOY_JARS = "DEPLOY_JARS";
+
+ static final String PORTLET_BRIDGE_RUNTIME = "PORTLET_BRIDGE_RUNTIME";
static final String JSF_SECTION = "jsfSection";
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java 2008-09-18 21:36:00 UTC (rev 10366)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java 2008-09-18 22:44:11 UTC (rev 10367)
@@ -24,7 +24,7 @@
AbstractClasspathContainerInitializer {
public String getDescription(IPath containerPath, IJavaProject project) {
- return "JBoss Portlet Classpath Container Initializer v2.0";
+ return "JBoss Portlet Classpath Container Initializer";
}
@Override
@@ -39,7 +39,7 @@
private class Portlet10ClasspathContainer extends BasePortletClasspathContainer {
- public final static String DESCRIPTION = "JBoss Portlet Libraries v2.0";
+ public final static String DESCRIPTION = "JBoss Portlet Library";
public Portlet10ClasspathContainer(IPath path) {
super(path, DESCRIPTION, SUFFIX);
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java 2008-09-18 21:36:00 UTC (rev 10366)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java 2008-09-18 22:44:11 UTC (rev 10367)
@@ -30,6 +30,9 @@
if (propertyName.equals(IPortletConstants.DEPLOY_JARS)) {
return Boolean.TRUE;
}
+ if (propertyName.equals(IPortletConstants.PORTLET_BRIDGE_RUNTIME)) {
+ return "";
+ }
return super.getDefaultProperty(propertyName);
}
@@ -37,6 +40,7 @@
public Set<String> getPropertyNames() {
Set<String> propertyNames = super.getPropertyNames();
propertyNames.add(IPortletConstants.DEPLOY_JARS);
+ propertyNames.add(IPortletConstants.PORTLET_BRIDGE_RUNTIME);
return propertyNames;
}
}
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java 2008-09-18 21:36:00 UTC (rev 10366)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java 2008-09-18 22:44:11 UTC (rev 10367)
@@ -11,7 +11,9 @@
package org.jboss.tools.portlet.core.internal.project.facet;
import java.io.File;
+import java.io.FilenameFilter;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -278,26 +280,45 @@
.getBooleanProperty(IPortletConstants.DEPLOY_JARS);
if (deployJars) {
try {
- URL installURL = FileLocator.toFileURL(PortletCoreActivator
- .getDefault().getBundle().getEntry("/"));
- String baseDir = installURL.getFile().toString();
- File libDir = new File(baseDir + "/"
- + PortletCoreActivator.RESOURCES_FOLDER + "/"
- + PortletCoreActivator.JSFPORTLET_FOLDER);
- List<File> filesToImport = Arrays.asList(libDir.listFiles());
- IVirtualComponent component = ComponentCore
- .createComponent(project);
- IVirtualFile libVirtualFile = component.getRootFolder()
- .getFile(IPortletConstants.WEB_INF_LIB);
+
+ String pbRuntime = config
+ .getStringProperty(IPortletConstants.PORTLET_BRIDGE_RUNTIME);
+ if (pbRuntime != null && pbRuntime.trim().length() > 0) {
+ pbRuntime = pbRuntime.trim();
+ File pbFolder = new File(pbRuntime);
+ if (pbFolder.exists() && pbFolder.isDirectory()) {
+ String[] fileList = pbFolder.list(new FilenameFilter() {
- IFile folder = libVirtualFile.getUnderlyingFile();
+ public boolean accept(File dir, String name) {
+ if (name.startsWith("portletbridge") || name.endsWith(".jar")) {
+ return true;
+ }
+ return false;
+ }
- ImportOperation importOperation = new ImportOperation(folder
- .getFullPath(), libDir,
- FileSystemStructureProvider.INSTANCE,
- PortletCoreActivator.OVERWRITE_ALL_QUERY, filesToImport);
- importOperation.setCreateContainerStructure(false);
- importOperation.run(monitor);
+ });
+
+ List<File> filesToImport = new ArrayList<File>();
+
+ for (int i = 0; i < fileList.length; i++) {
+ filesToImport.add(new File(pbRuntime,fileList[i]));
+ }
+ IVirtualComponent component = ComponentCore
+ .createComponent(project);
+ IVirtualFile libVirtualFile = component.getRootFolder()
+ .getFile(IPortletConstants.WEB_INF_LIB);
+
+ IFile folder = libVirtualFile.getUnderlyingFile();
+
+ ImportOperation importOperation = new ImportOperation(
+ folder.getFullPath(), pbFolder,
+ FileSystemStructureProvider.INSTANCE,
+ PortletCoreActivator.OVERWRITE_ALL_QUERY,
+ filesToImport);
+ importOperation.setCreateContainerStructure(false);
+ importOperation.run(monitor);
+ }
+ }
} catch (Exception e) {
PortletCoreActivator
.log(e, "Error loading classpath container");
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java 2008-09-18 21:36:00 UTC (rev 10366)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java 2008-09-18 22:44:11 UTC (rev 10367)
@@ -77,11 +77,11 @@
IJavaProject javaProject = JavaCore.create(project);
IPath containerPath = null;
- if (IPortletConstants.PORTLET_FACET_VERSION_10.equals(fv.getVersionString())) {
+ //if (IPortletConstants.PORTLET_FACET_VERSION_10.equals(fv.getVersionString())) {
containerPath = new Path(IPortletConstants.PORTLET_CONTAINER_10_ID);
- } else {
+ //} else {
containerPath = new Path(IPortletConstants.PORTLET_CONTAINER_20_ID);
- }
+ //}
IClasspathEntry entry = JavaCore.newContainerEntry(containerPath, true);
IClasspathEntry[] entries = javaProject.getRawClasspath();
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java 2008-09-18 22:44:11 UTC (rev 10367)
@@ -0,0 +1,154 @@
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+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.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+public class PortletPostInstallListener implements IFacetedProjectListener {
+
+ private static final String SEAM_FACET_ID = "jst.seam";
+ private static final IOverwriteQuery OVERWRITE_NONE_QUERY = new IOverwriteQuery()
+ {
+ public String queryOverwrite(String pathString)
+ {
+ return IOverwriteQuery.NO_ALL;
+ }
+ };
+ private String portletbridgeRuntime;
+
+ public void handleEvent(IFacetedProjectEvent event) {
+ IFacetedProject facetedProject = event.getProject();
+ Set<IProjectFacetVersion> projectFacets = facetedProject
+ .getProjectFacets();
+ boolean isJSFPortlet = false;
+ boolean isSeamProject = false;
+ for (IProjectFacetVersion projectFacetVersion : projectFacets) {
+ IProjectFacet projectFacet = projectFacetVersion.getProjectFacet();
+ if (IPortletConstants.JSFPORTLET_FACET_ID.equals(projectFacet
+ .getId())) {
+ isJSFPortlet = true;
+ }
+ if (SEAM_FACET_ID.equals(projectFacet.getId())) {
+ isSeamProject = true;
+ }
+
+ }
+ if (!isJSFPortlet)
+ return;
+
+ if (isJSFPortlet) {
+ IProjectFacetActionEvent actionEvent = (IProjectFacetActionEvent) event;
+ IDataModel dataModel = (IDataModel) actionEvent.getActionConfig();
+ try {
+ portletbridgeRuntime = dataModel
+ .getStringProperty(IPortletConstants.PORTLET_BRIDGE_RUNTIME);
+ if (portletbridgeRuntime == null) {
+ PortletCoreActivator.log(null, "Invalid Portletbridge Runtime.");
+ return;
+ }
+ } catch (Exception e) {
+ //PortletCoreActivator.log(e);
+ }
+ }
+
+ if (isJSFPortlet) {
+ File portletbridgeHome = new File(portletbridgeRuntime);
+ if (!portletbridgeHome.exists()) {
+ PortletCoreActivator.log(null, "Cannot find Portletbridge Runtime.");
+ return;
+ }
+ if (!portletbridgeHome.isDirectory()) {
+ PortletCoreActivator.log(null, "Invalid Portletbridge Runtime.");
+ return;
+ }
+ File examplesHome = new File(portletbridgeHome,"examples");
+ if (!examplesHome.exists() || !examplesHome.isDirectory()) {
+ PortletCoreActivator.log(null, "Cannot find the examples directory.");
+ return;
+ }
+ File richFacesPortletZip = new File(examplesHome,"RichFacesPortlet.war");
+ if (!richFacesPortletZip.exists() || !richFacesPortletZip.isFile()) {
+ PortletCoreActivator.log(null, "Cannot find the RichFacesPortlet.war file.");
+ return;
+ }
+ try {
+ ZipFile zipFile = new ZipFile(richFacesPortletZip);
+ ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(
+ zipFile );
+ List<ZipEntry> list = prepareList(zipFile, isSeamProject);
+
+ IProject project = facetedProject.getProject();
+ IVirtualComponent component = ComponentCore
+ .createComponent(project);
+ //IVirtualFile libVirtualFile = component.getRootFolder()
+ // .getFile(IPortletConstants.WEB_INF_LIB);
+
+ IVirtualFolder rootFolder = component.getRootFolder();
+ IContainer folder = rootFolder.getUnderlyingFolder();
+ IPath destPath = folder.getFullPath();
+
+ ImportOperation op = new ImportOperation( destPath,
+ structureProvider.getRoot( ), structureProvider, OVERWRITE_NONE_QUERY,
+ list );
+ op.run(new NullProgressMonitor() );
+ } catch (Exception e) {
+ PortletCoreActivator.log(e);
+ }
+
+ }
+ }
+
+ private List<ZipEntry> prepareList(ZipFile zipFile, boolean isSeamProject) {
+ if (zipFile == null) {
+ return null;
+ }
+ List<ZipEntry> list = new ArrayList<ZipEntry>();
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ ZipEntry entry = entries.nextElement();
+ if (entry.getName().endsWith(".jar")) {
+ if (entry.getName().startsWith("WEB-INF/lib/richfaces")) {
+ list.add(entry);
+ }
+ if (!isSeamProject) {
+ if (entry.getName().startsWith(
+ "WEB-INF/lib/commons-beanutils")
+ || entry.getName().startsWith(
+ "WEB-INF/lib/commons-digester")
+ || entry.getName().startsWith(
+ "WEB-INF/lib/jsf-facelets")) {
+ list.add(entry);
+ }
+ }
+ }
+ }
+ return list;
+ }
+
+}
15 years, 9 months
JBoss Tools SVN: r10366 - trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-09-18 17:36:00 -0400 (Thu, 18 Sep 2008)
New Revision: 10366
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2785 fixed
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java 2008-09-18 19:27:04 UTC (rev 10365)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java 2008-09-18 21:36:00 UTC (rev 10366)
@@ -28,7 +28,6 @@
import org.eclipse.wst.common.componentcore.internal.StructureEdit;
import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -173,7 +172,7 @@
ComponentResource[] resources = module.findResourcesBySourcePath(
new Path("/"), 0);
IPath projectPath = project.getLocation();
- IResource member = null;
+ IFile member = null;
for (int i = 0; resources != null && i < resources.length; i++) {
IPath runtimePath = resources[i].getRuntimePath();
@@ -184,10 +183,9 @@
IPath relativePath = Utils.getRelativePath(webRootPath,
basePath);
IPath filePath = relativePath.append(path);
- member = project.getFolder(sourcePath).findMember(filePath);
- if (member != null && (member instanceof IFile)) {
- if (((IFile) member).exists())
- return (IFile) member;
+ member = project.getFolder(sourcePath).getFile(filePath);
+ if (member.exists()) {
+ return member;
}
// Look in runtime environment
@@ -195,10 +193,9 @@
webRootPath = projectPath.append(runtimePath);
relativePath = Utils.getRelativePath(webRootPath, basePath);
filePath = relativePath.append(path);
- member = project.getFolder(runtimePath).findMember(filePath);
- if (member != null && (member instanceof IFile)) {
- if (((IFile) member).exists())
- return (IFile) member;
+ member = project.getFolder(runtimePath).getFile(filePath);
+ if (member.exists()) {
+ return member;
}
}
}
@@ -209,26 +206,24 @@
WorkbenchComponent module, String path) {
ComponentResource[] resources = module.findResourcesBySourcePath(
new Path("/"), 0);
-// IPath projectPath = project.getLocation();
- IResource member = null;
+ IFile member = null;
+
for (int i = 0; resources != null && i < resources.length; i++) {
IPath runtimePath = resources[i].getRuntimePath();
IPath sourcePath = resources[i].getSourcePath();
// Look in source environment
- member = project.getFolder(sourcePath).findMember(path);
- if (member != null) {
- if (((IFile) member).exists())
- return (IFile) member;
- }
+ member = project.getFolder(sourcePath).getFile(path);
+ if(member.exists()) {
+ return member;
+ }
// Look in runtime environment
if (runtimePath.segmentCount() >= ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH - 1) {
- member = project.getFolder(runtimePath).findMember(path);
- if (member != null) {
- if (((IFile) member).exists())
- return (IFile) member;
+ member = project.getFolder(runtimePath).getFile(path);
+ if (member.exists()) {
+ return member;
}
}
}
15 years, 9 months
JBoss Tools SVN: r10365 - in trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4: editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2008-09-18 15:27:04 -0400 (Thu, 18 Sep 2008)
New Revision: 10365
Removed:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editpart/
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java
Log:
get rid of unnecessary editparts and - factory
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java 2008-09-18 17:25:53 UTC (rev 10364)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlEditor.java 2008-09-18 19:27:04 UTC (rev 10365)
@@ -13,7 +13,6 @@
public class JpdlEditor extends GenericModelEditor {
protected EditPartFactory createEditPartFactory() {
-// return new JpdlEditPartFactory();
return new DefaultEditPartFactory();
}
@@ -30,7 +29,6 @@
}
protected void createModel(InputStream is) {
- // TODO
setModel(createModel());
}
}
15 years, 9 months
JBoss Tools SVN: r10364 - in trunk: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-09-18 13:25:53 -0400 (Thu, 18 Sep 2008)
New Revision: 10364
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesTableProvider.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeEditAnyDialog.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/editor/template/VpeTemplateManagerTest.java
Log:
JBIDE-2521
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2008-09-18 17:25:53 UTC (rev 10364)
@@ -14,7 +14,8 @@
org.jboss.tools.jst.jsp.editor,
org.jboss.tools.jst.jsp.jspeditor,
org.jboss.tools.jst.jsp.outline,
- org.jboss.tools.jst.jsp.outline.cssdialog.common,
+ org.jboss.tools.jst.jsp.outline.cssdialog,
+ org.jboss.tools.jst.jsp.outline.common,
org.jboss.tools.jst.jsp.preferences,
org.jboss.tools.jst.jsp.support.kb,
org.jboss.tools.jst.jsp.text,
@@ -59,5 +60,6 @@
org.eclipse.core.runtime,
org.eclipse.ui.views
Bundle-Version: 2.0.0
-Export-Package: org.jboss.tools.jst.jsp.outline.cssdialog.parsers
+Export-Package: org.jboss.tools.jst.jsp.outline.cssdialog.common,
+ org.jboss.tools.jst.jsp.outline.cssdialog.parsers
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesTableProvider.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesTableProvider.java 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesTableProvider.java 2008-09-18 17:25:53 UTC (rev 10364)
@@ -48,8 +48,6 @@
return data.getTagForDisplay();
case 2:
return data.getName();
- case 3:
- return data.getDisplay();
case 4:
if(data.isChildren()) return "yes";
else return "no";
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyCreator.java 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyCreator.java 2008-09-18 17:25:53 UTC (rev 10364)
@@ -14,7 +14,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.expression.VpeExpression;
@@ -22,7 +21,6 @@
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilderException;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionInfo;
-import org.jboss.tools.vpe.editor.template.expression.VpeValue;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -31,43 +29,35 @@
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-
+/**
+ * Creator for any attribute
+ * @author mareshkau
+ *
+ */
public class VpeAnyCreator extends VpeAbstractCreator {
- static final String CLASS_TAG_BLOCK = "__any__tag__block";
- static final String CLASS_TAG_INLINE = "__any__tag__inline";
- static final String CLASS_TAG_NONE = "__any__tag__none";
- static final String CLASS_TAG_CAPTION = "__any__tag__caption";
+
+ private static final String DEFAULT_TAG_FOR_DISPLAY=HTML.TAG_DIV;
+
+ static final String CLASS_TAG_BLOCK = "__any__tag__block"; //$NON-NLS-1$
+ static final String CLASS_TAG_INLINE = "__any__tag__inline"; //$NON-NLS-1$
+ static final String CLASS_TAG_NONE = "__any__tag__none"; //$NON-NLS-1$
+ static final String CLASS_TAG_CAPTION = "__any__tag__caption"; //$NON-NLS-1$
- static final String VAL_DISPLAY_BLOCK = "block";
- static final String VAL_DISPLAY_INLINE = "inline";
- static final String VAL_DISPLAY_NONE = "none";
- private boolean caseSensitive;
- private VpeExpression tagForDisplayExpr;
- private VpeExpression displayExpr;
private VpeExpression valueExpr;
- private VpeExpression borderExpr;
- private VpeExpression valueColorExpr;
- private VpeExpression valueBackgroundColorExpr;
- private VpeExpression backgroundColorExpr;
- private VpeExpression borderColorExpr;
- private VpeExpression showIconExpr;
-
+ private VpeExpression tagForDisplayExpr;
+ private VpeExpression styleExpr;
+
private List propertyCreators;
private Set dependencySet;
private String tagForDisplayStr;
- private String displayStr;
private String valueStr;
- private String borderStr;
- private String valueColorStr;
- private String valueBackgroundColorStr;
- private String backgroundColorStr;
- private String borderColorStr;
+ private String styleStr;
private boolean showIconBool;
+ private boolean children;
VpeAnyCreator(Element element, VpeDependencyMap dependencyMap, boolean caseSensitive) {
- this.caseSensitive = caseSensitive;
build(element, dependencyMap);
}
@@ -76,33 +66,31 @@
if (tagForDisplay != null) {
try {
tagForDisplayStr = tagForDisplay.getNodeValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(tagForDisplayStr,caseSensitive);
+ VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(tagForDisplayStr,true);
tagForDisplayExpr = info.getExpression();
- dependencySet = info.getDependencySet();
dependencyMap.setCreator(this, info.getDependencySet());
} catch(VpeExpressionBuilderException ex) {
VpePlugin.reportProblem(ex);
}
}
- Attr displayAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_DISPLAY);
- if (displayAttr != null) {
+ Attr styleAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_STYLE);
+ if (styleAttr!=null) {
try {
- displayStr = displayAttr.getValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(displayStr, caseSensitive);
- displayExpr = info.getExpression();
- dependencySet = info.getDependencySet();
+ styleStr = styleAttr.getValue();
+ VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(styleStr, true);
+ styleExpr = info.getExpression();
dependencyMap.setCreator(this, info.getDependencySet());
} catch(VpeExpressionBuilderException e) {
VpePlugin.reportProblem(e);
}
}
-
+
Attr valueAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_VALUE);
if (valueAttr != null) {
try {
valueStr = valueAttr.getValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(valueStr, caseSensitive);
+ VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(valueStr, true);
valueExpr = info.getExpression();
dependencyMap.setCreator(this, info.getDependencySet());
} catch(VpeExpressionBuilderException e) {
@@ -115,189 +103,134 @@
try {
if("yes".equals(showIconAttr.getValue())) showIconBool = true;
else showIconBool = false;
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(showIconAttr.getValue(), caseSensitive);
- showIconExpr = info.getExpression();
+ VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(showIconAttr.getValue(), true);
dependencyMap.setCreator(this, info.getDependencySet());
} catch(VpeExpressionBuilderException e) {
VpePlugin.reportProblem(e);
}
}
- Attr borderAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_BORDER);
- if (borderAttr != null) {
- try {
- borderStr = borderAttr.getValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(borderStr, caseSensitive);
- borderExpr = info.getExpression();
- dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
- VpePlugin.reportProblem(e);
- }
- }
- Attr valueColorAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_VALUE_COLOR);
- if (valueColorAttr != null) {
- try {
- valueColorStr = valueColorAttr.getValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(valueColorStr, caseSensitive);
- valueColorExpr = info.getExpression();
- dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
- VpePlugin.reportProblem(e);
- }
- }
- Attr valueBackgroundColorAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_VALUE_BACKGROUND_COLOR);
- if (valueBackgroundColorAttr != null) {
- try {
- valueBackgroundColorStr = valueBackgroundColorAttr.getValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(valueBackgroundColorStr, caseSensitive);
- valueBackgroundColorExpr = info.getExpression();
- dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
- VpePlugin.reportProblem(e);
- }
- }
-
- Attr backgroundColorAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_BACKGROUND_COLOR);
- if (backgroundColorAttr != null) {
- try {
- backgroundColorStr = backgroundColorAttr.getValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(backgroundColorStr, caseSensitive);
- backgroundColorExpr = info.getExpression();
- dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
- VpePlugin.reportProblem(e);
- }
- }
-
- Attr borderColorAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ANY_BORDER_COLOR);
- if (borderColorAttr != null) {
- try {
- borderColorStr = borderColorAttr.getValue();
- VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(borderColorStr, caseSensitive);
- borderColorExpr = info.getExpression();
- dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
- VpePlugin.reportProblem(e);
- }
- }
-
if (VpeTemplateManager.ATTR_ANY_PROPERTIES != null) {
for (int i = 0; i < VpeTemplateManager.ATTR_ANY_PROPERTIES.length; i++) {
String attrName = VpeTemplateManager.ATTR_ANY_PROPERTIES[i];
Attr attr = element.getAttributeNode(attrName);
if (attr != null) {
if (propertyCreators == null) propertyCreators = new ArrayList();
- propertyCreators.add(new VpeAttributeCreator(attrName, attr.getValue(), dependencyMap, caseSensitive));
+ propertyCreators.add(new VpeAttributeCreator(attrName, attr.getValue(), dependencyMap, true));
}
}
}
Attr attr = element.getAttributeNode("title");
if (attr == null) {
if (propertyCreators == null) propertyCreators = new ArrayList();
- propertyCreators.add(new VpeAttributeCreator("title", "{tagstring()}", dependencyMap, caseSensitive));
+ propertyCreators.add(new VpeAttributeCreator("title", "{tagstring()}", dependencyMap, true));
}
}
-
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, nsIDOMElement visualElement, Map visualNodeMap) throws VpeExpressionException {
- nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- VpeCreatorInfo creatorInfo = new VpeCreatorInfo(div);
+
+ String tagForDisplay =getExprValue(pageContext, tagForDisplayExpr, sourceNode);
+
+ if(tagForDisplay == null||tagForDisplay.length()==0) {
+ tagForDisplay = DEFAULT_TAG_FOR_DISPLAY;
+ }
+
+ nsIDOMElement anyElement = visualDocument.createElement(tagForDisplay);
+
+ VpeCreatorInfo creatorInfo = new VpeCreatorInfo(anyElement);
- nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
- div.appendChild(span);
if(showIconBool){
nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG);
- img.setAttribute("src","any.gif");
- img.setAttribute("width","16");
- img.setAttribute("height","16");
- span.appendChild(img);
+ img.setAttribute("src","any.gif"); //$NON-NLS-1$//$NON-NLS-2$
+ img.setAttribute("width","16"); //$NON-NLS-1$ //$NON-NLS-2$
+ img.setAttribute("height","16"); //$NON-NLS-1$ //$NON-NLS-2$
+ anyElement.appendChild(img);
}
-
- visualNodeMap.put(this, new VisualElements(div, span));
-
+ anyElement.setAttribute(HTML.ATTR_CLASS, CLASS_TAG_CAPTION);
+
+ String styleString = getExprValue(pageContext, styleExpr, sourceNode);
+
+ anyElement.setAttribute(HTML.ATTR_STYLE, styleString);
+
if (propertyCreators != null) {
for (int i = 0; i < propertyCreators.size(); i++) {
VpeCreator creator = (VpeCreator)propertyCreators.get(i);
if (creator != null) {
- VpeCreatorInfo info = creator.create(pageContext, (Element) sourceNode, visualDocument, div, visualNodeMap);
+ VpeCreatorInfo info = creator.create(pageContext, (Element) sourceNode, visualDocument, anyElement, visualNodeMap);
if (info != null && info.getVisualNode() != null) {
nsIDOMAttr attr = (nsIDOMAttr)info.getVisualNode();
- div.setAttributeNode(attr);
+ anyElement.setAttributeNode(attr);
}
}
}
}
- setStyles(pageContext, sourceNode, div, span);
+// setStyles(pageContext, sourceNode, div, span);
String valueStr = getExprValue(pageContext, valueExpr, sourceNode);
nsIDOMNode valueNode = visualDocument.createTextNode(valueStr);
- span.appendChild(valueNode);
+ anyElement.appendChild(valueNode);
creatorInfo.addDependencySet(dependencySet);
return creatorInfo;
}
- private void setStyles(VpePageContext pageContext, Node sourceNode, nsIDOMElement div, nsIDOMElement span) throws VpeExpressionException {
- boolean display = true;
- boolean displayBlock = true;
+// private void setStyles(VpePageContext pageContext, Node sourceNode, nsIDOMElement div, nsIDOMElement span) throws VpeExpressionException {
+// boolean display = true;
+// boolean displayBlock = true;
+//
+// if (displayExpr != null) {
+// VpeValue vpeValue = displayExpr.exec(pageContext, sourceNode);
+// if (vpeValue != null) {
+// String displayStr = vpeValue.stringValue();
+// if (caseSensitive) {
+// display = !VAL_DISPLAY_NONE.equals(displayStr);
+// displayBlock = display && !VAL_DISPLAY_INLINE.equals(displayStr);
+// } else {
+// display = !VAL_DISPLAY_NONE.equalsIgnoreCase(displayStr);
+// displayBlock = display && !VAL_DISPLAY_INLINE.equalsIgnoreCase(displayStr);
+// }
+// }
+// }
+//
+// if (display) {
+// div.setAttribute("class", displayBlock ? CLASS_TAG_BLOCK : CLASS_TAG_INLINE);
+//
+// String styleStr = "";
+// String borderStr = getExprValue(pageContext, borderExpr, sourceNode);
+//
+// if ("yes".equalsIgnoreCase(VpePreference.SHOW_BORDER_FOR_UNKNOWN_TAGS.getValue())) {
+// styleStr += borderStr.length() > 0 ? "border-width:" + borderStr + ";" : "";
+// } else {
+// styleStr += "border-width:0px;";
+// }
+//
+// String borderColorStr = getExprValue(pageContext, borderColorExpr, sourceNode);
+// styleStr += borderColorStr.length() > 0 ? "border-color:" + borderColorStr + ";" : "";
+// String backgroundColorStr = getExprValue(pageContext, backgroundColorExpr, sourceNode);
+// styleStr += backgroundColorStr.length() > 0 ? "background-color:" + backgroundColorStr : "";
+// if (styleStr.trim().length() > 0) div.setAttribute("style", styleStr);
+// } else {
+// div.setAttribute("class", CLASS_TAG_NONE);
+// }
+//
+// span.setAttribute("class", CLASS_TAG_CAPTION);
+//
+// String styleStr = "";
+// String valueColorStr = getExprValue(pageContext, valueColorExpr, sourceNode);
+// styleStr += valueColorStr.length() > 0 ? "color:" + valueColorStr + ";" : "";
+// String valueBackgroundColorStr = getExprValue(pageContext, valueBackgroundColorExpr, sourceNode);
+// styleStr += valueBackgroundColorStr.length() > 0 ? "background-color:" + valueBackgroundColorStr : "";
+// if (styleStr.trim().length() > 0) span.setAttribute("style", styleStr);
+// }
- if (displayExpr != null) {
- VpeValue vpeValue = displayExpr.exec(pageContext, sourceNode);
- if (vpeValue != null) {
- String displayStr = vpeValue.stringValue();
- if (caseSensitive) {
- display = !VAL_DISPLAY_NONE.equals(displayStr);
- displayBlock = display && !VAL_DISPLAY_INLINE.equals(displayStr);
- } else {
- display = !VAL_DISPLAY_NONE.equalsIgnoreCase(displayStr);
- displayBlock = display && !VAL_DISPLAY_INLINE.equalsIgnoreCase(displayStr);
- }
- }
- }
-
- if (display) {
- div.setAttribute("class", displayBlock ? CLASS_TAG_BLOCK : CLASS_TAG_INLINE);
-
- String styleStr = "";
- String borderStr = getExprValue(pageContext, borderExpr, sourceNode);
-
- if ("yes".equalsIgnoreCase(VpePreference.SHOW_BORDER_FOR_UNKNOWN_TAGS.getValue())) {
- styleStr += borderStr.length() > 0 ? "border-width:" + borderStr + ";" : "";
- } else {
- styleStr += "border-width:0px;";
- }
-
- String borderColorStr = getExprValue(pageContext, borderColorExpr, sourceNode);
- styleStr += borderColorStr.length() > 0 ? "border-color:" + borderColorStr + ";" : "";
- String backgroundColorStr = getExprValue(pageContext, backgroundColorExpr, sourceNode);
- styleStr += backgroundColorStr.length() > 0 ? "background-color:" + backgroundColorStr : "";
- if (styleStr.trim().length() > 0) div.setAttribute("style", styleStr);
- } else {
- div.setAttribute("class", CLASS_TAG_NONE);
- }
-
- span.setAttribute("class", CLASS_TAG_CAPTION);
-
- String styleStr = "";
- String valueColorStr = getExprValue(pageContext, valueColorExpr, sourceNode);
- styleStr += valueColorStr.length() > 0 ? "color:" + valueColorStr + ";" : "";
- String valueBackgroundColorStr = getExprValue(pageContext, valueBackgroundColorExpr, sourceNode);
- styleStr += valueBackgroundColorStr.length() > 0 ? "background-color:" + valueBackgroundColorStr : "";
- if (styleStr.trim().length() > 0) span.setAttribute("style", styleStr);
- }
-
public VpeAnyData getAnyData() {
return new VpeAnyData(
- displayStr,
tagForDisplayStr,
valueStr,
- borderStr,
- valueColorStr,
- valueBackgroundColorStr,
- backgroundColorStr,
- borderColorStr,
+ styleStr,
showIconBool
);
}
@@ -319,39 +252,39 @@
return value;
}
- public void setAttribute(VpePageContext pageContext, Element sourceElement, Map visualNodeMap, String name, String value) {
- Object elements = visualNodeMap.get(this);
- if (elements != null && elements instanceof VisualElements) {
- VisualElements o = (VisualElements)elements;
- try {
- setStyles(pageContext, sourceElement, o.div, o.span);
- } catch (VpeExpressionException e) {
- VpeExpressionException exception = new VpeExpressionException(sourceElement.toString()+" "+name+" "+value,e); //$NON-NLS-1$ //$NON-NLS-2$
- VpePlugin.reportProblem(exception) ;
- }
- }
- }
+// public void setAttribute(VpePageContext pageContext, Element sourceElement, Map visualNodeMap, String name, String value) {
+// Object elements = visualNodeMap.get(this);
+// if (elements != null && elements instanceof VisualElements) {
+// VisualElements o = (VisualElements)elements;
+// try {
+// setStyles(pageContext, sourceElement, o.div, o.span);
+// } catch (VpeExpressionException e) {
+// VpeExpressionException exception = new VpeExpressionException(sourceElement.toString()+" "+name+" "+value,e); //$NON-NLS-1$ //$NON-NLS-2$
+// VpePlugin.reportProblem(exception) ;
+// }
+// }
+// }
- public void removeAttribute(VpePageContext pageContext, Element sourceElement, Map visualNodeMap, String name) {
- Object elements = visualNodeMap.get(this);
- if (elements != null && elements instanceof VisualElements) {
- VisualElements o = (VisualElements)elements;
- try {
- setStyles(pageContext, sourceElement, o.div, o.span);
- } catch (VpeExpressionException e) {
- VpeExpressionException exception = new VpeExpressionException(sourceElement.toString()+" "+name,e); //$NON-NLS-1$
- VpePlugin.reportProblem(exception);
- }
- }
- }
+// public void removeAttribute(VpePageContext pageContext, Element sourceElement, Map visualNodeMap, String name) {
+// Object elements = visualNodeMap.get(this);
+// if (elements != null && elements instanceof VisualElements) {
+// VisualElements o = (VisualElements)elements;
+// try {
+// setStyles(pageContext, sourceElement, o.div, o.span);
+// } catch (VpeExpressionException e) {
+// VpeExpressionException exception = new VpeExpressionException(sourceElement.toString()+" "+name,e); //$NON-NLS-1$
+// VpePlugin.reportProblem(exception);
+// }
+// }
+// }
- private class VisualElements {
- private nsIDOMElement div;
- private nsIDOMElement span;
-
- private VisualElements(nsIDOMElement div, nsIDOMElement span) {
- this.div = div;
- this.span = span;
- }
- }
+// private class VisualElements {
+// private nsIDOMElement div;
+// private nsIDOMElement span;
+//
+// private VisualElements(nsIDOMElement div, nsIDOMElement span) {
+// this.div = div;
+// this.span = span;
+// }
+// }
}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java 2008-09-18 17:25:53 UTC (rev 10364)
@@ -9,73 +9,49 @@
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.vpe.editor.template;
-
+/**
+ * Class which store properties for any template
+ *
+ * @author mareshkau
+ *
+ */
public class VpeAnyData extends VpeTemplateData {
private String uri;
private String tagForDisplay;
private boolean showIcon;
-
- private String display;
private String value;
- private String border;
- private String valueColor;
- private String valueBackgroundColor;
- private String backgroundColor;
- private String borderColor;
+ private String style;
-
public VpeAnyData(String name) {
super(name);
}
-
+/**
+ *
+ * @param tagForDisplay
+ * @param value
+ * @param style
+ * @param showIcon
+ */
public VpeAnyData(
- String display,
- String value,
- String border,
- String valueColor,
- String valueBackgroundColor,
- String backgroundColor,
- String borderColor,
- boolean showIcon
- ) {
- this(display,
- null,
- value,
- border,
- valueColor,
- valueBackgroundColor,
- backgroundColor,
- borderColor,
- showIcon);
- }
- public VpeAnyData(
- String display,
String tagForDisplay,
String value,
- String border,
- String valueColor,
- String valueBackgroundColor,
- String backgroundColor,
- String borderColor,
+ String style,
boolean showIcon
) {
- this.display = display;
this.value = value;
- this.border = border;
- this.valueColor = valueColor;
- this.valueBackgroundColor = valueBackgroundColor;
- this.backgroundColor = backgroundColor;
- this.borderColor = borderColor;
this.showIcon = showIcon;
this.tagForDisplay = tagForDisplay;
+ this.style=style;
}
public String getUri() {
+
return uri;
}
public void setUri(String uri) {
+
this.uri = uri;
}
@@ -87,62 +63,38 @@
showIcon = flag;
}
- public String getBackgroundColor() {
- return backgroundColor;
- }
-
- public void setBackgroundColor(String backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public String getBorder() {
- return border;
- }
-
- public void setBorder(String border) {
- this.border = border;
- }
-
- public String getBorderColor() {
- return borderColor;
- }
-
- public void setBorderColor(String borderColor) {
- this.borderColor = borderColor;
- }
-
- public String getDisplay() {
- return display;
- }
-
- public void setDisplay(String display) {
- this.display = display;
- }
-
public String getValue() {
+
return value;
}
public void setValue(String value) {
+
this.value = value;
}
- public String getValueBackgroundColor() {
- return valueBackgroundColor;
- }
- public void setValueBackgroundColor(String valueBackgroundColor) {
- this.valueBackgroundColor = valueBackgroundColor;
- }
-
- public String getValueColor() {
- return valueColor;
- }
- public void setValueColor(String valueColor) {
- this.valueColor = valueColor;
- }
public String getTagForDisplay() {
- return tagForDisplay;
+
+ return tagForDisplay;
}
+
public void setTagForDisplay(String tagForDisplay) {
- this.tagForDisplay = tagForDisplay;
+
+ this.tagForDisplay = tagForDisplay;
}
+
+ /**
+ * @return the style
+ */
+ public String getStyle() {
+
+ return style;
+ }
+
+ /**
+ * @param style the style to set
+ */
+ public void setStyle(String style) {
+
+ this.style = style;
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeEditAnyDialog.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeEditAnyDialog.java 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeEditAnyDialog.java 2008-09-18 17:25:53 UTC (rev 10364)
@@ -10,85 +10,48 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
-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.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.ColorDialog;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-
import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
-import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
import org.jboss.tools.vpe.messages.VpeUIMessages;
-
+/**
+ * Class which presents dialog for any template
+ * @author mareshkau
+ *
+ */
public class VpeEditAnyDialog extends TitleAreaDialog {
+
private VpeAnyData data;
- private CheckControl ctlCaseSensitive;
private CheckControl ctlChildren;
- private CheckControl ctlModify;
- private Combo cbDisplay;
- private Combo cbTagForDisplay;
- private int displayIndexMem;
- private int tagNameItemIndex;
+ private Text txtTagForDisplay;
private Text txtValue;
- private Text txtBorder;
- private ColorControl ctlValueColor;
- private ColorControl ctlValueBackgroundColor;
- private ColorControl ctlBackgroundColor;
- private ColorControl ctlBorderColor;
+ private Text txtStyle;
private CheckControl ctlShowIcon;
- private static String[] displayItems = new String[3];
-
- private static List<String> displayTags = new ArrayList<String>();
-
- static {
- displayItems[0] = VpeAnyCreator.VAL_DISPLAY_BLOCK;
- displayItems[1] = VpeAnyCreator.VAL_DISPLAY_INLINE;
- displayItems[2] = VpeAnyCreator.VAL_DISPLAY_NONE;
- }
- static{
- displayTags.add(VpeUIMessages.TAG_DIV);
- displayTags.add(VpeUIMessages.TAG_SPAN);
- displayTags.add(VpeUIMessages.TAG_B);
- displayTags.add(VpeUIMessages.TAG_P);
- displayTags.add(VpeUIMessages.TAG_TABLE);
- }
-
-
-
public VpeEditAnyDialog(Shell shell, VpeAnyData data) {
super(shell);
this.data = data;
}
+ @Override
protected Control createDialogArea(Composite parent) {
getShell().setText(VpeUIMessages.TEMPLATE);
setTitle(VpeUIMessages.TAG_ATTRIBUTES);
@@ -97,7 +60,7 @@
Composite topComposite = (Composite)super.createDialogArea(parent);
((GridData)topComposite.getLayoutData()).widthHint = 300;
- Composite composite = new Composite(topComposite, SWT.NONE);
+ final Composite composite = new Composite(topComposite, SWT.NONE);
GridLayout gridLayout = new GridLayout(3, false);
gridLayout.marginWidth = 50;
gridLayout.marginHeight = 20;
@@ -114,37 +77,20 @@
Label tagFDisplayLabel = makeLabel(composite, VpeUIMessages.TAG_FOR_DISPLAY);
tagFDisplayLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- cbTagForDisplay = new Combo(composite,SWT.DROP_DOWN | SWT.READ_ONLY);
+ txtTagForDisplay = new Text(composite,SWT.BORDER);
gd.horizontalSpan=2;
- cbTagForDisplay.setLayoutData(gd);
- cbTagForDisplay.setItems(displayTags.toArray(new String[displayTags.size()]));
- tagNameItemIndex = displayTags.indexOf(data.getTagForDisplay());
- if(tagNameItemIndex==-1) {
- tagNameItemIndex=0;
- }
- cbTagForDisplay.select(tagNameItemIndex);
+ txtTagForDisplay.setLayoutData(gd);
+ txtTagForDisplay.setText(data.getTagForDisplay() != null ? data.getTagForDisplay() : ""); //$NON-NLS-1$
+// txtTagForDisplay.select(tagNameItemIndex);
// ctlCaseSensitive = new CheckControl(composite, "Case sensitive", data.isCaseSensitive());
ctlChildren = new CheckControl(composite, VpeUIMessages.CHILDREN, data.isChildren());
// ctlModify = new CheckControl(composite, "Modify", data.isModify());
-
-
-
- gd = new GridData(GridData.FILL_HORIZONTAL);
- Label lblDisplay = makeLabel(composite, VpeUIMessages.DISPLAY);
- lblDisplay.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- cbDisplay = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- gd.horizontalSpan = 2;
- cbDisplay.setLayoutData(gd);
- cbDisplay.setItems(displayItems);
- displayIndexMem = getDisplayItemIndex(data.getDisplay());
- cbDisplay.select(displayIndexMem);
-
ctlShowIcon = new CheckControl(composite, VpeUIMessages.ICON, data.isShowIcon());
-
+
+ //value control
Label lblValue = makeLabel(composite, VpeUIMessages.VALUE);
lblValue.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
txtValue = new Text(composite, SWT.BORDER);
@@ -153,20 +99,40 @@
txtValue.setLayoutData(gd);
txtValue.setText(data.getValue() != null ? data.getValue() : ""); //$NON-NLS-1$
- ctlValueColor = new ColorControl(composite, VpeUIMessages.VALUE_COLOR, data.getValueColor());
- ctlValueBackgroundColor = new ColorControl(composite, VpeUIMessages.VALUE_BACKGROUND_COLOR, data.getValueBackgroundColor());
- ctlBackgroundColor = new ColorControl(composite, VpeUIMessages.BACKGROUND_COLOR, data.getBackgroundColor());
-
- Label lblBorder = makeLabel(composite, VpeUIMessages.BORDER);
- lblBorder.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- txtBorder = new Text(composite, SWT.BORDER);
+ //style control
+ Label lbStyle = makeLabel(composite, VpeUIMessages.STYLE);
+ lbStyle.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ txtStyle = new Text(composite, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- txtBorder.setLayoutData(gd);
- txtBorder.setText(data.getBorder() != null ? data.getBorder() : ""); //$NON-NLS-1$
+ gd.horizontalSpan = 1;
+ gd.grabExcessHorizontalSpace = true;
+ txtStyle.setLayoutData(gd);
+ txtStyle.setText(data.getStyle() !=null ? data.getStyle() : ""); //$NON-NLS-1$
+
+ Button button = new Button(composite, SWT.PUSH);
+ button.setLayoutData(new GridData());
+ button.setToolTipText(MessageUtil.getString("BACKGROUND_COLOR_TIP")); //$NON-NLS-1$
+ ImageDescriptor colorDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_COLORLARGE_FILE_LOCATION);
+ Image im = colorDesc.createImage();
+ button.setImage(im);
+
+ button.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ CSSDialog cssDialog = new CSSDialog(composite.getShell(),txtStyle.getText());
+ if (cssDialog.open() == Window.OK) {
+ txtStyle.setText(cssDialog.getNewStyle());
+ }
+ }
+ });
- ctlBorderColor = new ColorControl(composite, VpeUIMessages.BORDER_COLOR, data.getBorderColor());
-
return composite;
}
@@ -177,60 +143,24 @@
return lbl;
}
- private int getDisplayItemIndex(String text) {
- int index = 0;
- if (text != null) {
- for (int i = 0; i < displayItems.length; i++) {
- if ((data.isCaseSensitive() && text.equals(displayItems[i])) ||
- (!data.isCaseSensitive() && text.equalsIgnoreCase(displayItems[i]))) {
- index = i;
- break;
- }
- }
- }
- return index;
- }
-
+ @Override
protected void okPressed() {
-// data.setChanged(data.isChanged() || (data.isCaseSensitive() == ctlCaseSensitive.getSelection()));
-// data.setCaseSensitive(ctlCaseSensitive.getSelection());
data.setChanged(data.isChanged() || (data.isChildren() != ctlChildren.getSelection()));
data.setChildren(ctlChildren.getSelection());
-// data.setChanged(data.isChanged() || (data.isModify() == ctlChildren.getSelection()));
-// data.setModify(ctlModify.getSelection());
-
- int index = cbDisplay.getSelectionIndex();
- String display = (index >= 1 && index<= 2) ? displayItems[index] : ""; //$NON-NLS-1$
- if (displayIndexMem != index) {
- data.setChanged(true);
- data.setDisplay(display);
- }
- if(tagNameItemIndex!=cbTagForDisplay.getSelectionIndex()) {
- data.setChanged(true);
- data.setTagForDisplay(displayTags.get(cbTagForDisplay.getSelectionIndex()));
- }
+ data.setChanged(isChanged(data,data.getTagForDisplay(),txtTagForDisplay.getText()));
+ data.setTagForDisplay(txtTagForDisplay.getText().trim());
+
data.setChanged(isChanged(data, data.getValue(), txtValue.getText()));
data.setValue(txtValue.getText().trim());
- data.setChanged(isChanged(data, data.getValueColor(), ctlValueColor.getText()));
- data.setValueColor(ctlValueColor.getText());
-
- data.setChanged(isChanged(data, data.getValueBackgroundColor(), ctlValueBackgroundColor.getText()));
- data.setValueBackgroundColor(ctlValueBackgroundColor.getText());
-
- data.setChanged(isChanged(data, data.getBackgroundColor(), ctlBackgroundColor.getText()));
- data.setBackgroundColor(ctlBackgroundColor.getText());
-
- data.setChanged(isChanged(data, data.getBorder(), txtBorder.getText()));
- data.setBorder(txtBorder.getText().trim());
-
- data.setChanged(isChanged(data, data.getBorderColor(), ctlBorderColor.getText()));
- data.setBorderColor(ctlBorderColor.getText());
-
data.setChanged(isChanged(data, data.isShowIcon(), ctlShowIcon.getSelection()));
data.setShowIcon(ctlShowIcon.getSelection());
+
+ data.setChanged(isChanged(data, data.getStyle(), txtStyle.getText()));
+ data.setStyle(txtStyle.getText());
+
super.okPressed();
}
@@ -250,7 +180,7 @@
return data.isChanged() || (oldValue != newValue);
}
- public class CheckControl {
+ private class CheckControl {
private Label label;
private Button button;
@@ -274,67 +204,4 @@
return button.getSelection();
}
}
-
- public class ColorControl {
- private Composite parent;
- private Label label;
- private ImageCombo colorCombo;
-
- public ColorControl(Composite parent, String labelText, String value) {
- label = new Label(parent, SWT.NONE);
- label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- label.setText(labelText);
- colorCombo = new ImageCombo(parent, SWT.BORDER);
- GridData gd =new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.grabExcessHorizontalSpace =true;
- colorCombo.setLayoutData(gd);
- colorCombo.setText(value != null ? value : ""); //$NON-NLS-1$
-
- Set<Entry<String, String>> set = ColorParser.getInstance().getMap()
- .entrySet();
-
- for (Map.Entry<String, String> me : set) {
- RGB rgb = Util.getColor(me.getKey());
- colorCombo.add(me.getValue(), rgb);
- }
- Button button = new Button(parent, SWT.PUSH);
- button.setLayoutData(new GridData());
- button.setToolTipText(MessageUtil.getString("BACKGROUND_COLOR_TIP")); //$NON-NLS-1$
- ImageDescriptor colorDesc = JspEditorPlugin
- .getImageDescriptor(Constants.IMAGE_COLORLARGE_FILE_LOCATION);
- Image im = colorDesc.createImage();
- button.setImage(im);
- button.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- Button button = (Button) e.getSource();
- button.getImage().dispose();
- }
- });
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- ColorDialog dlg = new ColorDialog(getShell());
-
- dlg
- .setRGB(Util.getColor((colorCombo.getText().trim())) == null ? new RGB(
- 0, 0, 0)
- : Util.getColor((colorCombo.getText().trim())));
- dlg.setText(MessageUtil.getString("COLOR_DIALOG_TITLE")); //$NON-NLS-1$
- RGB rgb = dlg.open();
- if (rgb != null) {
- String colorStr = Util.createColorString(rgb);
- colorCombo.setText(colorStr);
- }
- }
- });
- }
-
- public void selectColor(Shell shell) {
- ColorDialog dialog = new ColorDialog(shell);
- dialog.open();
- }
-
- public String getText() {
- return colorCombo.getText().trim();
- }
- }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2008-09-18 17:25:53 UTC (rev 10364)
@@ -31,7 +31,6 @@
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
-import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.osgi.framework.Bundle;
@@ -182,16 +181,36 @@
"title", //$NON-NLS-1$
"dir" //$NON-NLS-1$
};
-
- static final String ATTR_ANY_DISPLAY = "display"; //$NON-NLS-1$
+ @Deprecated
+ //used just for conversion old configuration to new configuration
+ //should be deleted from some time
+ private static final String ATTR_ANY_DISPLAY = "display"; //$NON-NLS-1$
+
static final String ATTR_ANY_TAG_FOR_DISPLAY="tag-for-display"; //$NON-NLS-1$
static final String ATTR_ANY_ICON = "icon"; //$NON-NLS-1$
static final String ATTR_ANY_VALUE = "value"; //$NON-NLS-1$
- static final String ATTR_ANY_BORDER = "border"; //$NON-NLS-1$
- static final String ATTR_ANY_VALUE_COLOR = "value-color"; //$NON-NLS-1$
- static final String ATTR_ANY_VALUE_BACKGROUND_COLOR = "value-background-color"; //$NON-NLS-1$
- static final String ATTR_ANY_BACKGROUND_COLOR = "background-color"; //$NON-NLS-1$
- static final String ATTR_ANY_BORDER_COLOR = "border-color"; //$NON-NLS-1$
+ static final String ATTR_ANY_STYLE = "style"; //$NON-NLS-1$
+ @Deprecated
+ //used just for conversion old configuration to new configuration
+ //should be deleted from some time
+ private static final String ATTR_ANY_BORDER = "border"; //$NON-NLS-1$
+ @Deprecated
+ //used just for conversion old configuration to new configuration
+ //should be deleted from some time
+ private static final String ATTR_ANY_VALUE_COLOR = "value-color"; //$NON-NLS-1$
+ @Deprecated
+ //used just for conversion old configuration to new configuration
+ //should be deleted from some time
+ private static final String ATTR_ANY_VALUE_BACKGROUND_COLOR = "value-background-color"; //$NON-NLS-1$
+ @Deprecated
+ //used just for conversion old configuration to new configuration
+ //should be deleted from some time
+ private static final String ATTR_ANY_BACKGROUND_COLOR = "background-color"; //$NON-NLS-1$
+ @Deprecated
+ //used just for conversion old configuration to new configuration
+ //should be deleted from some time
+ private static final String ATTR_ANY_BORDER_COLOR = "border-color"; //$NON-NLS-1$
+
static final String[] ATTR_ANY_PROPERTIES = {"title"}; //$NON-NLS-1$
static final String ATTR_DATATABLE_HEADER_CLASS = "headerClass"; //$NON-NLS-1$
@@ -238,6 +257,8 @@
//comment template name
private static final String COMMENT_TEMPLATE_NAME="#comment"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_TEMPLATE_NAME="attribute"; //$NON-NLS-1$
+
/**
* added by Max Areshkau, JBIDE-1494
* Contains default text formating data
@@ -328,6 +349,9 @@
return COMMENT_TEMPLATE_NAME;
+ case Node.ATTRIBUTE_NODE:
+
+ return ATTRIBUTE_TEMPLATE_NAME;
case Node.ELEMENT_NODE:
String sourcePrefix = sourceNode.getPrefix();
@@ -613,10 +637,10 @@
anyData.setChildren(ATTR_VALUE_YES.equalsIgnoreCase(attr.getNodeValue()));
}
- attr = anyNode.getAttributeNode(ATTR_ANY_DISPLAY);
- if (attr != null) {
- anyData.setDisplay(attr.getNodeValue());
- }
+// attr = anyNode.getAttributeNode(ATTR_ANY_DISPLAY);
+// if (attr != null) {
+// anyData.setDisplay(attr.getNodeValue());
+// }
attr = anyNode.getAttributeNode(ATTR_ANY_ICON);
if (attr != null){
@@ -627,31 +651,36 @@
if (attr != null) {
anyData.setValue(attr.getNodeValue());
}
-
- attr = anyNode.getAttributeNode(ATTR_ANY_BORDER);
- if (attr != null) {
- anyData.setBorder(attr.getNodeValue());
+
+ attr = anyNode.getAttributeNode(ATTR_ANY_STYLE);
+ if (attr !=null) {
+ anyData.setValue(attr.getNodeValue());
}
- attr = anyNode.getAttributeNode(ATTR_ANY_VALUE_COLOR);
- if (attr != null) {
- anyData.setValueColor(attr.getNodeValue());
- }
-
- attr = anyNode.getAttributeNode(ATTR_ANY_VALUE_BACKGROUND_COLOR);
- if (attr != null) {
- anyData.setValueBackgroundColor(attr.getNodeValue());
- }
-
- attr = anyNode.getAttributeNode(ATTR_ANY_BACKGROUND_COLOR);
- if (attr != null) {
- anyData.setBackgroundColor(attr.getNodeValue());
- }
-
- attr = anyNode.getAttributeNode(ATTR_ANY_BORDER_COLOR);
- if (attr != null) {
- anyData.setBorderColor(attr.getNodeValue());
- }
+// attr = anyNode.getAttributeNode(ATTR_ANY_BORDER);
+// if (attr != null) {
+// anyData.setBorder(attr.getNodeValue());
+// }
+//
+// attr = anyNode.getAttributeNode(ATTR_ANY_VALUE_COLOR);
+// if (attr != null) {
+// anyData.setValueColor(attr.getNodeValue());
+// }
+//
+// attr = anyNode.getAttributeNode(ATTR_ANY_VALUE_BACKGROUND_COLOR);
+// if (attr != null) {
+// anyData.setValueBackgroundColor(attr.getNodeValue());
+// }
+//
+// attr = anyNode.getAttributeNode(ATTR_ANY_BACKGROUND_COLOR);
+// if (attr != null) {
+// anyData.setBackgroundColor(attr.getNodeValue());
+// }
+//
+// attr = anyNode.getAttributeNode(ATTR_ANY_BORDER_COLOR);
+// if (attr != null) {
+// anyData.setBorderColor(attr.getNodeValue());
+// }
}
}
@@ -738,20 +767,22 @@
if(data.getTagForDisplay()!=null&& data.getTagForDisplay().length() > 0)
newAnyElement.setAttribute(ATTR_ANY_TAG_FOR_DISPLAY, data.getTagForDisplay());
- if (data.getDisplay() != null && data.getDisplay().length() > 0)
- newAnyElement.setAttribute(ATTR_ANY_DISPLAY, data.getDisplay());
+// if (data.getDisplay() != null && data.getDisplay().length() > 0)
+// newAnyElement.setAttribute(ATTR_ANY_DISPLAY, data.getDisplay());
if (data.getValue() != null && data.getValue().length() > 0)
newAnyElement.setAttribute(ATTR_ANY_VALUE, data.getValue());
- if (data.getBorder() != null && data.getBorder().length() > 0)
- newAnyElement.setAttribute(ATTR_ANY_BORDER, data.getBorder());
- if (data.getValueColor() != null && data.getValueColor().length() > 0)
- newAnyElement.setAttribute(ATTR_ANY_VALUE_COLOR, data.getValueColor());
- if (data.getValueBackgroundColor() != null && data.getValueBackgroundColor().length() > 0)
- newAnyElement.setAttribute(ATTR_ANY_VALUE_BACKGROUND_COLOR, data.getValueBackgroundColor());
- if (data.getBackgroundColor() != null && data.getBackgroundColor().length() > 0)
- newAnyElement.setAttribute(ATTR_ANY_BACKGROUND_COLOR, data.getBackgroundColor());
- if (data.getBorderColor() != null && data.getBorderColor().length() > 0)
- newAnyElement.setAttribute(ATTR_ANY_BORDER_COLOR, data.getBorderColor());
+ if(data.getStyle()!=null && data.getStyle().length()>0)
+ newAnyElement.setAttribute(ATTR_ANY_STYLE, data.getStyle());
+// if (data.getBorder() != null && data.getBorder().length() > 0)
+// newAnyElement.setAttribute(ATTR_ANY_BORDER, data.getBorder());
+// if (data.getValueColor() != null && data.getValueColor().length() > 0)
+// newAnyElement.setAttribute(ATTR_ANY_VALUE_COLOR, data.getValueColor());
+// if (data.getValueBackgroundColor() != null && data.getValueBackgroundColor().length() > 0)
+// newAnyElement.setAttribute(ATTR_ANY_VALUE_BACKGROUND_COLOR, data.getValueBackgroundColor());
+// if (data.getBackgroundColor() != null && data.getBackgroundColor().length() > 0)
+// newAnyElement.setAttribute(ATTR_ANY_BACKGROUND_COLOR, data.getBackgroundColor());
+// if (data.getBorderColor() != null && data.getBorderColor().length() > 0)
+// newAnyElement.setAttribute(ATTR_ANY_BORDER_COLOR, data.getBorderColor());
newAnyElement.setAttribute(ATTR_ANY_ICON, data.isShowIcon() ? ATTR_VALUE_YES : ATTR_VALUE_NO);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2008-09-18 17:25:53 UTC (rev 10364)
@@ -99,13 +99,5 @@
public static String SHOW;
public static String HIDE;
public static String TAG_FOR_DISPLAY;
-
- public static String TAG_B;
- public static String TAG_TABLE;
- public static String TAG_P;
- public static String TAG_A;
- public static String TAG_DIV;
- public static String TAG_SPAN;
-
-
+ public static String STYLE;
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2008-09-18 17:25:53 UTC (rev 10364)
@@ -60,10 +60,5 @@
SHOW=Show
HIDE=Hide
TAG_FOR_DISPLAY=Tag for Display
-TAG_B=B
-TAG_TABLE=TABLE
-TAG_P=P
-TAG_A=A
-TAG_DIV=DIV
-TAG_SPAN=SPAN
+STYLE=Style
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html 2008-09-18 17:25:53 UTC (rev 10364)
@@ -16,6 +16,7 @@
padding: 2px 1px 1px 1px;
}
.__any__tag__caption {
+ border: 1px solid black;
color:#006727;
font-size: 12px;
padding: 0px 2px 0px 2px;
Modified: trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/editor/template/VpeTemplateManagerTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/editor/template/VpeTemplateManagerTest.java 2008-09-18 17:12:06 UTC (rev 10363)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/editor/template/VpeTemplateManagerTest.java 2008-09-18 17:25:53 UTC (rev 10364)
@@ -12,11 +12,7 @@
VpeAnyData data = new VpeAnyData(
"tag-name1",
"tag-value",
- "yes",
- "red",
- "green",
- "blue",
- "white",
+ "color:red",
true
);
@@ -25,11 +21,7 @@
data = new VpeAnyData(
"tag-name2",
"tag-value",
- "yes",
- "red",
- "green",
- "blue",
- "white",
+ "color:white",
true
);
15 years, 9 months
JBoss Tools SVN: r10363 - trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-09-18 13:12:06 -0400 (Thu, 18 Sep 2008)
New Revision: 10363
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java
Log:
JSFPromptingProviderTest is disabled
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java 2008-09-18 15:15:20 UTC (rev 10362)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java 2008-09-18 17:12:06 UTC (rev 10363)
@@ -26,8 +26,7 @@
// FIXME http://jira.jboss.org/jira/browse/JBIDE-2441
// suite.addTestSuite(JSFImportTest.class);
suite.addTestSuite(JSFBeansTest.class);
- suite.addTestSuite(JSFPromptingProviderTest.class);
-
+ //suite.addTestSuite(JSFPromptingProviderTest.class);
return suite;
}
15 years, 9 months
JBoss Tools SVN: r10362 - in trunk/portlet/docs/reference: en/modules and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-09-18 11:15:20 -0400 (Thu, 18 Sep 2008)
New Revision: 10362
Modified:
trunk/portlet/docs/reference/
trunk/portlet/docs/reference/en/modules/intro.xml
trunk/portlet/docs/reference/en/modules/portlets_support.xml
trunk/portlet/docs/reference/en/modules/starting_project.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-407
spelling is corrected
Property changes on: trunk/portlet/docs/reference
___________________________________________________________________
Name: svn:ignore
+ target
Modified: trunk/portlet/docs/reference/en/modules/intro.xml
===================================================================
--- trunk/portlet/docs/reference/en/modules/intro.xml 2008-09-18 14:52:45 UTC (rev 10361)
+++ trunk/portlet/docs/reference/en/modules/intro.xml 2008-09-18 15:15:20 UTC (rev 10362)
@@ -43,7 +43,7 @@
<para>Wizards for creating Projects with Portlet Facets</para>
</entry>
<entry>
- <para>New Dynamic Web Project wizard allows you to select proper
+ <para>New Dynamic Web Project wizard allows you to select a proper
Configuration to enable Portlet Facet in it.</para>
</entry>
<entry>
Modified: trunk/portlet/docs/reference/en/modules/portlets_support.xml
===================================================================
--- trunk/portlet/docs/reference/en/modules/portlets_support.xml 2008-09-18 14:52:45 UTC (rev 10361)
+++ trunk/portlet/docs/reference/en/modules/portlets_support.xml 2008-09-18 15:15:20 UTC (rev 10362)
@@ -32,7 +32,7 @@
</mediaobject>
</figure>
- <para>The Web Project and Source Folder fields the wizard fills in for you itself. Specify
+ <para>The wizard fills in The Web Project and Source Folder fields for you. Then you need to specify
the Java package and the Class name and click <emphasis>
<property>Next</property>
</emphasis>.</para>
Modified: trunk/portlet/docs/reference/en/modules/starting_project.xml
===================================================================
--- trunk/portlet/docs/reference/en/modules/starting_project.xml 2008-09-18 14:52:45 UTC (rev 10361)
+++ trunk/portlet/docs/reference/en/modules/starting_project.xml 2008-09-18 15:15:20 UTC (rev 10362)
@@ -114,10 +114,10 @@
</mediaobject>
</figure>
- <para>What <property>JBoos Tools</property> have done here, it's adding JBoss
- Portlet facet to the project, creating an empty <emphasis>
+ <para>Here <property>JBoos Tools</property> have added JBoss
+ Portlet facet to the project, created an empty <emphasis>
<property>portlet.xml</property>
- </emphasis> file and adding the portlet library to the project classpath.</para>
+ </emphasis> file and added the portlet library to the project classpath.</para>
</section>
</chapter>
15 years, 9 months
JBoss Tools SVN: r10360 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-09-18 10:52:25 -0400 (Thu, 18 Sep 2008)
New Revision: 10360
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandButton.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandLink.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/dataTable.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/graphicImage.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputSecret.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputText.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputTextArea.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/message.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/messages.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/outputFormat.jsp.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-2781
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandButton.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandButton.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandButton.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,17 @@
+<tests>
+ <test id="commandButton1">
+ <input type="submit" />
+ </test>
+ <test id="commandButton2">
+ <input type="button" />
+ </test>
+ <test id="commandButton3">
+ <input type="reset" />
+ </test>
+ <test id="commandButton4">
+ <input type="submit" />
+ </test>
+ <test id="commandButton5">
+ <input type="image" />
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandLink.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandLink.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/commandLink.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,8 @@
+<tests>
+ <test id="commandLink1">
+ <span>commandLink1</span>
+ </test>
+ <test id="commandLink2">
+ <a>commandLink2</a>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/dataTable.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/dataTable.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/dataTable.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,81 @@
+<tests>
+ <test id="dataTable">
+ <TABLE>
+ <TR>
+ <TD>
+ <DIV>
+ <TABLE>
+ <CAPTION>
+ <BR />
+ </CAPTION>
+ <THEAD>
+ <TR>
+ <TH>
+ <BR />
+ </TH>
+ </TR>
+ </THEAD>
+ <TFOOT>
+ <TR>
+ <TD>
+ <BR />
+ </TD>
+ </TR>
+ </TFOOT>
+ <TBODY>
+ <TR>
+ <TD>
+ <TABLE WIDTH="100%" BORDER="0">
+ <THEAD>
+ <TR>
+ <TH>
+ <DIV>
+ <SPAN> Last Name </SPAN>
+ </DIV>
+ </TH>
+ <TH>
+ <DIV>
+ <SPAN> First Name </SPAN>
+ </DIV>
+ </TH>
+ </TR>
+ </THEAD>
+ <TFOOT>
+ <TR>
+ <TD>
+ <DIV>
+ <SPAN> footer </SPAN>
+ </DIV>
+ </TD>
+ <TD>
+ <DIV>
+ <SPAN> footer </SPAN>
+ </DIV>
+ </TD>
+ </TR>
+ </TFOOT>
+ <TBODY>
+ <TR>
+ <TD>
+ <SPAN> Dupont </SPAN>
+ </TD>
+ <TD>
+ <SPAN> William </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ <COLGROUP>
+ <COL />
+ <COL />
+ </COLGROUP>
+ </TABLE>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </TD>
+ </TR>
+ </TABLE>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,14 @@
+<tests>
+ <test id="form">
+ <TABLE
+ STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%;">
+ <TR>
+ <TD>
+ <DIV>
+ </DIV>
+ <BR />
+ </TD>
+ </TR>
+ </TABLE>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/graphicImage.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/graphicImage.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/graphicImage.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,8 @@
+<tests>
+ <test id="graphicImage1">
+ <IMG SRC="unresolved.gif" />
+ </test>
+ <test id="graphicImage2">
+ <IMG />
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputSecret.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputSecret.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputSecret.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,5 @@
+<tests>
+ <test id="inputSecret">
+ <input type="password" />
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputText.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputText.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputText.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,5 @@
+<tests>
+ <test id="inputText">
+ <input />
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputTextArea.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputTextArea.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/inputTextArea.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,5 @@
+<tests>
+ <test id="inputTextArea">
+ <TEXTAREA> inputTextArea </TEXTAREA>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/message.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/message.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/message.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,5 @@
+<tests>
+ <test id="message">
+ <span> Error Message</span>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/messages.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/messages.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/messages.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,5 @@
+<tests>
+ <test id="messages">
+ <span> Error Messages </span>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/outputFormat.jsp.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/outputFormat.jsp.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/outputFormat.jsp.xml 2008-09-18 14:52:25 UTC (rev 10360)
@@ -0,0 +1,16 @@
+<tests>
+ <test id="outputFormat1">
+ <SPAN> outputFormat1 </SPAN>
+ </test>
+ <test id="outputFormat2">
+ <SPAN> outputFormat2 </SPAN>
+ </test>
+ <test id="outputFormat3">
+ <SPAN>
+ <SPAN> outputFormat3 </SPAN>
+ </SPAN>
+ </test>
+ <test id="outputFormat3">
+ <SPAN> outputFormat4 </SPAN>
+ </test>
+</tests>
\ No newline at end of file
15 years, 9 months