JBoss Tools SVN: r3335 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-08-25 07:43:40 -0400 (Sat, 25 Aug 2007)
New Revision: 3335
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
Log:
Attempt on fixing JBIDE-849
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2007-08-25 11:43:20 UTC (rev 3334)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2007-08-25 11:43:40 UTC (rev 3335)
@@ -92,10 +92,12 @@
protected void clean(IProgressMonitor monitor) throws CoreException {
IPath p = getProject().getLocation();
IArchiveModelNode root = ArchivesModel.instance().getRoot(p);
- IArchiveNode[] nodes = root.getChildren(IArchiveNode.TYPE_ARCHIVE);
- for( int i = 0; i < nodes.length; i++ ) {
- IPath path = ((IArchive)nodes[i]).getArchiveFilePath();
- TrueZipUtil.deleteAll(path);
+ if(root!=null) {
+ IArchiveNode[] nodes = root.getChildren(IArchiveNode.TYPE_ARCHIVE);
+ for( int i = 0; i < nodes.length; i++ ) {
+ IPath path = ((IArchive)nodes[i]).getArchiveFilePath();
+ TrueZipUtil.deleteAll(path);
+ }
}
}
@@ -147,20 +149,25 @@
final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
final int count = workspaceRoot.getLocation().segmentCount();
- ArchivesModel.instance().getRoot(getProject().getLocation()).accept(new IArchiveNodeVisitor () {
- public boolean visit (IArchiveNode node) {
- if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
- IArchiveFileSet fileset = (IArchiveFileSet)node;
- IPath p = fileset.getGlobalSourcePath();
- if( workspaceRoot.getLocation().isPrefixOf(p)) {
- IProject proj = workspaceRoot.getProject(p.segment(count));
- set.add(proj);
+ IArchiveModelNode root = ArchivesModel.instance().getRoot(getProject().getLocation());
+ if(root!=null) {
+ root.accept(new IArchiveNodeVisitor () {
+ public boolean visit (IArchiveNode node) {
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
+ IArchiveFileSet fileset = (IArchiveFileSet)node;
+ IPath p = fileset.getGlobalSourcePath();
+ if( workspaceRoot.getLocation().isPrefixOf(p)) {
+ IProject proj = workspaceRoot.getProject(p.segment(count));
+ set.add(proj);
+ }
}
+ return true;
}
- return true;
- }
- });
- return (IProject[]) set.toArray(new IProject[set.size()]);
+ });
+ return (IProject[]) set.toArray(new IProject[set.size()]);
+ } else {
+ return new IProject[0];
+ }
}
/**
16 years, 8 months
JBoss Tools SVN: r3334 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-08-25 07:43:20 -0400 (Sat, 25 Aug 2007)
New Revision: 3334
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java
Log:
avoid NPE and more specific exception
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java 2007-08-25 11:40:48 UTC (rev 3333)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java 2007-08-25 11:43:20 UTC (rev 3334)
@@ -198,13 +198,18 @@
}
protected int findPort(IPath path) {
- try {
+
XPathQuery query = XPathModel.getDefault().getQuery(getServer(), path);
- String result = query.getFirstResult();
- if( result != null ) {
- return Integer.parseInt(result);
- }
- } catch( Exception e ) {}
+ if(query!=null) {
+ String result = query.getFirstResult();
+ if( result != null ) {
+ try {
+ return Integer.parseInt(result);
+ } catch(NumberFormatException nfe) {
+ return -1;
+ }
+ }
+ }
return -1;
}
16 years, 8 months
JBoss Tools SVN: r3333 - trunk/seam/plugins/org.jboss.tools.seam.text.ext.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-08-25 07:40:48 -0400 (Sat, 25 Aug 2007)
New Revision: 3333
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/
Log:
bin ignore
Property changes on: trunk/seam/plugins/org.jboss.tools.seam.text.ext
___________________________________________________________________
Name: svn:ignore
+ bin
16 years, 8 months
JBoss Tools SVN: r3332 - trunk/jst/plugins/org.jboss.tools.jst.firstrun.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-08-25 07:39:53 -0400 (Sat, 25 Aug 2007)
New Revision: 3332
Modified:
trunk/jst/plugins/org.jboss.tools.jst.firstrun/
Log:
bin ignore
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.firstrun
___________________________________________________________________
Name: svn:ignore
+ bin
16 years, 8 months
JBoss Tools SVN: r3331 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core: publishers and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-08-24 22:44:34 -0400 (Fri, 24 Aug 2007)
New Revision: 3331
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/NestedPublishInfo.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ModulePackager.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/packages/ProjectArchiveStorer.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
Log:
JBIDE-674
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/packages/ProjectArchiveStorer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/packages/ProjectArchiveStorer.java 2007-08-25 00:53:28 UTC (rev 3330)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/packages/ProjectArchiveStorer.java 2007-08-25 02:44:34 UTC (rev 3331)
@@ -1,55 +0,0 @@
-package org.jboss.ide.eclipse.as.core.packages;
-
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.QualifiedName;
-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.internal.xb.XMLBinding;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-
-public class ProjectArchiveStorer {
- public static final String JST_ARCHIVE_CONFIGURATION = "jst.archive.configuration";
- private static HashMap cache = new HashMap();
-
- public static IArchive getArchiveFor(IProject project) {
- if( cache.containsKey(project))
- return (IArchive)cache.get(project);
- return loadArchiveFrom(project);
- }
-
- public static IArchive loadArchiveFrom(IProject project) {
- try {
- String s = project.getPersistentProperty(new QualifiedName(JBossServerCorePlugin.PLUGIN_ID, JST_ARCHIVE_CONFIGURATION));
- if( s != null ) {
- XbPackages packs = XMLBinding.unmarshal(s, new NullProgressMonitor());
- if( packs != null && packs.getAllChildren().size() == 1 ) {
- XbPackage pack = (XbPackage)packs.getAllChildren().get(0);
- IArchive node = (IArchive)ArchivesModel.instance().createPackageNodeImpl(project.getLocation(), pack, null);
- if( node != null ) {
- cache.put(project, node);
- }
- }
- }
- } catch( CoreException ce ) {
- ce.printStackTrace();
- }
- return (IArchive)cache.get(project);
- }
-
- public static void storeArchive(IProject project, IArchive archive) {
- try {
- String s = XMLBinding.marshall(archive, new NullProgressMonitor());
- if( s != null )
- project.setPersistentProperty(new QualifiedName(JBossServerCorePlugin.PLUGIN_ID, JST_ARCHIVE_CONFIGURATION), s);
- } catch( CoreException ce) {
- ce.printStackTrace();
- }
- }
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2007-08-25 00:53:28 UTC (rev 3330)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2007-08-25 02:44:34 UTC (rev 3331)
@@ -4,7 +4,7 @@
* 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
+ * 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.
@@ -21,195 +21,277 @@
*/
package org.jboss.ide.eclipse.as.core.publishers;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.TreeSet;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
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.eclipse.core.runtime.Status;
+import org.eclipse.jst.server.core.IEnterpriseApplication;
+import org.eclipse.jst.server.core.IWebModule;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.internal.ModuleFile;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.eclipse.wst.server.core.util.ProjectModule;
+import org.eclipse.wst.server.core.util.PublishUtil;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.model.EventLogModel;
import org.jboss.ide.eclipse.as.core.model.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.packages.ModulePackageTypeConverter;
-import org.jboss.ide.eclipse.as.core.packages.ProjectArchiveStorer;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublishEvent;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublisherFileUtilListener;
+import org.jboss.ide.eclipse.as.core.server.NestedPublishInfo;
+import org.jboss.ide.eclipse.as.core.server.NestedPublishInfo.OpenedModulePublishInfo;
import org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.xpl.ModulePackager;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
/**
- * This class provides a default implementation for
- * packaging different types of flexible projects. It uses
- * the built-in heirarchy of the projects to do so.
- *
+ * This class provides a default implementation for packaging different types of
+ * flexible projects. It uses the built-in heirarchy of the projects to do so.
+ *
* @author rob.stryker(a)jboss.com
*/
public class JstPublisher extends PackagesPublisher {
-
- private static HashMap moduleToArchiveMap = new HashMap();
-
+
public static final int BUILD_FAILED_CODE = 100;
public static final int PACKAGE_UNDETERMINED_CODE = 101;
-
+
protected IModuleResourceDelta[] delta;
public JstPublisher(IServer server, EventLogTreeItem context) {
super(server, context);
}
-
public void setDelta(IModuleResourceDelta[] delta) {
this.delta = delta;
}
- public IStatus publishModule(int kind, int deltaKind, int modulePublishState,
- IModule module, IProgressMonitor monitor) throws CoreException {
+ public IStatus publishModule(int kind, int deltaKind,
+ int modulePublishState, IModule module, IProgressMonitor monitor)
+ throws CoreException {
IStatus status = null;
- if(ServerBehaviourDelegate.REMOVED == deltaKind){
- status = unpublish(server, module, kind, deltaKind, modulePublishState, monitor);
- } else if( ServerBehaviourDelegate.NO_CHANGE != deltaKind || kind == IServer.PUBLISH_FULL || kind == IServer.PUBLISH_CLEAN ){
- // if there's no change, do nothing. Otherwise, on change or add, re-publish
- status = publish(server, module, kind, deltaKind, modulePublishState, monitor);
- } else if( ServerBehaviourDelegate.NO_CHANGE != deltaKind && kind == IServer.PUBLISH_INCREMENTAL ){
- status = publish(server, module, kind, deltaKind, modulePublishState, monitor);
- }
+
+ IPath root = new Path(server.getDeployDirectory());
+ if (ServerBehaviourDelegate.REMOVED == deltaKind) {
+ status = unpublish(server, module, monitor);
+ } else if (kind == IServer.PUBLISH_FULL || kind == IServer.PUBLISH_CLEAN) {
+ status = fullPublishPackIntoFolder(module, root, monitor);
+ } else if (kind == IServer.PUBLISH_INCREMENTAL) {
+ status = incrementalPublish(new ArrayList(), root, module, monitor);
+ }
return status;
}
-
- protected IStatus publish(IDeployableServer jbServer, IModule module, int kind,
- int deltaKind, int modulePublishState, IProgressMonitor monitor) throws CoreException {
- PublishEvent event = PublisherEventLogger.createSingleModuleTopEvent(eventRoot, module, kind, deltaKind);
- EventLogModel.markChanged(eventRoot);
- boolean incremental = shouldPublishIncremental(module, kind, deltaKind, modulePublishState);
-
- IArchive topLevel = getTopPackage(module, jbServer.getDeployDirectory(), monitor);
-
- if( topLevel != null ) {
- try {
- if( !incremental )
- new ArchiveBuildDelegate().fullArchiveBuild(topLevel);
- else {
- Set addedChanged = createDefaultTreeSet();
- Set removed = createDefaultTreeSet();
- fillDelta(delta, addedChanged, removed);
- new ArchiveBuildDelegate().incrementalBuild(topLevel, addedChanged, removed);
- }
- } catch( Exception e ) {
- return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, BUILD_FAILED_CODE, "", e);
+ protected void fullWebPublish(IModule module, IPath root, IProgressMonitor monitor ) throws CoreException {
+ ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
+ IModuleResource[] members = md.members();
+ IWebModule webmodule = (IWebModule)module.loadAdapter(IWebModule.class, monitor);
+ IPath moduleDeployPath = root.append(webmodule.getContextRoot() + ".war");
+ FileUtil.safeDelete(moduleDeployPath.toFile());
+ PublishUtil.publishSmart(members, moduleDeployPath, monitor);
+ IWebModule webModule = (IWebModule)module.loadAdapter(IWebModule.class, monitor);
+ IModule[] childModules = webModule.getModules();
+ for (int i = 0; i < childModules.length; i++) {
+ IModule module2 = childModules[i];
+ packModuleIntoJar(module, webModule.getURI(module2), moduleDeployPath);
+ }
+ }
+ protected void fullEarPublish(IModule module, IPath root, IProgressMonitor monitor) throws CoreException {
+ ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
+ IModuleResource[] members = md.members();
+ IEnterpriseApplication earModule = (IEnterpriseApplication)module.loadAdapter(IEnterpriseApplication.class, monitor);
+ IPath moduleDeployPath = root.append(module.getProject().getName() + ".ear");
+ FileUtil.safeDelete(moduleDeployPath.toFile());
+ PublishUtil.publishSmart(members, moduleDeployPath, monitor);
+ IModule[] childModules = earModule.getModules();
+ for (int i = 0; i < childModules.length; i++) {
+ IModule module2 = childModules[i];
+ String uri = earModule.getURI(module2);
+ if(uri==null){
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, 0, "unable to assemble module null uri",null ); //$NON-NLS-1$
+ throw new CoreException(status);
}
+ if( module2.getModuleType().getId().equals("jst.utility")) {
+ packModuleIntoJar(module2, uri, moduleDeployPath);
+ } else {
+ fullPublishPackIntoFolder(module2, moduleDeployPath, monitor);
+ }
+ }
+ }
+
+ protected IStatus fullPublishPackIntoFolder(IModule module, IPath root, IProgressMonitor monitor) throws CoreException {
+ if( module.getModuleType().getId().equals("jst.web")) {
+ fullWebPublish(module, root, monitor);
+ } else if( module.getModuleType().getId().equals("jst.ear")) {
+ fullEarPublish(module, root, monitor);
} else {
- return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, PACKAGE_UNDETERMINED_CODE, "", null);
+ ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
+ IModuleResource[] members = md.members();
+ IPath moduleDeployPath = root.append(module.getProject().getName() + ".jar");
+ FileUtil.safeDelete(moduleDeployPath.toFile());
+ PublishUtil.publishSmart(members, moduleDeployPath, monitor);
}
- return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, IStatus.OK, "", null);
+ return null;
}
- protected IStatus unpublish(IDeployableServer jbServer, IModule module,
- int kind, int deltaKind, int modulePublishKind, IProgressMonitor monitor) throws CoreException {
- PublishEvent event = PublisherEventLogger.createSingleModuleTopEvent(eventRoot, module, kind, deltaKind);
-
- IArchive topLevel = getTopPackage(module, jbServer.getDeployDirectory(), monitor);
- if( topLevel != null ) {
- IPath path = topLevel.getArchiveFilePath();
- FileUtil.safeDelete(path.toFile(), new PublisherFileUtilListener(event));
- } else if( module.getProject() == null ){
- // this is a problem. All I know is the module name, aka project name. Not it's suffix on the server.
+ private boolean hasDelta( IModule module, ArrayList moduleTree ) {
+ return getDelta(module, moduleTree).length > 0;
+ }
+
+ public IModuleResourceDelta[] getDelta(IModule module, ArrayList moduleTree) {
+ IModuleResourceDelta[] deltas;
+ if( moduleTree.size() == 0 ) {
+ final IModule[] modules ={module};
+ deltas = ((Server)server.getServer()).getPublishedResourceDelta( modules );
} else {
- return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, PACKAGE_UNDETERMINED_CODE, "", null);
+ deltas = NestedPublishInfo.getDefault().getServerPublishInfo(server.getServer()).getDelta(moduleTree, module);
}
- return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, IStatus.OK, "", null);
+ return deltas;
}
-
- protected IArchive getTopPackage(IModule module, String deployDir, IProgressMonitor monitor) {
- if( moduleToArchiveMap.containsKey(module.getId())) {
- return (IArchive)moduleToArchiveMap.get(module.getId());
+
+ protected void packModuleIntoJar(IModule module, String deploymentUnitName, IPath destination)throws CoreException {
+ String dest = destination.append(deploymentUnitName).toString();
+ ModulePackager packager = null;
+ try {
+ packager = new ModulePackager(dest, false);
+ ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
+ IModuleResource[] resources = pm.members();
+ for (int i = 0; i < resources.length; i++) {
+ doPackModule(resources[i], packager);
+ }
+ } catch (IOException e) {
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, 0,
+ "unable to assemble module", e); //$NON-NLS-1$
+ throw new CoreException(status);
}
-
- IProject project = module.getProject();
- IArchive top = ProjectArchiveStorer.getArchiveFor(project);
- if( top == null ) {
- top = createTopPackage(module, deployDir, monitor);
- if( top != null ) {
- ProjectArchiveStorer.storeArchive(project, top);
- moduleToArchiveMap.put(module.getId(), top);
+ finally{
+ try{
+ packager.finished();
}
+ catch(IOException e){
+ //unhandled
+ }
}
- return top;
}
+
- protected IArchive createTopPackage(IModule module, String deployDir, IProgressMonitor monitor) {
- IArchiveType type = ModulePackageTypeConverter.getPackageTypeFor(module);
- if( type != null && module.getProject() != null ) {
- IArchive topLevel = type.createDefaultConfiguration(module.getProject().getName(), monitor);
- topLevel.setDestinationPath(new Path(deployDir));
- topLevel.setInWorkspace(false);
- topLevel.setExploded(true);
- return topLevel;
- }
- return null;
+ /* Add one file or folder to a jar */
+ private void doPackModule(IModuleResource resource, ModulePackager packager) throws CoreException, IOException{
+ if (resource instanceof IModuleFolder) {
+ IModuleFolder mFolder = (IModuleFolder)resource;
+ IModuleResource[] resources = mFolder.members();
+
+ packager.writeFolder(resource.getModuleRelativePath().append(resource.getName()).toPortableString());
+
+ for (int i = 0; resources!= null && i < resources.length; i++) {
+ doPackModule(resources[i], packager);
+ }
+ } else {
+ String destination = resource.getModuleRelativePath().append(resource.getName()).toPortableString();
+ IFile file = (IFile) resource.getAdapter(IFile.class);
+ if (file != null)
+ packager.write(file, destination);
+ else {
+ File file2 = (File) resource.getAdapter(File.class);
+ packager.write(file2, destination);
+ }
+ }
}
- protected void fillDelta(IModuleResourceDelta[] delta, Set addedChanged, Set removed) {
- for( int i = 0; i < delta.length; i++ ) {
- fillDelta(delta[i], addedChanged, removed);
+
+ protected IStatus incrementalPublish(ArrayList moduleTree, IPath root, IModule module, IProgressMonitor monitor) throws CoreException {
+ if( module.getModuleType().getId().equals("jst.web")) {
+ incrementalWarPublish(moduleTree, module, root, monitor);
+ } else if( module.getModuleType().getId().equals("jst.ear")) {
+ incrementalEarPublish(moduleTree, module, root, monitor);
+ } else {
+ // cannot incrementally publish something unknown
+ // just package it
+ packModuleIntoJar(module, "blah" + module.getName().hashCode() + ".jar", root);
}
+ return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID,
+ IStatus.OK, "", null);
}
- protected void fillDelta(IModuleResourceDelta delta, Set addedChanged, Set removed) {
- IModuleResourceDelta[] children = delta.getAffectedChildren();
- if( children != null ) {
- for( int i = 0; i < children.length; i++ ) {
- fillDelta(children[i], addedChanged, removed);
- }
+
+ protected void incrementalWarPublish(ArrayList moduleTree, IModule module, IPath root, IProgressMonitor monitor) throws CoreException {
+ ArrayList newTree = new ArrayList();
+ newTree.addAll(moduleTree); newTree.add(module);
+
+ IModule[] modules = new IModule[] {module};
+ IModuleResourceDelta[] deltas = getDelta(module, moduleTree);
+ //((Server)server.getServer()).getPublishedResourceDelta( modules );
+ ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
+ IModuleResource[] members = md.members();
+ IWebModule webmodule = (IWebModule)module.loadAdapter(IWebModule.class, monitor);
+ IPath moduleDeployPath = root.append(webmodule.getContextRoot() + ".war");
+ PublishUtil.publishDelta(deltas, moduleDeployPath, monitor);
+ IWebModule webModule = (IWebModule)module.loadAdapter(IWebModule.class, monitor);
+ IModule[] childModules = webModule.getModules();
+ for (int i = 0; i < childModules.length; i++) {
+ IModule module2 = childModules[i];
+ // if a lib .jar needs to be repacked, repack the whole thing
+ if( hasDelta(module2, newTree))
+ packModuleIntoJar(module, webModule.getURI(module2), moduleDeployPath);
}
- handleResource(delta.getKind(), delta.getModuleResource(), addedChanged, removed);
+ if( moduleTree.size() > 0 ) {
+ // published it
+ NestedPublishInfo.getDefault().getServerPublishInfo(server.getServer()).getPublishInfo(moduleTree, module).setResources(md.members());
+ }
}
- protected void handleResource(int kind, IModuleResource resource, Set addedChanged, Set removed) {
- if( resource instanceof ModuleFile ) {
- ModuleFile mf = (ModuleFile)resource;
- IFile f = (IFile)resource.getAdapter(IFile.class);
- IPath p = null;
- if( f == null ) {
- IFile ifile = (IFile)resource.getAdapter(IFile.class);
- if( ifile != null )
- p = ifile.getLocation();
- } else {
- p = f.getLocation();
+ protected void incrementalEarPublish(ArrayList moduleTree, IModule module, IPath root, IProgressMonitor monitor) throws CoreException {
+ ArrayList newTree = new ArrayList();
+ newTree.addAll(moduleTree);
+ newTree.add(module);
+
+ IModuleResourceDelta[] deltas = getDelta(module, moduleTree);
+ //((Server)server.getServer()).getPublishedResourceDelta( modules );
+ IEnterpriseApplication earModule = (IEnterpriseApplication)module.loadAdapter(IEnterpriseApplication.class, monitor);
+ IPath moduleDeployPath = root.append(module.getProject().getName() + ".ear");
+ PublishUtil.publishDelta(deltas, moduleDeployPath, monitor);
+ IModule[] childModules = earModule.getModules();
+ for (int i = 0; i < childModules.length; i++) {
+ IModule childModule = childModules[i];
+ String uri = earModule.getURI(childModule);
+ if(uri==null){
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, 0, "unable to assemble module null uri",null ); //$NON-NLS-1$
+ throw new CoreException(status);
}
- if( p != null ) {
- if( kind == IModuleResourceDelta.ADDED || kind == IModuleResourceDelta.CHANGED) {
- addedChanged.add(p);
- } else if( kind == IModuleResourceDelta.REMOVED) {
- removed.add(p);
- }
- }
+ incrementalPublish(newTree, root, childModule, monitor);
}
+
}
- protected TreeSet createDefaultTreeSet() {
- return new TreeSet(new Comparator () {
- public int compare(Object o1, Object o2) {
- if (o1.equals(o2)) return 0;
- else return -1;
- }
- });
+
+ protected IStatus unpublish(IDeployableServer jbServer, IModule module,
+ IProgressMonitor monitor) throws CoreException {
+
+ IPath root = new Path(jbServer.getDeployDirectory());
+ if( module.getModuleType().getId().equals("jst.web")) {
+ // copy the module first
+ ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
+ IModuleResource[] members = md.members();
+ IWebModule webmodule = (IWebModule)module.loadAdapter(IWebModule.class, monitor);
+ IPath moduleDeployPath = root.append(webmodule.getContextRoot() + ".war");
+ FileUtil.completeDelete(moduleDeployPath.toFile());
+ } else if( module.getModuleType().getId().equals("jst.ear")) {
+ ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
+ IModuleResource[] members = md.members();
+ IEnterpriseApplication earModule = (IEnterpriseApplication)module.loadAdapter(IEnterpriseApplication.class, monitor);
+ IPath moduleDeployPath = root.append(module.getProject().getName() + ".ear");
+ FileUtil.completeDelete(moduleDeployPath.toFile());
+ }
+
+ return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID,
+ IStatus.OK, "", null);
}
}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/NestedPublishInfo.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/NestedPublishInfo.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/NestedPublishInfo.java 2007-08-25 02:44:34 UTC (rev 3331)
@@ -0,0 +1,99 @@
+package org.jboss.ide.eclipse.as.core.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.internal.ModulePublishInfo;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+
+
+
+public class NestedPublishInfo {
+ public static final String PUBLISH_INFO = "publishInfo";
+ public static final String INDEX = "index.properties";
+ private static NestedPublishInfo instance;
+
+
+ public static NestedPublishInfo getDefault() {
+ if( instance == null ) {
+ instance = new NestedPublishInfo();
+ }
+ return instance;
+ }
+
+ HashMap idToSPI;
+ protected NestedPublishInfo() {
+ idToSPI = new HashMap();
+ }
+
+ public NestedServerPublishInfo getServerPublishInfo(IServer server) {
+ if( idToSPI.get(server.getId()) == null ) {
+ idToSPI.put(server.getId(), new NestedServerPublishInfo());
+ }
+ return (NestedServerPublishInfo)idToSPI.get(server.getId());
+ }
+
+ public static class NestedServerPublishInfo {
+
+ private HashMap<String, OpenedModulePublishInfo> idToModulePublishInfo;
+ public NestedServerPublishInfo() {
+ idToModulePublishInfo = new HashMap<String, OpenedModulePublishInfo>();
+ }
+
+ public ModulePublishInfo getPublishInfo(ArrayList ids, IModule module) {
+ String id = getId(ids);
+ ModulePublishInfo ret = idToModulePublishInfo.get(id);
+ if( ret == null ) {
+ ret = new OpenedModulePublishInfo(id, module.getName(), module.getModuleType());
+ idToModulePublishInfo.put(id, (OpenedModulePublishInfo) ret);
+ }
+ return ret;
+ }
+
+ // Takes a list of the nesting pattern for the modules
+ // followed by the desired module (which can share its current resources)
+ public IModuleResourceDelta[] getDelta(ArrayList ids, IModule module) {
+ return ((OpenedModulePublishInfo)getPublishInfo(ids, module)).getDelta(new IModule[]{module});
+ }
+
+ protected String getId(ArrayList ids) {
+ String result = "";
+ Iterator i = ids.iterator();
+ while(i.hasNext()) {
+ result += i.next().hashCode() + "" + Path.SEPARATOR;
+ }
+ return result;
+ }
+ }
+
+ public static class OpenedModulePublishInfo extends ModulePublishInfo {
+
+ public OpenedModulePublishInfo(DataInput in) throws IOException {
+ super(in);
+ }
+
+ public OpenedModulePublishInfo(String moduleId, String name, IModuleType moduleType) {
+ super(moduleId, name, moduleType);
+ }
+
+ public IModuleResourceDelta[] getDelta(IModule[] module) {
+ return super.getDelta(module);
+ }
+
+ public void load(DataInput in) throws IOException {
+ super.load(in);
+ }
+
+ public void save(DataOutput out) {
+ super.save(out);
+ }
+ }
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ModulePackager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ModulePackager.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ModulePackager.java 2007-08-25 02:44:34 UTC (rev 3331)
@@ -0,0 +1,218 @@
+/***************************************************************************************************
+* Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the
+* accompanying materials are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors: Gorkem Ercan - initial API and implementation
+*
+**************************************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.xpl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarOutputStream;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * Packages resources to a .zip file
+ */
+public class ModulePackager {
+ private static final String JAR_FILE_SEPERATOR = "/"; //$NON-NLS-1$
+ private JarOutputStream outputStream;
+// private StringBuffer manifestContents;
+
+ private boolean useCompression = true;
+
+ /**
+ * Create an instance of this class.
+ *
+ * @param filename java.lang.String
+ * @param compress boolean
+ * @exception java.io.IOException
+ */
+ public ModulePackager(String filename, boolean compress) throws IOException {
+ Path directoryPath = new Path(filename);
+ directoryPath = (Path) directoryPath.removeLastSegments(1);
+ File newZipFile = new File(directoryPath.toString());
+ newZipFile.mkdirs();
+ outputStream = new JarOutputStream(new FileOutputStream(filename));
+ useCompression = compress;
+ }
+
+ /**
+ * Do all required cleanup now that we're finished with the currently-open .zip
+ *
+ * @exception java.io.IOException
+ */
+ public void finished() throws IOException {
+ outputStream.close();
+ }
+
+ /**
+ * Create a new ZipEntry with the passed pathname and contents, and write it to the current
+ * archive
+ *
+ * @param pathname
+ * java.lang.String
+ * @param contents
+ * byte[]
+ * @exception java.io.IOException
+ */
+ protected void write(String pathname, byte[] contents) throws IOException {
+ ZipEntry newEntry = new ZipEntry(pathname);
+
+ // if the contents are being compressed then we get the below for free.
+ if (!useCompression) {
+ newEntry.setMethod(ZipEntry.STORED);
+ newEntry.setSize(contents.length);
+ CRC32 checksumCalculator = new CRC32();
+ checksumCalculator.update(contents);
+ newEntry.setCrc(checksumCalculator.getValue());
+ }
+
+ outputStream.putNextEntry(newEntry);
+ outputStream.write(contents);
+ outputStream.closeEntry();
+ }
+
+ /**
+ * @param destinationPath
+ * @throws IOException
+ */
+ public void writeFolder(String destinationPath) throws IOException {
+ if (!destinationPath.endsWith(JAR_FILE_SEPERATOR ))
+ destinationPath = destinationPath + JAR_FILE_SEPERATOR;
+ ZipEntry newEntry = new ZipEntry(destinationPath);
+ outputStream.putNextEntry(newEntry);
+ outputStream.closeEntry();
+ }
+
+ /**
+ * Write the passed resource to the current archive
+ *
+ * @param resource
+ * org.eclipse.core.resources.IFile
+ * @param destinationPath
+ * java.lang.String
+ * @exception java.io.IOException
+ * @exception org.eclipse.core.runtime.CoreException
+ */
+ public void write(IFile resource, String destinationPath) throws IOException, CoreException {
+ InputStream contentStream = null;
+ try {
+ contentStream = resource.getContents(false);
+ write(contentStream, destinationPath);
+ } finally {
+ if (contentStream != null)
+ contentStream.close();
+ }
+ }
+
+ /**
+ * Write the passed resource to the current archive
+ *
+ * @param resource
+ * java.io.IFile
+ * @param destinationPath
+ * java.lang.String
+ * @exception java.io.IOException
+ * @exception org.eclipse.core.runtime.CoreException
+ */
+ public void write(File resource, String destinationPath) throws IOException, CoreException {
+ InputStream contentStream = null;
+ try {
+ contentStream = new FileInputStream(resource);
+ write(contentStream, destinationPath);
+ } finally {
+ if (contentStream != null)
+ contentStream.close();
+ }
+ }
+
+ /**
+ * @param contentStream
+ * @param destinationPath
+ * @throws IOException
+ * @throws CoreException
+ */
+ public void write(InputStream contentStream, String destinationPath) throws IOException, CoreException {
+ ByteArrayOutputStream output = null;
+
+ try {
+ output = new ByteArrayOutputStream();
+ int chunkSize = contentStream.available();
+ byte[] readBuffer = new byte[chunkSize];
+ int n = contentStream.read(readBuffer);
+
+ while (n > 0) {
+ output.write(readBuffer);
+ n = contentStream.read(readBuffer);
+ }
+ } finally {
+ if (output != null)
+ output.close();
+ }
+
+ write(destinationPath, output.toByteArray());
+ }
+
+ /**
+ * pack directory relative to root
+ * @param directory
+ * @param root
+ * @throws CoreException
+ * @throws IOException
+ */
+ public void pack(File directory, String root) throws CoreException, IOException
+ {
+ File[] files = directory.listFiles();
+ for( int i = 0; i < files.length; i++ )
+ {
+ String relativeFolder = makeRelative( files[i].getAbsolutePath(), root );
+ if( files[i].isDirectory() )
+ {
+ if( relativeFolder != null )
+ {// should always be true
+ writeFolder( relativeFolder );
+ }
+ pack( files[i], root );
+ } else
+ {
+ if( relativeFolder != null )
+ {// should always be true
+ write( files[i], relativeFolder );
+ }
+ }
+ }
+
+ }
+ /**
+ * Make directoryname relative to root
+ * @param fileName
+ * @param root
+ * @return
+ */
+ private String makeRelative(String fileName, String root)
+ {
+ String folder=null;
+ if(fileName.startsWith(root))
+ {
+ folder=fileName.substring(root.length());
+ }
+ folder = folder.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (folder.length() > 0 && folder.charAt(0) == '/')
+ folder = folder.substring(1);
+ return folder;
+ }
+
+}
16 years, 8 months
JBoss Tools SVN: r3330 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-08-24 20:53:28 -0400 (Fri, 24 Aug 2007)
New Revision: 3330
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-689
Only Generic JDBC connection profiles now showed in combo on Seam Facet Wizard Page.
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-08-24 23:48:46 UTC (rev 3329)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-08-25 00:53:28 UTC (rev 3330)
@@ -348,10 +348,15 @@
}
}
- // Utils method
+ public static final String GENERIC_JDBC_PROVIDER_ID
+ = "org.eclipse.datatools.connectivity.db.generic.connectionProfile";
+
+ /*
+ *
+ */
private List<String> getProfileNameList() {
IConnectionProfile[] profiles = ProfileManager.getInstance()
- .getProfilesByCategory(ProfileSelectionComposite.JDBC_CATEGORY);
+ .getProfileByProviderID(GENERIC_JDBC_PROVIDER_ID);
List<String> names = new ArrayList<String>();
for (IConnectionProfile connectionProfile : profiles) {
names.add(connectionProfile.getName());
@@ -359,6 +364,9 @@
return names;
}
+ /**
+ *
+ */
public class EditConnectionProfileAction extends
ButtonFieldEditor.ButtonPressedAction {
@@ -369,6 +377,9 @@
super("Edit...");
}
+ /**
+ *
+ */
@Override
public void run() {
IConnectionProfile selectedProfile = ProfileManager.getInstance()
@@ -412,13 +423,6 @@
@Override
public void run() {
NewConnectionProfileWizard wizard = new NewConnectionProfileWizard() {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.datatools.connectivity.ui.wizards.NewConnectionProfileWizard#performFinish()
- */
- @Override
public boolean performFinish() {
// create profile only
try {
16 years, 8 months
JBoss Tools SVN: r3329 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-08-24 19:48:46 -0400 (Fri, 24 Aug 2007)
New Revision: 3329
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java
Log:
NPE
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java 2007-08-24 16:52:40 UTC (rev 3328)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java 2007-08-24 23:48:46 UTC (rev 3329)
@@ -41,8 +41,10 @@
public static void safeDelete(File file, IFileUtilListener listener) {
if( file.isDirectory() ) {
File[] children = file.listFiles();
- for( int i = 0; i < children.length; i++ ) {
- safeDelete(children[i], listener);
+ if( children != null ) {
+ for( int i = 0; i < children.length; i++ ) {
+ safeDelete(children[i], listener);
+ }
}
try {
boolean tmp = file.delete();
16 years, 8 months
JBoss Tools SVN: r3328 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe: editor and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-08-24 12:52:40 -0400 (Fri, 24 Aug 2007)
New Revision: 3328
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-743
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2007-08-24 15:21:26 UTC (rev 3327)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2007-08-24 16:52:40 UTC (rev 3328)
@@ -13,12 +13,14 @@
import org.eclipse.swt.graphics.Rectangle;
import org.mozilla.interfaces.nsIComponentManager;
-import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMEvent;
import org.mozilla.interfaces.nsIDOMNSHTMLElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDragService;
import org.mozilla.interfaces.nsIServiceManager;
+import org.mozilla.interfaces.nsISupportsArray;
+import org.mozilla.interfaces.nsISupportsString;
+import org.mozilla.interfaces.nsITransferable;
import org.mozilla.xpcom.Mozilla;
import org.mozilla.xpcom.XPCOMException;
@@ -29,8 +31,14 @@
*/
public class VpeDnD {
- private static final String CID_DRAGSERVICE="@mozilla.org/widget/dragservice;1";
+ private static final String CID_DRAGSERVICE = "@mozilla.org/widget/dragservice;1";
+ private static final String CID_TRANSFERABLE = "@mozilla.org/widget/transferable;1";
+ private static final String CID_SUPPORTSSTRING = "@mozilla.org/supports-string;1";
+
private static final String CID_SUPPORTSARRAY = "@mozilla.org/supports-array;1";
+
+ private static final String kVpeModelFlavor = "vpe/model";
+ private static final String kVpeModelTransport ="vpe/model";
/**
* service manager */
private nsIServiceManager serviceManager;
@@ -65,9 +73,47 @@
*/
public void startDragSession(nsIDOMEvent domEvent) {
//TODO Max Areshkau
+ nsISupportsArray transArray = (nsISupportsArray) getComponentManager()
+ .createInstanceByContractID(CID_SUPPORTSARRAY, null,
+ nsISupportsArray.NS_ISUPPORTSARRAY_IID);
+ transArray.appendElement(createTransferable());
+ getDragService().invokeDragSession((nsIDOMNode) domEvent.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID), transArray, null,
+ nsIDragService.DRAGDROP_ACTION_MOVE
+ | nsIDragService.DRAGDROP_ACTION_COPY
+ | nsIDragService.DRAGDROP_ACTION_LINK);
+
+ domEvent.stopPropagation();
+ domEvent.preventDefault();
+
}
-
+
/**
+ * Creates transferable object to start drag session
+ *
+ * @return transferable object
+ */
+ private nsITransferable createTransferable() {
+
+ nsITransferable iTransferable = (nsITransferable) componentManager
+ .createInstanceByContractID(CID_TRANSFERABLE, null,
+ nsITransferable.NS_ITRANSFERABLE_IID);
+ nsISupportsString transferData = (nsISupportsString) componentManager
+ .createInstanceByContractID(CID_SUPPORTSSTRING, null,
+ nsISupportsString.NS_ISUPPORTSSTRING_IID);
+ String data="vpe-element";
+ transferData.setData(data);
+ iTransferable.setTransferData("text/plain", transferData, data.length());
+ iTransferable.setTransferData("text/unicode", transferData,data.length()*2);
+ iTransferable.setTransferData("text/html", transferData, data.length()*2);
+ iTransferable.setTransferData("text/xml", transferData, data.length()*2);
+ iTransferable.setTransferData("text/rtf", transferData, data.length()*2);
+ iTransferable.setTransferData("text/enriched", transferData, data.length()*2);
+ iTransferable.setTransferData("text/richtext", transferData, data.length()*2);
+ iTransferable.setTransferData("text/t140", transferData, data.length()*2);
+
+ return iTransferable;
+ }
+ /**
* @return the componentManager
*/
public nsIComponentManager getComponentManager() {
@@ -98,7 +144,7 @@
public nsIDragService getDragService() {
if(dragService==null) {
- dragService = (nsIDragService) serviceManager
+ dragService = (nsIDragService) getServiceManager()
.getServiceByContractID(CID_DRAGSERVICE,
nsIDragService.NS_IDRAGSERVICE_IID);
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-08-24 15:21:26 UTC (rev 3327)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-08-24 16:52:40 UTC (rev 3328)
@@ -2468,9 +2468,9 @@
/**
* Start drag session
*/
- public void startDragSession() {
- // TODO Auto-generated method stub
+ public void startDragSession(nsIDOMEvent domEvent) {
+ visualBuilder.getDnd().startDragSession(domEvent);
}
-}
\ No newline at end of file
+}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-08-24 15:21:26 UTC (rev 3327)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-08-24 16:52:40 UTC (rev 3328)
@@ -1613,4 +1613,20 @@
pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr.getLocalName(), ns);
}
}
+
+ /**
+ * @return the dnd
+ */
+ public VpeDnD getDnd() {
+
+ return dnd;
+ }
+
+ /**
+ * @param dnd the dnd to set
+ */
+ public void setDnd(VpeDnD dnd) {
+
+ this.dnd = dnd;
+ }
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java 2007-08-24 15:21:26 UTC (rev 3327)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java 2007-08-24 16:52:40 UTC (rev 3328)
@@ -64,5 +64,5 @@
* Calls when editor content changed, and we should highlight selected element.
*/
void onRefresh();
- void startDragSession();
+ void startDragSession(nsIDOMEvent domEvent);
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-24 15:21:26 UTC (rev 3327)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-24 16:52:40 UTC (rev 3328)
@@ -373,6 +373,7 @@
boolean canDragFlag = editorDomEventListener.canInnerDrag(mouseEvent);
//TODO Max Areshkau think about using can -or not can drag if we can drag we should
//start drag session
+ editorDomEventListener.startDragSession(domEvent);
System.out.println("Can drag"+canDragFlag);
}
//TODO Max Areshkau Drag gesture event
16 years, 8 months
JBoss Tools SVN: r3327 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-08-24 11:21:26 -0400 (Fri, 24 Aug 2007)
New Revision: 3327
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
Log:
Added new URIs to support Richfaces 3.1
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2007-08-24 15:21:11 UTC (rev 3326)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2007-08-24 15:21:26 UTC (rev 3327)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<vpe:templates>
+ <vpe:template-taglib uri="http://richfaces.org/a4j" prefix="a4j" />
<vpe:template-taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j" />
<vpe:tag name="a4j:page" case-sensitive="yes">
16 years, 8 months
JBoss Tools SVN: r3326 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-08-24 11:21:11 -0400 (Fri, 24 Aug 2007)
New Revision: 3326
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
Added new URIs to support Richfaces 3.1
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-08-24 14:30:03 UTC (rev 3325)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-08-24 15:21:11 UTC (rev 3326)
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<vpe:templates>
-
- <vpe:template-taglib uri="http://richfaces.ajax4jsf.org/rich"
- prefix="rich" />
+ <vpe:template-taglib uri="http://richfaces.org/rich" prefix="rich" />
+ <vpe:template-taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich" />
+
<vpe:tag name="rich:paint2D" case-sensitive="yes">
<vpe:template children="no" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesPaint2DTemplate">
@@ -73,7 +73,6 @@
</vpe:template>
</vpe:tag>
-
<vpe:tag name="rich:treeNode" case-sensitive="yes">
<vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodeTemplate">
@@ -142,8 +141,6 @@
</vpe:template>
</vpe:tag>
-
-
<vpe:tag name="rich:separator" case-sensitive="yes">
<vpe:template children="no" modify="no"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesSeparatorTemplate">
@@ -158,7 +155,6 @@
</vpe:template>
</vpe:tag>
-
<vpe:tag name="rich:datascroller" case-sensitive="yes">
<vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesDataTableScrollerTemplate">
16 years, 8 months