JBoss Tools SVN: r17685 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui: wizards and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-09-21 17:23:29 -0400 (Mon, 21 Sep 2009)
New Revision: 17685
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
Log:
JBIDE-4874 - changed the messaging. seems there's no way to tell if we're editing or not
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2009-09-21 19:30:27 UTC (rev 17684)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2009-09-21 21:23:29 UTC (rev 17685)
@@ -51,8 +51,7 @@
public static String JBossRuntimeWizardFragment_OutputFolderExists;
public static String rwf_CopyConfigLabel;
public static String rwf_DestinationLabel;
- public static String rwf_TitleCreate;
- public static String rwf_TitleEdit;
+ public static String rwf_JBossRuntime;
public static String rwf_Explanation;
public static String rwf_NameInUse;
public static String rwf_homeMissingFiles;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2009-09-21 19:30:27 UTC (rev 17684)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2009-09-21 21:23:29 UTC (rev 17685)
@@ -10,8 +10,7 @@
wf_ConfigLabel=Configuration
rwf_CopyConfigLabel=Copy configuration "{0}" to a new destination from "{1}".
rwf_DestinationLabel=Destination
-rwf_TitleCreate=Create a new JBoss Runtime
-rwf_TitleEdit=Edit a JBoss Runtime
+rwf_JBossRuntime=JBoss Runtime
rwf_Explanation=A JBoss Server runtime references a JBoss installation directory.\nIt can be used to set up classpaths for projects which depend on this runtime,\nas well as by a "server" which will be able to start and stop instances of JBoss.
rwf_NameInUse=Runtime name already in use
rwf_homeMissingFiles=The home directory does not exist or is missing the run.jar.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2009-09-21 19:30:27 UTC (rev 17684)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2009-09-21 21:23:29 UTC (rev 17685)
@@ -141,8 +141,7 @@
IRuntime r = (IRuntime) getTaskModel()
.getObject(TaskModel.TASK_RUNTIME);
String version = r.getRuntimeType().getVersion();
- handle.setTitle( getRuntime() == null ?
- Messages.rwf_TitleCreate : Messages.rwf_TitleEdit);
+ handle.setTitle( Messages.rwf_JBossRuntime);
String description = NLS.bind(
isEAP() ? Messages.JBEAP_version : Messages.JBAS_version,
version);
15 years, 4 months
JBoss Tools SVN: r17684 - in trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core: src/org/jboss/ide/eclipse/as/wtp/core/util and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-09-21 15:30:27 -0400 (Mon, 21 Sep 2009)
New Revision: 17684
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java
Log:
Adding further implementations for some primary use cases here
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/plugin.xml 2009-09-21 18:24:33 UTC (rev 17683)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/plugin.xml 2009-09-21 19:30:27 UTC (rev 17684)
@@ -8,6 +8,10 @@
class="org.jboss.ide.eclipse.as.wtp.core.vcf.OutputFolderReferenceResolver"
id="org.jboss.ide.eclipse.as.wtp.core.vcf.outputFolderReferenceResolver">
</resolver>
+ <resolver
+ class="org.jboss.ide.eclipse.as.wtp.core.vcf.ExportedClassFolderReferenceResolver"
+ id="org.jboss.ide.eclipse.as.wtp.core.vcf.exportedClasspathFolderReferenceResolver">
+ </resolver>
</extension>
</plugin>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java 2009-09-21 18:24:33 UTC (rev 17683)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java 2009-09-21 19:30:27 UTC (rev 17684)
@@ -2,9 +2,8 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.Collection;
+import java.util.HashMap;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -14,26 +13,69 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualFile;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualFolder;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
+// TODO THis class is fucked and incorrectly works.
+// The first instance (top) treats 'resources' as folders to search
+// Others try to treat it as items that are inside. This is bad.
public class ResourceListVirtualFolder extends VirtualFolder {
- private ArrayList<IResource> resources;
+ private ArrayList<IResource> children;
+ private ArrayList<IContainer> underlying;
public ResourceListVirtualFolder(
IProject aComponentProject,
- IPath aRuntimePath,
- IResource[] containers) {
+ IPath aRuntimePath) {
super(aComponentProject, aRuntimePath);
- this.resources = new ArrayList<IResource>();
- this.resources.addAll(Arrays.asList(containers));
+ this.children = new ArrayList<IResource>();
+ this.underlying = new ArrayList<IContainer>();
}
- protected void addResource(IResource c) {
- //this.resources.add(c);
+ public ResourceListVirtualFolder(
+ IProject aComponentProject,
+ IPath aRuntimePath, IContainer[] underlyingContainers) {
+ this(aComponentProject, aRuntimePath);
+ this.underlying.addAll(Arrays.asList(underlyingContainers));
}
+
+ public ResourceListVirtualFolder(
+ IProject aComponentProject,
+ IPath aRuntimePath, IContainer[] underlyingContainers,
+ IResource[] looseResources) {
+ this(aComponentProject, aRuntimePath, underlyingContainers);
+ this.children.addAll(Arrays.asList(looseResources));
+ }
+
+ protected void addUnderlyingResource(IResource resource) {
+ if( underlying instanceof IContainer ) {
+ underlying.add((IContainer)resource);
+ try {
+ IResource[] newChildren = ((IContainer)resource).members();
+ for( int i = 0; i < newChildren.length; i++ ) {
+ children.add(newChildren[i]);
+ }
+ } catch( CoreException ce) {
+ // TODO log
+ }
+ }
+ }
+
+ protected void addUnderlyingResource(IResource[] resources) {
+ for( int i = 0; i < resources.length; i++ ) {
+ addUnderlyingResource(resources[i]);
+ }
+ }
+ protected void addChild(IResource resource) {
+ this.children.add(resource);
+ }
+
+ protected void addChildren(IResource[] resources) {
+ this.children.addAll(Arrays.asList(resources));
+ }
+
+
public IResource getUnderlyingResource() {
- // Since I'm a container, pretend I'm a container I guess
return getUnderlyingFolder();
}
@@ -42,55 +84,45 @@
}
public IContainer getUnderlyingFolder() {
- IResource[] r = (IResource[]) resources.toArray(new IResource[resources.size()]);
- for( int i = 0; i < r.length; i++ )
- if( r[i] instanceof IContainer )
- return (IContainer)r[i];
- return null;
+ return underlying.size() > 0 ? underlying.get(0) : null;
}
public IContainer[] getUnderlyingFolders() {
- IResource[] r = (IResource[]) resources.toArray(new IResource[resources.size()]);
- ArrayList<IContainer> c = new ArrayList<IContainer>();
- for( int i = 0; i < r.length; i++ )
- if( r[i] instanceof IContainer )
- c.add((IContainer)r[i]);
- return (IContainer[]) c.toArray(new IContainer[c.size()]);
+ return (IContainer[]) underlying.toArray(new IContainer[underlying.size()]);
}
+
public IVirtualResource[] members(int memberFlags) throws CoreException {
- List<IVirtualResource> virtualResources = new ArrayList<IVirtualResource>(); // result
- Set allNames = new HashSet();
- IResource[] containers2 = (IResource[]) this.resources.toArray(new IResource[this.resources.size()]);
- for( int i = 0; i < containers2.length; i++ ) {
- IResource realResource = containers2[i];
- if ((realResource != null) && (realResource.getType() == IResource.FOLDER || realResource.getType() == IResource.PROJECT)) {
- IContainer realContainer = (IContainer) realResource;
- IResource[] realChildResources = realContainer.members(memberFlags);
- for (int realResourceIndex = 0; realResourceIndex < realChildResources.length; realResourceIndex++) {
- IResource child = realChildResources[realResourceIndex];
- String localName = child.getName();
- if (allNames.add(localName)) {
- IPath newRuntimePath = getRuntimePath().append(localName);
- if (child instanceof IFile) {
- virtualResources.add(new VirtualFile(getProject(), newRuntimePath, (IFile) child));
- } else if( child instanceof IContainer ){
- IContainer childContainer = (IContainer)child;
- IResource[] members = childContainer.members();
- ResourceListVirtualFolder childFolder =
- new ResourceListVirtualFolder(getProject(), newRuntimePath, members);
- virtualResources.add(childFolder);
- }
- }
- }
- } else if(realResource != null && realResource instanceof IFile) {
- // An IResource.FILE would be an error condition (as this is a container)
- virtualResources.add(new VirtualFile(getProject(),
- getRuntimePath().append(((IFile)realResource).getName()), (IFile)realResource));
- }
+ HashMap<String, IVirtualResource> virtualResources = new HashMap<String, IVirtualResource>(); // result
+ IResource[] resources = (IResource[]) this.children.toArray(new IResource[this.children.size()]);
+ for( int i = 0; i < resources.length; i++ ) {
+ handleResource(resources[i], virtualResources, memberFlags);
}
- return virtualResources.toArray(new IVirtualResource[virtualResources.size()]);
+ Collection c = virtualResources.values();
+ return (IVirtualResource[]) c.toArray(new IVirtualResource[c.size()]);
}
-
+ protected void handleResource(IResource resource, HashMap<String, IVirtualResource> map, int memberFlags) throws CoreException {
+ if( resource instanceof IFile ) {
+ if( !map.containsKey(resource.getName()) ) {
+ IVirtualFile virtFile = new VirtualFile(getProject(),
+ getRuntimePath().append(((IFile)resource).getName()), (IFile)resource);
+ map.put(resource.getName(), virtFile);
+ return;
+ }
+ }// end file
+ else if( resource instanceof IContainer ) {
+ IContainer realContainer = (IContainer) resource;
+ IResource[] realChildResources = realContainer.members(memberFlags);
+ IVirtualResource previousValue = map.get(resource.getName());
+ if( previousValue != null && previousValue instanceof ResourceListVirtualFolder ) {
+ ((ResourceListVirtualFolder)previousValue).addUnderlyingResource(realContainer);
+ } else if( previousValue == null ) {
+ ResourceListVirtualFolder childFolder =
+ new ResourceListVirtualFolder(getProject(), getRuntimePath().append(resource.getName()));
+ childFolder.addUnderlyingResource(realContainer);
+ map.put(resource.getName(), childFolder);
+ }
+ } // end container
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java 2009-09-21 18:24:33 UTC (rev 17683)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java 2009-09-21 19:30:27 UTC (rev 17684)
@@ -24,10 +24,14 @@
return ExportedClassFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL;
}
- protected IResource[] getExposableResources() {
+ protected IResource[] getLooseResources() {
+ return new IResource[]{};
+ }
+
+ protected IContainer[] getUnderlyingContainers() {
IJavaProject jp = JavaCore.create(project);
IClasspathEntry[] entries = findAllClassFolderEntries(jp);
- ArrayList<IResource> results = new ArrayList<IResource>();
+ ArrayList<IContainer> results = new ArrayList<IContainer>();
for( int i = 0; i < entries.length; i++ ) {
IClasspathAttribute attribute = ClasspathDependencyUtil.checkForComponentDependencyAttribute(
entries[i],
@@ -36,11 +40,11 @@
if( attribute != null ) {
final IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(entries[i].getPath());
if (resource != null && resource instanceof IContainer ) {
- results.add(resource);
+ results.add((IContainer)resource);
}
}
}
- return (IResource[]) results.toArray(new IResource[results.size()]);
+ return results.toArray(new IContainer[results.size()]);
}
protected IClasspathEntry[] findAllClassFolderEntries(IJavaProject javaProject) {
@@ -55,5 +59,4 @@
}
return list.toArray(new IClasspathEntry[list.size()]);
}
-
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java 2009-09-21 18:24:33 UTC (rev 17683)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java 2009-09-21 19:30:27 UTC (rev 17684)
@@ -2,6 +2,7 @@
import java.util.Properties;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -47,7 +48,6 @@
String firstSegment = getFirstIdSegment();
if (project.equals(referencingComp.getProject()))
return firstSegment;
-
return firstSegment + Path.SEPARATOR + project.getName();
}
@@ -63,12 +63,15 @@
}
public IVirtualFolder getRootFolder() {
- IResource[] resources = getExposableResources();
- return new ResourceListVirtualFolder(
- project, new Path("/"), resources);
+ IContainer[] containers = getUnderlyingContainers();
+ IResource[] looseResources = getLooseResources();
+ ResourceListVirtualFolder folder =
+ new ResourceListVirtualFolder(project, new Path("/"), containers, looseResources);
+ return folder;
}
- protected abstract IResource[] getExposableResources();
+ protected abstract IContainer[] getUnderlyingContainers();
+ protected abstract IResource[] getLooseResources();
public Properties getMetaProperties() {
return null;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java 2009-09-21 18:24:33 UTC (rev 17683)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java 2009-09-21 19:30:27 UTC (rev 17684)
@@ -23,7 +23,11 @@
return OutputFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL;
}
- protected IResource[] getExposableResources() {
+ protected IResource[] getLooseResources() {
+ return new IResource[]{};
+ }
+
+ protected IContainer[] getUnderlyingContainers() {
List<IContainer> result = new ArrayList<IContainer>();
try {
if (!project.hasNature(JavaCore.NATURE_ID))
15 years, 4 months
JBoss Tools SVN: r17683 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-09-21 14:24:33 -0400 (Mon, 21 Sep 2009)
New Revision: 17683
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
Log:
JBIDE-4912 - fixed an NPE
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-09-21 17:59:29 UTC (rev 17682)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-09-21 18:24:33 UTC (rev 17683)
@@ -474,13 +474,15 @@
copyFile(file.getContents(), path, file.getLocalTimeStamp(), mf);
else {
File file2 = (File) mf.getAdapter(File.class);
- InputStream in = null;
- try {
- in = new FileInputStream(file2);
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorReading, file2.getAbsolutePath()), e));
- }
- copyFile(in, path, file2.lastModified(), mf);
+ if( file2 != null ) {
+ InputStream in = null;
+ try {
+ in = new FileInputStream(file2);
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorReading, file2.getAbsolutePath()), e));
+ }
+ copyFile(in, path, file2.lastModified(), mf);
+ } // else silently ignore I guess
}
}
15 years, 4 months
JBoss Tools SVN: r17682 - trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-09-21 13:59:29 -0400 (Mon, 21 Sep 2009)
New Revision: 17682
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
Log:
Description is added for New Hibernate XML Mapping file New Wizard
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties 2009-09-21 17:42:04 UTC (rev 17681)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties 2009-09-21 17:59:29 UTC (rev 17682)
@@ -6,4 +6,5 @@
JavaEditorMenu_GenerateHibernateAnnotations=Generate &Hibernate/JPA annotations...
JavaElementMenu_GenerateHibernateAnnotations=Generate &Hibernate/JPA annotations
Menu_Source=&Source
-New_wizard_menu_New_mapping_file=Hibernate XML Mapping file (hbm.xml)
\ No newline at end of file
+New_wizard_menu_New_mapping_file=Hibernate XML Mapping file (hbm.xml)
+New_wizard_menu_New_mapping_file_description = Creates a new Hibernate XML Mapping file
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-09-21 17:42:04 UTC (rev 17681)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-09-21 17:59:29 UTC (rev 17682)
@@ -149,6 +149,10 @@
class="org.hibernate.eclipse.jdt.ui.wizards.NewHibernateMappingFileWizard"
icon="icons/hibernate_small_icon.gif"
id="org.hibernate.eclipse.console.wizards.NewHibernateMappingFileWizard"
- name="%New_wizard_menu_New_mapping_file"/>
+ name="%New_wizard_menu_New_mapping_file">
+ <description>
+ %New_wizard_menu_New_mapping_file_description
+ </description>
+ </wizard>
</extension>
</plugin>
15 years, 4 months
JBoss Tools SVN: r17681 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-09-21 13:42:04 -0400 (Mon, 21 Sep 2009)
New Revision: 17681
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
Log:
Fix description to look alike with other hibernate wizards. 'Create a ...' instead of 'Creates a ..'
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-09-21 13:30:56 UTC (rev 17680)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-09-21 17:42:04 UTC (rev 17681)
@@ -83,7 +83,7 @@
id="org.hibernate.eclipse.console.wizards.ConsoleConfigurationCreationWizard"
name="Hibernate Console Configuration"
preferredPerspectives="org.hibernate.eclipse.console.HibernateConsolePerspective">
- <description>Creates a new Hibernate Console Configuration</description>
+ <description>Create a new Hibernate Console Configuration</description>
</wizard>
<wizard
canFinishEarly="false"
@@ -836,4 +836,4 @@
</colorDefinition>
</extension>
-->
-</plugin>
\ No newline at end of file
+</plugin>
15 years, 4 months
JBoss Tools SVN: r17680 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui: select and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-21 09:30:56 -0400 (Mon, 21 Sep 2009)
New Revision: 17680
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/ModelContributionManager.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/ModelNavigatorActionGroup.java
Removed:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/StrutsContributionManager.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/StrutsNavigatorActionGroup.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/NavigatorViewPart.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Minor changes to remove 'jsf' and 'struts' names.
Copied: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/ModelContributionManager.java (from rev 16771, trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/StrutsContributionManager.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/ModelContributionManager.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/ModelContributionManager.java 2009-09-21 13:30:56 UTC (rev 17680)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.model.ui.action;
+
+import java.util.*;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.actions.ActionContext;
+import org.jboss.tools.common.model.XModelObject;
+
+public class ModelContributionManager extends MenuManager {
+ ActionContext context;
+ Shell shell;
+
+ public ModelContributionManager(Shell shell) {
+ super("JBoss Tools");
+ this.shell = shell;
+ }
+
+ public void setContext(ActionContext context) {
+ this.context = context;
+ }
+
+ protected void update(boolean force, boolean recursive) {
+ if (isDirty() || force) {
+ if (getMenu() != null && !getMenu().isDisposed()) {
+ Menu menu = getMenu();
+ MenuItem[] is = menu.getItems();
+ for (int i = 0; i < is.length; i++) is[i].dispose();
+ XModelObject[] os = getSelectedModelObjects();
+ if(os.length == 0) return;
+ XModelObject o = os[0];
+ if(os.length == 1) os = null;
+ XModelObjectActionList l = new XModelObjectActionList(o.getModelEntity().getActionList(), o, os, new Object[]{o});
+ l.setShell(shell);
+ l.createMenu(menu);
+ l.removeLastSeparator(menu);
+ }
+ }
+ }
+
+ public XModelObject[] getSelectedModelObjects() {
+ ISelection s = context.getSelection();
+ if(s.isEmpty() || !(s instanceof StructuredSelection)) return new XModelObject[0];
+ StructuredSelection ss = (StructuredSelection)s;
+ Iterator it = ss.iterator();
+ ArrayList<XModelObject> l = new ArrayList<XModelObject>();
+ while(it.hasNext()) {
+ IAdaptable a = (IAdaptable)it.next();
+ XModelObject o = (XModelObject)a.getAdapter(XModelObject.class);
+ if(o != null) l.add(o);
+ }
+ return l.toArray(new XModelObject[0]);
+ }
+
+}
Deleted: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/StrutsContributionManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/StrutsContributionManager.java 2009-09-21 12:41:16 UTC (rev 17679)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/StrutsContributionManager.java 2009-09-21 13:30:56 UTC (rev 17680)
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.action;
-
-import java.util.*;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.actions.ActionContext;
-import org.jboss.tools.common.model.XModelObject;
-
-public class StrutsContributionManager extends MenuManager {
- ActionContext context;
- Shell shell;
-
- public StrutsContributionManager(Shell shell) {
- super("JBoss Tools Struts");
- this.shell = shell;
- }
-
- public void setContext(ActionContext context) {
- this.context = context;
- }
-
- protected void update(boolean force, boolean recursive) {
- if (isDirty() || force) {
- if (getMenu() != null && !getMenu().isDisposed()) {
- Menu menu = getMenu();
- MenuItem[] is = menu.getItems();
- for (int i = 0; i < is.length; i++) is[i].dispose();
- XModelObject[] os = getSelectedModelObjects();
- if(os.length == 0) return;
- XModelObject o = os[0];
- if(os.length == 1) os = null;
- XModelObjectActionList l = new XModelObjectActionList(o.getModelEntity().getActionList(), o, os, new Object[]{o});
- l.setShell(shell);
- l.createMenu(menu);
- l.removeLastSeparator(menu);
- }
- }
- }
-
- public XModelObject[] getSelectedModelObjects() {
- ISelection s = context.getSelection();
- if(s.isEmpty() || !(s instanceof StructuredSelection)) return new XModelObject[0];
- StructuredSelection ss = (StructuredSelection)s;
- Iterator it = ss.iterator();
- ArrayList<XModelObject> l = new ArrayList<XModelObject>();
- while(it.hasNext()) {
- IAdaptable a = (IAdaptable)it.next();
- XModelObject o = (XModelObject)a.getAdapter(XModelObject.class);
- if(o != null) l.add(o);
- }
- return l.toArray(new XModelObject[0]);
- }
-
-}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java 2009-09-21 12:41:16 UTC (rev 17679)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java 2009-09-21 13:30:56 UTC (rev 17680)
@@ -88,9 +88,6 @@
String[] views = new String[]{
"org.jboss.tools.jst.web.ui.navigator.WebProjectsView" //$NON-NLS-1$
-// "org.jboss.tools.jsf.ui.navigator.JsfProjectsView",
-// "org.jboss.tools.struts.ui.navigator.StrutsProjectsView",
-// "org.jboss.tools.common.model.ui.navigator.NavigatorViewPart"
};
private XModelObject selectInNavigator() {
Copied: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/ModelNavigatorActionGroup.java (from rev 16771, trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/StrutsNavigatorActionGroup.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/ModelNavigatorActionGroup.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/ModelNavigatorActionGroup.java 2009-09-21 13:30:56 UTC (rev 17680)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.model.ui.views.navigator;
+
+import org.jboss.tools.common.model.ui.action.ModelContributionManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+//import org.eclipse.jface.util.IPropertyChangeListener;
+//import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.AddBookmarkAction;
+import org.eclipse.ui.actions.AddTaskAction;
+import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.views.navigator.*;
+
+public class ModelNavigatorActionGroup extends ResourceNavigatorActionGroup {
+
+ protected AddBookmarkAction addBookmarkAction;
+ protected AddTaskAction addTaskAction;
+ protected PropertyDialogAction propertyDialogAction;
+ protected CollapseAllAction collapseAllAction;
+ protected ToggleLinkingAction toggleLinkingAction;
+
+ protected OpenActionGroup openGroup;
+ protected NRefactorActionGroup refactorGroup;
+ protected WorkingSetFilterActionGroup workingSetGroup;
+ protected WorkspaceActionGroup workspaceGroup;
+
+ protected ModelContributionManager mcm;
+ protected boolean activateModelContribution = false;
+
+ /**
+ * Constructs the main action group.
+ */
+ public ModelNavigatorActionGroup(IResourceNavigator navigator) {
+ super(navigator);
+ makeSubGroups();
+ }
+
+ /**
+ * Makes the actions contained directly in this action group.
+ */
+ protected void makeActions() {
+ Shell shell = navigator.getSite().getShell();
+
+ if(activateModelContribution) {
+ mcm = new ModelContributionManager(shell);
+ }
+
+ addBookmarkAction = new AddBookmarkAction(shell);
+ addTaskAction = new AddTaskAction(shell);
+ propertyDialogAction =
+ new PropertyDialogAction(navigator.getSite(), navigator.getViewer());
+
+ collapseAllAction = new CollapseAllAction(navigator, "Collapse All");
+ collapseAllAction.setToolTipText("Collapse All");
+ collapseAllAction.setImageDescriptor(getImageDescriptor("elcl16/collapseall.gif")); //$NON-NLS-1$
+
+ toggleLinkingAction = new ToggleLinkingAction(
+ navigator, "Link with Editor");
+ toggleLinkingAction.setToolTipText("Link with Editor");
+ toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$
+ }
+
+ /**
+ * Makes the sub action groups.
+ */
+ protected void makeSubGroups() {
+ openGroup = new OpenActionGroup(navigator);
+ refactorGroup = new NRefactorActionGroup(navigator);
+ workspaceGroup = new WorkspaceActionGroup(navigator);
+ }
+
+ /**
+ * Extends the superclass implementation to set the context in the subgroups.
+ */
+ public void setContext(ActionContext context) {
+ super.setContext(context);
+ openGroup.setContext(context);
+ refactorGroup.setContext(context);
+ workspaceGroup.setContext(context);
+ if(mcm != null) mcm.setContext(context);
+ }
+
+ /**
+ * Adds the actions in this group and its subgroups to the action bars.
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler(
+ ActionFactory.PROPERTIES.getId(),
+ propertyDialogAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.BOOKMARK.getId(),
+ addBookmarkAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.ADD_TASK.getId(),
+ addTaskAction);
+ openGroup.fillActionBars(actionBars);
+ refactorGroup.fillActionBars(actionBars);
+ workspaceGroup.fillActionBars(actionBars);
+
+ IToolBarManager toolBar = actionBars.getToolBarManager();
+ toolBar.add(new Separator());
+ toolBar.add(collapseAllAction);
+ toolBar.add(toggleLinkingAction);
+ }
+
+ /**
+ * Updates the actions which were added to the action bars,
+ * delegating to the subgroups as necessary.
+ */
+ public void updateActionBars() {
+ IStructuredSelection selection =
+ (IStructuredSelection) getContext().getSelection();
+ propertyDialogAction.setEnabled(selection.size() == 1);
+ addBookmarkAction.selectionChanged(selection);
+ addTaskAction.selectionChanged(selection);
+
+ openGroup.updateActionBars();
+ refactorGroup.updateActionBars();
+ workspaceGroup.updateActionBars();
+ if(mcm != null) mcm.markDirty();
+ if(mcm != null) mcm.update(true);
+ }
+
+ /**
+ * Runs the default action (open file) by delegating the open group.
+ */
+ public void runDefaultAction(IStructuredSelection selection) {
+ openGroup.runDefaultAction(selection);
+ }
+
+ /**
+ * Handles a key pressed event by invoking the appropriate action,
+ * delegating to the subgroups as necessary.
+ */
+ public void handleKeyPressed(KeyEvent event) {
+ refactorGroup.handleKeyPressed(event);
+ workspaceGroup.handleKeyPressed(event);
+ }
+
+ /**
+ * Extends the superclass implementation to dispose the subgroups.
+ */
+ public void dispose() {
+ openGroup.dispose();
+ refactorGroup.dispose();
+ workspaceGroup.dispose();
+ if(mcm != null) mcm.dispose();
+ super.dispose();
+ }
+
+
+}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/NavigatorViewPart.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/NavigatorViewPart.java 2009-09-21 12:41:16 UTC (rev 17679)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/NavigatorViewPart.java 2009-09-21 13:30:56 UTC (rev 17680)
@@ -104,7 +104,7 @@
private NavigatorStatusLineProvider statusLineProvider = new NavigatorStatusLineProvider();
private ActivationListener fActivationListener= new ActivationListener();
- boolean useStrutsMenu = true;
+ boolean useModelMenu = true;
public NavigatorViewPart() {
selectionProvider.addSelectionChangedListener(new SL());
@@ -167,8 +167,6 @@
protected String[] getActionClasses() {
String[] actions = new String[]{
- "org.jboss.tools.struts.ui.internal.action.CreateProjectAction", //$NON-NLS-1$
- "org.jboss.tools.struts.ui.internal.action.ImportProjectAction" //$NON-NLS-1$
};
return actions;
}
@@ -246,7 +244,7 @@
//@S_CHECK@
TreeViewerMenuInvoker listener = createMenuInvoker();
listener.setViewer(viewer);
- if(useStrutsMenu) {
+ if(useModelMenu) {
viewer.getTree().addMouseListener(listener);
}
}
@@ -453,7 +451,7 @@
}
protected void makeActions() {
- setActionGroup(new StrutsNavigatorActionGroup(this));
+ setActionGroup(new ModelNavigatorActionGroup(this));
}
ResourceNavigatorActionGroup actionGroup;
@@ -486,7 +484,7 @@
fillContextMenu(manager);
}
});
- if(!useStrutsMenu) {
+ if(!useModelMenu) {
TreeViewer treeViewer = getViewer();
Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
treeViewer.getTree().setMenu(menu);
@@ -530,11 +528,11 @@
};
private void saveLinkingEnabled(IMemento _memento) {
- _memento.putInteger("LinkStrutsProjectsToEditor", isLinkingEnabled ? 1 : 0); //$NON-NLS-1$
+ _memento.putInteger("LinkModelProjectsToEditor", isLinkingEnabled ? 1 : 0); //$NON-NLS-1$
}
private void restoreLinkingEnabled() {
- Integer val = memento.getInteger("LinkStrutsProjectsToEditor");//IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR); //$NON-NLS-1$
+ Integer val = memento.getInteger("LinkModelProjectsToEditor");//IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR); //$NON-NLS-1$
if (val != null) {
isLinkingEnabled = val.intValue() != 0;
}
Deleted: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/StrutsNavigatorActionGroup.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/StrutsNavigatorActionGroup.java 2009-09-21 12:41:16 UTC (rev 17679)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/navigator/StrutsNavigatorActionGroup.java 2009-09-21 13:30:56 UTC (rev 17680)
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.views.navigator;
-
-import org.jboss.tools.common.model.ui.action.StrutsContributionManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-//import org.eclipse.jface.util.IPropertyChangeListener;
-//import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.AddBookmarkAction;
-import org.eclipse.ui.actions.AddTaskAction;
-import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.ide.IDEActionFactory;
-import org.eclipse.ui.views.navigator.*;
-
-public class StrutsNavigatorActionGroup extends ResourceNavigatorActionGroup {
-
- protected AddBookmarkAction addBookmarkAction;
- protected AddTaskAction addTaskAction;
- protected PropertyDialogAction propertyDialogAction;
- protected CollapseAllAction collapseAllAction;
- protected ToggleLinkingAction toggleLinkingAction;
-
- protected OpenActionGroup openGroup;
- protected NRefactorActionGroup refactorGroup;
- protected WorkingSetFilterActionGroup workingSetGroup;
- protected WorkspaceActionGroup workspaceGroup;
-
- protected StrutsContributionManager struts;
- protected boolean activateStrutsContribution = false;
-
- /**
- * Constructs the main action group.
- */
- public StrutsNavigatorActionGroup(IResourceNavigator navigator) {
- super(navigator);
- makeSubGroups();
- }
-
- /**
- * Makes the actions contained directly in this action group.
- */
- protected void makeActions() {
- Shell shell = navigator.getSite().getShell();
-
- if(activateStrutsContribution) {
- struts = new StrutsContributionManager(shell);
- }
-
- addBookmarkAction = new AddBookmarkAction(shell);
- addTaskAction = new AddTaskAction(shell);
- propertyDialogAction =
- new PropertyDialogAction(navigator.getSite(), navigator.getViewer());
-
- collapseAllAction = new CollapseAllAction(navigator, "Collapse All");
- collapseAllAction.setToolTipText("Collapse All");
- collapseAllAction.setImageDescriptor(getImageDescriptor("elcl16/collapseall.gif")); //$NON-NLS-1$
-
- toggleLinkingAction = new ToggleLinkingAction(
- navigator, "Link with Editor");
- toggleLinkingAction.setToolTipText("Link with Editor");
- toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$
- }
-
- /**
- * Makes the sub action groups.
- */
- protected void makeSubGroups() {
- openGroup = new OpenActionGroup(navigator);
- refactorGroup = new NRefactorActionGroup(navigator);
- workspaceGroup = new WorkspaceActionGroup(navigator);
- }
-
- /**
- * Extends the superclass implementation to set the context in the subgroups.
- */
- public void setContext(ActionContext context) {
- super.setContext(context);
- openGroup.setContext(context);
- refactorGroup.setContext(context);
- workspaceGroup.setContext(context);
- if(struts != null) struts.setContext(context);
- }
-
- /**
- * Adds the actions in this group and its subgroups to the action bars.
- */
- public void fillActionBars(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(
- ActionFactory.PROPERTIES.getId(),
- propertyDialogAction);
- actionBars.setGlobalActionHandler(
- IDEActionFactory.BOOKMARK.getId(),
- addBookmarkAction);
- actionBars.setGlobalActionHandler(
- IDEActionFactory.ADD_TASK.getId(),
- addTaskAction);
- openGroup.fillActionBars(actionBars);
- refactorGroup.fillActionBars(actionBars);
- workspaceGroup.fillActionBars(actionBars);
-
- IToolBarManager toolBar = actionBars.getToolBarManager();
- toolBar.add(new Separator());
- toolBar.add(collapseAllAction);
- toolBar.add(toggleLinkingAction);
- }
-
- /**
- * Updates the actions which were added to the action bars,
- * delegating to the subgroups as necessary.
- */
- public void updateActionBars() {
- IStructuredSelection selection =
- (IStructuredSelection) getContext().getSelection();
- propertyDialogAction.setEnabled(selection.size() == 1);
- addBookmarkAction.selectionChanged(selection);
- addTaskAction.selectionChanged(selection);
-
- openGroup.updateActionBars();
- refactorGroup.updateActionBars();
- workspaceGroup.updateActionBars();
- if(struts != null) struts.markDirty();
- if(struts != null) struts.update(true);
- }
-
- /**
- * Runs the default action (open file) by delegating the open group.
- */
- public void runDefaultAction(IStructuredSelection selection) {
- openGroup.runDefaultAction(selection);
- }
-
- /**
- * Handles a key pressed event by invoking the appropriate action,
- * delegating to the subgroups as necessary.
- */
- public void handleKeyPressed(KeyEvent event) {
- refactorGroup.handleKeyPressed(event);
- workspaceGroup.handleKeyPressed(event);
- }
-
- /**
- * Extends the superclass implementation to dispose the subgroups.
- */
- public void dispose() {
- openGroup.dispose();
- refactorGroup.dispose();
- workspaceGroup.dispose();
- if(struts != null) struts.dispose();
- super.dispose();
- }
-
-
-}
15 years, 4 months
JBoss Tools SVN: r17679 - in trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette: src/org/jboss/tools/vpe/ui/palette and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-21 08:41:16 -0400 (Mon, 21 Sep 2009)
New Revision: 17679
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteDragSourceListener.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Splitting PaletteInsertHelper into jsp and non-jsp related parts.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/META-INF/MANIFEST.MF 2009-09-21 12:32:55 UTC (rev 17678)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/META-INF/MANIFEST.MF 2009-09-21 12:41:16 UTC (rev 17679)
@@ -11,6 +11,7 @@
org.eclipse.jface.text,
org.eclipse.ui,
org.eclipse.gef,
- org.jboss.tools.common.model.ui
+ org.jboss.tools.common.model.ui,
+ org.jboss.tools.jst.jsp
Bundle-Version: 2.1.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteDragSourceListener.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteDragSourceListener.java 2009-09-21 12:32:55 UTC (rev 17678)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteDragSourceListener.java 2009-09-21 12:41:16 UTC (rev 17679)
@@ -23,6 +23,7 @@
import org.jboss.tools.common.model.XModelTransferBuffer;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
import org.jboss.tools.vpe.ui.palette.model.PaletteItem;
public class PaletteDragSourceListener extends DragSourceAdapter {
@@ -67,7 +68,7 @@
defaultPrefix = object.getParent().getAttributeValue("default prefix"); //$NON-NLS-1$
}
if(defaultPrefix != null && tag != null) {
- PaletteInsertHelper.applyPrefix(d, "", tag, "xxx", defaultPrefix); //$NON-NLS-1$ //$NON-NLS-2$
+ JSPPaletteInsertHelper.applyPrefix(d, "", tag, "xxx", defaultPrefix); //$NON-NLS-1$ //$NON-NLS-2$
}
int i = d[0].indexOf('|');
if(i >= 0) d[0] = d[0].substring(0, i) + d[0].substring(i + 1);
15 years, 4 months
JBoss Tools SVN: r17678 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-21 08:32:55 -0400 (Mon, 21 Sep 2009)
New Revision: 17678
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/CssLinkAttributeValueLoader.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Splitting PaletteInsertHelper into jsp and non-jsp related parts.
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/CssLinkAttributeValueLoader.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/CssLinkAttributeValueLoader.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/CssLinkAttributeValueLoader.java 2009-09-21 12:32:55 UTC (rev 17678)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.jspeditor.dnd;
+
+import org.jboss.tools.common.model.ui.editors.dnd.AbsoluteFilePathAttributeValueLoader;
+import org.jboss.tools.common.model.ui.editors.dnd.IDropWizardModel;
+
+public class CssLinkAttributeValueLoader extends AbsoluteFilePathAttributeValueLoader {
+
+ public CssLinkAttributeValueLoader(String pathAttributeName) {
+ super(pathAttributeName, null, null);
+ }
+
+ public void fillTagAttributes(IDropWizardModel model) {
+ super.fillTagAttributes(model);
+ model.setAttributeValue("rel", "stylesheet"); //$NON-NLS-1$ //$NON-NLS-2$
+ model.setAttributeValue("type", "text/css"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java 2009-09-21 12:31:32 UTC (rev 17677)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java 2009-09-21 12:32:55 UTC (rev 17678)
@@ -14,7 +14,6 @@
import java.util.Map;
import org.jboss.tools.common.model.ui.editors.dnd.AbsoluteFilePathAttributeValueLoader;
-import org.jboss.tools.common.model.ui.editors.dnd.CssLinkAttributeValueLoader;
import org.jboss.tools.common.model.ui.editors.dnd.DropURI;
import org.jboss.tools.common.model.ui.editors.dnd.IAttributeValueLoader;
import org.jboss.tools.common.model.ui.editors.dnd.IDropWizardModel;
@@ -22,7 +21,6 @@
import org.jboss.tools.common.model.ui.editors.dnd.ITagProposalLoader;
import org.jboss.tools.common.model.ui.editors.dnd.LoadBundleBaseNameAttributeValueLoader;
import org.jboss.tools.common.model.ui.editors.dnd.context.DropContext;
-import org.jboss.tools.common.model.ui.views.palette.PaletteTaglibInserter;
public class FileTagProposalLoader implements ITagProposalLoader {
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java 2009-09-21 12:31:32 UTC (rev 17677)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java 2009-09-21 12:32:55 UTC (rev 17678)
@@ -1,5 +1,10 @@
package org.jboss.tools.jst.jsp.jspeditor.dnd;
+import java.util.Properties;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
public class JSPPaletteInsertHelper extends PaletteInsertHelper {
@@ -10,6 +15,126 @@
return instance;
}
- public JSPPaletteInsertHelper() {}
+ static PaletteTaglibInserter PaletteTaglibInserter = new PaletteTaglibInserter();
+ public JSPPaletteInsertHelper() {}
+
+ protected void modify(ISourceViewer v, Properties p, String[] texts) {
+ String tagname = p.getProperty(PROPOPERTY_TAG_NAME);
+ String uri = p.getProperty(PROPOPERTY_TAGLIBRARY_URI);
+ String startText = texts[0];
+ if(startText != null && startText.startsWith("<%@ taglib")) { //$NON-NLS-1$
+ if(PaletteTaglibInserter.inserTaglibInXml(v, p)) {
+ return;
+ }
+ } else {
+ p = PaletteTaglibInserter.inserTaglib(v, p);
+ }
+
+ String defaultPrefix = p.getProperty(PROPOPERTY_DEFAULT_PREFIX);
+ IDocument d = v.getDocument();
+ applyPrefix(texts, d, tagname, uri, defaultPrefix);
+ }
+
+
+
+ /**
+ * adding prefix to tag
+ */
+ public static void applyPrefix(String[] text, ITextEditor editor, String tagname, String uri, String defaultPrefix) {
+ if(defaultPrefix == null || defaultPrefix.length() == 0) return;
+ IDocument doc = null;
+ if(editor != null && editor.getDocumentProvider() != null) {
+ doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ }
+ applyPrefix(text, doc, tagname, uri, defaultPrefix);
+ }
+
+ public static void applyPrefix(String[] text, IDocument doc, String tagname, String uri, String defaultPrefix) {
+ if(doc == null) return;
+ String body = doc.get();
+ applyPrefix(text, body, tagname, uri, defaultPrefix);
+ }
+
+ public static void applyPrefix(String[] text, String body, String tagname, String uri, String defaultPrefix) {
+ if(uri == null || uri.length() == 0) return;
+ Properties p = getPrefixes(body);
+ String prefix = p.getProperty(uri, defaultPrefix);
+ if(prefix == null || prefix.length() == 0) return;
+ for (int i = 0; i < text.length; i++) text[i] = applyPrefix(text[i], tagname, prefix, p);
+ }
+
+ static String applyPrefix(String text, String tagname, String prefix, Properties prefixes) {
+ if(text == null || text.length() == 0) return text;
+ if(tagname == null || tagname.length() == 0) return text;
+ while(true) {
+ int i = text.indexOf("%prefix|"); //$NON-NLS-1$
+ if(i < 0) break;
+ int j = text.indexOf("%", i + 8); //$NON-NLS-1$
+ if(j < 0) break;
+ int j1 = text.indexOf("|", i + 8); //$NON-NLS-1$
+ String uri = ""; //$NON-NLS-1$
+ String defaultPrefix = ""; //$NON-NLS-1$
+ String pr = ""; //$NON-NLS-1$
+ uri = text.substring(i + 8, j1);
+ defaultPrefix = text.substring(j1 + 1, j);
+ pr = prefixes.getProperty(uri, defaultPrefix);
+ if(pr.length() > 0) {
+ text = text.substring(0, i) + pr + ":" + text.substring(j + 1); //$NON-NLS-1$
+ } else {
+ text = text.substring(0, i) + text.substring(j + 1);
+ }
+ }
+
+ int k = text.toLowerCase().indexOf(":" + tagname.toLowerCase()); //$NON-NLS-1$
+ if(k >= 0) {
+ int g = text.indexOf("</"); //$NON-NLS-1$
+ if(g >= 0 && g < k) {
+ return text.substring(0, g + 2) + prefix + text.substring(k);
+ }
+ g = text.indexOf("<"); //$NON-NLS-1$
+ if(g >= 0 && g < k) {
+ return text.substring(0, g + 1) + prefix + text.substring(k);
+ }
+ }
+ k = text.toLowerCase().indexOf("<" + tagname.toLowerCase()); //$NON-NLS-1$
+ if(k >= 0) {
+ return text.substring(0, k + 1) + prefix + ":" + text.substring(k + 1); //$NON-NLS-1$
+ }
+ k = text.toLowerCase().indexOf("</" + tagname.toLowerCase()); //$NON-NLS-1$
+ if(k >= 0) {
+ return text.substring(0, k + 2) + prefix + ":" + text.substring(k + 2); //$NON-NLS-1$
+ }
+ return text;
+ }
+
+ static Properties getPrefixes(String body) {
+ Properties p = new Properties();
+ int i = 0;
+ while(i >= 0 && i < body.length()) {
+ i = body.indexOf("<%@ taglib ", i); //$NON-NLS-1$
+ if(i < 0) break;
+ int j = body.indexOf("%>", i); //$NON-NLS-1$
+ if(j < 0) j = body.length();
+ String taglib = body.substring(i, j);
+ getPrefix(p, taglib);
+ i = j + 1;
+ }
+ return p;
+ }
+
+ static void getPrefix(Properties p, String taglib) {
+ int i = taglib.indexOf("uri=\""); //$NON-NLS-1$
+ if(i < 0) return;
+ int j = taglib.indexOf("\"", i + 5); //$NON-NLS-1$
+ if(j < 0) return;
+ String uri = taglib.substring(i + 5, j);
+ i = taglib.indexOf("prefix=\""); //$NON-NLS-1$
+ if(i < 0) return;
+ j = taglib.indexOf("\"", i + 8); //$NON-NLS-1$
+ if(j < 0) return;
+ String prefix = taglib.substring(i + 8, j);
+ p.setProperty(uri, prefix);
+ }
+
}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java 2009-09-21 12:32:55 UTC (rev 17678)
@@ -0,0 +1,404 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.jspeditor.dnd;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.jst.web.tld.VpeTaglibManager;
+import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class PaletteTaglibInserter {
+
+ private static final String JSP_SOURCE_ROOT_ELEMENT = "jsp:root"; //$NON-NLS-1$
+ public static final String JSP_URI = "http://java.sun.com/JSP/Page"; //$NON-NLS-1$
+ public static final String faceletUri = "http://java.sun.com/jsf/facelets"; //$NON-NLS-1$
+
+ private static final String TAGLIB_START = "<%@ taglib"; //$NON-NLS-1$
+
+ public Properties inserTaglib(ISourceViewer v, Properties p) {
+ if(!inserTaglibInXml(v, p)) {
+ inserTaglibInOldJsp(v, p);
+ }
+ return p;
+ }
+
+ private boolean checkProperties(Properties p) {
+ return "true".equalsIgnoreCase(p.getProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB)) && //$NON-NLS-1$
+ p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI) != null &&
+ p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI).length() > 0 &&
+ !p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI).equals(JSP_URI) &&
+ p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX) != null &&
+ p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX).length() > 0 &&
+ p.getProperty(PaletteInsertHelper.PROPOPERTY_START_TEXT) != null;
+ }
+
+ public boolean inserTaglibInOldJsp(ISourceViewer v, Properties p) {
+ if(!checkProperties(p)) {
+ return false;
+ }
+
+ IDocument d = v.getDocument();
+ IStructuredModel model = null;
+
+ try {
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(d);
+ IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
+ if (xmlDocument == null) {
+ return false;
+ }
+ Properties tl = getPrefixes(v);
+ if(tl == null) tl = JSPPaletteInsertHelper.getPrefixes(d.get());
+ Element root = xmlDocument.getDocumentElement();
+
+ String uri_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
+ String defaultPrefix_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX);
+ String lineDelimiter = PaletteInsertHelper.getLineDelimiter(d);
+ StringBuffer tg = new StringBuffer(TAGLIB_START).append(" uri=\"").append(uri_p).append("\"").append(" prefix=\"").append(defaultPrefix_p).append("\"%>").append(lineDelimiter); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ if (tl != null && !tl.isEmpty()) {
+ //If taglib already exist check the prefix if changed
+ if (tl.containsKey(uri_p)) {
+ if (!tl.get(uri_p).equals(defaultPrefix_p)) {
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, (String)tl.get(uri_p));
+ }
+ } else if(!tl.containsValue(defaultPrefix_p)) {
+ if (checkplace(xmlDocument, d, "jsp:directive.taglib", tg, p, v) == false) { //$NON-NLS-1$
+ d.replace(0, 0, tg.toString());
+ mouveFocusOnPage(p,v, tg.toString().length(), 0);
+ return true;
+ }
+ }
+ } else if(xmlDocument instanceof DocumentImpl) {
+ DocumentImpl docImpl = (DocumentImpl)xmlDocument;
+ // Only for JSP
+ if(docImpl.isJSPType()) {
+ if (checkplace(xmlDocument, d, "jsp:directive.page", tg, p, v) == false) { //$NON-NLS-1$
+ d.replace(0, 0, tg.toString());
+ mouveFocusOnPage(p,v, tg.toString().length(), 0);
+ return true;
+ }
+ }
+ }
+ } catch (BadLocationException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ } finally {
+ if (model != null) model.releaseFromRead();
+ }
+ return false;
+ }
+
+ private static Node getSelectedNode(ISourceViewer v, Properties p){
+ ISelectionProvider selProvider = (ISelectionProvider)p.get(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER);
+ if(selProvider == null) return null;
+
+ ITextSelection selection = null;
+
+ if(selProvider.getSelection() instanceof ITextSelection)
+ selection = (ITextSelection)selProvider.getSelection();
+ else return null;
+
+ IndexedRegion region = ContentAssistUtils.getNodeAt(v, selection.getOffset());
+ if(region == null) return null;
+
+ if(!(region instanceof Node)) return null;
+
+ Node text = (Node)region;
+
+
+ if("#text".equals(text.getNodeName())) //$NON-NLS-1$
+ return text.getParentNode();
+ else
+ return text;
+ }
+
+ private static boolean checkSelectedElement(HashMap<String,String> map, ISourceViewer v, Properties p){
+ String taglibUri = p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
+ if(taglibUri == null) return false;
+
+ Node selectedNode = getSelectedNode(v, p);
+ if(selectedNode == null) return false;
+
+ return checkElement(map, selectedNode, taglibUri);
+ }
+
+ private static boolean checkElement(HashMap<String,String> map, Node node, String taglibUri){
+
+ NamedNodeMap attrs = node.getAttributes();
+ for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
+ Node a = attrs.item(j);
+ String name = a.getNodeName();
+
+ if (name.startsWith("xmlns:")) { //$NON-NLS-1$
+ map.put(a.getNodeValue(), name.substring("xmlns:".length())); //$NON-NLS-1$
+ }
+ }
+
+ if (map.containsKey(taglibUri)) return true;
+ else{
+ if(node.getParentNode() == null) return false;
+ else return checkElement(map, node.getParentNode(), taglibUri);
+ }
+ }
+
+ public boolean inserTaglibInXml(ISourceViewer v, Properties p) {
+ if(!checkProperties(p)) {
+ return false;
+ }
+
+ IDocument d = v.getDocument();
+ IStructuredModel model = null;
+
+ try {
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(d);
+ IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
+
+ if (xmlDocument == null) {
+ return false;
+ }
+
+ Properties tl = getPrefixes(v);
+ if(tl == null) tl = JSPPaletteInsertHelper.getPrefixes(d.get());
+ Element root = xmlDocument.getDocumentElement();
+ if(root != null) {
+ // for xhtml and jsp:root
+ if (xmlDocument.getDoctype() != null /* && tagLibListConainsFacelet(tl)*/ ) {
+ String publicId = xmlDocument.getDoctype().getPublicId();
+ if (publicId!=null && publicId.toUpperCase().startsWith("-//W3C//DTD XHTML")) { // && root.getNodeName().equalsIgnoreCase(HTML_SOURCE_ROOT_ELEMENT)) { //$NON-NLS-1$
+ checkTL(root, v, p, d);
+ return true;
+ }
+ } else if(xmlDocument.isXMLType() || root.getNodeName().equals(JSP_SOURCE_ROOT_ELEMENT)) {
+ checkTL(root, v, p, d);
+ return true;
+ }
+ }
+ } finally {
+ if (model != null) model.releaseFromRead();
+ }
+ return false;
+ }
+
+// private static boolean tagLibListConainsFacelet(List tagLibList) {
+// if (tagLibList != null && !tagLibList.isEmpty()) {
+// for (int i = 0; i < tagLibList.size(); i++) {
+// TaglibData tgld = (TaglibData)tagLibList.get(i);
+// if(faceletUri.equals(tgld.getUri())) {
+// return true;
+// }
+// }
+// }
+// return false;
+// }
+
+ /*
+ * analyse source for taglib, return the list of taglib
+ */
+ private static Properties getPrefixes(ISourceViewer viewer) {
+ VpeTaglibManager tldManager = null;
+ if((tldManager == null) && (viewer instanceof VpeTaglibManagerProvider)) {
+ tldManager = ((VpeTaglibManagerProvider)viewer).getTaglibManager();
+ if(tldManager != null) {
+ List list = tldManager.getTagLibs();
+ Properties p = new Properties();
+ for (int i = 0; i < list.size(); i++) {
+ TaglibData data = (TaglibData)list.get(i);
+ p.setProperty(data.getUri(), data.getPrefix());
+ }
+ return p;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * for jsp:root and html check the taglib if exist check the prefix else add the taglib
+ * with text formatting
+ */
+ private static Properties checkTL(Element root, ISourceViewer v, Properties p, IDocument d) {
+ String uri_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
+ String defaultPrefix_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX);
+
+ HashMap<String,String> map = new HashMap<String,String>();
+ NamedNodeMap attrs = root.getAttributes();
+ for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
+ Node a = attrs.item(j);
+ String name = a.getNodeName();
+
+ if (name.startsWith("xmlns:")) { //$NON-NLS-1$
+ map.put(a.getNodeValue(), name.substring("xmlns:".length())); //$NON-NLS-1$
+ }
+ }
+
+ if (map.containsKey(uri_p) || checkSelectedElement(map, v, p)) {
+ if (!map.get(uri_p).equals(defaultPrefix_p)) {
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, (String) map.get(uri_p));
+ }
+ } else if(!map.containsValue(defaultPrefix_p)) {
+ StringBuffer attribute = new StringBuffer("xmlns:").append(defaultPrefix_p).append("=\"").append(uri_p).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ int so = ((IDOMElement)root).getStartOffset();
+ int seo = ((IDOMElement)root).getStartEndOffset();
+ try {
+ String lineDelimiter = PaletteInsertHelper.getLineDelimiter(d);
+ StringBuffer selectedSource = new StringBuffer().append(d.get(so, seo-so));
+ int xmlns = selectedSource.indexOf("xmlns"); //$NON-NLS-1$
+ attribute = new StringBuffer().append(createEmptyCharArray(xmlns)).append("xmlns:").append(defaultPrefix_p).append("=\"").append(uri_p).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (d.getLineOffset(d.getLineOfOffset(so)) != so) {
+ attribute.insert(0, analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
+ }
+ if(xmlns>0) {
+ attribute.insert(0, lineDelimiter);
+ } else {
+ attribute.insert(0, ' ');
+ }
+ selectedSource.insert(selectedSource.length()-1, attribute);
+ d.replace(so, seo-so, selectedSource.toString());
+ } catch (BadLocationException t) {
+ ModelUIPlugin.getPluginLog().logError("", t); //$NON-NLS-1$
+ }
+ }
+ return p;
+ }
+
+ private static char[] createEmptyCharArray(int n){
+ if(n<1) {
+ return new char[0];
+ }
+ char[] ca = new char[n];
+ for (int i = 0; i < n; i++)
+ ca[i]=' ';
+ return ca;
+ }
+
+ private static void mouveFocusOnPage(Properties p, ISourceViewer v, int length, int pos){
+ ISelectionProvider selProvider = (ISelectionProvider)p.get(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER);
+ IDocument doc = v.getDocument();
+
+ if (doc== null || selProvider == null) return;
+
+ ITextSelection selection = (ITextSelection)selProvider.getSelection();
+ if (selection.getOffset() == 0) {
+ v.setSelectedRange(length,0);
+ p.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER,v.getSelectionProvider());
+ }
+ else
+ if (selection.getOffset() == pos ){
+ v.setSelectedRange(length, 0);
+ p.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER,v.getSelectionProvider());
+ }
+ }
+
+ /*
+ * analyse the space between the left corner and the start offset o the text
+ */
+ private static StringBuffer analyseSubstring(String str){
+ StringBuffer st = new StringBuffer().append(str);
+ for (int i = 0; i < st.length(); i++) {
+ if (st.charAt(i) != ' ' && st.charAt(i) !='\t' ) {
+ st.setCharAt(i, ' ');
+ }
+ }
+ return st;
+ }
+
+ private static boolean checkplace(IDOMDocument xmlDocument, IDocument d, String st, StringBuffer tg, Properties p, ISourceViewer v) throws BadLocationException {
+ NodeList nl = xmlDocument.getChildNodes();
+ boolean docType = false;
+ IndexedRegion irdt = null;
+
+ if (xmlDocument.getDoctype() != null) {
+ docType = true;
+ String publicId = xmlDocument.getDoctype().getPublicId();
+ if (publicId!=null && publicId.toUpperCase().startsWith("-//W3C//DTD HTML")) { //$NON-NLS-1$
+ irdt = (xmlDocument.getDoctype() instanceof IndexedRegion) ?
+ (IndexedRegion)xmlDocument.getDoctype(): null;
+ }
+ }
+
+ if (nl != null && nl.getLength() != 0) {
+ for (int i=0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+ //fing the first taglib to insert before
+ if (n.getNodeName().equals(st) && st.equals("jsp:directive.taglib")) { //$NON-NLS-1$
+ //calculate the space between taglib and left page corner
+ int so = ((ElementImpl)n).getStartOffset();
+ //taglib is at left corner
+ if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
+ d.replace(so, 0, tg.toString());
+ } else {
+ StringBuffer left = new StringBuffer().
+ append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
+ tg.insert(tg.length(), left);
+ d.replace(so, 0, tg.toString());
+ }
+ return true;
+ }
+ if ((n.getNodeName().equals(st) && st.equals("jsp:directive.page")) ) { //$NON-NLS-1$
+ tg.delete(tg.lastIndexOf(PaletteInsertHelper.getLineDelimiter(d)), tg.length());
+ int so = ((ElementImpl)n).getStartOffset();
+ int eo = ((ElementImpl)n).getEndStartOffset();
+ StringBuffer tgleft = new StringBuffer().append(PaletteInsertHelper.getLineDelimiter(d));
+ if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
+ tgleft.append(tg);
+ d.replace(eo, 0, tgleft.toString());
+ mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ } else {
+ tgleft.append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
+ tgleft.append(tg);
+ d.replace(eo, 0, tgleft.toString());
+ mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ }
+ return true;
+ }
+ if (docType && irdt != null) {
+ tg.delete(tg.lastIndexOf(PaletteInsertHelper.getLineDelimiter(d)), tg.length());
+ int so = irdt.getStartOffset();
+ int eo = irdt.getEndOffset();
+ StringBuffer tgleft = new StringBuffer().append(PaletteInsertHelper.getLineDelimiter(d));
+ if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
+ tgleft.append(tg);
+ d.replace(eo, 0, tgleft.toString());
+ mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ } else {
+ tgleft.append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
+ tgleft.append(tg);
+ d.replace(eo, 0, tgleft.toString());
+ mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
15 years, 4 months
JBoss Tools SVN: r17677 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: menu and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-21 08:31:32 -0400 (Mon, 21 Sep 2009)
New Revision: 17677
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Splitting PaletteInsertHelper into jsp and non-jsp related parts.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-09-21 12:30:56 UTC (rev 17676)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-09-21 12:31:32 UTC (rev 17677)
@@ -90,6 +90,7 @@
import org.jboss.tools.common.resref.core.ResourceReferenceListListener;
import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
import org.jboss.tools.jst.jsp.editor.IVisualController;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPTagProposalFactory;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.jst.web.tld.TLDUtil;
@@ -2233,7 +2234,7 @@
String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
String[] texts = new String[] { "<" + tagname + ">" }; //$NON-NLS-1$ //$NON-NLS-2$
- PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri,
+ JSPPaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri,
defaultPrefix);
tagname = texts[0].substring(1, texts[0].length() - 1);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java 2009-09-21 12:30:56 UTC (rev 17676)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java 2009-09-21 12:31:32 UTC (rev 17677)
@@ -32,6 +32,7 @@
import org.jboss.tools.common.model.ui.util.ModelUtilities;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
import org.jboss.tools.jst.web.tld.URIConstants;
import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.VpePlugin;
@@ -509,7 +510,7 @@
String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
String[] texts = new String[] { "<" + tagName + ">" }; //$NON-NLS-1$ //$NON-NLS-2$
if (tagName.indexOf("taglib") < 0) { //$NON-NLS-1$
- PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagName, uri, defaultPrefix);
+ JSPPaletteInsertHelper.applyPrefix(texts, sourceEditor, tagName, uri, defaultPrefix);
}
tagName = texts[0];
15 years, 4 months
JBoss Tools SVN: r17676 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui: problem and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-21 08:30:56 -0400 (Mon, 21 Sep 2009)
New Revision: 17676
Removed:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/CssLinkAttributeValueLoader.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ProblemDialog.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Splitting PaletteInsertHelper into jsp and non-jsp related parts.
Deleted: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/CssLinkAttributeValueLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/CssLinkAttributeValueLoader.java 2009-09-21 11:42:44 UTC (rev 17675)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/CssLinkAttributeValueLoader.java 2009-09-21 12:30:56 UTC (rev 17676)
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.editors.dnd;
-
-public class CssLinkAttributeValueLoader extends AbsoluteFilePathAttributeValueLoader {
-
- public CssLinkAttributeValueLoader(String pathAttributeName) {
- super(pathAttributeName, null, null);
- }
-
- public void fillTagAttributes(IDropWizardModel model) {
- super.fillTagAttributes(model);
- model.setAttributeValue("rel", "stylesheet"); //$NON-NLS-1$ //$NON-NLS-2$
- model.setAttributeValue("type", "text/css"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ProblemDialog.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ProblemDialog.java 2009-09-21 11:42:44 UTC (rev 17675)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ProblemDialog.java 2009-09-21 12:30:56 UTC (rev 17676)
@@ -76,12 +76,6 @@
super.buttonPressed(buttonId);
}
-/*
- public static int open(Shell shell, String message) {
- JspPreviewErrorDialog dialog = new JspPreviewErrorDialog(shell, JspPreviewMessages.getString(DEFAULT_TITLE), message);
- return dialog.open();
- }
-*/
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#open()
*/
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java 2009-09-21 11:42:44 UTC (rev 17675)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java 2009-09-21 12:30:56 UTC (rev 17676)
@@ -56,8 +56,6 @@
public static final String PROPOPERTY_SELECTION_PROVIDER = "selectionProvider"; //$NON-NLS-1$
public static final String PROPOPERTY_ADD_TAGLIB = TLDToPaletteHelper.ADD_TAGLIB;
- static PaletteTaglibInserter PaletteTaglibInserter = new PaletteTaglibInserter();
-
static PaletteInsertHelper instance = new PaletteInsertHelper();
public static PaletteInsertHelper getInstance() {
@@ -101,10 +99,8 @@
}
public void insertIntoEditor(final ISourceViewer v, Properties p) {
- String tagname = p.getProperty(PROPOPERTY_TAG_NAME);
String startText = p.getProperty(PROPOPERTY_START_TEXT);
String endText = p.getProperty(PROPOPERTY_END_TEXT);
- String uri = p.getProperty(PROPOPERTY_TAGLIBRARY_URI);
ISelectionProvider selProvider
= (ISelectionProvider)p.get(PROPOPERTY_SELECTION_PROVIDER);
@@ -113,18 +109,12 @@
}
IDocument d = v.getDocument();
+
String[] texts = new String[] {startText, endText};
+
+ //do any auxiliary job here
+ modify(v, p, texts);
- if(startText != null && startText.startsWith("<%@ taglib")) { //$NON-NLS-1$
- if(PaletteTaglibInserter.inserTaglibInXml(v, p)) {
- return;
- }
- } else {
- p = PaletteTaglibInserter.inserTaglib(v, p);
- }
-
- String defaultPrefix = p.getProperty(PROPOPERTY_DEFAULT_PREFIX);
- applyPrefix(texts, d, tagname, uri, defaultPrefix);
startText = texts[0];
endText = texts[1];
@@ -155,6 +145,10 @@
}
}
+ protected void modify(ISourceViewer v, Properties p, String[] texts) {
+ //override
+ }
+
protected void insertIntoEditorInternal(IDocument doc, Properties p) {
String startText = p.getProperty(PROPOPERTY_START_TEXT);
String endText = p.getProperty(PROPOPERTY_END_TEXT);
@@ -496,102 +490,4 @@
}
}
- /**
- * adding prefix to tag
- */
- public static void applyPrefix(String[] text, ITextEditor editor, String tagname, String uri, String defaultPrefix) {
- if(defaultPrefix == null || defaultPrefix.length() == 0) return;
- IDocument doc = null;
- if(editor != null && editor.getDocumentProvider() != null) {
- doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
- }
- applyPrefix(text, doc, tagname, uri, defaultPrefix);
- }
-
- public static void applyPrefix(String[] text, IDocument doc, String tagname, String uri, String defaultPrefix) {
- if(doc == null) return;
- String body = doc.get();
- applyPrefix(text, body, tagname, uri, defaultPrefix);
- }
-
- public static void applyPrefix(String[] text, String body, String tagname, String uri, String defaultPrefix) {
- if(uri == null || uri.length() == 0) return;
- Properties p = getPrefixes(body);
- String prefix = p.getProperty(uri, defaultPrefix);
- if(prefix == null || prefix.length() == 0) return;
- for (int i = 0; i < text.length; i++) text[i] = applyPrefix(text[i], tagname, prefix, p);
- }
-
- static String applyPrefix(String text, String tagname, String prefix, Properties prefixes) {
- if(text == null || text.length() == 0) return text;
- if(tagname == null || tagname.length() == 0) return text;
- while(true) {
- int i = text.indexOf("%prefix|"); //$NON-NLS-1$
- if(i < 0) break;
- int j = text.indexOf("%", i + 8); //$NON-NLS-1$
- if(j < 0) break;
- int j1 = text.indexOf("|", i + 8); //$NON-NLS-1$
- String uri = ""; //$NON-NLS-1$
- String defaultPrefix = ""; //$NON-NLS-1$
- String pr = ""; //$NON-NLS-1$
- uri = text.substring(i + 8, j1);
- defaultPrefix = text.substring(j1 + 1, j);
- pr = prefixes.getProperty(uri, defaultPrefix);
- if(pr.length() > 0) {
- text = text.substring(0, i) + pr + ":" + text.substring(j + 1); //$NON-NLS-1$
- } else {
- text = text.substring(0, i) + text.substring(j + 1);
- }
- }
-
- int k = text.toLowerCase().indexOf(":" + tagname.toLowerCase()); //$NON-NLS-1$
- if(k >= 0) {
- int g = text.indexOf("</"); //$NON-NLS-1$
- if(g >= 0 && g < k) {
- return text.substring(0, g + 2) + prefix + text.substring(k);
- }
- g = text.indexOf("<"); //$NON-NLS-1$
- if(g >= 0 && g < k) {
- return text.substring(0, g + 1) + prefix + text.substring(k);
- }
- }
- k = text.toLowerCase().indexOf("<" + tagname.toLowerCase()); //$NON-NLS-1$
- if(k >= 0) {
- return text.substring(0, k + 1) + prefix + ":" + text.substring(k + 1); //$NON-NLS-1$
- }
- k = text.toLowerCase().indexOf("</" + tagname.toLowerCase()); //$NON-NLS-1$
- if(k >= 0) {
- return text.substring(0, k + 2) + prefix + ":" + text.substring(k + 2); //$NON-NLS-1$
- }
- return text;
- }
-
- static Properties getPrefixes(String body) {
- Properties p = new Properties();
- int i = 0;
- while(i >= 0 && i < body.length()) {
- i = body.indexOf("<%@ taglib ", i); //$NON-NLS-1$
- if(i < 0) break;
- int j = body.indexOf("%>", i); //$NON-NLS-1$
- if(j < 0) j = body.length();
- String taglib = body.substring(i, j);
- getPrefix(p, taglib);
- i = j + 1;
- }
- return p;
- }
-
- static void getPrefix(Properties p, String taglib) {
- int i = taglib.indexOf("uri=\""); //$NON-NLS-1$
- if(i < 0) return;
- int j = taglib.indexOf("\"", i + 5); //$NON-NLS-1$
- if(j < 0) return;
- String uri = taglib.substring(i + 5, j);
- i = taglib.indexOf("prefix=\""); //$NON-NLS-1$
- if(i < 0) return;
- j = taglib.indexOf("\"", i + 8); //$NON-NLS-1$
- if(j < 0) return;
- String prefix = taglib.substring(i + 8, j);
- p.setProperty(uri, prefix);
- }
}
\ No newline at end of file
Deleted: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java 2009-09-21 11:42:44 UTC (rev 17675)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java 2009-09-21 12:30:56 UTC (rev 17676)
@@ -1,403 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.views.palette;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class PaletteTaglibInserter {
-
- private static final String JSP_SOURCE_ROOT_ELEMENT = "jsp:root"; //$NON-NLS-1$
- public static final String JSP_URI = "http://java.sun.com/JSP/Page"; //$NON-NLS-1$
- public static final String faceletUri = "http://java.sun.com/jsf/facelets"; //$NON-NLS-1$
-
- private static final String TAGLIB_START = "<%@ taglib"; //$NON-NLS-1$
-
- public Properties inserTaglib(ISourceViewer v, Properties p) {
- if(!inserTaglibInXml(v, p)) {
- inserTaglibInOldJsp(v, p);
- }
- return p;
- }
-
- private boolean checkProperties(Properties p) {
- return "true".equalsIgnoreCase(p.getProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB)) && //$NON-NLS-1$
- p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI) != null &&
- p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI).length() > 0 &&
- !p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI).equals(JSP_URI) &&
- p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX) != null &&
- p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX).length() > 0 &&
- p.getProperty(PaletteInsertHelper.PROPOPERTY_START_TEXT) != null;
- }
-
- public boolean inserTaglibInOldJsp(ISourceViewer v, Properties p) {
- if(!checkProperties(p)) {
- return false;
- }
-
- IDocument d = v.getDocument();
- IStructuredModel model = null;
-
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(d);
- IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
- if (xmlDocument == null) {
- return false;
- }
- Properties tl = getPrefixes(v);
- if(tl == null) tl = PaletteInsertHelper.getPrefixes(d.get());
- Element root = xmlDocument.getDocumentElement();
-
- String uri_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
- String defaultPrefix_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX);
- String lineDelimiter = PaletteInsertHelper.getLineDelimiter(d);
- StringBuffer tg = new StringBuffer(TAGLIB_START).append(" uri=\"").append(uri_p).append("\"").append(" prefix=\"").append(defaultPrefix_p).append("\"%>").append(lineDelimiter); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- if (tl != null && !tl.isEmpty()) {
- //If taglib already exist check the prefix if changed
- if (tl.containsKey(uri_p)) {
- if (!tl.get(uri_p).equals(defaultPrefix_p)) {
- p.setProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, (String)tl.get(uri_p));
- }
- } else if(!tl.containsValue(defaultPrefix_p)) {
- if (checkplace(xmlDocument, d, "jsp:directive.taglib", tg, p, v) == false) { //$NON-NLS-1$
- d.replace(0, 0, tg.toString());
- mouveFocusOnPage(p,v, tg.toString().length(), 0);
- return true;
- }
- }
- } else if(xmlDocument instanceof DocumentImpl) {
- DocumentImpl docImpl = (DocumentImpl)xmlDocument;
- // Only for JSP
- if(docImpl.isJSPType()) {
- if (checkplace(xmlDocument, d, "jsp:directive.page", tg, p, v) == false) { //$NON-NLS-1$
- d.replace(0, 0, tg.toString());
- mouveFocusOnPage(p,v, tg.toString().length(), 0);
- return true;
- }
- }
- }
- } catch (BadLocationException e) {
- ModelUIPlugin.getPluginLog().logError(e);
- } finally {
- if (model != null) model.releaseFromRead();
- }
- return false;
- }
-
- private static Node getSelectedNode(ISourceViewer v, Properties p){
- ISelectionProvider selProvider = (ISelectionProvider)p.get(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER);
- if(selProvider == null) return null;
-
- ITextSelection selection = null;
-
- if(selProvider.getSelection() instanceof ITextSelection)
- selection = (ITextSelection)selProvider.getSelection();
- else return null;
-
- IndexedRegion region = ContentAssistUtils.getNodeAt(v, selection.getOffset());
- if(region == null) return null;
-
- if(!(region instanceof Node)) return null;
-
- Node text = (Node)region;
-
-
- if("#text".equals(text.getNodeName())) //$NON-NLS-1$
- return text.getParentNode();
- else
- return text;
- }
-
- private static boolean checkSelectedElement(HashMap<String,String> map, ISourceViewer v, Properties p){
- String taglibUri = p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
- if(taglibUri == null) return false;
-
- Node selectedNode = getSelectedNode(v, p);
- if(selectedNode == null) return false;
-
- return checkElement(map, selectedNode, taglibUri);
- }
-
- private static boolean checkElement(HashMap<String,String> map, Node node, String taglibUri){
-
- NamedNodeMap attrs = node.getAttributes();
- for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
- Node a = attrs.item(j);
- String name = a.getNodeName();
-
- if (name.startsWith("xmlns:")) { //$NON-NLS-1$
- map.put(a.getNodeValue(), name.substring("xmlns:".length())); //$NON-NLS-1$
- }
- }
-
- if (map.containsKey(taglibUri)) return true;
- else{
- if(node.getParentNode() == null) return false;
- else return checkElement(map, node.getParentNode(), taglibUri);
- }
- }
-
- public boolean inserTaglibInXml(ISourceViewer v, Properties p) {
- if(!checkProperties(p)) {
- return false;
- }
-
- IDocument d = v.getDocument();
- IStructuredModel model = null;
-
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(d);
- IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
-
- if (xmlDocument == null) {
- return false;
- }
-
- Properties tl = getPrefixes(v);
- if(tl == null) tl = PaletteInsertHelper.getPrefixes(d.get());
- Element root = xmlDocument.getDocumentElement();
- if(root != null) {
- // for xhtml and jsp:root
- if (xmlDocument.getDoctype() != null /* && tagLibListConainsFacelet(tl)*/ ) {
- String publicId = xmlDocument.getDoctype().getPublicId();
- if (publicId!=null && publicId.toUpperCase().startsWith("-//W3C//DTD XHTML")) { // && root.getNodeName().equalsIgnoreCase(HTML_SOURCE_ROOT_ELEMENT)) { //$NON-NLS-1$
- checkTL(root, v, p, d);
- return true;
- }
- } else if(xmlDocument.isXMLType() || root.getNodeName().equals(JSP_SOURCE_ROOT_ELEMENT)) {
- checkTL(root, v, p, d);
- return true;
- }
- }
- } finally {
- if (model != null) model.releaseFromRead();
- }
- return false;
- }
-
-// private static boolean tagLibListConainsFacelet(List tagLibList) {
-// if (tagLibList != null && !tagLibList.isEmpty()) {
-// for (int i = 0; i < tagLibList.size(); i++) {
-// TaglibData tgld = (TaglibData)tagLibList.get(i);
-// if(faceletUri.equals(tgld.getUri())) {
-// return true;
-// }
-// }
-// }
-// return false;
-// }
-
- /*
- * analyse source for taglib, return the list of taglib
- */
- private static Properties getPrefixes(ISourceViewer viewer) {
- VpeTaglibManager tldManager = null;
- if((tldManager == null) && (viewer instanceof VpeTaglibManagerProvider)) {
- tldManager = ((VpeTaglibManagerProvider)viewer).getTaglibManager();
- if(tldManager != null) {
- List list = tldManager.getTagLibs();
- Properties p = new Properties();
- for (int i = 0; i < list.size(); i++) {
- TaglibData data = (TaglibData)list.get(i);
- p.setProperty(data.getUri(), data.getPrefix());
- }
- return p;
- }
- }
- return null;
- }
-
- /*
- * for jsp:root and html check the taglib if exist check the prefix else add the taglib
- * with text formatting
- */
- private static Properties checkTL(Element root, ISourceViewer v, Properties p, IDocument d) {
- String uri_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
- String defaultPrefix_p = p.getProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX);
-
- HashMap<String,String> map = new HashMap<String,String>();
- NamedNodeMap attrs = root.getAttributes();
- for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
- Node a = attrs.item(j);
- String name = a.getNodeName();
-
- if (name.startsWith("xmlns:")) { //$NON-NLS-1$
- map.put(a.getNodeValue(), name.substring("xmlns:".length())); //$NON-NLS-1$
- }
- }
-
- if (map.containsKey(uri_p) || checkSelectedElement(map, v, p)) {
- if (!map.get(uri_p).equals(defaultPrefix_p)) {
- p.setProperty(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, (String) map.get(uri_p));
- }
- } else if(!map.containsValue(defaultPrefix_p)) {
- StringBuffer attribute = new StringBuffer("xmlns:").append(defaultPrefix_p).append("=\"").append(uri_p).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- int so = ((IDOMElement)root).getStartOffset();
- int seo = ((IDOMElement)root).getStartEndOffset();
- try {
- String lineDelimiter = PaletteInsertHelper.getLineDelimiter(d);
- StringBuffer selectedSource = new StringBuffer().append(d.get(so, seo-so));
- int xmlns = selectedSource.indexOf("xmlns"); //$NON-NLS-1$
- attribute = new StringBuffer().append(createEmptyCharArray(xmlns)).append("xmlns:").append(defaultPrefix_p).append("=\"").append(uri_p).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (d.getLineOffset(d.getLineOfOffset(so)) != so) {
- attribute.insert(0, analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
- }
- if(xmlns>0) {
- attribute.insert(0, lineDelimiter);
- } else {
- attribute.insert(0, ' ');
- }
- selectedSource.insert(selectedSource.length()-1, attribute);
- d.replace(so, seo-so, selectedSource.toString());
- } catch (BadLocationException t) {
- ModelUIPlugin.getPluginLog().logError("", t); //$NON-NLS-1$
- }
- }
- return p;
- }
-
- private static char[] createEmptyCharArray(int n){
- if(n<1) {
- return new char[0];
- }
- char[] ca = new char[n];
- for (int i = 0; i < n; i++)
- ca[i]=' ';
- return ca;
- }
-
- private static void mouveFocusOnPage(Properties p, ISourceViewer v, int length, int pos){
- ISelectionProvider selProvider = (ISelectionProvider)p.get(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER);
- IDocument doc = v.getDocument();
-
- if (doc== null || selProvider == null) return;
-
- ITextSelection selection = (ITextSelection)selProvider.getSelection();
- if (selection.getOffset() == 0) {
- v.setSelectedRange(length,0);
- p.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER,v.getSelectionProvider());
- }
- else
- if (selection.getOffset() == pos ){
- v.setSelectedRange(length, 0);
- p.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER,v.getSelectionProvider());
- }
- }
-
- /*
- * analyse the space between the left corner and the start offset o the text
- */
- private static StringBuffer analyseSubstring(String str){
- StringBuffer st = new StringBuffer().append(str);
- for (int i = 0; i < st.length(); i++) {
- if (st.charAt(i) != ' ' && st.charAt(i) !='\t' ) {
- st.setCharAt(i, ' ');
- }
- }
- return st;
- }
-
- private static boolean checkplace(IDOMDocument xmlDocument, IDocument d, String st, StringBuffer tg, Properties p, ISourceViewer v) throws BadLocationException {
- NodeList nl = xmlDocument.getChildNodes();
- boolean docType = false;
- IndexedRegion irdt = null;
-
- if (xmlDocument.getDoctype() != null) {
- docType = true;
- String publicId = xmlDocument.getDoctype().getPublicId();
- if (publicId!=null && publicId.toUpperCase().startsWith("-//W3C//DTD HTML")) { //$NON-NLS-1$
- irdt = (xmlDocument.getDoctype() instanceof IndexedRegion) ?
- (IndexedRegion)xmlDocument.getDoctype(): null;
- }
- }
-
- if (nl != null && nl.getLength() != 0) {
- for (int i=0; i < nl.getLength(); i++) {
- Node n = nl.item(i);
- //fing the first taglib to insert before
- if (n.getNodeName().equals(st) && st.equals("jsp:directive.taglib")) { //$NON-NLS-1$
- //calculate the space between taglib and left page corner
- int so = ((ElementImpl)n).getStartOffset();
- //taglib is at left corner
- if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
- d.replace(so, 0, tg.toString());
- } else {
- StringBuffer left = new StringBuffer().
- append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
- tg.insert(tg.length(), left);
- d.replace(so, 0, tg.toString());
- }
- return true;
- }
- if ((n.getNodeName().equals(st) && st.equals("jsp:directive.page")) ) { //$NON-NLS-1$
- tg.delete(tg.lastIndexOf(PaletteInsertHelper.getLineDelimiter(d)), tg.length());
- int so = ((ElementImpl)n).getStartOffset();
- int eo = ((ElementImpl)n).getEndStartOffset();
- StringBuffer tgleft = new StringBuffer().append(PaletteInsertHelper.getLineDelimiter(d));
- if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
- tgleft.append(tg);
- d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
- } else {
- tgleft.append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
- tgleft.append(tg);
- d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
- }
- return true;
- }
- if (docType && irdt != null) {
- tg.delete(tg.lastIndexOf(PaletteInsertHelper.getLineDelimiter(d)), tg.length());
- int so = irdt.getStartOffset();
- int eo = irdt.getEndOffset();
- StringBuffer tgleft = new StringBuffer().append(PaletteInsertHelper.getLineDelimiter(d));
- if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
- tgleft.append(tg);
- d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
- } else {
- tgleft.append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)), so-d.getLineOffset(d.getLineOfOffset(so)))));
- tgleft.append(tg);
- d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
- }
- return true;
- }
- }
- }
- return false;
- }
-}
\ No newline at end of file
15 years, 4 months