JBoss Tools SVN: r8804 - trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/model/pv/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-06-17 01:27:19 -0400 (Tue, 17 Jun 2008)
New Revision: 8804
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/model/pv/test/JSFPromptingProviderTest.java
Log:
fix test errors
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/model/pv/test/JSFPromptingProviderTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/model/pv/test/JSFPromptingProviderTest.java 2008-06-17 05:25:39 UTC (rev 8803)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/model/pv/test/JSFPromptingProviderTest.java 2008-06-17 05:27:19 UTC (rev 8804)
@@ -139,7 +139,7 @@
provider.getList(model, WebPromptingProvider.JSF_BEAN_OPEN, object.toString(), null);
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
assertNotNull(editor);
- assertTrue(editor.getClass().getName().endsWith("JavaEditor"));
+ assertTrue(editor.getClass().getName().endsWith("CompilationUnitEditor"));
// TODO check that right java class opened
}
17 years, 10 months
JBoss Tools SVN: r8803 - in trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject: .settings and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-06-17 01:25:39 -0400 (Tue, 17 Jun 2008)
New Revision: 8803
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.classpath
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.settings/org.eclipse.jst.common.project.facet.core.prefs
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/web.xml
Log:
fix test errors
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.classpath
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.classpath 2008-06-16 18:29:05 UTC (rev 8802)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.classpath 2008-06-17 05:25:39 UTC (rev 8803)
@@ -3,7 +3,6 @@
<classpathentry kind="src" path="JavaSource"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
- <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss 4.2 Runtime"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-1.5.0-sun-1.5.0.15"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="WebContent/WEB-INF/classes"/>
</classpath>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.settings/org.eclipse.jst.common.project.facet.core.prefs
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.settings/org.eclipse.jst.common.project.facet.core.prefs 2008-06-16 18:29:05 UTC (rev 8802)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/.settings/org.eclipse.jst.common.project.facet.core.prefs 2008-06-17 05:25:39 UTC (rev 8803)
@@ -1,4 +1,4 @@
#Mon Jun 09 14:09:36 PDT 2008
-classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:java-1.5.0-sun-1.5.0.15/owners=jst.java\:5.0
+classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER/owners=jst.java\:5.0
classpath.helper/org.eclipse.jst.server.core.container\:\:org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget\:\:JBoss\ 4.2\ Runtime/owners=jst.web\:2.4
eclipse.preferences.version=1
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/web.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/web.xml 2008-06-16 18:29:05 UTC (rev 8802)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/web.xml 2008-06-17 05:25:39 UTC (rev 8803)
@@ -6,6 +6,10 @@
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config-1.xml</param-value>
+ </context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
17 years, 10 months
JBoss Tools SVN: r8802 - in trunk: as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-06-16 14:29:05 -0400 (Mon, 16 Jun 2008)
New Revision: 8802
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
Log:
JBIDE-2319 - also in trunk
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-06-16 18:19:03 UTC (rev 8801)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-06-16 18:29:05 UTC (rev 8802)
@@ -1,186 +1,185 @@
-/**
- * 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.as.core.modules;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.IModuleContributor;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
-
-/**
- *
- * @author Rob Stryker rob.stryker(a)jboss.com
- *
- */
-public class ArchivesModelModuleContributor implements IModuleContributor {
-
- private static ArchivesModelModuleContributor instance;
- public static ArchivesModelModuleContributor getInstance() {
- if( instance == null ) {
- instance = new ArchivesModelModuleContributor(PackageModuleFactory.getFactory());
- }
- return instance;
- }
-
- private PackageModuleFactory factory;
- protected ArrayList<IModule> modules = null;
- protected HashMap<IPath, ArrayList<IModule>> projectToModules = new HashMap<IPath, ArrayList<IModule>>(5); //IPath to IModule
- protected HashMap<IModule, Object> moduleDelegates = new HashMap<IModule, Object>(5);
- protected HashMap<IArchive, IModule> packageToModule = new HashMap<IArchive, IModule>(5);
-
- private ArchivesModelModuleContributor(PackageModuleFactory factory) {
- this.factory = factory;
- }
-
- public IModule[] getModules() {
- if( modules == null ) {
- modules = new ArrayList<IModule>();
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- int size = projects2.length;
- for (int i = 0; i < size; i++) {
- if (projects2[i].isAccessible()) {
-
- if( !ArchivesModel.instance().isProjectRegistered(projects2[i].getLocation())) {
- if( ArchivesModel.instance().canReregister(projects2[i].getLocation()))
- // registration should also add this to the factory manually, so do not create the module
- ArchivesModel.instance().registerProject(projects2[i].getLocation(), new NullProgressMonitor());
- } else {
- try {
- // project is already registered. create the module
- createModules(projects2[i]);
- } catch(ArchivesModelException ame) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ame.getMessage(), ame);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
- }
- }
- }
- return modules.toArray(new IModule[modules.size()]);
- }
-
- protected void createModules(IProject project) throws ArchivesModelException {
- IArchive[] packages = ModelUtil.getProjectArchives(project.getLocation());
- if( packages != null && packages.length > 0 ) {
- IModule module;
- boolean requiresSave = ensureArchivesHaveIDs(project, packages);
- ArrayList<IModule> mods = new ArrayList<IModule>();
- for( int i = 0; i < packages.length; i++ ) {
- module = factory.createModule2(packages[i], project);
- modules.add(module);
- Object moduleDelegate = new PackagedModuleDelegate(packages[i]);
- packageToModule.put(packages[i], module);
- moduleDelegates.put(module, moduleDelegate);
- mods.add(module);
- }
- projectToModules.put(project.getLocation(), mods);
- if( requiresSave ) {
- try {
- ArchivesModel.instance().save(project.getLocation(),
- new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
-
- }
- }
- }
- }
-
- public boolean containsModule(IModule module) {
- return moduleDelegates.containsKey(module);
- }
-
- public PackagedModuleDelegate getModuleDelegate(IModule module) {
- return (PackagedModuleDelegate)moduleDelegates.get(module);
- }
-
- public void refreshProject(IPath projectLoc) {
- // prime, make sure all are found
- if( modules == null )
- getModules();
-
- // remove old mods
- ArrayList<IModule> mods = projectToModules.get(projectLoc);
- IModule mod;
- PackagedModuleDelegate delegate;
- if (mods != null) {
- for( Iterator<IModule> i = mods.iterator(); i.hasNext();) {
- mod = (IModule)i.next();
- if( modules.contains(mod)) {
- delegate = ((PackagedModuleDelegate)moduleDelegates.get(mod));
- moduleDelegates.remove(mod);
- modules.remove(mod);
- if( delegate != null )
- packageToModule.remove(delegate.getPackage());
- }
- }
- }
- try {
- createModules(findProject(projectLoc));
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ame.getMessage(), ame);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
-
- protected IProject findProject(IPath projectLoc) {
- IProject proj = null;
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- int size = projects2.length;
- for (int i = 0; i < size; i++) {
- if( projects2[i].getLocation().equals(projectLoc))
- proj = projects2[i];
- }
- return proj;
- }
-
- /**
- * Set a property so that each module that's here in the factory
- * has a unique ID other than it's name (which is not unique)
- * @param archives
- * @return returns whether a save has occurred
- */
- protected boolean ensureArchivesHaveIDs(IProject project, IArchive[] archives) {
- boolean requiresSave = false;
- for( int i = 0; i < archives.length; i++ ) {
- if( PackageModuleFactory.getID(archives[i]) == null ) {
- requiresSave = true;
- archives[i].setProperty(PackageModuleFactory.MODULE_ID_PROPERTY_KEY,
- PackageModuleFactory.getID(archives[i], true));
- }
- }
- return requiresSave;
- }
-}
+/**
+ * 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.as.core.modules;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.IModuleContributor;
+import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
+
+/**
+ *
+ * @author Rob Stryker rob.stryker(a)jboss.com
+ *
+ */
+public class ArchivesModelModuleContributor implements IModuleContributor {
+
+ private static ArchivesModelModuleContributor instance;
+ public static ArchivesModelModuleContributor getInstance() {
+ if( instance == null ) {
+ instance = new ArchivesModelModuleContributor(PackageModuleFactory.getFactory());
+ }
+ return instance;
+ }
+
+ private PackageModuleFactory factory;
+ protected ArrayList<IModule> modules = null;
+ protected HashMap<IPath, ArrayList<IModule>> projectToModules = new HashMap<IPath, ArrayList<IModule>>(5); //IPath to IModule
+ protected HashMap<IModule, Object> moduleDelegates = new HashMap<IModule, Object>(5);
+ protected HashMap<IArchive, IModule> packageToModule = new HashMap<IArchive, IModule>(5);
+
+ private ArchivesModelModuleContributor(PackageModuleFactory factory) {
+ this.factory = factory;
+ }
+
+ public IModule[] getModules() {
+ if( modules == null ) {
+ modules = new ArrayList<IModule>();
+ IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ int size = projects2.length;
+ for (int i = 0; i < size; i++) {
+ if (projects2[i].isAccessible()) {
+
+ if( !ArchivesModel.instance().isProjectRegistered(projects2[i].getLocation())) {
+ if( ArchivesModel.instance().canReregister(projects2[i].getLocation()))
+ // registration should also add this to the factory manually, so do not create the module
+ ArchivesModel.instance().registerProject(projects2[i].getLocation(), new NullProgressMonitor());
+ } else {
+ try {
+ // project is already registered. create the module
+ createModules(projects2[i]);
+ } catch(ArchivesModelException ame) {
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ame.getMessage(), ame);
+ JBossServerCorePlugin.getDefault().getLog().log(status);
+ }
+ }
+ }
+ }
+ }
+ return modules.toArray(new IModule[modules.size()]);
+ }
+
+ protected void createModules(IProject project) throws ArchivesModelException {
+ IArchive[] packages = ModelUtil.getProjectArchives(project.getLocation());
+ if( packages != null && packages.length > 0 ) {
+ IModule module;
+ boolean requiresSave = ensureArchivesHaveIDs(project, packages);
+ ArrayList<IModule> mods = new ArrayList<IModule>();
+ for( int i = 0; i < packages.length; i++ ) {
+ module = factory.createModule2(packages[i], project);
+ modules.add(module);
+ Object moduleDelegate = new PackagedModuleDelegate(packages[i]);
+ packageToModule.put(packages[i], module);
+ moduleDelegates.put(module, moduleDelegate);
+ mods.add(module);
+ }
+ projectToModules.put(project.getLocation(), mods);
+ if( requiresSave ) {
+ try {
+ ArchivesModel.instance().save(project.getLocation(),
+ new NullProgressMonitor());
+ } catch( ArchivesModelException ame ) {
+ }
+ }
+ }
+ }
+
+ public boolean containsModule(IModule module) {
+ return moduleDelegates.containsKey(module);
+ }
+
+ public PackagedModuleDelegate getModuleDelegate(IModule module) {
+ return (PackagedModuleDelegate)moduleDelegates.get(module);
+ }
+
+ public void refreshProject(IPath projectLoc) {
+ // prime, make sure all are found
+ if( modules == null )
+ getModules();
+
+ // remove old mods
+ ArrayList<IModule> mods = projectToModules.get(projectLoc);
+ IModule mod;
+ PackagedModuleDelegate delegate;
+ if (mods != null) {
+ for( Iterator<IModule> i = mods.iterator(); i.hasNext();) {
+ mod = (IModule)i.next();
+ if( modules.contains(mod)) {
+ delegate = ((PackagedModuleDelegate)moduleDelegates.get(mod));
+ moduleDelegates.remove(mod);
+ modules.remove(mod);
+ if( delegate != null )
+ packageToModule.remove(delegate.getPackage());
+ }
+ }
+ }
+ try {
+ createModules(findProject(projectLoc));
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ame.getMessage(), ame);
+ JBossServerCorePlugin.getDefault().getLog().log(status);
+ }
+ }
+
+ protected IProject findProject(IPath projectLoc) {
+ IProject proj = null;
+ IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ int size = projects2.length;
+ for (int i = 0; i < size; i++) {
+ if( projects2[i].getLocation().equals(projectLoc))
+ proj = projects2[i];
+ }
+ return proj;
+ }
+
+ /**
+ * Set a property so that each module that's here in the factory
+ * has a unique ID other than it's name (which is not unique)
+ * @param archives
+ * @return returns whether a save has occurred
+ */
+ protected boolean ensureArchivesHaveIDs(IProject project, IArchive[] archives) {
+ boolean requiresSave = false;
+ for( int i = 0; i < archives.length; i++ ) {
+ if( PackageModuleFactory.getID(archives[i]) == null ) {
+ requiresSave = true;
+ archives[i].setProperty(PackageModuleFactory.MODULE_ID_PROPERTY_KEY,
+ PackageModuleFactory.getID(archives[i], true));
+ }
+ }
+ return requiresSave;
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java 2008-06-16 18:19:03 UTC (rev 8801)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java 2008-06-16 18:29:05 UTC (rev 8802)
@@ -27,6 +27,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
@@ -48,16 +49,7 @@
pack.setProperty(ArchivesBuildListener.DEPLOY_SERVERS, alwaysPublish ? getServers() : null);
pack.setProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD, getAutoDeploy());
final IPath p = pack.getProjectPath();
- new Job("Saving Archives Preferences") {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- ArchivesModel.instance().save(p, null);
- return Status.OK_STATUS;
- } catch( ArchivesModelException ame ) {
- return new Status(IStatus.ERROR, JBossServerUIPlugin.PLUGIN_ID, "Unable to save archive preferences", ame);
- }
- }
- }.schedule();
+ new SaveArchivesJob(p).schedule();
return true;
}
public void addPages() {
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java 2008-06-16 18:29:05 UTC (rev 8802)
@@ -0,0 +1,43 @@
+package org.jboss.ide.eclipse.archives.core.build;
+
+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.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+
+public class SaveArchivesJob extends Job {
+ private Runnable runnable;
+ private IPath projectPath;
+ public SaveArchivesJob(IPath projectPath) {
+ this(projectPath, null, null);
+ }
+ public SaveArchivesJob(IPath projectPath,Runnable runnable, String jobName) {
+ super(jobName == null ? "Save Archives Job" : jobName);
+ this.runnable = runnable;
+ this.projectPath = projectPath;
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ if( runnable != null ) {
+ try {
+ runnable.run();
+ } catch( Exception e ) {
+ IStatus status = new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID, "Problem executing pre-save runnable", e);
+ return status;
+ }
+ }
+ try {
+ ArchivesModel.instance().save(projectPath, new NullProgressMonitor());
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID, "Problem saving archives model", ame);
+ return status;
+ }
+ return Status.OK_STATUS;
+ }
+
+}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java 2008-06-16 18:19:03 UTC (rev 8801)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java 2008-06-16 18:29:05 UTC (rev 8802)
@@ -1,449 +1,405 @@
-package org.jboss.ide.eclipse.archives.ui.views;
-
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
-import org.jboss.ide.eclipse.archives.ui.NodeContribution;
-import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
-import org.jboss.ide.eclipse.archives.ui.actions.ActionWithDelegate;
-import org.jboss.ide.eclipse.archives.ui.actions.NewArchiveAction;
-import org.jboss.ide.eclipse.archives.ui.actions.NewJARAction;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider.WrappedProject;
-import org.jboss.ide.eclipse.archives.ui.wizards.FilesetWizard;
-import org.jboss.ide.eclipse.archives.ui.wizards.NewJARWizard;
-
-/**
- * Manages the actions associated with the view
- * @author rstryker
- *
- */
-public class ArchivesMenuHandler {
- public static final String NEW_PACKAGE_MENU_ID = "org.jboss.ide.eclipse.archives.ui.newPackageMenu";
- public static final String NODE_CONTEXT_MENU_ID = "org.jboss.ide.eclipse.archives.ui.nodeContextMenu";
- public static final String NEW_PACKAGE_ADDITIONS = "newPackageAdditions";
-
- private MenuManager newPackageManager, contextMenuManager;
- private NodeContribution[] nodePopupMenuContributions;
- private NewArchiveAction[] newPackageActions;
- private Menu treeContextMenu;
- private TreeViewer packageTree;
-
- private Action editAction, deleteAction, newFolderAction, newFilesetAction;
- private NewJARAction newJARAction;
- private Action buildAction;
-
- public ArchivesMenuHandler(TreeViewer viewer) {
- this.packageTree = viewer;
-
- // load from extensions
- newPackageActions = ExtensionManager.findNewArchiveActions();
- nodePopupMenuContributions = ExtensionManager.findNodePopupMenuContributions();
- Arrays.sort(nodePopupMenuContributions);
-
-
- createActions();
- createMenu();
- createContextMenu();
- addToActionBars();
- }
-
- private void addToActionBars() {
- IActionBars bars = getSite().getActionBars();
- bars.getToolBarManager().add(buildAction);
- }
-
- /**
- * Creates the primary menu as well as adds the package actions to it
- *
- */
- private void createMenu () {
- newPackageManager = new MenuManager(ArchivesUIMessages.ProjectPackagesView_newPackageMenu_label, NEW_PACKAGE_MENU_ID);
- addNewPackageActions(newPackageManager);
- newPackageManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- private void createContextMenu () {
- contextMenuManager = new MenuManager(NODE_CONTEXT_MENU_ID); //$NON-NLS-1$
- contextMenuManager.setRemoveAllWhenShown(true);
- contextMenuManager.addMenuListener(new IMenuListener () {
- public void menuAboutToShow(IMenuManager manager) {
- IStructuredSelection selection = (IStructuredSelection) packageTree.getSelection();
- if (selection != null && !selection.isEmpty()) {
- Object element = selection.getFirstElement();
-
- if (element instanceof WrappedProject) {
- newJARAction.setEnabled(true);
- manager.add(newPackageManager);
- manager.add(buildAction);
- buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildProjectAction_label);
- } else if( element instanceof IArchiveNode ){
- IArchiveNode node = (IArchiveNode)element;
-
- switch(node.getNodeType()) {
- case IArchiveNode.TYPE_ARCHIVE:
- newJARAction.setEnabled(true);
- manager.add(newPackageManager);
- manager.add(newFolderAction);
- manager.add(newFilesetAction);
- manager.add(new Separator());
- editAction.setText(ArchivesUIMessages.ProjectPackagesView_editPackageAction_label); //$NON-NLS-1$
- deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label); //$NON-NLS-1$
- editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT));
- buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildArchiveAction_label);
- manager.add(buildAction);
- break;
- case IArchiveNode.TYPE_ARCHIVE_FOLDER:
- newJARAction.setEnabled(true);
- manager.add(newPackageManager);
- manager.add(newFolderAction);
- manager.add(newFilesetAction);
- manager.add(new Separator());
- editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFolderAction_label); //$NON-NLS-1$
- deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFolderAction_label); //$NON-NLS-1$
- editAction.setImageDescriptor(platformDescriptor(ISharedImages.IMG_OBJ_FOLDER));
- break;
- case IArchiveNode.TYPE_ARCHIVE_FILESET:
- editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFilesetAction_label); //$NON-NLS-1$
- deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFilesetAction_label); //$NON-NLS-1$
- editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES));
- break;
- case IArchiveNode.TYPE_ARCHIVE_ACTION:
- editAction.setText(ArchivesUIMessages.ProjectPackagesView_editActionAction_label); //$NON-NLS-1$
- deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteActionAction_label); //$NON-NLS-1$
- //editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES));
- editAction.setImageDescriptor(null);
- break;
- default:
- // TODO unknown?
- break;
- }
- manager.add(editAction);
- manager.add(deleteAction);
- addContextMenuContributions(node);
- }
- } else {
- manager.add(newPackageManager);
- }
- }
- });
-
- treeContextMenu = contextMenuManager.createContextMenu(packageTree.getTree());
- packageTree.getTree().setMenu(treeContextMenu);
-
- getSite().registerContextMenu(NEW_PACKAGE_MENU_ID, newPackageManager, packageTree);
- }
-
- protected void createActions() {
- newJARAction = new NewJARAction();
- newJARAction.setEnabled(false);
-
- newFolderAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFolderAction_label, platformDescriptor(ISharedImages.IMG_OBJ_FOLDER)) { //$NON-NLS-1$
- public void run () {
- createFolder();
- }
- };
-
- newFilesetAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFilesetAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES)) { //$NON-NLS-1$
- public void run () {
- createFileset();
- }
- };
-
- deleteAction = new Action (ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label, platformDescriptor(ISharedImages.IMG_TOOL_DELETE)) { //$NON-NLS-1$
- public void run () {
- deleteSelectedNode();
- }
- };
-
- editAction = new Action (ArchivesUIMessages.ProjectPackagesView_editPackageAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT)) { //$NON-NLS-1$
- public void run () {
- editSelectedNode();
- }
- };
-
- buildAction = new ActionWithDelegate("", ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_BUILD_PACKAGES)) {
- public void run() {
- final Object selected = getSelectedObject();
- new Job("Build Archive Node") {
- protected IStatus run(IProgressMonitor monitor) {
- buildSelectedNode(selected);
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- public IStructuredSelection getSelection() {
- return ProjectArchivesView.getInstance().getSelection();
- }
- };
- }
-
- private void addContextMenuContributions (final IArchiveNode context) {
-
- for( int i = 0; i < nodePopupMenuContributions.length; i++ ) {
- try {
-
- final NodeContribution contribution = nodePopupMenuContributions[i];
- if ( contribution.getActionDelegate().isEnabledFor(context)) {
- Action action = new Action () {
- public String getId() {
- return contribution.getId();
- }
-
- public ImageDescriptor getImageDescriptor() {
- return contribution.getIcon();
- }
-
- public String getText() {
- return contribution.getLabel();
- }
-
- public void run() {
- contribution.getActionDelegate().run(context);
- }
- };
- contextMenuManager.add(action);
- }
- } catch( Exception e) { System.out.println(e.getMessage()); }
- }
-
- }
-
-
- /**
- * Adds the new package type actions (which come from an extension point)
- * to the menu.
- * @param manager
- */
- private void addNewPackageActions (IMenuManager manager) {
- for( int i = 0; i < newPackageActions.length; i++ ) {
- final NewArchiveAction action = newPackageActions[i];
-
- Action actionWrapper = new Action () {
- public String getId() {
- return action.getId();
- }
-
- public ImageDescriptor getImageDescriptor() {
- return action.getIconDescriptor();
- }
-
- public String getText() {
- return action.getLabel();
- }
-
- public void run() {
- action.getAction().run(this);
- }
- };
-
- manager.add(actionWrapper);
- }
- }
-
-
-
-
- /*
- * Methods below are called from the standard actions,
- * the implementations of the action, where the action does its work etc
- */
-
- private void createFolder ()
- {
- IInputValidator validator = new IInputValidator () {
- public String isValid(String newText) {
- IArchiveNode selected = getSelectedNode();
-
- boolean folderExists = false;
- IArchiveNode[] folders = selected.getChildren(IArchiveNode.TYPE_ARCHIVE_FOLDER);
- for (int i = 0; i < folders.length; i++) {
- IArchiveFolder folder = (IArchiveFolder) folders[i];
- if (folder.getName().equals(newText)) {
- folderExists = true; break;
- }
- }
-
- if (folderExists) {
- return ArchivesUIMessages.bind(
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_warnFolderExists, newText);
-
- }
- return null;
- }
- };
-
- InputDialog dialog = new InputDialog(getSite().getShell(),
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, "", validator);
-
- int response = dialog.open();
- if (response == Dialog.OK) {
- try {
- String[] folderPaths = dialog.getValue().split("[\\\\/]");
- IArchiveNode selected = getSelectedNode();
- IArchiveFolder current = null;
- IArchiveFolder temp = null;
-
- for(int i = folderPaths.length-1; i >= 0 ; i-- ) {
- temp = ArchiveNodeFactory.createFolder();
- temp.setName(folderPaths[i]);
- if( current == null )
- current = temp;
- else {
- temp.addChild(current);
- current = temp;
- }
- }
-
- selected.addChild(current);
- ArchivesModel.instance().save(selected.getProjectPath(), new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Error Attaching Archives Node", ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
- }
- }
- }
-
- private void createFileset () {
- try {
- IArchiveNode selected = getSelectedNode();
- WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(null, selected));
-
- dialog.open();
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- private void editSelectedNode () {
- IArchiveNode node = getSelectedNode();
- if (node != null) {
- if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
- IArchiveFileSet fileset = (IArchiveFileSet) node;
- WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(fileset, node.getParent()));
- try {
- dialog.open();
- } catch( Exception e ) { e.printStackTrace(); }
- } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- IArchive pkg = (IArchive) node;
- WizardDialog dialog = new WizardDialog(getSite().getShell(), new NewJARWizard(pkg));
- dialog.open();
- } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- // folder can do the model save here.
- IArchiveFolder folder = (IArchiveFolder) node;
- InputDialog dialog = new InputDialog(getSite().getShell(),
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, folder.getName(), null);
-
- int response = dialog.open();
- if (response == Dialog.OK) {
- folder.setName(dialog.getValue());
- try {
- ArchivesModel.instance().save(folder.getProjectPath(), new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Problem saving archives model", ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
- }
- }
- }
- }
- }
-
- private void buildSelectedNode(Object selected) {
- if( selected == null ) return;
- if (selected instanceof IArchiveNode &&
- ((IArchiveNode)selected).getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- new ArchiveBuildDelegate().fullArchiveBuild((IArchive)selected);
- } else if( selected != null && selected instanceof WrappedProject ){
- new ArchiveBuildDelegate().fullProjectBuild(((WrappedProject)selected).getProject().getLocation());
- } else {
- new ArchiveBuildDelegate().fullArchiveBuild(((IArchiveNode)selected).getRootArchive());
- }
-
- }
-
- private void deleteSelectedNode () {
- IArchiveNode node = getSelectedNode();
- if (node != null) {
- final IArchiveNode parent = (IArchiveNode) node.getParent();
- parent.removeChild(node);
- new Job("Delete Archives Node") {
- protected IStatus run(IProgressMonitor monitor) {
- if( parent.getProjectPath() != null ) {
- try {
- ArchivesModel.instance().save(parent.getProjectPath(), new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Problem saving archives model", ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
- }
- }
- return Status.OK_STATUS;
- }
-
- }.schedule();
- }
- }
-
-
-
- /*
- * Utility methods below
- */
-
- private IViewSite getSite() {
- return (IViewSite) ProjectArchivesView.getInstance().getSite();
- }
-
- private IArchiveNode getSelectedNode () {
- Object selected = getSelectedObject();
- if( selected instanceof IArchiveNode )
- return ((IArchiveNode)selected);
- return null;
- }
- private Object getSelectedObject() {
- IStructuredSelection selection = (IStructuredSelection) ProjectArchivesView.getInstance().getSelection();
- if (selection != null && !selection.isEmpty())
- return selection.getFirstElement();
- return null;
- }
-
- private ImageDescriptor platformDescriptor(String desc) {
- return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(desc);
- }
-
-}
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
+import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
+import org.jboss.ide.eclipse.archives.ui.NodeContribution;
+import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
+import org.jboss.ide.eclipse.archives.ui.actions.ActionWithDelegate;
+import org.jboss.ide.eclipse.archives.ui.actions.NewArchiveAction;
+import org.jboss.ide.eclipse.archives.ui.actions.NewJARAction;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider.WrappedProject;
+import org.jboss.ide.eclipse.archives.ui.wizards.FilesetWizard;
+import org.jboss.ide.eclipse.archives.ui.wizards.NewJARWizard;
+
+/**
+ * Manages the actions associated with the view
+ * @author rstryker
+ *
+ */
+public class ArchivesMenuHandler {
+ public static final String NEW_PACKAGE_MENU_ID = "org.jboss.ide.eclipse.archives.ui.newPackageMenu";
+ public static final String NODE_CONTEXT_MENU_ID = "org.jboss.ide.eclipse.archives.ui.nodeContextMenu";
+ public static final String NEW_PACKAGE_ADDITIONS = "newPackageAdditions";
+
+ private MenuManager newPackageManager, contextMenuManager;
+ private NodeContribution[] nodePopupMenuContributions;
+ private NewArchiveAction[] newPackageActions;
+ private Menu treeContextMenu;
+ private TreeViewer packageTree;
+
+ private Action editAction, deleteAction, newFolderAction, newFilesetAction;
+ private NewJARAction newJARAction;
+ private Action buildAction;
+
+ public ArchivesMenuHandler(TreeViewer viewer) {
+ this.packageTree = viewer;
+
+ // load from extensions
+ newPackageActions = ExtensionManager.findNewArchiveActions();
+ nodePopupMenuContributions = ExtensionManager.findNodePopupMenuContributions();
+ Arrays.sort(nodePopupMenuContributions);
+
+
+ createActions();
+ createMenu();
+ createContextMenu();
+ addToActionBars();
+ }
+
+ private void addToActionBars() {
+ IActionBars bars = getSite().getActionBars();
+ bars.getToolBarManager().add(buildAction);
+ }
+
+ /**
+ * Creates the primary menu as well as adds the package actions to it
+ *
+ */
+ private void createMenu () {
+ newPackageManager = new MenuManager(ArchivesUIMessages.ProjectPackagesView_newPackageMenu_label, NEW_PACKAGE_MENU_ID);
+ addNewPackageActions(newPackageManager);
+ newPackageManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void createContextMenu () {
+ contextMenuManager = new MenuManager(NODE_CONTEXT_MENU_ID); //$NON-NLS-1$
+ contextMenuManager.setRemoveAllWhenShown(true);
+ contextMenuManager.addMenuListener(new IMenuListener () {
+ public void menuAboutToShow(IMenuManager manager) {
+ IStructuredSelection selection = (IStructuredSelection) packageTree.getSelection();
+ if (selection != null && !selection.isEmpty()) {
+ Object element = selection.getFirstElement();
+
+ if (element instanceof WrappedProject) {
+ newJARAction.setEnabled(true);
+ manager.add(newPackageManager);
+ manager.add(buildAction);
+ buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildProjectAction_label);
+ } else if( element instanceof IArchiveNode ){
+ IArchiveNode node = (IArchiveNode)element;
+
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE
+ || node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER)
+ {
+ newJARAction.setEnabled(true);
+ manager.add(newPackageManager);
+
+ manager.add(newFolderAction);
+ manager.add(newFilesetAction);
+ manager.add(new Separator());
+ }
+
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ editAction.setText(ArchivesUIMessages.ProjectPackagesView_editPackageAction_label); //$NON-NLS-1$
+ deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label); //$NON-NLS-1$
+ editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT));
+ buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildArchiveAction_label);
+ manager.add(buildAction);
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+ editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFolderAction_label); //$NON-NLS-1$
+ deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFolderAction_label); //$NON-NLS-1$
+ editAction.setImageDescriptor(platformDescriptor(ISharedImages.IMG_OBJ_FOLDER));
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
+ editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFilesetAction_label); //$NON-NLS-1$
+ deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFilesetAction_label); //$NON-NLS-1$
+ editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES));
+ }
+ manager.add(editAction);
+ manager.add(deleteAction);
+ addContextMenuContributions(node);
+ }
+ } else {
+ manager.add(newPackageManager);
+ }
+ }
+ });
+
+ treeContextMenu = contextMenuManager.createContextMenu(packageTree.getTree());
+ packageTree.getTree().setMenu(treeContextMenu);
+
+ getSite().registerContextMenu(NEW_PACKAGE_MENU_ID, newPackageManager, packageTree);
+ }
+
+ protected void createActions() {
+ newJARAction = new NewJARAction();
+ newJARAction.setEnabled(false);
+
+ newFolderAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFolderAction_label, platformDescriptor(ISharedImages.IMG_OBJ_FOLDER)) { //$NON-NLS-1$
+ public void run () {
+ createFolder();
+ }
+ };
+
+ newFilesetAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFilesetAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES)) { //$NON-NLS-1$
+ public void run () {
+ createFileset();
+ }
+ };
+
+ deleteAction = new Action (ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label, platformDescriptor(ISharedImages.IMG_TOOL_DELETE)) { //$NON-NLS-1$
+ public void run () {
+ deleteSelectedNode();
+ }
+ };
+
+ editAction = new Action (ArchivesUIMessages.ProjectPackagesView_editPackageAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT)) { //$NON-NLS-1$
+ public void run () {
+ editSelectedNode();
+ }
+ };
+
+ buildAction = new ActionWithDelegate("", ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_BUILD_PACKAGES)) {
+ public void run() {
+ buildSelectedNode(getSelectedObject());
+ }
+
+ public IStructuredSelection getSelection() {
+ return ProjectArchivesView.getInstance().getSelection();
+ }
+ };
+ }
+
+ private void addContextMenuContributions (final IArchiveNode context) {
+
+ for( int i = 0; i < nodePopupMenuContributions.length; i++ ) {
+ try {
+
+ final NodeContribution contribution = nodePopupMenuContributions[i];
+ if ( contribution.getActionDelegate().isEnabledFor(context)) {
+ Action action = new Action () {
+ public String getId() {
+ return contribution.getId();
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return contribution.getIcon();
+ }
+
+ public String getText() {
+ return contribution.getLabel();
+ }
+
+ public void run() {
+ contribution.getActionDelegate().run(context);
+ }
+ };
+ contextMenuManager.add(action);
+ }
+ } catch( Exception e) {}
+ }
+
+ }
+
+
+ /**
+ * Adds the new package type actions (which come from an extension point)
+ * to the menu.
+ * @param manager
+ */
+ private void addNewPackageActions (IMenuManager manager) {
+ for( int i = 0; i < newPackageActions.length; i++ ) {
+ final NewArchiveAction action = newPackageActions[i];
+
+ Action actionWrapper = new Action () {
+ public String getId() {
+ return action.getId();
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return action.getIconDescriptor();
+ }
+
+ public String getText() {
+ return action.getLabel();
+ }
+
+ public void run() {
+ action.getAction().run(this);
+ }
+ };
+
+ manager.add(actionWrapper);
+ }
+ }
+
+
+
+
+ /*
+ * Methods below are called from the standard actions,
+ * the implementations of the action, where the action does its work etc
+ */
+
+ private void createFolder ()
+ {
+ IInputValidator validator = new IInputValidator () {
+ public String isValid(String newText) {
+ IArchiveNode selected = getSelectedNode();
+
+ boolean folderExists = false;
+ IArchiveNode[] folders = selected.getChildren(IArchiveNode.TYPE_ARCHIVE_FOLDER);
+ for (int i = 0; i < folders.length; i++) {
+ IArchiveFolder folder = (IArchiveFolder) folders[i];
+ if (folder.getName().equals(newText)) {
+ folderExists = true; break;
+ }
+ }
+
+ if (folderExists) {
+ return ArchivesUIMessages.bind(
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_warnFolderExists, newText);
+
+ }
+ return null;
+ }
+ };
+
+ InputDialog dialog = new InputDialog(getSite().getShell(),
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, "", validator);
+
+ int response = dialog.open();
+ if (response == Dialog.OK) {
+ String[] folderPaths = dialog.getValue().split("[\\\\/]");
+ IArchiveNode selected = getSelectedNode();
+ IArchiveFolder current = null;
+ IArchiveFolder temp = null;
+
+ for(int i = folderPaths.length-1; i >= 0 ; i-- ) {
+ temp = ArchiveNodeFactory.createFolder();
+ temp.setName(folderPaths[i]);
+ if( current == null )
+ current = temp;
+ else {
+ temp.addChild(current);
+ current = temp;
+ }
+ }
+
+ selected.addChild(current);
+ new SaveArchivesJob(selected.getProjectPath()).schedule();
+ }
+ }
+
+ private void createFileset () {
+ IArchiveNode selected = getSelectedNode();
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(null, selected));
+ dialog.open();
+ }
+
+ private void editSelectedNode () {
+ IArchiveNode node = getSelectedNode();
+ if (node != null) {
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
+ IArchiveFileSet fileset = (IArchiveFileSet) node;
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(fileset, node.getParent()));
+ dialog.open();
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ IArchive pkg = (IArchive) node;
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), new NewJARWizard(pkg));
+ dialog.open();
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+ // folder can do the model save here.
+ IArchiveFolder folder = (IArchiveFolder) node;
+ InputDialog dialog = new InputDialog(getSite().getShell(),
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, folder.getName(), null);
+
+ int response = dialog.open();
+ if (response == Dialog.OK) {
+ folder.setName(dialog.getValue());
+ new SaveArchivesJob(folder.getProjectPath()).schedule();
+ }
+ }
+ }
+ }
+
+ private void buildSelectedNode(final Object selected) {
+ new Job("Build Archive Node") {
+ protected IStatus run(IProgressMonitor monitor) {
+ if( selected == null ) return Status.OK_STATUS;
+ if (selected instanceof IArchiveNode &&
+ ((IArchiveNode)selected).getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ new ArchiveBuildDelegate().fullArchiveBuild((IArchive)selected);
+ } else if( selected != null && selected instanceof WrappedProject ){
+ new ArchiveBuildDelegate().fullProjectBuild(((WrappedProject)selected).getProject().getLocation());
+ } else {
+ new ArchiveBuildDelegate().fullArchiveBuild(((IArchiveNode)selected).getRootArchive());
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+
+ private void deleteSelectedNode () {
+ IArchiveNode node = getSelectedNode();
+ if (node != null) {
+ final IArchiveNode parent = (IArchiveNode) node.getParent();
+ parent.removeChild(node);
+ SaveArchivesJob job = new SaveArchivesJob(parent.getProjectPath());
+ job.schedule();
+ }
+ }
+
+ /*
+ * Utility methods below
+ */
+
+ private IViewSite getSite() {
+ return (IViewSite) ProjectArchivesView.getInstance().getSite();
+ }
+
+ private IArchiveNode getSelectedNode () {
+ Object selected = getSelectedObject();
+ if( selected instanceof IArchiveNode )
+ return ((IArchiveNode)selected);
+ return null;
+ }
+ private Object getSelectedObject() {
+ IStructuredSelection selection = (IStructuredSelection) ProjectArchivesView.getInstance().getSelection();
+ if (selection != null && !selection.isEmpty())
+ return selection.getFirstElement();
+ return null;
+ }
+
+ private ImageDescriptor platformDescriptor(String desc) {
+ return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(desc);
+ }
+
+}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2008-06-16 18:19:03 UTC (rev 8801)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2008-06-16 18:29:05 UTC (rev 8802)
@@ -82,7 +82,7 @@
if (performed) {
try {
- getContainer().run(false, false, new IRunnableWithProgress () {
+ getContainer().run(true, false, new IRunnableWithProgress () {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IArchiveNode parent = null;
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java 2008-06-16 18:19:03 UTC (rev 8801)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java 2008-06-16 18:29:05 UTC (rev 8802)
@@ -37,11 +37,11 @@
fillFilesetFromPage(fileset);
try {
- getContainer().run(false, false, new IRunnableWithProgress () {
+ getContainer().run(true, false, new IRunnableWithProgress () {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ if (createFileset)
+ parentNode.addChild(fileset);
try {
- if (createFileset)
- parentNode.addChild(fileset);
ArchivesModel.instance().save(fileset.getProjectPath(), monitor);
} catch( ArchivesModelException ame ) {
IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Error Completing Wizard", ame);
17 years, 10 months
JBoss Tools SVN: r8801 - in branches/jbosstools-2.1.x: as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-06-16 14:19:03 -0400 (Mon, 16 Jun 2008)
New Revision: 8801
Added:
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java
Modified:
branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
Log:
JBIDE-2319 - build events occurring in main thread
Modified: branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
===================================================================
--- branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-06-16 16:48:10 UTC (rev 8800)
+++ branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-06-16 18:19:03 UTC (rev 8801)
@@ -112,7 +112,6 @@
ArchivesModel.instance().save(project.getLocation(),
new NullProgressMonitor());
} catch( ArchivesModelException ame ) {
-
}
}
}
Modified: branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java
===================================================================
--- branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java 2008-06-16 16:48:10 UTC (rev 8800)
+++ branches/jbosstools-2.1.x/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java 2008-06-16 18:19:03 UTC (rev 8801)
@@ -27,6 +27,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
@@ -48,16 +49,7 @@
pack.setProperty(ArchivesBuildListener.DEPLOY_SERVERS, alwaysPublish ? getServers() : null);
pack.setProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD, getAutoDeploy());
final IPath p = pack.getProjectPath();
- new Job("Saving Archives Preferences") {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- ArchivesModel.instance().save(p, null);
- return Status.OK_STATUS;
- } catch( ArchivesModelException ame ) {
- return new Status(IStatus.ERROR, JBossServerUIPlugin.PLUGIN_ID, "Unable to save archive preferences", ame);
- }
- }
- }.schedule();
+ new SaveArchivesJob(p).schedule();
return true;
}
public void addPages() {
Added: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java (rev 0)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/SaveArchivesJob.java 2008-06-16 18:19:03 UTC (rev 8801)
@@ -0,0 +1,43 @@
+package org.jboss.ide.eclipse.archives.core.build;
+
+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.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+
+public class SaveArchivesJob extends Job {
+ private Runnable runnable;
+ private IPath projectPath;
+ public SaveArchivesJob(IPath projectPath) {
+ this(projectPath, null, null);
+ }
+ public SaveArchivesJob(IPath projectPath,Runnable runnable, String jobName) {
+ super(jobName == null ? "Save Archives Job" : jobName);
+ this.runnable = runnable;
+ this.projectPath = projectPath;
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ if( runnable != null ) {
+ try {
+ runnable.run();
+ } catch( Exception e ) {
+ IStatus status = new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID, "Problem executing pre-save runnable", e);
+ return status;
+ }
+ }
+ try {
+ ArchivesModel.instance().save(projectPath, new NullProgressMonitor());
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID, "Problem saving archives model", ame);
+ return status;
+ }
+ return Status.OK_STATUS;
+ }
+
+}
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java 2008-06-16 16:48:10 UTC (rev 8800)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java 2008-06-16 18:19:03 UTC (rev 8801)
@@ -27,6 +27,7 @@
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
@@ -185,13 +186,7 @@
buildAction = new ActionWithDelegate("", ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_BUILD_PACKAGES)) {
public void run() {
- final Object selected = getSelectedObject();
- new Job("Build Archive Node") {
- protected IStatus run(IProgressMonitor monitor) {
- buildSelectedNode(selected);
- return Status.OK_STATUS;
- }
- }.schedule();
+ buildSelectedNode(getSelectedObject());
}
public IStructuredSelection getSelection() {
@@ -226,7 +221,7 @@
};
contextMenuManager.add(action);
}
- } catch( Exception e) { System.out.println(e.getMessage()); }
+ } catch( Exception e) {}
}
}
@@ -301,41 +296,31 @@
int response = dialog.open();
if (response == Dialog.OK) {
- try {
- String[] folderPaths = dialog.getValue().split("[\\\\/]");
- IArchiveNode selected = getSelectedNode();
- IArchiveFolder current = null;
- IArchiveFolder temp = null;
-
- for(int i = folderPaths.length-1; i >= 0 ; i-- ) {
- temp = ArchiveNodeFactory.createFolder();
- temp.setName(folderPaths[i]);
- if( current == null )
- current = temp;
- else {
- temp.addChild(current);
- current = temp;
- }
+ String[] folderPaths = dialog.getValue().split("[\\\\/]");
+ IArchiveNode selected = getSelectedNode();
+ IArchiveFolder current = null;
+ IArchiveFolder temp = null;
+
+ for(int i = folderPaths.length-1; i >= 0 ; i-- ) {
+ temp = ArchiveNodeFactory.createFolder();
+ temp.setName(folderPaths[i]);
+ if( current == null )
+ current = temp;
+ else {
+ temp.addChild(current);
+ current = temp;
}
-
- selected.addChild(current);
- ArchivesModel.instance().save(selected.getProjectPath(), new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Error Attaching Archives Node", ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
}
+
+ selected.addChild(current);
+ new SaveArchivesJob(selected.getProjectPath()).schedule();
}
}
private void createFileset () {
- try {
- IArchiveNode selected = getSelectedNode();
- WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(null, selected));
-
- dialog.open();
- } catch( Exception e ) {
- e.printStackTrace();
- }
+ IArchiveNode selected = getSelectedNode();
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(null, selected));
+ dialog.open();
}
private void editSelectedNode () {
@@ -344,9 +329,7 @@
if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
IArchiveFileSet fileset = (IArchiveFileSet) node;
WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(fileset, node.getParent()));
- try {
- dialog.open();
- } catch( Exception e ) { e.printStackTrace(); }
+ dialog.open();
} else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
IArchive pkg = (IArchive) node;
WizardDialog dialog = new WizardDialog(getSite().getShell(), new NewJARWizard(pkg));
@@ -355,34 +338,33 @@
// folder can do the model save here.
IArchiveFolder folder = (IArchiveFolder) node;
InputDialog dialog = new InputDialog(getSite().getShell(),
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, folder.getName(), null);
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, folder.getName(), null);
int response = dialog.open();
if (response == Dialog.OK) {
folder.setName(dialog.getValue());
- try {
- ArchivesModel.instance().save(folder.getProjectPath(), new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Problem saving archives model", ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
- }
+ new SaveArchivesJob(folder.getProjectPath()).schedule();
}
}
}
}
- private void buildSelectedNode(Object selected) {
- if( selected == null ) return;
- if (selected instanceof IArchiveNode &&
- ((IArchiveNode)selected).getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- new ArchiveBuildDelegate().fullArchiveBuild((IArchive)selected);
- } else if( selected != null && selected instanceof WrappedProject ){
- new ArchiveBuildDelegate().fullProjectBuild(((WrappedProject)selected).getProject().getLocation());
- } else {
- new ArchiveBuildDelegate().fullArchiveBuild(((IArchiveNode)selected).getRootArchive());
- }
-
+ private void buildSelectedNode(final Object selected) {
+ new Job("Build Archive Node") {
+ protected IStatus run(IProgressMonitor monitor) {
+ if( selected == null ) return Status.OK_STATUS;
+ if (selected instanceof IArchiveNode &&
+ ((IArchiveNode)selected).getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ new ArchiveBuildDelegate().fullArchiveBuild((IArchive)selected);
+ } else if( selected != null && selected instanceof WrappedProject ){
+ new ArchiveBuildDelegate().fullProjectBuild(((WrappedProject)selected).getProject().getLocation());
+ } else {
+ new ArchiveBuildDelegate().fullArchiveBuild(((IArchiveNode)selected).getRootArchive());
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
}
private void deleteSelectedNode () {
@@ -390,25 +372,11 @@
if (node != null) {
final IArchiveNode parent = (IArchiveNode) node.getParent();
parent.removeChild(node);
- new Job("Delete Archives Node") {
- protected IStatus run(IProgressMonitor monitor) {
- if( parent.getProjectPath() != null ) {
- try {
- ArchivesModel.instance().save(parent.getProjectPath(), new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Problem saving archives model", ame);
- PackagesUIPlugin.getDefault().getLog().log(status);
- }
- }
- return Status.OK_STATUS;
- }
-
- }.schedule();
+ SaveArchivesJob job = new SaveArchivesJob(parent.getProjectPath());
+ job.schedule();
}
}
-
-
/*
* Utility methods below
*/
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2008-06-16 16:48:10 UTC (rev 8800)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2008-06-16 18:19:03 UTC (rev 8801)
@@ -82,7 +82,7 @@
if (performed) {
try {
- getContainer().run(false, false, new IRunnableWithProgress () {
+ getContainer().run(true, false, new IRunnableWithProgress () {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IArchiveNode parent = null;
Modified: branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
===================================================================
--- branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java 2008-06-16 16:48:10 UTC (rev 8800)
+++ branches/jbosstools-2.1.x/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java 2008-06-16 18:19:03 UTC (rev 8801)
@@ -37,11 +37,11 @@
fillFilesetFromPage(fileset);
try {
- getContainer().run(false, false, new IRunnableWithProgress () {
+ getContainer().run(true, false, new IRunnableWithProgress () {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ if (createFileset)
+ parentNode.addChild(fileset);
try {
- if (createFileset)
- parentNode.addChild(fileset);
ArchivesModel.instance().save(fileset.getProjectPath(), monitor);
} catch( ArchivesModelException ame ) {
IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Error Completing Wizard", ame);
17 years, 10 months
JBoss Tools SVN: r8800 - branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-06-16 12:48:10 -0400 (Mon, 16 Jun 2008)
New Revision: 8800
Modified:
branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
Log:
Fix http://jira.jboss.com/jira/browse/JBIDE-2277 in branch.
Modified: branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
===================================================================
--- branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-06-16 16:47:36 UTC (rev 8799)
+++ branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-06-16 16:48:10 UTC (rev 8800)
@@ -14,7 +14,6 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
@@ -86,11 +85,11 @@
}
- protected void checkProposals(String fileName, int offset, String[] proposals, boolean exactly){
- checkProposals(fileName, null, offset, proposals, exactly);
+ protected ICompletionProposal[] checkProposals(String fileName, int offset, String[] proposals, boolean exactly){
+ return checkProposals(fileName, null, offset, proposals, exactly);
}
- protected void checkProposals(String fileName, String substring, int offset, String[] proposals, boolean exactly){
+ protected ICompletionProposal[] checkProposals(String fileName, String substring, int offset, String[] proposals, boolean exactly){
openEditor(fileName);
int position = 0;
@@ -122,6 +121,7 @@
if(exactly)
assertTrue("Some other proposals was found!", result.length == proposals.length);
+ return result;
}
protected boolean compareProposal(String proposalName, ICompletionProposal[] proposals){
17 years, 10 months
JBoss Tools SVN: r8799 - in branches/jbosstools-2.1.x: seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/WebContent and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-06-16 12:47:36 -0400 (Mon, 16 Jun 2008)
New Revision: 8799
Added:
branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java
branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/WebContent/jbide2277/
branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/WebContent/jbide2277/jbide2277.xhtml
branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/jbide/
branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/jbide/JBide2277Test.java
Log:
Fix http://jira.jboss.com/jira/browse/JBIDE-2277 in branch.
Added: branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java
===================================================================
--- branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java (rev 0)
+++ branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java 2008-06-16 16:47:36 UTC (rev 8799)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+
+package org.jboss.tools.jst.jsp.test.ca;
+
+
+import org.eclipse.core.resources.IResource;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+
+
+/**
+ * Abstract class contains of common methods.
+ *
+ * @author Eugene Stherbin
+ *
+ */
+public abstract class CommonContentAssistantTestCase extends ContentAssistantTestCase {
+ /** The make copy. */
+ protected boolean makeCopy;
+
+ /** The provider. */
+ protected TestProjectProvider provider;
+
+ protected abstract String getSetUpProjectName();
+
+ @Override
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.tools.seam.ui.test", null, getSetUpProjectName(), makeCopy);
+ project = provider.getProject();
+ Throwable exception = null;
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (Exception x) {
+ exception = x;
+ x.printStackTrace();
+ }
+ assertNull("An exception caught: " + (exception != null ? exception.getMessage() : ""), exception);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ if (provider != null) {
+ provider.dispose();
+ }
+ }
+}
Property changes on: branches/jbosstools-2.1.x/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/WebContent/jbide2277/jbide2277.xhtml
===================================================================
--- branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/WebContent/jbide2277/jbide2277.xhtml (rev 0)
+++ branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/WebContent/jbide2277/jbide2277.xhtml 2008-06-16 16:47:36 UTC (rev 8799)
@@ -0,0 +1,12 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.ajax4jsf.org/rich"
+ template="layout/template.xhtml">
+<ui:define name="body">
+ <h:outputText value=""/>
+</ui:define>
+</ui:composition>
Property changes on: branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/projects/TestSeamELContentAssist/WebContent/jbide2277/jbide2277.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/html
Name: svn:eol-style
+ native
Added: branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/jbide/JBide2277Test.java
===================================================================
--- branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/jbide/JBide2277Test.java (rev 0)
+++ branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/jbide/JBide2277Test.java 2008-06-16 16:47:36 UTC (rev 8799)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.test.jbide;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.jboss.tools.jst.jsp.test.ca.CommonContentAssistantTestCase;
+import org.jboss.tools.seam.ui.text.java.SeamELProposalProcessor;
+
+/**
+ * @author Eugene Stherbin
+ *
+ */
+public class JBide2277Test extends CommonContentAssistantTestCase {
+ protected static final String JBIDE_2277_PAGE="/WebContent/jbide2277/jbide2277.xhtml";
+
+ public static Test suite() {
+ return new TestSuite(JBide2277Test.class);
+ }
+
+ /**
+ * @see org.jboss.tools.jst.jsp.test.ca.CommonContentAssistantTestCase#getSetUpProjectName()
+ */
+ @Override
+ protected String getSetUpProjectName() {
+ return "TestSeamELContentAssist";
+ }
+
+ public void testJbide2227(){
+ final String[] proposals = new String[]{};
+ final ICompletionProposal[] rst = checkProposals(JBIDE_2277_PAGE,574, proposals, false);
+
+ checkResult(rst);
+ }
+
+ /**
+ * @param rst
+ */
+ private void checkResult(ICompletionProposal[] rst) {
+ assertTrue(rst.length > 5);
+ String prevDisplay = "";
+ for (ICompletionProposal p : rst) {
+ //Check stars with #{
+ assertTrue(p.getDisplayString().startsWith(SeamELProposalProcessor.EL_START_EXPRESSION));
+
+ //Check alphabetical order
+
+
+ }
+
+
+ }
+
+
+}
Property changes on: branches/jbosstools-2.1.x/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/jbide/JBide2277Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
17 years, 10 months
JBoss Tools SVN: r8798 - branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-06-16 11:54:10 -0400 (Mon, 16 Jun 2008)
New Revision: 8798
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
Log:
Fix http://jira.jboss.com/jira/browse/JBIDE-2277 issue
Modified: branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
===================================================================
--- branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2008-06-16 14:10:56 UTC (rev 8797)
+++ branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2008-06-16 15:54:10 UTC (rev 8798)
@@ -18,11 +18,13 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension4;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
@@ -30,6 +32,7 @@
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension3;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension4;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension5;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.swt.graphics.Image;
@@ -59,6 +62,7 @@
import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.w3c.dom.Node;
+import org.w3c.tidy.AttrCheckImpl.CheckBool;
/**
* Content assist proposal processor.
@@ -68,434 +72,524 @@
*/
public class SeamELProposalProcessor extends AbstractContentAssistProcessor {
- private static final ICompletionProposal[] NO_PROPOSALS= new ICompletionProposal[0];
- private static final IContextInformation[] NO_CONTEXTS= new IContextInformation[0];
+ private static final ICompletionProposal[] NO_PROPOSALS= new ICompletionProposal[0];
+ private static final IContextInformation[] NO_CONTEXTS= new IContextInformation[0];
+ public static final String EL_END_EXPRESSION = "}";
+ public static final String EL_START_EXPRESSION = "#{";
+
+ public static final class Proposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3, ICompletionProposalExtension4,ICompletionProposalExtension5{
- public static final class Proposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3, ICompletionProposalExtension4 {
+ private final String fString;
+ private final String fPrefix;
+ private final String fNewPrefix;
+ private final int fOffset;
+ private int fNewPosition;
+ private final String fDisplaySuffix;
+ private final String fDisplayPrefix;
- private final String fString;
- private final String fPrefix;
- private final String fNewPrefix;
- private final int fOffset;
- private int fNewPosition;
+// public Proposal(String string, String prefix, int offset) {
+// this(string, prefix, offset, offset + string.length());
+// }
+// public Proposal(String string, String prefix, int offset, String fDisplayPrefix,String fDisplaySuffix) {
+// this(string, prefix, offset, offset + string.length());
+// }
+//
+
+ public Proposal(String string, String prefix, int offset, int newPosition,String fDisplayPrefix,String fDisplaySuffix) {
+ this(string, prefix, prefix, offset, offset + string.length(),fDisplayPrefix,fDisplaySuffix);
+ }
- public Proposal(String string, String prefix, int offset) {
- this(string, prefix, offset, offset + string.length());
- }
+ public Proposal(String string, String prefix, String newPrefix, int offset, int newPosition,String fDisplayPrefix,String fDisplaySuffix) {
+ fString = string;
+ fPrefix = prefix;
+ fNewPrefix = newPrefix;
+ fOffset = offset;
+ fNewPosition = newPosition;
+ this.fDisplayPrefix = fDisplayPrefix;
+ this.fDisplaySuffix = fDisplaySuffix;
+ }
- public Proposal(String string, String prefix, int offset, int newPosition) {
- this(string, prefix, prefix, offset, offset + string.length());
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(IDocument)
+ */
+ public void apply(IDocument document) {
+ apply(null, '\0', 0, fOffset);
+ }
- public Proposal(String string, String prefix, String newPrefix, int offset, int newPosition) {
- fString = string;
- fPrefix = prefix;
- fNewPrefix = newPrefix;
- fOffset = offset;
- fNewPosition = newPosition;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(IDocument)
+ */
+ public Point getSelection(IDocument document) {
+ int position = fNewPosition;
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2277
+ if(isStartsWithEl()){
+ position+=EL_START_EXPRESSION.length();
+ }
+ return new Point(position, 0);
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(IDocument)
- */
- public void apply(IDocument document) {
- apply(null, '\0', 0, fOffset);
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ return null;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fNewPosition, 0);
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+ */
+ public String getDisplayString() {
+ final StringBuffer sb = new StringBuffer();
+
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2277
+ if((this.fDisplayPrefix.length() > 0) && (this.fDisplaySuffix.length() > 0)){
+ sb.append(fDisplayPrefix+fPrefix+fString+fDisplaySuffix);
+ }else{
+ sb.append((fNewPrefix == null ? fPrefix : fNewPrefix) + fString);
+ }
+ return sb.toString();
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return null;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+ */
+ public Image getImage() {
+ return SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE);
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return (fNewPrefix == null ? fPrefix : fNewPrefix) + fString;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+ */
+ public IContextInformation getContextInformation() {
+ return null;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- return SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE);
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#apply(IDocument, char, int)
+ */
+ public void apply(IDocument document, char trigger, int offset) {
+ try {
+ int docCharsToReplace = (fNewPrefix == null || fPrefix == null) ? 0 : fPrefix.length() - fNewPrefix.length();
+ String replacement = fString.substring(offset - fOffset);
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2277
+ if (isStartsWithEl()) {
+ replacement = EL_START_EXPRESSION + fPrefix + fString + EL_END_EXPRESSION;
+ if (document instanceof IDocumentExtension4) {
+ ((IDocumentExtension4) document).replace(offset - fPrefix.length(), getRemovedLength(offset,document,fPrefix.length()), "",
+ ((IDocumentExtension4) document).getModificationStamp());
+ }
+ document.replace(offset - fPrefix.length(), 0, replacement);
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
+ } else {
+ document.replace(offset - docCharsToReplace, docCharsToReplace, replacement);
+ }
+ } catch (BadLocationException x) {
+ SeamGuiPlugin.getPluginLog().logError(x);
+ }
+ }
+
+ /**
+ * @param document
+ * @param length
+ * @return
+ */
+ private int getRemovedLength(int offset,IDocument document, int length) {
+ int len = length;
+// int _offset = offset;
+// while(document.getChar(offset))
+ return len;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#apply(IDocument, char, int)
- */
- public void apply(IDocument document, char trigger, int offset) {
- try {
- int docCharsToReplace = (fNewPrefix == null || fPrefix == null) ? 0 :
- fPrefix.length() - fNewPrefix.length();
- String replacement= fString.substring(offset - fOffset);
- document.replace(offset - docCharsToReplace, docCharsToReplace, replacement);
- } catch (BadLocationException x) {
- SeamGuiPlugin.getPluginLog().logError(x);
- }
- }
+ protected boolean isStartsWithEl(){
+ return ((this.fDisplayPrefix.length() > 0) && (this.fDisplaySuffix.length() > 0));
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#isValidFor(IDocument, int)
- */
- public boolean isValidFor(IDocument document, int offset) {
- return validate(document, offset, null);
- }
+ /**
+ * @param document
+ * @param offset
+ * @return
+ */
+ private int getBeginOffset(IDocument document, int offset) {
+ int _offset = offset;
+ while(_offset-- > 0){
+ try {
+ if ('"' == document.getChar(offset) || '\'' == document.getChar(offset)) {
+ return _offset;
+ }
+ } catch (BadLocationException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ }
+ }
+ return 0;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getTriggerCharacters()
- */
- public char[] getTriggerCharacters() {
- return null;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#isValidFor(IDocument, int)
+ */
+ public boolean isValidFor(IDocument document, int offset) {
+ return validate(document, offset, null);
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getContextInformationPosition()
- */
- public int getContextInformationPosition() {
- return 0;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getTriggerCharacters()
+ */
+ public char[] getTriggerCharacters() {
+ return null;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(ITextViewer, char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- apply(viewer.getDocument(), trigger, offset);
-
- if (fString != null && fString.endsWith("}")) {
- fNewPosition -= 1;
- }
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getContextInformationPosition()
+ */
+ public int getContextInformationPosition() {
+ return 0;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(ITextViewer, boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(ITextViewer, char, int, int)
+ */
+ public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+ apply(viewer.getDocument(), trigger, offset);
+ if (fString != null && fString.endsWith(EL_END_EXPRESSION)) {
+ fNewPosition -= 1;
+ }
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(ITextViewer, boolean)
+ */
+ public void selected(ITextViewer viewer, boolean smartToggle) {
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(IDocument document, int offset, DocumentEvent event)
- */
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
- try {
- int prefixStart= fOffset - fPrefix.length();
- return offset >= fOffset && offset < fOffset + fString.length() && document.get(prefixStart, offset - (prefixStart)).equals((fPrefix + fString).substring(0, offset - prefixStart));
- } catch (BadLocationException x) {
- return false;
- }
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(ITextViewer)
+ */
+ public void unselected(ITextViewer viewer) {
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator()
- */
- public IInformationControlCreator getInformationControlCreator() {
- return null;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(IDocument document, int offset, DocumentEvent event)
+ */
+ public boolean validate(IDocument document, int offset, DocumentEvent event) {
+ try {
+ int prefixStart= fOffset - fPrefix.length();
+ return offset >= fOffset && offset < fOffset + fString.length() && document.get(prefixStart, offset - (prefixStart)).equals((fPrefix + fString).substring(0, offset - prefixStart));
+ } catch (BadLocationException x) {
+ return false;
+ }
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getPrefixCompletionText(IDocument, int)
- */
- public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
- return fPrefix + fString;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator()
+ */
+ public IInformationControlCreator getInformationControlCreator() {
+ return null;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getPrefixCompletionStart(IDocument, int)
- */
- public int getPrefixCompletionStart(IDocument document, int completionOffset) {
- return fOffset - fPrefix.length();
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getPrefixCompletionText(IDocument, int)
+ */
+ public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
+ return fPrefix + fString;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension4#isAutoInsertable()
- */
- public boolean isAutoInsertable() {
- return false;
- }
-
- /**
- * Return cursor position of proposal replacement string.
- */
- public int getCursorPosition() {
- return fNewPosition;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getPrefixCompletionStart(IDocument, int)
+ */
+ public int getPrefixCompletionStart(IDocument document, int completionOffset) {
+ return fOffset - fPrefix.length();
+ }
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension4#isAutoInsertable()
+ */
+ public boolean isAutoInsertable() {
+ return false;
+ }
+
+ /**
+ * Return cursor position of proposal replacement string.
+ */
+ public int getCursorPosition() {
+ return fNewPosition;
+ }
- private final SeamELCompletionEngine fEngine= new SeamELCompletionEngine();
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension5#getAdditionalProposalInfo(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- /**
- * Creates a new Seam EL completion proposal computer.
- */
- public SeamELProposalProcessor() {
- }
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- try {
- ITextEditor part = getActiveEditor();
- if (part == null) {
- return NO_PROPOSALS;
- }
+ private final SeamELCompletionEngine fEngine= new SeamELCompletionEngine();
- IEditorInput editorInput = part.getEditorInput();
- if (!(editorInput instanceof IFileEditorInput)) {
- return NO_PROPOSALS;
- }
+ /**
+ * Creates a new Seam EL completion proposal computer.
+ */
+ public SeamELProposalProcessor() {
+ }
- IFile file = ((IFileEditorInput)editorInput).getFile();
- IProject project = (file == null ? null : file.getProject());
+ /*
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
+ */
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ try {
+ ITextEditor part = getActiveEditor();
+ if (part == null) {
+ return NO_PROPOSALS;
+ }
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
- if (seamProject == null) {
- return NO_PROPOSALS;
- }
+ IEditorInput editorInput = part.getEditorInput();
+ if (!(editorInput instanceof IFileEditorInput)) {
+ return NO_PROPOSALS;
+ }
- String prefix= SeamELCompletionEngine.getPrefix(viewer, offset);
- prefix = (prefix == null ? "" : prefix); //$NON-NLS-1$
+ IFile file = ((IFileEditorInput)editorInput).getFile();
+ IProject project = (file == null ? null : file.getProject());
- String proposalPrefix = "";
- String proposalSufix = "";
- String documentContent = null;
- IDocument document = viewer.getDocument();
- if (!checkStartPositionInEL(viewer, offset)) {
- // Work only with attribute value for JSP/HTML
- if((part instanceof XMLTextEditor) || (!isAttributeValue(viewer, offset))) {
- return NO_PROPOSALS;
- }
- prefix = ""; // Clear prefix because it's not the part of EL
- if(isCharSharp(viewer, offset-1)) {
- proposalPrefix = "{"; //$NON-NLS-1$
- } else {
- proposalPrefix = "#{"; //$NON-NLS-1$
- }
-
- if(document != null) {
- documentContent = document.get(0,offset) + proposalPrefix + document.get(offset, document.getLength() - offset);
- }
-
- proposalSufix = "}"; //$NON-NLS-1$
- } else {
- if(viewer.getDocument() != null) {
- documentContent = document.get();
- }
- }
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
+ if (seamProject == null) {
+ return NO_PROPOSALS;
+ }
- List<ElVarSearcher.Var> vars = ElVarSearcher.findAllVars(viewer, offset);
- List<String> suggestions = fEngine.getCompletions(seamProject, file, documentContent, prefix, offset + proposalPrefix.length() - prefix.length(), false, vars);
- List<String> uniqueSuggestions = fEngine.makeUnique(suggestions);
+ String prefix= SeamELCompletionEngine.getPrefix(viewer, offset);
+ prefix = (prefix == null ? "" : prefix); //$NON-NLS-1$
- List<ICompletionProposal> result= new ArrayList<ICompletionProposal>();
- for (String string : uniqueSuggestions) {
- if (string.length() >= 0) {
- string = proposalPrefix + string + proposalSufix;
- if (string.startsWith("['") && string.endsWith("']") && prefix != null && prefix.endsWith(".")) {
- String newPrefix = prefix.substring(0, prefix.length() - 1);
- result.add(new Proposal(string, prefix, newPrefix, offset, offset - 1 + string.length() - proposalSufix.length()));
- } else {
- result.add(new Proposal(string, prefix, offset, offset + string.length() - proposalSufix.length()));
- }
- }
- }
+ String proposalPrefix = "";
+ String proposalSufix = "";
+ String documentContent = null;
+ IDocument document = viewer.getDocument();
+ if (!checkStartPositionInEL(viewer, offset,true)) {
+ // Work only with attribute value for JSP/HTML
+ if((part instanceof XMLTextEditor) || (!isAttributeValue(viewer, offset))) {
+ return NO_PROPOSALS;
+ }
+ prefix = ""; // Clear prefix because it's not the part of EL
+ if(isCharSharp(viewer, offset-1)) {
+ proposalPrefix = "{"; //$NON-NLS-1$
+ } else {
+ proposalPrefix = "#{"; //$NON-NLS-1$
+ }
+
+ if(document != null) {
+ documentContent = document.get(0,offset) + proposalPrefix + document.get(offset, document.getLength() - offset);
+ }
+
+ proposalSufix = "}"; //$NON-NLS-1$
+ } else {
+ if(viewer.getDocument() != null) {
+ documentContent = document.get();
+ }
+ }
- if (result == null || result.size() == 0) {
- return NO_PROPOSALS;
- }
- ICompletionProposal[] resultArray = result.toArray(new ICompletionProposal[result.size()]);
- Arrays.sort(resultArray, new Comparator<ICompletionProposal>() {
- public int compare(ICompletionProposal arg0,
- ICompletionProposal arg1) {
- String str0 = (arg0 == null ? "" : arg0.getDisplayString()); //$NON-NLS-1$
- String str1 = (arg1 == null ? "" : arg1.getDisplayString()); //$NON-NLS-1$
- return str0.compareTo(str1);
- }});
- return resultArray;
- } catch (BadLocationException x) {
- SeamGuiPlugin.getPluginLog().logError(x);
- return NO_PROPOSALS;
- } catch (StringIndexOutOfBoundsException e) {
- SeamGuiPlugin.getPluginLog().logError(e);
- return NO_PROPOSALS;
- }
- }
+ List<ElVarSearcher.Var> vars = ElVarSearcher.findAllVars(viewer, offset);
+ List<String> suggestions = fEngine.getCompletions(seamProject, file, documentContent, prefix, offset + proposalPrefix.length() - prefix.length(), false, vars);
+ List<String> uniqueSuggestions = fEngine.makeUnique(suggestions);
- private boolean isAttributeValue(ITextViewer viewer, int offset) {
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(viewer, offset);
+ List<ICompletionProposal> result= new ArrayList<ICompletionProposal>();
+ for (String string : uniqueSuggestions) {
+
+ if (string.length() >= 0) {
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2277
+ string = proposalPrefix + string + proposalSufix;
+ String elDisplaySuffix ="";
+ String elDisplayPrefix ="";
+ if(!checkStartPositionInEL(viewer, offset,false) && !string.endsWith(".")){
+ elDisplaySuffix="}";
+ elDisplayPrefix="#{";
+ }
+ if (string.startsWith("['") && string.endsWith("']") && prefix != null && prefix.endsWith(".")) {
+ String newPrefix = prefix.substring(0, prefix.length() - 1);
+ result.add(new Proposal(string, prefix, newPrefix, offset, (offset - 1 + string.length() - proposalSufix.length()),elDisplayPrefix,elDisplaySuffix));
+ } else {
+ result.add(new Proposal(string, prefix, offset, offset + string.length() - proposalSufix.length(),elDisplayPrefix,elDisplaySuffix));
+ }
+ }
+ }
- if(treeNode instanceof Node) {
- Node node = (Node) treeNode;
- while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) {
- node = node.getParentNode();
- }
- if(node instanceof IDOMNode) {
- IDOMNode xmlnode = (IDOMNode) node;
- ITextRegion completionRegion = getCompletionRegion(offset, node);
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE != completionRegion.getType())
- return false;
- ITextRegion nextRegion = getCompletionRegion(offset + 1, node);
- return DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE == nextRegion.getType();
- }
- }
- return false;
- }
+ if (result == null || result.size() == 0) {
+ return NO_PROPOSALS;
+ }
+ ICompletionProposal[] resultArray = result.toArray(new ICompletionProposal[result.size()]);
+ Arrays.sort(resultArray, new Comparator<ICompletionProposal>() {
+ public int compare(ICompletionProposal arg0,
+ ICompletionProposal arg1) {
+ String str0 = (arg0 == null ? "" : arg0.getDisplayString()); //$NON-NLS-1$
+ String str1 = (arg1 == null ? "" : arg1.getDisplayString()); //$NON-NLS-1$
+ return str0.compareTo(str1);
+ }});
+ return resultArray;
+ } catch (BadLocationException x) {
+ SeamGuiPlugin.getPluginLog().logError(x);
+ return NO_PROPOSALS;
+ } catch (StringIndexOutOfBoundsException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ return NO_PROPOSALS;
+ }
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
- // no context informations for Seam EL completions
- return NO_CONTEXTS;
- }
-
- private char[] autoActivChars;
+ private boolean isAttributeValue(ITextViewer viewer, int offset) {
+ IndexedRegion treeNode = ContentAssistUtils.getNodeAt(viewer, offset);
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- if(autoActivChars==null) {
- IPreferenceStore store= EditorsUI.getPreferenceStore();
- String superDefaultChars = store.getDefaultString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
- StringBuffer redhatDefaultChars = new StringBuffer(superDefaultChars);
- if(superDefaultChars.indexOf("{")<0) { //$NON-NLS-1$
- redhatDefaultChars.append('{');
- }
- if(superDefaultChars.indexOf(".")<0) { //$NON-NLS-1$
- redhatDefaultChars.append('.');
- }
- autoActivChars = new char[redhatDefaultChars.length()];
- redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
- store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, redhatDefaultChars.toString());
- store.setValue(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, redhatDefaultChars.toString());
- }
- return autoActivChars;
- }
+ if(treeNode instanceof Node) {
+ Node node = (Node) treeNode;
+ while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) {
+ node = node.getParentNode();
+ }
+ if(node instanceof IDOMNode) {
+ IDOMNode xmlnode = (IDOMNode) node;
+ ITextRegion completionRegion = getCompletionRegion(offset, node);
+ if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE != completionRegion.getType())
+ return false;
+ ITextRegion nextRegion = getCompletionRegion(offset + 1, node);
+ return DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE == nextRegion.getType();
+ }
+ }
+ return false;
+ }
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
+ */
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ // no context informations for Seam EL completions
+ return NO_CONTEXTS;
+ }
+
+ private char[] autoActivChars;
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#getErrorMessage()
- */
- public String getErrorMessage() {
- return null; // no custom error message
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
+ */
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ if(autoActivChars==null) {
+ IPreferenceStore store= EditorsUI.getPreferenceStore();
+ String superDefaultChars = store.getDefaultString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
+ StringBuffer redhatDefaultChars = new StringBuffer(superDefaultChars);
+ if(superDefaultChars.indexOf("{")<0) { //$NON-NLS-1$
+ redhatDefaultChars.append('{');
+ }
+ if(superDefaultChars.indexOf(".")<0) { //$NON-NLS-1$
+ redhatDefaultChars.append('.');
+ }
+ autoActivChars = new char[redhatDefaultChars.length()];
+ redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, redhatDefaultChars.toString());
+ store.setValue(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, redhatDefaultChars.toString());
+ }
+ return autoActivChars;
+ }
- /*
- * Returns active text editor
- * @return
- */
- private ITextEditor getActiveEditor() {
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page= window.getActivePage();
- if (page != null) {
- IEditorPart editor= page.getActiveEditor();
- if (editor instanceof IEditorWrapper)
- editor = ((IEditorWrapper) editor).getEditor();
-
- if (editor instanceof ITextEditor)
- return (ITextEditor) editor;
- else
- return (ITextEditor)editor.getAdapter(ITextEditor.class);
- }
- }
- return null;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
+ */
+ public char[] getContextInformationAutoActivationCharacters() {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
+ */
+ public IContextInformationValidator getContextInformationValidator() {
+ return null;
+ }
- private boolean isCharSharp(ITextViewer viewer, int offset) throws BadLocationException {
- IDocument doc= viewer.getDocument();
- if (doc == null || offset > doc.getLength() || offset < 0) {
- return false;
- }
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return null; // no custom error message
+ }
- return '#' == doc.getChar(offset);
- }
+ /*
+ * Returns active text editor
+ * @return
+ */
+ private ITextEditor getActiveEditor() {
+ IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page= window.getActivePage();
+ if (page != null) {
+ IEditorPart editor= page.getActiveEditor();
+ if (editor instanceof IEditorWrapper)
+ editor = ((IEditorWrapper) editor).getEditor();
+
+ if (editor instanceof ITextEditor)
+ return (ITextEditor) editor;
+ else
+ return (ITextEditor)editor.getAdapter(ITextEditor.class);
+ }
+ }
+ return null;
+ }
- /*
- * Checks if the EL start starting characters are present
- * @param viewer
- * @param offset
- * @return
- * @throws BadLocationException
- */
- private boolean checkStartPositionInEL(ITextViewer viewer, int offset) throws BadLocationException {
-
- // JBIDE-1676: Do not even try to get IStructuredDocument in case of not-a-structured document
- // This will prevent class cast exceptions while using the editors other than StructuredEditor
- // (CompilationUnitEditor, for example).
- IStructuredDocumentRegion sdRegion =
- (viewer.getDocument() instanceof IStructuredDocument ?
- ContentAssistUtils.getStructuredDocumentRegion(viewer, offset) :
- null);
- ITextRegion region = (sdRegion == null ? null : sdRegion.getRegionAtCharacterOffset(offset));
-
- int startIndex = (region == null ? 0 : sdRegion.getStartOffset() + region.getStart());
-
- IDocument doc= viewer.getDocument();
- if (doc == null || offset > doc.getLength())
- return false;
+ private boolean isCharSharp(ITextViewer viewer, int offset) throws BadLocationException {
+ IDocument doc= viewer.getDocument();
+ if (doc == null || offset > doc.getLength() || offset < 0) {
+ return false;
+ }
- while (--offset >= startIndex) {
- if ('}' == doc.getChar(offset))
- return false;
+ return '#' == doc.getChar(offset);
+ }
- if ('"' == doc.getChar(offset) || '\'' == doc.getChar(offset)) {
- int backslashCount = 0;
- while (doc.getChar(offset - 1 - backslashCount) == '\\') {
- backslashCount++;
- }
- // Added by estherbin
- // JBIDE-2227
- if ((backslashCount > 0) && (backslashCount % 2 == 0)) {
- return false;
- } else {
- return true;
+ /*
+ * Checks if the EL start starting characters are present
+ * @param viewer
+ * @param offset
+ * @return
+ * @throws BadLocationException
+ */
+ private boolean checkStartPositionInEL(ITextViewer viewer, int offset,boolean isCheckBackslashes) throws BadLocationException {
+
+ // JBIDE-1676: Do not even try to get IStructuredDocument in case of not-a-structured document
+ // This will prevent class cast exceptions while using the editors other than StructuredEditor
+ // (CompilationUnitEditor, for example).
+ IStructuredDocumentRegion sdRegion =
+ (viewer.getDocument() instanceof IStructuredDocument ?
+ ContentAssistUtils.getStructuredDocumentRegion(viewer, offset) :
+ null);
+ ITextRegion region = (sdRegion == null ? null : sdRegion.getRegionAtCharacterOffset(offset));
+
+ int startIndex = (region == null ? 0 : sdRegion.getStartOffset() + region.getStart());
+
+ IDocument doc= viewer.getDocument();
+ if (doc == null || offset > doc.getLength())
+ return false;
+
+ while (--offset >= startIndex) {
+ if ('}' == doc.getChar(offset))
+ return false;
+
+ if (isCheckBackslashes) {
+ if ('"' == doc.getChar(offset) || '\'' == doc.getChar(offset)) {
+ int backslashCount = 0;
+ while (doc.getChar(offset - 1 - backslashCount) == '\\') {
+ backslashCount++;
+ }
+ // Added by estherbin
+ // JBIDE-2227
+ if (backslashCount > 0 && (backslashCount % 2 == 0)) {
+ return false;
+ } else {
+ return true;
+ }
}
- }
+ }
- if ('{' == doc.getChar(offset) &&
- (offset - 1) >= 0 &&
- ('#' == doc.getChar(offset - 1) ||
- '$' == doc.getChar(offset - 1))) {
- return true;
- }
- }
- return false;
- }
+ if ('{' == doc.getChar(offset) &&
+ (offset - 1) >= 0 &&
+ ('#' == doc.getChar(offset - 1) ||
+ '$' == doc.getChar(offset - 1))) {
+ return true;
+ }
+
+ }
+ return false;
+ }
}
\ No newline at end of file
17 years, 10 months
JBoss Tools SVN: r8797 - branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-06-16 10:10:56 -0400 (Mon, 16 Jun 2008)
New Revision: 8797
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2330 Fixed
Modified: branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java
===================================================================
--- branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java 2008-06-16 14:03:31 UTC (rev 8796)
+++ branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java 2008-06-16 14:10:56 UTC (rev 8797)
@@ -225,8 +225,8 @@
*/
private ELToken readStringToken() {
fState = STATE_STRING;
+ int ch = readNextChar(); // skip first '
int startOfToken = index;
- int ch;
while((ch = readNextChar()) != -1) {
if (ch==STRING_SYMBOL) {
break;
17 years, 10 months
JBoss Tools SVN: r8796 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-06-16 10:03:31 -0400 (Mon, 16 Jun 2008)
New Revision: 8796
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2330 Fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java 2008-06-16 13:56:46 UTC (rev 8795)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java 2008-06-16 14:03:31 UTC (rev 8796)
@@ -225,8 +225,8 @@
*/
private ELToken readStringToken() {
fState = STATE_STRING;
+ int ch = readNextChar(); // skip first '
int startOfToken = index;
- int ch;
while((ch = readNextChar()) != -1) {
if (ch==STRING_SYMBOL) {
break;
17 years, 10 months
JBoss Tools SVN: r8795 - branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2008-06-16 09:56:46 -0400 (Mon, 16 Jun 2008)
New Revision: 8795
Modified:
branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2333 java.lang.NullPointerException when make openOn on EL w/o atribute.
Issue is fixed
Modified: branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java
===================================================================
--- branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java 2008-06-16 13:54:19 UTC (rev 8794)
+++ branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java 2008-06-16 13:56:46 UTC (rev 8795)
@@ -90,6 +90,8 @@
String valText = (n instanceof IDOMAttr)?
((IDOMAttr)n).getValueRegionText():
((IDOMText)n).getData();
+ if (valText == null)
+ return null;
int startBracket = 0;
int exprStart = 0;
17 years, 10 months