JBoss Tools SVN: r15256 - trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-05-14 11:51:13 -0400 (Thu, 14 May 2009)
New Revision: 15256
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectAdoptOperation.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectCreationOperation.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectAdoptOperation.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectAdoptOperation.java 2009-05-14 15:50:38 UTC (rev 15255)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectAdoptOperation.java 2009-05-14 15:51:13 UTC (rev 15256)
@@ -30,6 +30,7 @@
import org.jboss.tools.jsf.web.JSFTemplate;
import org.jboss.tools.jsf.web.helpers.context.AdoptJSFProjectFinisher;
import org.jboss.tools.jst.web.context.IImportWebProjectContext;
+import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.ui.operation.WebProjectAdoptOperation;
public class JSFProjectAdoptOperation extends WebProjectAdoptOperation {
@@ -100,6 +101,11 @@
});
}
}
+ try {
+ EclipseResourceUtil.addNatureToProject(getProject(), IKbProject.NATURE_ID);
+ } catch (CoreException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ }
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectCreationOperation.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectCreationOperation.java 2009-05-14 15:50:38 UTC (rev 15255)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/operation/JSFProjectCreationOperation.java 2009-05-14 15:51:13 UTC (rev 15256)
@@ -35,6 +35,7 @@
import org.jboss.tools.jsf.web.JSFTemplate;
import org.jboss.tools.jst.web.WebUtils;
import org.jboss.tools.jst.web.context.RegisterServerContext;
+import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.project.helpers.IWebProjectTemplate;
import org.jboss.tools.jst.web.project.helpers.NewWebProjectContext;
import org.jboss.tools.jst.web.ui.operation.WebProjectCreationOperation;
@@ -140,6 +141,12 @@
projectFile = null;
}
model.getProperties().put(XModelConstants.AUTOLOAD, new JSFAutoLoad());
+
+ try {
+ EclipseResourceUtil.addNatureToProject(getProject(), IKbProject.NATURE_ID);
+ } catch (CoreException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ }
}
}
15 years, 6 months
JBoss Tools SVN: r15255 - in trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf: project/facet and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-05-14 11:50:38 -0400 (Thu, 14 May 2009)
New Revision: 15255
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/facet/PostInstallJsfFacetDelegate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java 2009-05-14 15:50:04 UTC (rev 15254)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java 2009-05-14 15:50:38 UTC (rev 15255)
@@ -1,10 +1,15 @@
package org.jboss.tools.jsf.model.handlers;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.common.meta.action.SpecialWizard;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.model.JSFConstants;
+import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
public class RemoveJSFNatureContribution implements SpecialWizard {
@@ -38,6 +43,15 @@
DefaultRemoveHandler.removeFromParent(params[i]);
}
}
+
+ IProject project = EclipseResourceUtil.getProject(model.getRoot());
+ if(project != null) {
+ try {
+ EclipseResourceUtil.removeNatureFromProject(project, IKbProject.NATURE_ID);
+ } catch (CoreException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ }
+ }
return 0;
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/facet/PostInstallJsfFacetDelegate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/facet/PostInstallJsfFacetDelegate.java 2009-05-14 15:50:04 UTC (rev 15254)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/facet/PostInstallJsfFacetDelegate.java 2009-05-14 15:50:38 UTC (rev 15255)
@@ -17,6 +17,8 @@
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jsf.project.JSFNature;
+import org.jboss.tools.jst.web.kb.IKbProject;
/**
*
@@ -33,7 +35,8 @@
writeXModel(project);
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- EclipseResourceUtil.addNatureToProject(project, "org.jboss.tools.jsf.jsfnature");
+ EclipseResourceUtil.addNatureToProject(project, JSFNature.NATURE_ID);
+ EclipseResourceUtil.addNatureToProject(project, IKbProject.NATURE_ID);
}
private void writeXModel(IProject project) {
15 years, 6 months
JBoss Tools SVN: r15254 - in trunk/jst/plugins/org.jboss.tools.jst.web: src/org/jboss/tools/jst/web/kb and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-05-14 11:50:04 -0400 (Thu, 14 May 2009)
New Revision: 15254
Added:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml 2009-05-14 15:20:00 UTC (rev 15253)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml 2009-05-14 15:50:04 UTC (rev 15254)
@@ -272,4 +272,29 @@
</extension>
+ <extension
+ id="kbbuilder"
+ name="KB Builder"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ hasNature="false">
+ <run
+ class="org.jboss.tools.jst.web.kb.internal.KbBuilder">
+ </run>
+ </builder>
+ </extension>
+ <extension
+ id="kbnature"
+ name="KB Project Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.jboss.tools.jst.web.kb.internal.KbProject">
+ </run>
+ </runtime>
+ <builder
+ id="org.jboss.tools.jst.web.kbbuilder">
+ </builder>
+ </extension>
+
</plugin>
Added: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java 2009-05-14 15:50:04 UTC (rev 15254)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb;
+
+import org.eclipse.core.resources.IProjectNature;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public interface IKbProject extends IProjectNature {
+ public static String NATURE_ID = "org.jboss.tools.jst.web.kbnature"; //$NON-NLS-1$
+
+ public ITagLibrary[] getTagLibraries();
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java 2009-05-14 15:50:04 UTC (rev 15254)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public class KbBuilder extends IncrementalProjectBuilder {
+ public static String BUILDER_ID = "org.jboss.tools.jst.web.kbbuilder"; //$NON-NLS-1$
+
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
+ throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-14 15:50:04 UTC (rev 15254)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public class KbProject implements IKbProject {
+ IProject project;
+
+ ITagLibrary[] tagLibraries = new ITagLibrary[0];
+
+ public ITagLibrary[] getTagLibraries() {
+ return tagLibraries;
+ }
+
+ public void configure() throws CoreException {
+ addToBuildSpec(KbBuilder.BUILDER_ID);
+ }
+
+ public void deconfigure() throws CoreException {
+ removeFromBuildSpec(KbBuilder.BUILDER_ID);
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
+ protected void addToBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand command = null;
+ ICommand commands[] = description.getBuildSpec();
+ for (int i = 0; i < commands.length && command == null; ++i) {
+ if (commands[i].getBuilderName().equals(builderID))
+ command = commands[i];
+ }
+ if (command == null) {
+ command = description.newCommand();
+ command.setBuilderName(builderID);
+ ICommand[] oldCommands = description.getBuildSpec();
+ ICommand[] newCommands = new ICommand[oldCommands.length + 1];
+ System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length);
+ newCommands[oldCommands.length] = command;
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ }
+ }
+
+ static String EXTERNAL_TOOL_BUILDER = "org.eclipse.ui.externaltools.ExternalToolBuilder";
+ static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle";
+
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
+ protected void removeFromBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ String builderName = commands[i].getBuilderName();
+ if (!builderName.equals(builderID)) {
+ if(!builderName.equals(EXTERNAL_TOOL_BUILDER)) continue;
+ Object handle = commands[i].getArguments().get(LAUNCH_CONFIG_HANDLE);
+ if(handle == null || handle.toString().indexOf(builderID) < 0) continue;
+ }
+ ICommand[] newCommands = new ICommand[commands.length - 1];
+ System.arraycopy(commands, 0, newCommands, 0, i);
+ System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ return;
+ }
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 6 months
JBoss Tools SVN: r15253 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-05-14 11:20:00 -0400 (Thu, 14 May 2009)
New Revision: 15253
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4315
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java 2009-05-14 14:43:47 UTC (rev 15252)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java 2009-05-14 15:20:00 UTC (rev 15253)
@@ -17,6 +17,7 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
@@ -24,6 +25,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.refactoring.RenameComponentProcessor;
@@ -54,17 +56,21 @@
IProject project = file.getProject();
ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
- ISeamComponent component=null;
if (seamProject != null) {
Set<ISeamComponent> components = seamProject.getComponentsByPath(file.getFullPath());
- if (!components.isEmpty()) {
- // This is a component which we want to rename.
- component = components.iterator().next();
+ for(ISeamComponent component : components){
+ ISeamJavaComponentDeclaration declaration = component.getJavaDeclaration();
+ if(declaration != null){
+ IResource resource = declaration.getResource();
+ if(resource != null && resource.getFullPath().equals(file.getFullPath())){
+ if(declaration.getName().equals(component.getName())){
+ invokeRenameWizard(component, activeShell);
+ return null;
+ }
+ }
+ }
}
}
-
- invokeRenameWizard(component, activeShell);
-
}
return null;
}
15 years, 6 months
JBoss Tools SVN: r15252 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-05-14 10:43:47 -0400 (Thu, 14 May 2009)
New Revision: 15252
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4313
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-05-14 14:42:10 UTC (rev 15251)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-05-14 14:43:47 UTC (rev 15252)
@@ -417,14 +417,15 @@
Set<ISeamFactory> factorySet = seamProject.getFactoriesByName(component.getName());
for(ISeamFactory factory : factorySet){
- ISeamTextSourceReference location = factory.getLocationFor(SeamAnnotations.FACTORY_ANNOTATION_TYPE);
- if(location != null){
- IFile file = (IFile)factory.getResource();
-
- if(file.getFileExtension().equalsIgnoreCase(XML_EXT))
+ IFile file = (IFile)factory.getResource();
+ if(file.getFileExtension().equalsIgnoreCase(JAVA_EXT)){
+ ISeamTextSourceReference location = factory.getLocationFor(SeamAnnotations.FACTORY_ANNOTATION_TYPE);
+ if(location != null)
+ changeAnnotation(location, file);
+ }else{
+ ISeamTextSourceReference location = factory.getLocationFor(ISeamXmlComponentDeclaration.NAME);
+ if(location != null)
changeXMLNode(location, file);
- else
- changeAnnotation(location, file);
}
}
}
15 years, 6 months
JBoss Tools SVN: r15251 - in trunk/hibernatetools/plugins: org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-05-14 10:42:10 -0400 (Thu, 14 May 2009)
New Revision: 15251
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenFileActionUtils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLQuickAssistProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4285 - code review - make code more readable: rename/create functions where it was necessary, use proper interfaces, reduce code size, add code comments; functionality remains the same
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenFileActionUtils.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenFileActionUtils.java 2009-05-14 14:10:06 UTC (rev 15250)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenFileActionUtils.java 2009-05-14 14:42:10 UTC (rev 15251)
@@ -23,180 +23,268 @@
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.VisitorSupport;
+import org.dom4j.io.SAXReader;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
+import org.hibernate.tool.hbm2x.Cfg2HbmTool;
import org.hibernate.util.StringHelper;
import org.hibernate.util.XMLHelper;
+import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
+/**
+ * Utility class for useful open mapping file action functions.
+ *
+ * @author Dmitry Geraskov
+ * @author Vitali Yemialyanchyk
+ */
public class OpenFileActionUtils {
- private static XMLHelper helper = new XMLHelper();
+
+ public static final String HIBERNATE_TAG_CLASS = "class"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_TABLE = "table"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_SUBCLASS = "subclass"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_JOINED_SUBCLASS = "joined-subclass"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_UNION_SUBCLASS = "union-subclass"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_NAME = "name"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_ENTITY_NAME = "entity-name"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_SESSION_FACTORY = "session-factory"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_MAPPING = "mapping"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_RESOURCE = "resource"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_CATALOG = "catalog"; //$NON-NLS-1$
+ public static final String HIBERNATE_TAG_SCHEMA = "schema"; //$NON-NLS-1$
+ public static final String EJB_TAG_ENTITY = "entity"; //$NON-NLS-1$
+ public static final String EJB_TAG_CLASS = "class"; //$NON-NLS-1$
+
+ //prohibit constructor call
+ private OpenFileActionUtils() {}
- private static final String HIBERNATE_TAG_CLASS = "class"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_TABLE = "table"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_SUBCLASS = "subclass"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_JOINED_SUBCLASS = "joined-subclass"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_UNION_SUBCLASS = "union-subclass"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_NAME = "name"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_ENTITY_NAME = "entity-name"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_SESSION_FACTORY = "session-factory"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_MAPPING = "mapping"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_RESOURCE = "resource"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_CATALOG = "catalog"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_SCHEMA = "schema"; //$NON-NLS-1$
-
- private OpenFileActionUtils() {
+ /**
+ * Get name of a persistent class.
+ * @param rootClass
+ * @return
+ */
+ public static String getPersistentClassName(PersistentClass rootClass) {
+ if (rootClass == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return rootClass.getEntityName() != null ? rootClass.getEntityName() : rootClass.getClassName();
}
- public static IEditorPart openEditor(IWorkbenchPage page, IResource resource) throws PartInitException {
- return IDE.openEditor(page, (IFile) resource);
+ /**
+ * Formulate a full table name.
+ * @param catalog
+ * @param schema
+ * @param name
+ * @return
+ */
+ public static String getTableName(String catalog, String schema, String name) {
+ return (catalog != null ? catalog + '.' : "") + (schema != null ? schema + '.' : "") + name; //$NON-NLS-1$ //$NON-NLS-2$
}
+ /**
+ * Get a full table name.
+ * @param table
+ * @return
+ */
+ public static String getTableName(Table table) {
+ return getTableName(table.getCatalog(), table.getSchema(), table.getName());
+ }
- public static boolean rootClassHasAnnotations(ConsoleConfiguration consoleConfiguration, PersistentClass rootClass) {
+ /**
+ * Check has consoleConfiguration config.xml file a mapping class for provided rootClass.
+ * @param consoleConfiguration
+ * @param rootClass
+ * @return
+ */
+ public static boolean hasConfigXMLMappingClassAnnotation(ConsoleConfiguration consoleConfiguration, PersistentClass rootClass) {
java.io.File configXMLFile = consoleConfiguration.getPreferences().getConfigXMLFile();
if (configXMLFile == null) {
return true;
}
- Document doc = getDocument(consoleConfiguration, configXMLFile);
+ EntityResolver entityResolver = consoleConfiguration.getConfiguration().getEntityResolver();
+ Document doc = getDocument(configXMLFile, entityResolver);
return getElements(doc, HIBERNATE_TAG_MAPPING, HIBERNATE_TAG_CLASS, getPersistentClassName(rootClass)).hasNext();
}
- static String getPersistentClassName(PersistentClass rootClass) {
- if (rootClass == null) {
- return ""; //$NON-NLS-1$
- } else {
- return rootClass.getEntityName() != null ? rootClass.getEntityName() : rootClass.getClassName();
- }
- }
-
- private static String getTableName(String catalog, String schema, String name) {
- return (catalog != null ? catalog + '.' : "") + (schema != null ? schema + '.' : "") + name; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static String getTableName(Table table) {
- return getTableName(table.getCatalog(), table.getSchema(), table.getName());
- }
-
-
- private static boolean elementInResource(ConsoleConfiguration consoleConfiguration, IResource resource, Object element) {
+ /**
+ * Check has this particular element correspondence in the file.
+ * @param consoleConfiguration
+ * @param file
+ * @param element
+ * @return
+ */
+ public static boolean elementInFile(ConsoleConfiguration consoleConfiguration, IFile file, Object element) {
boolean res = false;
if (element instanceof RootClass) {
- res = rootClassInResource(consoleConfiguration, resource, (RootClass)element);
+ res = rootClassInFile(consoleConfiguration, file, (RootClass)element);
} else if (element instanceof Subclass) {
- res = subclassInResource(consoleConfiguration, resource, (Subclass)element);
+ res = subclassInFile(consoleConfiguration, file, (Subclass)element);
} else if (element instanceof Table) {
- res = tableInResource(consoleConfiguration, resource, (Table)element);
+ res = tableInFile(consoleConfiguration, file, (Table)element);
}
return res;
}
+
+ private static String[][] classPairs = {
+ { HIBERNATE_TAG_CLASS, HIBERNATE_TAG_NAME, },
+ { HIBERNATE_TAG_CLASS, HIBERNATE_TAG_ENTITY_NAME, },
+ { EJB_TAG_ENTITY, HIBERNATE_TAG_CLASS, },
+ { EJB_TAG_ENTITY, HIBERNATE_TAG_NAME, },
+ };
- // TODO: this is *extremely* inefficient - no need to scan the whole tree again and again.
- private static boolean rootClassInResource(ConsoleConfiguration consoleConfiguration, IResource resource, RootClass persistentClass) {
- Document doc = getDocument(consoleConfiguration, resource.getLocation().toFile());
- return getElements(doc, OpenFileActionUtils.HIBERNATE_TAG_CLASS, HIBERNATE_TAG_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, OpenFileActionUtils.HIBERNATE_TAG_CLASS, HIBERNATE_TAG_NAME, getPersistentClassName(persistentClass)).hasNext() ||
- getElements(doc, OpenFileActionUtils.HIBERNATE_TAG_CLASS, HIBERNATE_TAG_ENTITY_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, OpenFileActionUtils.HIBERNATE_TAG_CLASS, HIBERNATE_TAG_ENTITY_NAME, getPersistentClassName(persistentClass)).hasNext();
+ /**
+ * Check has this particular rootClass correspondence in the file.
+ * @param consoleConfiguration
+ * @param file
+ * @param rootClass
+ * @return
+ */
+ public static boolean rootClassInFile(ConsoleConfiguration consoleConfiguration, IFile file, RootClass rootClass) {
+ EntityResolver entityResolver = consoleConfiguration.getConfiguration().getEntityResolver();
+ Document doc = getDocument(file.getLocation().toFile(), entityResolver);
+ final String clName = getPersistentClassName(rootClass);
+ final String clNameUnq = StringHelper.unqualify(clName);
+ boolean res = false;
+ // TODO: getElements - this is *extremely* inefficient - no need to scan the whole tree again and again.
+ for (int i = 0; i < classPairs.length; i++) {
+ res = getElements(doc, classPairs[i][0], classPairs[i][1], clNameUnq).hasNext();
+ if (res) break;
+ res = getElements(doc, classPairs[i][0], classPairs[i][1], clName).hasNext();
+ if (res) break;
+ }
+ return res;
}
+
+ private static String[][] subClassPairs = {
+ { HIBERNATE_TAG_SUBCLASS, HIBERNATE_TAG_NAME, },
+ { HIBERNATE_TAG_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, },
+ { HIBERNATE_TAG_JOINED_SUBCLASS, HIBERNATE_TAG_NAME, },
+ { HIBERNATE_TAG_JOINED_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, },
+ { HIBERNATE_TAG_UNION_SUBCLASS, HIBERNATE_TAG_NAME, },
+ { HIBERNATE_TAG_UNION_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, },
+ { EJB_TAG_ENTITY, HIBERNATE_TAG_CLASS, },
+ { EJB_TAG_ENTITY, HIBERNATE_TAG_NAME, },
+ };
- // TODO: this is *extremely* inefficient - no need to scan the whole tree again and again.
- private static boolean subclassInResource(ConsoleConfiguration consoleConfiguration, IResource resource, Subclass persistentClass) {
- Document doc = getDocument(consoleConfiguration, resource.getLocation().toFile());
- return getElements(doc, HIBERNATE_TAG_SUBCLASS, HIBERNATE_TAG_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, HIBERNATE_TAG_SUBCLASS, HIBERNATE_TAG_NAME, getPersistentClassName(persistentClass)).hasNext() ||
- getElements(doc, HIBERNATE_TAG_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, HIBERNATE_TAG_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, getPersistentClassName(persistentClass)).hasNext() ||
-
- getElements(doc, HIBERNATE_TAG_JOINED_SUBCLASS, HIBERNATE_TAG_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, HIBERNATE_TAG_JOINED_SUBCLASS, HIBERNATE_TAG_NAME, getPersistentClassName(persistentClass)).hasNext() ||
- getElements(doc, HIBERNATE_TAG_JOINED_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, HIBERNATE_TAG_JOINED_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, getPersistentClassName(persistentClass)).hasNext() ||
-
- getElements(doc, HIBERNATE_TAG_UNION_SUBCLASS, HIBERNATE_TAG_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, HIBERNATE_TAG_UNION_SUBCLASS, HIBERNATE_TAG_NAME, getPersistentClassName(persistentClass)).hasNext() ||
- getElements(doc, HIBERNATE_TAG_UNION_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, StringHelper.unqualify(getPersistentClassName(persistentClass))).hasNext() ||
- getElements(doc, HIBERNATE_TAG_UNION_SUBCLASS, HIBERNATE_TAG_ENTITY_NAME, getPersistentClassName(persistentClass)).hasNext();
+ /**
+ * Check has this particular subclass correspondence in the file.
+ * @param consoleConfiguration
+ * @param file
+ * @param subclass
+ * @return
+ */
+ public static boolean subclassInFile(ConsoleConfiguration consoleConfiguration, IFile file, Subclass subclass) {
+ EntityResolver entityResolver = consoleConfiguration.getConfiguration().getEntityResolver();
+ Document doc = getDocument(file.getLocation().toFile(), entityResolver);
+ final String clName = getPersistentClassName(subclass);
+ final String clNameUnq = StringHelper.unqualify(clName);
+ boolean res = false;
+ // TODO: getElements - this is *extremely* inefficient - no need to scan the whole tree again and again.
+ for (int i = 0; i < subClassPairs.length; i++) {
+ res = getElements(doc, subClassPairs[i][0], subClassPairs[i][1], clNameUnq).hasNext();
+ if (res) break;
+ res = getElements(doc, subClassPairs[i][0], subClassPairs[i][1], clName).hasNext();
+ if (res) break;
+ }
+ return res;
}
- private static boolean tableInResource(ConsoleConfiguration consoleConfiguration, IResource resource, Table table) {
- Document doc = getDocument(consoleConfiguration, resource.getLocation().toFile());
-
- Iterator classes = getElements(doc, OpenFileActionUtils.HIBERNATE_TAG_CLASS);
+ /**
+ * Check has this particular table correspondence in the file.
+ * @param consoleConfiguration
+ * @param file
+ * @param table
+ * @return
+ */
+ public static boolean tableInFile(ConsoleConfiguration consoleConfiguration, IFile file, Table table) {
+ EntityResolver entityResolver = consoleConfiguration.getConfiguration().getEntityResolver();
+ Document doc = getDocument(file.getLocation().toFile(), entityResolver);
+ Iterator<Element> classes = getElements(doc, HIBERNATE_TAG_CLASS);
+ boolean res = false;
while (classes.hasNext()) {
- Element element = (Element) classes.next();
-
- Attribute tableAttr = element.attribute( HIBERNATE_TAG_TABLE );
+ Element element = (Element)classes.next();
+ Attribute tableAttr = element.attribute(HIBERNATE_TAG_TABLE);
if (tableAttr != null) {
- Attribute catalogAttr = element.attribute( HIBERNATE_TAG_CATALOG );
- if (catalogAttr == null) catalogAttr = doc.getRootElement().attribute(HIBERNATE_TAG_CATALOG);
- Attribute schemaAttr = element.attribute( HIBERNATE_TAG_SCHEMA );
- if (schemaAttr == null) schemaAttr = doc.getRootElement().attribute(HIBERNATE_TAG_SCHEMA);
- if (
- getTableName(
- (catalogAttr != null ? catalogAttr.getValue() : null),
- (schemaAttr != null ? schemaAttr.getValue() : null),
- tableAttr.getValue()
- ).equals(getTableName(table))
- ) {
- return true;
+ Attribute catalogAttr = element.attribute(HIBERNATE_TAG_CATALOG);
+ if (catalogAttr == null) {
+ catalogAttr = doc.getRootElement().attribute(HIBERNATE_TAG_CATALOG);
}
+ Attribute schemaAttr = element.attribute(HIBERNATE_TAG_SCHEMA);
+ if (schemaAttr == null) {
+ schemaAttr = doc.getRootElement().attribute(HIBERNATE_TAG_SCHEMA);
+ }
+ String catalog = catalogAttr != null ? catalogAttr.getValue() : null;
+ String schema = schemaAttr != null ? schemaAttr.getValue() : null;
+ String name = tableAttr.getValue();
+ if (getTableName(catalog, schema, name).equals(getTableName(table))) {
+ res = true;
+ break;
+ }
}
-
- Attribute classNameAttr = element.attribute( HIBERNATE_TAG_NAME );
- if (classNameAttr == null) classNameAttr = element.attribute( HIBERNATE_TAG_ENTITY_NAME);
+ Attribute classNameAttr = element.attribute(HIBERNATE_TAG_NAME);
+ if (classNameAttr == null) {
+ classNameAttr = element.attribute(HIBERNATE_TAG_ENTITY_NAME);
+ }
if (classNameAttr != null) {
String physicalTableName = consoleConfiguration.getConfiguration().getNamingStrategy().classToTableName(classNameAttr.getValue());
if (table.getName().equals(physicalTableName)) {
- return true;
+ res = true;
+ break;
}
}
}
-
- if (getElements(doc, HIBERNATE_TAG_TABLE, table.getName()).hasNext()) {
- return true;
+ if (!res && getElements(doc, HIBERNATE_TAG_TABLE, table.getName()).hasNext()) {
+ res = true;
}
-
- return false;
+ return res;
}
- private static Iterator getElements(Document doc, String elementName) {
+ private static Iterator<Element> getElements(Document doc, String elementName) {
return getElements(doc, elementName, null, null);
}
- private static Iterator getElements(Document doc, String attrName, String attrValue) {
+ private static Iterator<Element> getElements(Document doc, String attrName, String attrValue) {
return getElements(doc, null, attrName, attrValue);
}
- private static Iterator getElements(Document doc, String elementName, String attrName, String attrValue) {
+ private static Iterator<Element> getElements(Document doc, String elementName, String attrName, String attrValue) {
LVS visitor = new LVS(elementName, attrName, attrValue);
- doc.accept( visitor );
+ doc.accept(visitor);
return visitor.iterator();
}
- static class LVS extends VisitorSupport {
+ private static class LVS extends VisitorSupport {
private String nodeName;
private String attrName;
private String attrValue;
- private List ret = new ArrayList();
+ private List<Element> ret = new ArrayList<Element>();
public LVS(String nodeName, String attrName, String attrValue) {
super();
@@ -208,14 +296,14 @@
public void visit(Element element) {
if (nodeName == null) {
if (attrName != null && attrValue != null) {
- if (attrIsCorrect(element, attrName, attrValue)) {
+ if (inspectAttributeForValue(element, attrName, attrValue)) {
ret.add(element);
}
}
} else {
if (nodeName.equals(element.getName())) {
if (attrName != null) {
- if (attrIsCorrect(element, attrName, attrValue)) {
+ if (inspectAttributeForValue(element, attrName, attrValue)) {
ret.add(element);
}
} else {
@@ -223,111 +311,402 @@
}
}
}
-
}
- public Iterator iterator() {
+ public Iterator<Element> iterator() {
return ret.iterator();
}
- }
- private static boolean attrIsCorrect(Element element, String attrName, String attrValue) {
- Attribute attr = element.attribute(attrName);
- if (attr != null && attrValue.equals(attr.getValue())) {
- return attrValue.equals(attr.getValue());
+ protected boolean inspectAttributeForValue(Element element, String attrName, String checkValue) {
+ Attribute attr = element.attribute(attrName);
+ if (attr != null && checkValue.equals(attr.getValue())) {
+ return checkValue.equals(attr.getValue());
+ }
+ return false;
}
- return false;
}
- public static Document getDocument(ConsoleConfiguration consoleConfiguration, java.io.File configXMLFile) {
+ /**
+ * Trying to find hibernate console config mapping file,
+ * which is corresponding to provided element.
+ *
+ * @param configXMLFile
+ * @param entityResolver
+ * @return
+ */
+ public static Document getDocument(java.io.File configXMLFile, EntityResolver entityResolver) {
Document doc = null;
- if (consoleConfiguration != null && configXMLFile != null) {
- InputStream stream = null;
- try {
- stream = new FileInputStream( configXMLFile );
- } catch (FileNotFoundException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("Configuration file not found", e); //$NON-NLS-1$
+ if (configXMLFile == null) {
+ return doc;
+ }
+ InputStream stream = null;
+ try {
+ stream = new FileInputStream(configXMLFile);
+ } catch (FileNotFoundException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Configuration file not found", e); //$NON-NLS-1$
+ }
+ try {
+ List errors = new ArrayList();
+ XMLHelper helper = new XMLHelper();
+ SAXReader saxReader = helper.createSAXReader(configXMLFile.getPath(), errors, entityResolver);
+ doc = saxReader.read(new InputSource( stream));
+ if (errors.size() != 0) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("invalid configuration", (Throwable)null); //$NON-NLS-1$
}
+ }
+ catch (DocumentException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Could not parse configuration", e); //$NON-NLS-1$
+ }
+ finally {
try {
- List errors = new ArrayList();
- doc = helper.createSAXReader( configXMLFile.getPath(), errors, consoleConfiguration.getConfiguration().getEntityResolver() )
- .read( new InputSource( stream ) );
- if ( errors.size() != 0 ) {
- HibernateConsolePlugin.getDefault().logErrorMessage("invalid configuration", (Throwable)null); //$NON-NLS-1$
- }
+ stream.close();
}
- catch (DocumentException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("Could not parse configuration", e); //$NON-NLS-1$
+ catch (IOException ioe) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("could not close input stream for", ioe); //$NON-NLS-1$
}
- finally {
- try {
- stream.close();
- }
- catch (IOException ioe) {
- HibernateConsolePlugin.getDefault().logErrorMessage("could not close input stream for", ioe); //$NON-NLS-1$
- }
- }
}
return doc;
}
- public static IResource getResource(ConsoleConfiguration consoleConfiguration, IJavaProject proj, Object element) {
- IResource resource = null;
- if (consoleConfiguration == null) {
- return resource;
+ /**
+ * Trying to find hibernate console config mapping file,
+ * which is corresponding to provided element.
+ *
+ * @param consoleConfiguration
+ * @param proj
+ * @param element
+ * @return
+ */
+ public static IFile searchInMappingFiles(ConsoleConfiguration consoleConfiguration, IJavaProject proj, Object element) {
+ IFile file = null;
+ if (consoleConfiguration == null || proj == null) {
+ return file;
}
java.io.File configXMLFile = consoleConfiguration.getPreferences().getConfigXMLFile();
- Document doc = getDocument(consoleConfiguration, configXMLFile);
- if (proj != null && doc != null) {
- Element sfNode = doc.getRootElement().element( HIBERNATE_TAG_SESSION_FACTORY );
- Iterator elements = sfNode.elements(HIBERNATE_TAG_MAPPING).iterator();
- while (elements.hasNext() && resource == null) {
- Element subelement = (Element) elements.next();
- Attribute file = subelement.attribute( HIBERNATE_TAG_RESOURCE );
- if (file != null) {
- try {
- IPackageFragmentRoot[] packageFragmentRoots =
- proj.getAllPackageFragmentRoots();
- for (int i = 0; i < packageFragmentRoots.length; i++) {
- //search in source folders.
- if (packageFragmentRoots[i].getClass() == PackageFragmentRoot.class) {
- IPackageFragmentRoot packageFragmentRoot = packageFragmentRoots[i];
- IPath path = packageFragmentRoot.getPath().append(file.getValue());
- resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- if (resource != null) {
- if (resource.exists() && elementInResource(consoleConfiguration, resource, element)) {
- break;
- }
- else {
- resource = null;
- }
- }
- }
- }
- } catch (JavaModelException e) {
- resource = null;
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenFileActionUtils_problems_while_get_project_package_fragment_roots, e);
- }
+ EntityResolver entityResolver = consoleConfiguration.getConfiguration().getEntityResolver();
+ Document doc = getDocument(configXMLFile, entityResolver);
+ if (doc == null) {
+ return file;
+ }
+ Element sfNode = doc.getRootElement().element(HIBERNATE_TAG_SESSION_FACTORY);
+ Iterator elements = sfNode.elements(HIBERNATE_TAG_MAPPING).iterator();
+ while (elements.hasNext() && file == null) {
+ Element subelement = (Element)elements.next();
+ Attribute resourceAttr = subelement.attribute(HIBERNATE_TAG_RESOURCE);
+ if (resourceAttr == null) {
+ continue;
+ }
+ IPackageFragmentRoot[] packageFragmentRoots = new IPackageFragmentRoot[0];
+ try {
+ packageFragmentRoots = proj.getAllPackageFragmentRoots();
+ } catch (JavaModelException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenFileActionUtils_problems_while_get_project_package_fragment_roots, e);
+ }
+ for (int i = 0; i < packageFragmentRoots.length; i++) {
+ //search in source folders.
+ if (packageFragmentRoots[i].getClass() != PackageFragmentRoot.class) {
+ continue;
}
+ IPackageFragmentRoot packageFragmentRoot = packageFragmentRoots[i];
+ IPath path = packageFragmentRoot.getPath().append(resourceAttr.getValue());
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file == null) {
+ continue;
+ }
+ if (file.exists() && elementInFile(consoleConfiguration, file, element)) {
+ break;
+ }
+ file = null;
}
}
- if (resource == null) {
- java.io.File[] files = consoleConfiguration.getPreferences().getMappingFiles();
- for (int i = 0; i < files.length; i++) {
- java.io.File file = files[i];
- if (file != null) {
- resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(file.getPath()));
- if (resource != null) {
- if (resource.exists() && elementInResource(consoleConfiguration, resource, element)) {
- break;
- }
- else {
- resource = null;
- }
- }
+ return file;
+ }
+
+ /**
+ * Trying to find console configuration additional mapping file,
+ * which is corresponding to provided element.
+ *
+ * @param consoleConfiguration
+ * @param element
+ * @return
+ */
+ public static IFile searchInAdditionalMappingFiles(ConsoleConfiguration consoleConfiguration, Object element) {
+ IFile file = null;
+ if (consoleConfiguration == null) {
+ return file;
+ }
+ java.io.File[] files = consoleConfiguration.getPreferences().getMappingFiles();
+ for (int i = 0; i < files.length; i++) {
+ java.io.File fileTmp = files[i];
+ if (fileTmp == null) {
+ continue;
+ }
+ file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileTmp.getPath()));
+ if (file == null) {
+ continue;
+ }
+ if (file.exists() && elementInFile(consoleConfiguration, file, element)) {
+ break;
+ }
+ file = null;
+ }
+ return file;
+ }
+
+ /**
+ * This function is trying to find hibernate console config file,
+ * which is corresponding to provided element.
+ *
+ * @param consoleConfiguration
+ * @param proj
+ * @param element
+ * @return
+ */
+ public static IFile searchFileToOpen(ConsoleConfiguration consoleConfiguration, IJavaProject proj, Object element) {
+ IFile file = searchInMappingFiles(consoleConfiguration, proj, element);
+ if (file == null) {
+ file = searchInAdditionalMappingFiles(consoleConfiguration, element);
+ }
+ //if (file == null) {
+ // file = searchInEjb3MappingFiles(consoleConfiguration, proj, element);
+ //}
+ return file;
+ }
+
+ /**
+ * Creates FindReplaceDocumentAdapter for provided text editor.
+ *
+ * @param textEditor
+ * @return
+ */
+ public static FindReplaceDocumentAdapter createFindDocAdapter(ITextEditor textEditor) {
+ IDocument document = null;
+ if (textEditor.getDocumentProvider() != null){
+ document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
+ }
+ if (document == null) {
+ return null;
+ }
+ return new FindReplaceDocumentAdapter(document);
+ }
+
+ /**
+ * Opens an editor on the given file resource.
+ * @param file the editor input
+ * @return an open editor or <code>null</code> if an external editor was opened
+ * @exception PartInitException if the editor could not be initialized
+ */
+ public static IEditorPart openFileInEditor(IFile file) throws PartInitException {
+ IWorkbenchPage page =
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ return IDE.openEditor(page, file);
+ }
+
+ /**
+ * Finds a document region, which corresponds of given selection object.
+ * @param findAdapter
+ * @param selection
+ * @return a proper document region
+ */
+ public static IRegion findSelectRegion(FindReplaceDocumentAdapter findAdapter, Object selection) {
+ IRegion selectRegion = null;
+ if (selection instanceof RootClass || selection instanceof Subclass) {
+ selectRegion = findSelectRegion(findAdapter, (PersistentClass)selection);
+ } else if (selection instanceof Property){
+ selectRegion = findSelectRegion(findAdapter, (Property)selection);
+ }
+ return selectRegion;
+ }
+
+ /**
+ * Finds a document region, which corresponds of given property.
+ * @param findAdapter
+ * @param property
+ * @return a proper document region
+ */
+ public static IRegion findSelectRegion(FindReplaceDocumentAdapter findAdapter, Property property) {
+ Assert.isNotNull(property.getPersistentClass());
+ IRegion classRegion = findSelectRegion(findAdapter, property.getPersistentClass());
+ if (classRegion == null) {
+ return null;
+ }
+ final Cfg2HbmTool tool = new Cfg2HbmTool();
+ final String tagName = tool.getTag(property.getPersistentClass());
+ IRegion finalRegion = null;
+ IRegion propRegion = null;
+ int startOffset = classRegion.getOffset() + classRegion.getLength();
+ try {
+ String tagClose = "</" + tagName; //$NON-NLS-1$
+ finalRegion = findAdapter.find(startOffset, tagClose, true, true, false, false);
+ if (finalRegion == null) {
+ tagClose = "</" + EJB_TAG_ENTITY; //$NON-NLS-1$
+ finalRegion = findAdapter.find(startOffset, tagClose, true, true, false, false);
+ }
+ propRegion = findAdapter.find(startOffset, generateHbmPropertyPattern(property), true, true, false, true);
+ if (propRegion == null) {
+ propRegion = findAdapter.find(startOffset, generateEjbPropertyPattern(property), true, true, false, true);
+ }
+ } catch (BadLocationException e) {
+ //ignore
+ }
+ IRegion res = null;
+ if (propRegion != null) {
+ int length = property.getName().length();
+ int offset = propRegion.getOffset() + propRegion.getLength() - length - 1;
+ res = new Region(offset, length);
+ if (finalRegion != null && propRegion.getOffset() > finalRegion.getOffset()) {
+ res = null;
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Finds a document region, which corresponds of given persistent class.
+ * @param findAdapter
+ * @param persistentClass
+ * @return a proper document region
+ */
+ public static IRegion findSelectRegion(FindReplaceDocumentAdapter findAdapter, PersistentClass persistentClass) {
+ IRegion res = null;
+ String[] classPatterns = generatePersistentClassPatterns(persistentClass);
+ IRegion classRegion = null;
+ try {
+ for (int i = 0; (classRegion == null) && (i < classPatterns.length); i++){
+ classRegion = findAdapter.find(0, classPatterns[i], true, true, false, true);
+ }
+ } catch (BadLocationException e) {
+ //ignore
+ }
+ if (classRegion != null) {
+ int length = persistentClass.getNodeName().length();
+ int offset = classRegion.getOffset() + classRegion.getLength() - length - 1;
+ res = new Region(offset, length);
+ }
+ return res;
+ }
+
+ /**
+ * Creates a xml tag search pattern with given tag name which should contains
+ * proper name-value pair.
+ *
+ * @param tagName
+ * @param name
+ * @param value
+ * @return a result search pattern
+ */
+ public static String createPattern(String tagName, String name, String value) {
+ StringBuffer pattern = new StringBuffer("<"); //$NON-NLS-1$
+ pattern.append(tagName);
+ pattern.append("[\\s]+[.[^>]]*"); //$NON-NLS-1$
+ pattern.append(name);
+ pattern.append("[\\s]*=[\\s]*\""); //$NON-NLS-1$
+ pattern.append(value);
+ pattern.append('\"');
+ return pattern.toString();
+ }
+
+ private static String[][] persistentClassPairs = {
+ { HIBERNATE_TAG_CLASS, HIBERNATE_TAG_NAME, },
+ { HIBERNATE_TAG_CLASS, HIBERNATE_TAG_ENTITY_NAME, },
+ { EJB_TAG_ENTITY, HIBERNATE_TAG_NAME, },
+ { EJB_TAG_ENTITY, EJB_TAG_CLASS, },
+ };
+
+ /**
+ * Generates a persistent class xml tag search patterns.
+ *
+ * @param persClass
+ * @return an arrays of search patterns
+ */
+ public static String[] generatePersistentClassPatterns(PersistentClass persClass){
+ String fullClassName = null;
+ String shortClassName = null;
+ if (persClass.getEntityName() != null){
+ fullClassName = persClass.getEntityName();
+ } else {
+ fullClassName = persClass.getClassName();
+ }
+ shortClassName = fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
+ final Cfg2HbmTool tool = new Cfg2HbmTool();
+ final String tagName = tool.getTag(persClass);
+ persistentClassPairs[0][0] = tagName;
+ persistentClassPairs[1][0] = tagName;
+ List<String> patterns = new ArrayList<String>();
+ for (int i = 0; i < persistentClassPairs.length; i++) {
+ patterns.add(createPattern(persistentClassPairs[i][0], persistentClassPairs[i][1], shortClassName));
+ patterns.add(createPattern(persistentClassPairs[i][0], persistentClassPairs[i][1], fullClassName));
+ }
+ return patterns.toArray(new String[0]);
+ }
+
+ /**
+ * Generates a property xml tag search pattern, which corresponds hibernate hbm syntax.
+ *
+ * @param property
+ * @return a search patterns
+ */
+ public static String generateHbmPropertyPattern(Property property) {
+ final Cfg2HbmTool tool = new Cfg2HbmTool();
+ String toolTag = ""; //$NON-NLS-1$
+ PersistentClass pc = property.getPersistentClass();
+ if (pc != null && pc.getIdentifierProperty() == property) {
+ if (property.isComposite()) {
+ toolTag = "composite-id"; //$NON-NLS-1$
+ } else {
+ toolTag = "id"; //$NON-NLS-1$
+ }
+ } else {
+ toolTag = tool.getTag(property);
+ if ("component".equals(toolTag) && "embedded".equals(property.getPropertyAccessorName())) { //$NON-NLS-1$//$NON-NLS-2$
+ toolTag = "properties"; //$NON-NLS-1$
+ }
+ }
+ return createPattern(toolTag, HIBERNATE_TAG_NAME, property.getName());
+ }
+
+ /**
+ * Generates a property xml tag search pattern, which corresponds ejb3 syntax.
+ *
+ * @param property
+ * @return a search patterns
+ */
+ public static String generateEjbPropertyPattern(Property property) {
+ String toolTag = ""; //$NON-NLS-1$
+ PersistentClass pc = property.getPersistentClass();
+ if (pc != null && pc.getIdentifierProperty() == property) {
+ if (property.isComposite()) {
+ toolTag = "composite-id"; //$NON-NLS-1$
+ } else {
+ toolTag = "id"; //$NON-NLS-1$
+ }
+ } else {
+ toolTag = "basic"; //$NON-NLS-1$
+ }
+ return createPattern(toolTag, HIBERNATE_TAG_NAME, property.getName());
+ }
+
+ /**
+ * Method gets all ITextEditors from IEditorPart. Shouldn't returns null value.
+ *
+ * @param editorPart
+ * @return
+ */
+ public static ITextEditor[] getTextEditors(IEditorPart editorPart) {
+ // if EditorPart is MultiPageEditorPart then get ITextEditor from it.
+ ITextEditor[] res = new ITextEditor[0];
+ if (editorPart instanceof MultiPageEditorPart) {
+ List<ITextEditor> testEditors = new ArrayList<ITextEditor>();
+ IEditorPart[] editors = ((MultiPageEditorPart)editorPart).findEditors(editorPart.getEditorInput());
+ for (int i = 0; i < editors.length; i++) {
+ if (editors[i] instanceof ITextEditor){
+ testEditors.add((ITextEditor)editors[i]);
}
}
+ res = (ITextEditor[])testEditors.toArray(res);
+ } else if (editorPart instanceof ITextEditor){
+ res = new ITextEditor[]{(ITextEditor) editorPart};
}
- return resource;
+ return res;
}
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2009-05-14 14:10:06 UTC (rev 15250)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2009-05-14 14:42:10 UTC (rev 15251)
@@ -11,17 +11,12 @@
package org.hibernate.eclipse.console.actions;
import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -31,7 +26,6 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.SelectionListenerAction;
-import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.texteditor.ITextEditor;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
@@ -41,53 +35,53 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Subclass;
-import org.hibernate.tool.hbm2x.Cfg2HbmTool;
/**
+ * Open Mapping File action
+ *
* @author Dmitry Geraskov
+ * @author Vitali Yemialyanchyk
*/
-
public class OpenMappingAction extends SelectionListenerAction {
- private static final String HIBERNATE_TAG_NAME = "name"; //$NON-NLS-1$
- private static final String HIBERNATE_TAG_ENTITY_NAME = "entity-name"; //$NON-NLS-1$
- private String imageFilePath = "icons/images/mapping.gif"; //$NON-NLS-1$
+ private final String imageFilePath = "icons/images/mapping.gif"; //$NON-NLS-1$
public OpenMappingAction() {
super(HibernateConsoleMessages.OpenMappingAction_open_mapping_file);
setToolTipText(HibernateConsoleMessages.OpenMappingAction_open_mapping_file);
- setEnabled( true );
+ setEnabled(true);
setImageDescriptor(HibernateConsolePlugin.getImageDescriptor(imageFilePath ));
}
public void run() {
IStructuredSelection sel = getStructuredSelection();
- if (sel instanceof TreeSelection){
- for (int i = 0; i < ((TreeSelection)sel).getPaths().length; i++) {
- TreePath path = ((TreeSelection)sel).getPaths()[i];
- ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration)(path.getSegment(0));
- try {
- run(path, consoleConfiguration);
- } catch (JavaModelException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_cannot_find_mapping_file, e);
- } catch (PartInitException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_cannot_open_mapping_file, e);
- } catch (FileNotFoundException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_cannot_find_mapping_file, e);
- }
+ if (!(sel instanceof TreeSelection)) {
+ return;
+ }
+ TreePath[] paths = ((TreeSelection)sel).getPaths();
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration)(path.getSegment(0));
+ try {
+ run(path, consoleConfiguration);
+ } catch (JavaModelException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_cannot_find_mapping_file, e);
+ } catch (PartInitException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_cannot_open_mapping_file, e);
+ } catch (FileNotFoundException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_cannot_find_mapping_file, e);
}
}
}
public static IEditorPart run(TreePath path, ConsoleConfiguration consoleConfiguration) throws PartInitException, JavaModelException, FileNotFoundException {
boolean isPropertySel = (path.getLastSegment().getClass() == Property.class);
- if (isPropertySel){
+ if (isPropertySel) {
Property propertySel = (Property)path.getLastSegment();
PersistentClass persClass = propertySel.getPersistentClass();
- if ( persClass == null
+ if (persClass == null
|| (RootClass.class.isAssignableFrom(persClass.getClass())
- && persClass.getClass() != RootClass.class)){
+ && persClass.getClass() != RootClass.class)) {
Property parentProp = (Property)path.getParentPath().getLastSegment();
return run(propertySel, parentProp, consoleConfiguration);
}
@@ -106,22 +100,22 @@
public static IEditorPart run(Object selection, ConsoleConfiguration consoleConfiguration) throws PartInitException, JavaModelException, FileNotFoundException {
IEditorPart editorPart = null;
IJavaProject proj = ProjectUtils.findJavaProject(consoleConfiguration);
- IResource resource = null;
+ IFile file = null;
if (selection instanceof Property) {
Property p = (Property)selection;
if (p.getPersistentClass() != null) {
//use PersistentClass to open editor
- resource = OpenFileActionUtils.getResource(consoleConfiguration, proj, p.getPersistentClass());
+ file = OpenFileActionUtils.searchFileToOpen(consoleConfiguration, proj, p.getPersistentClass());
//editorPart = openMapping(p.getPersistentClass(), consoleConfiguration);
}
}
else {
- resource = OpenFileActionUtils.getResource(consoleConfiguration, proj, selection);
+ file = OpenFileActionUtils.searchFileToOpen(consoleConfiguration, proj, selection);
//editorPart = openMapping(selection, consoleConfiguration);
}
- if (resource != null) {
- editorPart = openMapping(resource);
- applySelectionToEditor(selection, editorPart);
+ if (file != null) {
+ editorPart = OpenFileActionUtils.openFileInEditor(file);
+ updateEditorSelection(editorPart, selection);
}
if (editorPart == null) {
//try to find hibernate-annotations
@@ -136,9 +130,9 @@
}
}
if (rootClass != null){
- if (OpenFileActionUtils.rootClassHasAnnotations(consoleConfiguration, rootClass)) {
+ if (OpenFileActionUtils.hasConfigXMLMappingClassAnnotation(consoleConfiguration, rootClass)) {
String fullyQualifiedName = rootClass.getClassName();
- editorPart = OpenSourceAction.run(selection, proj, fullyQualifiedName);
+ editorPart = OpenSourceAction.run(selection, proj, fullyQualifiedName);
}
}
else {
@@ -150,38 +144,6 @@
}
/**
- * @param selection
- * @param editorPart
- */
- static public boolean applySelectionToEditor(Object selection, IEditorPart editorPart) {
- ITextEditor[] textEditors = getTextEditors(editorPart);
- if (textEditors.length == 0) {
- return false;
- }
- textEditors[0].selectAndReveal(0, 0);
- FindReplaceDocumentAdapter findAdapter = null;
- ITextEditor textEditor = null;
- for (int i = 0; i < textEditors.length && findAdapter == null; i++) {
- textEditor = textEditors[i];
- findAdapter = getFindDocAdapter(textEditor);
- }
- if (findAdapter == null) {
- return false;
- }
- IRegion selectRegion = null;
- if (selection instanceof RootClass || selection instanceof Subclass) {
- selectRegion = findSelection((PersistentClass)selection, findAdapter);
- } else if (selection instanceof Property){
- selectRegion = findSelection((Property)selection, findAdapter);
- }
- if (selectRegion != null){
- textEditor.selectAndReveal(selectRegion.getOffset(), selectRegion.getLength());
- return true;
- }
- return false;
- }
-
- /**
* @param compositeProperty
* @param parentProperty
* @param consoleConfiguration
@@ -193,14 +155,14 @@
public static IEditorPart run(Property compositeProperty, Property parentProperty, ConsoleConfiguration consoleConfiguration) throws PartInitException, JavaModelException, FileNotFoundException{
PersistentClass rootClass = parentProperty.getPersistentClass();
IJavaProject proj = ProjectUtils.findJavaProject(consoleConfiguration);
- IResource resource = OpenFileActionUtils.getResource(consoleConfiguration, proj, rootClass);
+ IFile file = OpenFileActionUtils.searchFileToOpen(consoleConfiguration, proj, rootClass);
IEditorPart editorPart = null;
- if (resource != null){
- editorPart = openMapping(resource);
- updateEditorSelection(compositeProperty, parentProperty, editorPart);
+ if (file != null){
+ editorPart = OpenFileActionUtils.openFileInEditor(file);
+ updateEditorSelection(editorPart, compositeProperty, parentProperty);
}
if (editorPart == null && parentProperty.isComposite()) {
- if (OpenFileActionUtils.rootClassHasAnnotations(consoleConfiguration, rootClass)) {
+ if (OpenFileActionUtils.hasConfigXMLMappingClassAnnotation(consoleConfiguration, rootClass)) {
String fullyQualifiedName =((Component)((Property) parentProperty).getValue()).getComponentClassName();
editorPart = OpenSourceAction.run(compositeProperty, proj, fullyQualifiedName);
}
@@ -213,12 +175,39 @@
}
/**
+ * @param editorPart
+ * @param selection
+ */
+ public static boolean updateEditorSelection(IEditorPart editorPart, Object selection) {
+ ITextEditor[] textEditors = OpenFileActionUtils.getTextEditors(editorPart);
+ if (textEditors.length == 0) {
+ return false;
+ }
+ textEditors[0].selectAndReveal(0, 0);
+ FindReplaceDocumentAdapter findAdapter = null;
+ ITextEditor textEditor = null;
+ for (int i = 0; i < textEditors.length && findAdapter == null; i++) {
+ textEditor = textEditors[i];
+ findAdapter = OpenFileActionUtils.createFindDocAdapter(textEditor);
+ }
+ if (findAdapter == null) {
+ return false;
+ }
+ IRegion selectRegion = OpenFileActionUtils.findSelectRegion(findAdapter, selection);
+ if (selectRegion != null) {
+ textEditor.selectAndReveal(selectRegion.getOffset(), selectRegion.getLength());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param editorPart
* @param compositeProperty
* @param parentProperty
- * @param editorPart
*/
- static public boolean updateEditorSelection(Property compositeProperty, Property parentProperty, IEditorPart editorPart) {
- ITextEditor[] textEditors = getTextEditors(editorPart);
+ public static boolean updateEditorSelection(IEditorPart editorPart, Property compositeProperty, Property parentProperty) {
+ ITextEditor[] textEditors = OpenFileActionUtils.getTextEditors(editorPart);
if (textEditors.length == 0) {
return false;
}
@@ -227,28 +216,30 @@
ITextEditor textEditor = null;
for (int i = 0; i < textEditors.length && findAdapter == null; i++) {
textEditor = textEditors[i];
- findAdapter = getFindDocAdapter(textEditor);
+ findAdapter = OpenFileActionUtils.createFindDocAdapter(textEditor);
}
if (findAdapter == null) {
return false;
}
- IRegion parentRegion = findSelection(parentProperty, findAdapter);
+ IRegion parentRegion = OpenFileActionUtils.findSelectRegion(findAdapter, parentProperty);
if (parentRegion == null) {
return false;
}
+ int startOffset = parentRegion.getOffset() + parentRegion.getLength();
IRegion propRegion = null;
try {
- propRegion = findAdapter.find(parentRegion.getOffset()+parentRegion.getLength(), generatePattern(compositeProperty), true, true, false, true);
+ final String hbmPropertyPattern = OpenFileActionUtils.generateHbmPropertyPattern(compositeProperty);
+ propRegion = findAdapter.find(startOffset, hbmPropertyPattern, true, true, false, true);
PersistentClass rootClass = parentProperty.getPersistentClass();
if (propRegion == null && parentProperty.isComposite()
&& rootClass.getIdentifierProperty() == parentProperty) {
// try to use key-property
- String pattern = generatePattern(compositeProperty).replaceFirst("<property", "<key-property"); //$NON-NLS-1$ //$NON-NLS-2$
- propRegion = findAdapter.find(parentRegion.getOffset()+parentRegion.getLength(), pattern, true, true, false, true);
+ String pattern = hbmPropertyPattern.replaceFirst("<property", "<key-property"); //$NON-NLS-1$ //$NON-NLS-2$
+ propRegion = findAdapter.find(startOffset, pattern, true, true, false, true);
if (propRegion == null) {
// try to use key-many-to-one
- pattern = generatePattern(compositeProperty).replaceFirst("<many-to-one", "<key-many-to-one"); //$NON-NLS-1$ //$NON-NLS-2$
- propRegion = findAdapter.find(parentRegion.getOffset()+parentRegion.getLength(), pattern, true, true, false, true);
+ pattern = hbmPropertyPattern.replaceFirst("<many-to-one", "<key-many-to-one"); //$NON-NLS-1$ //$NON-NLS-2$
+ propRegion = findAdapter.find(startOffset, pattern, true, true, false, true);
}
}
} catch (BadLocationException e) {
@@ -263,181 +254,4 @@
textEditor.selectAndReveal(propRegion.getOffset(), propRegion.getLength());
return true;
}
-
- /**
- * @param textEditor
- * @return
- */
- private static FindReplaceDocumentAdapter getFindDocAdapter(
- ITextEditor textEditor) {
- IDocument document = null;
- if (textEditor.getDocumentProvider() != null){
- document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- }
- if (document == null) {
- return null;
- }
- FindReplaceDocumentAdapter findAdapter = new FindReplaceDocumentAdapter(document);
- return findAdapter;
- }
-
- static public IEditorPart openMapping(IResource resource) {
- IEditorPart editorPart = null;
- if (resource != null && resource instanceof IFile){
- try {
- editorPart = OpenFileActionUtils.openEditor(HibernateConsolePlugin.getDefault().getActiveWorkbenchWindow().getActivePage(), (IFile) resource);
- } catch (PartInitException e) {
- // ignore
- }
- } else {
- HibernateConsolePlugin.getDefault().log(HibernateConsoleMessages.OpenMappingAction_cannot_open_mapping_file + resource);
- }
- return editorPart;
- }
-
- public static IRegion findSelection(Property property, FindReplaceDocumentAdapter findAdapter) {
- Assert.isNotNull(property.getPersistentClass());
- IRegion classRegion = findSelection(property.getPersistentClass(), findAdapter);
- if (classRegion == null) {
- return null;
- }
- IRegion finalRegion = null;
- IRegion propRegion = null;
- try {
- finalRegion = findAdapter.find(classRegion.getOffset()+classRegion.getLength(), "</class", true, true, false, false); //$NON-NLS-1$
- propRegion = findAdapter.find(classRegion.getOffset()+classRegion.getLength(), generatePattern(property), true, true, false, true);
- } catch (BadLocationException e) {
- //ignore
- }
- IRegion res = null;
- if (propRegion != null) {
- int length = property.getName().length();
- int offset = propRegion.getOffset() + propRegion.getLength() - length - 1;
- res = new Region(offset, length);
- if (finalRegion != null && propRegion.getOffset() > finalRegion.getOffset()) {
- res = null;
- }
- }
- return res;
- }
- public static IRegion findSelection(PersistentClass persClass,
- FindReplaceDocumentAdapter findAdapter) {
- IRegion res = null;
- try {
- String[] classPatterns = generatePatterns(persClass);
- IRegion classRegion = null;
- for (int i = 0; (classRegion == null) && (i < classPatterns.length); i++){
- classRegion = findAdapter.find(0, classPatterns[i], true, true, false, true);
- }
- if (classRegion != null) {
- int length = persClass.getNodeName().length();
- int offset = classRegion.getOffset() + classRegion.getLength() - length - 1;
- res = new Region(offset, length);
- }
- } catch (BadLocationException e) {
- //ignore
- }
- return res;
- }
-
- private static String[] generatePatterns(PersistentClass persClass){
- String fullClassName = null;
- String shortClassName = null;
- if (persClass.getEntityName() != null){
- fullClassName = persClass.getEntityName();
- } else {
- fullClassName = persClass.getClassName();
- }
- shortClassName = fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
-
- Cfg2HbmTool tool = new Cfg2HbmTool();
- String[] patterns = new String[4];
- StringBuffer pattern = new StringBuffer("<"); //$NON-NLS-1$
- pattern.append(tool.getTag(persClass));
- pattern.append("[\\s]+[.[^>]]*"); //$NON-NLS-1$
- pattern.append(HIBERNATE_TAG_NAME);
- pattern.append("[\\s]*=[\\s]*\""); //$NON-NLS-1$
- pattern.append(shortClassName);
- pattern.append('\"');
- patterns[0] = pattern.toString();
-
- pattern = new StringBuffer("<"); //$NON-NLS-1$
- pattern.append(tool.getTag(persClass));
- pattern.append("[\\s]+[.[^>]]*"); //$NON-NLS-1$
- pattern.append(HIBERNATE_TAG_NAME);
- pattern.append("[\\s]*=[\\s]*\""); //$NON-NLS-1$
- pattern.append(fullClassName);
- pattern.append('\"');
- patterns[1] = pattern.toString();
-
- pattern = new StringBuffer("<"); //$NON-NLS-1$
- pattern.append(tool.getTag(persClass));
- pattern.append("[\\s]+[.[^>]]*"); //$NON-NLS-1$
- pattern.append(HIBERNATE_TAG_ENTITY_NAME);
- pattern.append("[\\s]*=[\\s]*\""); //$NON-NLS-1$
- pattern.append(shortClassName);
- pattern.append('\"');
- patterns[2] = pattern.toString();
-
- pattern = new StringBuffer("<"); //$NON-NLS-1$
- pattern.append(tool.getTag(persClass));
- pattern.append("[\\s]+[.[^>]]*"); //$NON-NLS-1$
- pattern.append(HIBERNATE_TAG_ENTITY_NAME);
- pattern.append("[\\s]*=[\\s]*\""); //$NON-NLS-1$
- pattern.append(fullClassName);
- pattern.append('\"');
- patterns[3] = pattern.toString();
- return patterns;
- }
-
- private static String generatePattern(Property property){
- Cfg2HbmTool tool = new Cfg2HbmTool();
- StringBuffer pattern = new StringBuffer("<"); //$NON-NLS-1$
- if(property.getPersistentClass() != null &&
- property.getPersistentClass().getIdentifierProperty()==property) {
- if (property.isComposite()){
- pattern.append("composite-id"); //$NON-NLS-1$
- } else {
- pattern.append("id"); //$NON-NLS-1$
- }
- } else{
- String toolTag = tool.getTag(property);
- if ("component".equals(toolTag) && "embedded".equals(property.getPropertyAccessorName())){ //$NON-NLS-1$//$NON-NLS-2$
- toolTag = "properties"; //$NON-NLS-1$
- }
- pattern.append(toolTag);
- }
- pattern.append("[\\s]+[.[^>]]*"); //$NON-NLS-1$
- pattern.append(HIBERNATE_TAG_NAME);
- pattern.append("[\\s]*=[\\s]*\""); //$NON-NLS-1$
- pattern.append(property.getName());
- pattern.append('\"');
- return pattern.toString();
- }
-
- /**
- * Method gets all ITextEditors from IEditorPart.
- * Never returns null.
- * @param editorPart
- * @return
- */
- public static ITextEditor[] getTextEditors(IEditorPart editorPart) {
- /*
- * if EditorPart is MultiPageEditorPart then get ITextEditor from it.
- */
- ITextEditor[] res = new ITextEditor[0];
- if (editorPart instanceof MultiPageEditorPart) {
- List testEditors = new ArrayList();
- IEditorPart[] editors = ((MultiPageEditorPart) editorPart).findEditors(editorPart.getEditorInput());
- for (int i = 0; i < editors.length; i++) {
- if (editors[i] instanceof ITextEditor){
- testEditors.add(editors[i]);
- }
- }
- res = (ITextEditor[])testEditors.toArray(res);
- } else if (editorPart instanceof ITextEditor){
- res = new ITextEditor[]{(ITextEditor) editorPart};
- }
- return res;
- }
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java 2009-05-14 14:10:06 UTC (rev 15250)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java 2009-05-14 14:42:10 UTC (rev 15251)
@@ -39,7 +39,7 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.hibernate.console.ImageConstants;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.console.actions.OpenMappingAction;
+import org.hibernate.eclipse.console.actions.OpenFileActionUtils;
import org.hibernate.eclipse.console.utils.EclipseImages;
import org.hibernate.eclipse.jdt.ui.Activator;
@@ -62,7 +62,7 @@
public void apply(IDocument target) {
//IEditorPart editorPart = HibernateConsolePlugin.getDefault().openCriteriaEditor(getName(), getContents());
IEditorPart editorPart = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- ITextEditor[] textEditors = OpenMappingAction.getTextEditors(editorPart);
+ ITextEditor[] textEditors = OpenFileActionUtils.getTextEditors(editorPart);
if (textEditors.length == 0) return;
new SaveQueryEditorListener(textEditors[0], getName(), getContents(), position, SaveQueryEditorListener.CriteriaEditor);
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLQuickAssistProcessor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLQuickAssistProcessor.java 2009-05-14 14:10:06 UTC (rev 15250)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLQuickAssistProcessor.java 2009-05-14 14:42:10 UTC (rev 15251)
@@ -32,7 +32,7 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.texteditor.ITextEditor;
import org.hibernate.console.ImageConstants;
-import org.hibernate.eclipse.console.actions.OpenMappingAction;
+import org.hibernate.eclipse.console.actions.OpenFileActionUtils;
import org.hibernate.eclipse.console.utils.EclipseImages;
import org.hibernate.eclipse.jdt.ui.Activator;
@@ -55,7 +55,7 @@
result[0] = new ExternalActionQuickAssistProposal(contents, EclipseImages.getImage(ImageConstants.HQL_EDITOR), JdtUiMessages.HQLQuickAssistProcessor_copy_to_hql_editor, context) {
public void apply(IDocument document) {
IEditorPart editorPart = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- ITextEditor[] textEditors = OpenMappingAction.getTextEditors(editorPart);
+ ITextEditor[] textEditors = OpenFileActionUtils.getTextEditors(editorPart);
if (textEditors.length == 0) return;
Point position = new Point(stringLiteral.getStartPosition() + 1, stringLiteral.getLength() - 2);
new SaveQueryEditorListener(textEditors[0], getName(), getContents(), position, SaveQueryEditorListener.HQLEditor);
15 years, 6 months
JBoss Tools SVN: r15250 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-05-14 10:10:06 -0400 (Thu, 14 May 2009)
New Revision: 15250
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/fileUpload.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/fileUpload.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/progressBar.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/progressBar.xhtml.xml
Log:
JUnit tests update for RichFaces UI.
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml 2009-05-14 13:01:28 UTC (rev 15249)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml 2009-05-14 14:10:06 UTC (rev 15250)
@@ -7,6 +7,7 @@
xmlns:rich="http://richfaces.org/rich">
<head>
+ <link href="/WebContent/pages/components/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h1>columns</h1>
@@ -18,6 +19,29 @@
<h:outputText value="#{book.price}" />
</rich:columns>
</rich:dataTable>
+ <rich:panel id="columns1" styleClass="btn" style=" height : 138px;">
+ <f:facet name="header">
+ <h:outputText value="Columns" />
+ </f:facet>
+ <rich:dataTable value="#{dataTableScrollerBean.model}" var="model"
+ width="750"
+ style="text-align:center;color:Orchid;font-style:italic;font-size:x-large;border-style:dotted;background-color:Turquoise;
+ border-color:Cornsilk;text-decoration:overline;font-family:Agency FB,Arial,Arial Baltic,Arial Black,Arial CE,Arial CYR,Arial Cyr,Arial Greek,Arial Narrow,Arial Rounded MT Bold,Arial TUR,Blackadder ITC,Bodoni MT,Bodoni MT Black,Bodoni MT Condensed,Book Antiqua,Bookman Old Style,Bookshelf Symbol 7,Bradley Hand ITC,Calisto MT,Castellar,Century Gothic,Century Schoolbook,Comic Sans MS,Copperplate Gothic Bold,Copperplate Gothic Light,Courier,Courier New,Courier New Baltic,Courier New CE,Courier New CYR,Courier New Cyr,Courier New Greek,Courier New TUR,Curlz MT,Edwardian Script ITC,Elephant,Engravers MT,Eras Bold ITC,Eras Demi ITC,Eras Light ITC,Eras Medium ITC,Estrangelo Edessa,Felix Titling,Fixedsys,Forte,Franklin Gothic Book,Franklin Gothic Demi,Franklin Gothic Demi Cond,Franklin Gothic Heavy,Franklin Gothic Medium,Franklin Gothic Medium Cond,French Script MT,Garamond,Gautami,Georgia,Gigi,Gill Sans MT,Gill Sans MT Condensed,Gill Sans MT Ext Condensed Bold,Gill Sans !
Ultra Bold,Gill Sans Ultra Bold Condensed,Gloucester MT Extra Condensed,Goudy Old Style,Goudy Stout,Haettenschweiler,Impact,Imprint MT Shadow,Latha,Lucida Console,Lucida Sans,Lucida Sans Typewriter,Lucida Sans Unicode,MS Outlook,MS Reference Sans Serif,MS Reference Specialty,MS Sans Serif,MS Serif,MT Extra,MV Boli,Maiandra GD,Mangal,Marlett,Microsoft Sans Serif,Modern,Monotype Corsiva,OCR A Extended,Palace Script MT,Palatino Linotype,Papyrus,Perpetua,Perpetua Titling MT,Pristina,Raavi,Rage Italic,Rockwell,Rockwell Condensed,Rockwell Extra Bold,Roman,Script,Script MT Bold,Shruti,Small Fonts,Sylfaen,Symbol,System,Tahoma,Terminal,Times New Roman,Times New Roman Baltic,Times New Roman CE,Times New Roman CYR,Times New Roman Cyr,Times New Roman Greek,Times New Roman TUR,Trebuchet MS,Tunga,Tw Cen MT,Tw Cen MT Condensed,Tw Cen MT Condensed Extra Bold,Verdana,WST_Czec,WST_Engl,WST_Fren,WST_Germ,WST_Ital,WST_Span,WST_Swed,Webdings,Wingdings,Wingdings 2,Wingdings 3;border-width:thick;!
font-weight:bold;">
+ <f:facet name="header">
+ <h:outputText value="Cars Available"></h:outputText>
+ </f:facet>
+ <rich:columns value="#{dataTableScrollerBean.columns}" var="columns"
+ index="ind" sortBy="#{model[ind].price}">
+ <f:facet name="header">
+ <h:outputText value="#{columns.header}" />
+ </f:facet>
+ <h:outputText value="#{model[ind].model} " />
+ <h:outputText value="#{model[ind].mileage} miles " />
+ <h:outputText value="#{model[ind].price}$"
+ style="font-style:italic;" />
+ </rich:columns>
+ </rich:dataTable>
+ </rich:panel>
</h:form>
</body>
</html>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml 2009-05-14 13:01:28 UTC (rev 15249)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml 2009-05-14 14:10:06 UTC (rev 15250)
@@ -4,4 +4,66 @@
<SPAN> #{book.price}</SPAN>
</TD>
</test>
+ <test id="columns1">
+ <DIV CLASS="dr-pnl rich-panel btn" STYLE="height: 138px;">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="/background-image: url\(.*resources/common/background.gif\);/">
+ <SPAN CLASS="vpe-text">
+ Columns
+ </SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <TABLE WIDTH="750" VALUE="#{dataTableScrollerBean.model}" VAR="model"
+ STYLE="border: thick dotted Cornsilk; text-align: center; color: Orchid; font-style: italic; font-size: x-large; background-color: Turquoise; text-decoration: overline; font-weight: bold;"
+ CLASS="dr-table rich-table">
+ <COLGROUP SPAN="1">
+ </COLGROUP>
+ <THEAD>
+ <TR CLASS="dr-table-header rich-table-header"
+ STYLE="/background-image: url\(.*resources/common/background.gif\);/">
+ <TD CLASS="dr-table-headercell rich-table-headercell" COLSPAN="100"
+ SCOPE="colgroup">
+ <SPAN CLASS="vpe-text">
+ Cars Available
+ </SPAN>
+ <BR _MOZ_DIRTY="" TYPE="_moz" />
+
+ </TD>
+ </TR>
+ <TR CLASS="dr-table-subheader rich-table-subheader">
+ <TD CLASS="dr-table-subheadercell rich-table-subheadercell"
+ SCOPE="col">
+ <SPAN>
+ <SPAN CLASS="vpe-text">
+ #{columns.header}
+ </SPAN>
+ </SPAN>
+ <IMG
+ SRC="/.*resources/column/sortable.gif/"
+ STYLE="vertical-align: middle;" />
+ <BR _MOZ_DIRTY="" TYPE="_moz" />
+
+ </TD>
+ </TR>
+ </THEAD>
+ <TR CLASS="dr-table-firstrow rich-table-firstrow">
+ <TD VALUE="#{dataTableScrollerBean.columns}" VAR="columns"
+ INDEX="ind" SORTBY="#{model[ind].price}" CLASS="dr-table-cell rich-table-cell">
+ <SPAN CLASS="vpe-text">
+ #{model[ind].model}
+ </SPAN>
+ <SPAN CLASS="vpe-text">
+ #{model[ind].mileage} miles
+ </SPAN>
+ <SPAN STYLE="font-style: italic;">
+ #{model[ind].price}$
+ </SPAN>
+ <BR _MOZ_DIRTY="" TYPE="_moz" />
+
+ </TD>
+ </TR>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </test>
</tests>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml 2009-05-14 13:01:28 UTC (rev 15249)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml 2009-05-14 14:10:06 UTC (rev 15250)
@@ -7,29 +7,51 @@
xmlns:rich="http://richfaces.org/rich">
<head>
- <style type="text/css">
- .red-text {
- color:red;
- }
- .blue-text {
- color:blue;
- }
- .yellow-background {
- background-color: yellow;
- }
- </style>
+<style type="text/css">
+.red-text {
+ color: red;
+}
+
+.blue-text {
+ color: blue;
+}
+
+.yellow-background {
+ background-color: yellow;
+}
+</style>
</head>
<body>
<f:view>
<rich:dataDefinitionList id="dataDefinitionList" rows="5"
- styleClass="yellow-background" rowClasses="red-text, blue-text">
- <f:facet name="term"><h:outputText value="TERM-VISIBLE"/></f:facet>
- <f:facet name="term"><h:outputText value="TERM-INVISIBLE"/></f:facet>
+ styleClass="yellow-background" rowClasses="red-text, blue-text">
+ <f:facet name="term">
+ <h:outputText value="TERM-VISIBLE" />
+ </f:facet>
+ <f:facet name="term">
+ <h:outputText value="TERM-INVISIBLE" />
+ </f:facet>
<h:outputText value="col1" />
<h:outputText value="col2" />
<h:outputText value="col3" />
<h:outputText value="col4" />
</rich:dataDefinitionList>
+ <rich:panel id="dataDefinitionList1">
+ <f:facet name="header">
+ <h:outputText value="Data Defenition list" />
+ </f:facet>
+ <h:form>
+ <rich:dataDefinitionList id="defList" rows="3" title="Book Store"
+ style="text-align:center;color:PaleVioletRed;font-style:oblique;font-size:x-large;border-style:dotted;background-color:Grey;border-color:Cornsilk;text-decoration:overline;font-family:Arial TUR;border-width:thick;font-weight:bolder;"
+ value="#{dataTableScrollerBean.columns}" var="columns">
+ <f:facet name="term">
+ <h:outputText value="Facet Term" />
+ </f:facet>
+ <h:outputText value="Price: "></h:outputText>
+ <h:outputText value="Number of copies:"></h:outputText>
+ </rich:dataDefinitionList>
+ </h:form>
+ </rich:panel>
</f:view>
</body>
</html>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml.xml 2009-05-14 13:01:28 UTC (rev 15249)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataDefinitionList.xhtml.xml 2009-05-14 14:10:06 UTC (rev 15250)
@@ -4,109 +4,172 @@
<DL CLASS="yellow-background">
<DT CLASS="headerClass">
<DIV>
- <SPAN>
+ <SPAN CLASS="vpe-text">
TERM-VISIBLE
-</SPAN>
+ </SPAN>
</DIV>
</DT>
<DD CLASS="columnClass red-text">
- <SPAN>
+ <SPAN CLASS="vpe-text">
col1
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col2
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col3
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col4
-</SPAN>
+ </SPAN>
</DD>
<DT CLASS="headerClass">
<DIV>
- <SPAN>
- TERM-VISIBLE
-</SPAN>
+ <SPAN CLASS="vpe-text">
+ TERM-VISIBLE
+ </SPAN>
</DIV>
</DT>
<DD CLASS="columnClass blue-text">
- <SPAN>
+ <SPAN CLASS="vpe-text">
col1
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col2
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col3
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col4
-</SPAN>
+ </SPAN>
</DD>
<DT CLASS="headerClass">
<DIV>
- <SPAN>
+ <SPAN CLASS="vpe-text">
TERM-VISIBLE
-</SPAN>
+ </SPAN>
</DIV>
</DT>
<DD CLASS="columnClass red-text">
- <SPAN>
+ <SPAN CLASS="vpe-text">
col1
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col2
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col3
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col4
-</SPAN>
+ </SPAN>
</DD>
<DT CLASS="headerClass">
<DIV>
- <SPAN>
+ <SPAN CLASS="vpe-text">
TERM-VISIBLE
-</SPAN>
+ </SPAN>
</DIV>
</DT>
<DD CLASS="columnClass blue-text">
- <SPAN>
+ <SPAN CLASS="vpe-text">
col1
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col2
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col3
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col4
-</SPAN>
+ </SPAN>
</DD>
<DT CLASS="headerClass">
<DIV>
- <SPAN>
+ <SPAN CLASS="vpe-text">
TERM-VISIBLE
-</SPAN>
+ </SPAN>
</DIV>
</DT>
<DD CLASS="columnClass red-text">
- <SPAN>
+ <SPAN CLASS="vpe-text">
col1
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col2
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col3
-</SPAN>
- <SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
col4
-</SPAN>
+ </SPAN>
</DD>
</DL>
</test>
+ <test id="dataDefinitionList1">
+ <DIV CLASS="dr-pnl rich-panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="background-image: url(file:///D:/Java/WorkSpace/trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/common/background.gif);">
+ <SPAN CLASS="vpe-text">
+ Data Defenition list
+ </SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <FORM STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px;">
+ <DL
+ STYLE="border: thick dotted Cornsilk; text-align: center; color: PaleVioletRed; font-style: oblique; font-size: x-large; background-color: Grey; text-decoration: overline; font-family: Arial TUR; font-weight: bolder;"
+ CLASS="listClass">
+ <DT CLASS="headerClass">
+ <DIV>
+ <SPAN CLASS="vpe-text">
+ Facet Term
+ </SPAN>
+ </DIV>
+ </DT>
+ <DD CLASS="columnClass">
+ <SPAN CLASS="vpe-text">
+ Price:
+ </SPAN>
+ <SPAN CLASS="vpe-text">
+ Number of copies:
+ </SPAN>
+ </DD>
+ <DT CLASS="headerClass">
+ <DIV>
+ <SPAN CLASS="vpe-text">
+ Facet Term
+ </SPAN>
+ </DIV>
+ </DT>
+ <DD CLASS="columnClass">
+ <SPAN CLASS="vpe-text">
+ Price:
+ </SPAN>
+ <SPAN CLASS="vpe-text">
+ Number of copies:
+ </SPAN>
+ </DD>
+ <DT CLASS="headerClass">
+ <DIV>
+ <SPAN CLASS="vpe-text">
+ Facet Term
+ </SPAN>
+ </DIV>
+ </DT>
+ <DD CLASS="columnClass">
+ <SPAN CLASS="vpe-text">
+ Price:
+ </SPAN>
+ <SPAN CLASS="vpe-text">
+ Number of copies:
+ </SPAN>
+ </DD>
+ </DL>
+ </FORM>
+ </DIV>
+ </DIV>
+ </test>
</tests>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/fileUpload.xhtml
===================================================================
(Binary files differ)
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/fileUpload.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/fileUpload.xhtml.xml 2009-05-14 13:01:28 UTC (rev 15249)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/fileUpload.xhtml.xml 2009-05-14 14:10:06 UTC (rev 15250)
@@ -32,4 +32,251 @@
</DIV>
</DIV>
</test>
+ <test id="fileUpload1">
+ <DIV CLASS="dr-pnl rich-panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="/background-image: url\(.*resources/common/background.gif\);/">
+ <SPAN CLASS="vpe-text">
+ File Upload
+ </SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <FORM STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px;">
+ <TABLE BORDER="0" STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD CLASS="top">
+ <DIV CLASS="rich-fileupload-list-decor" STYLE="width: 400px;">
+ <TABLE CLASS="rich-fileupload-toolbar-decor">
+ <TR>
+ <TD>
+ <DIV CLASS="rich-fileupload-button-border" STYLE="float: left;">
+ <DIV CLASS="rich-fileupload-button rich-fileupload-font btn"
+ STYLE="position: relative;">
+ <DIV
+ CLASS="rich-fileupload-button-content rich-fileupload-font rich-fileupload-ico rich-fileupload-ico-add btn">
+ Add...
+ </DIV>
+ </DIV>
+ </DIV>
+ <DIV CLASS="rich-fileupload-button-border" STYLE="float: left;">
+ <DIV CLASS="rich-fileupload-button rich-fileupload-font btn">
+ <DIV
+ CLASS="rich-fileupload-button-content rich-fileupload-font rich-fileupload-ico rich-fileupload-ico-start btn">
+ <B>
+ Upload
+ </B>
+ </DIV>
+ </DIV>
+ </DIV>
+ <DIV CLASS="rich-fileupload-button-border" STYLE="float: right;">
+ <DIV CLASS="rich-fileupload-button rich-fileupload-font btn">
+ <DIV
+ CLASS="rich-fileupload-button-content rich-fileupload-font rich-fileupload-ico rich-fileupload-ico-clear btn">
+ Clear All
+ </DIV>
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ </TABLE>
+ <DIV CLASS="rich-fileupload-list-overflow" STYLE="width: 100%; height: 210px;">
+ </DIV>
+ </DIV>
+ </TD>
+ <TD CLASS="top">
+ <SPAN STYLE="-moz-user-modify: read-write;">
+ <DIV CLASS="dr-pnl rich-panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="/background-image: url\(.*resources/common/background.gif\);/">
+ <SPAN CLASS="vpe-text">
+ Uploaded Files Info
+ </SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body info">
+ <SPAN CLASS="vpe-text">
+ No files currently uploaded
+ </SPAN>
+ <TABLE COLUMNS="1" VALUE="#{fileUploadBean.files}"
+ VAR="file" ROWKEYVAR="row" CLASS="dr-table rich-table">
+ <COLGROUP SPAN="1">
+ </COLGROUP>
+ <TBODY>
+ <TR CLASS="dr-table-row rich-table-row">
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <DIV CLASS="dr-pnl rich-panel">
+ <DIV
+ CLASS="dr-pnl-b rich-panel-body rich-laguna-panel-no-header">
+ <TABLE BORDER="0" STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD>
+ <IMG
+ SRC="/.*resources/mediaOutput/mediaOutput.jpg/"
+ STYLE="width: 50px; height: 50px;" />
+
+ </TD>
+ <TD>
+ <TABLE BORDER="0"
+ STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ File Name:
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ #{file.name}
+ </SPAN>
+ </TD>
+ </TR>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ File Length(bytes):
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ #{file.length}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ <TR CLASS="dr-table-row rich-table-row">
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <DIV CLASS="dr-pnl rich-panel">
+ <DIV
+ CLASS="dr-pnl-b rich-panel-body rich-laguna-panel-no-header">
+ <TABLE BORDER="0" STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD>
+ <IMG
+ SRC="/.*resources/mediaOutput/mediaOutput.jpg/"
+ STYLE="width: 50px; height: 50px;" />
+
+ </TD>
+ <TD>
+ <TABLE BORDER="0"
+ STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ File Name:
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ #{file.name}
+ </SPAN>
+ </TD>
+ </TR>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ File Length(bytes):
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ #{file.length}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ <TR CLASS="dr-table-row rich-table-row">
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <DIV CLASS="dr-pnl rich-panel">
+ <DIV
+ CLASS="dr-pnl-b rich-panel-body rich-laguna-panel-no-header">
+ <TABLE BORDER="0" STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD>
+ <IMG
+ SRC="/.*resources/mediaOutput/mediaOutput.jpg/"
+ STYLE="width: 50px; height: 50px;" />
+
+ </TD>
+ <TD>
+ <TABLE BORDER="0"
+ STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ File Name:
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ #{file.name}
+ </SPAN>
+ </TD>
+ </TR>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ File Length(bytes):
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ #{file.length}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ <IMG WIDTH="1" HEIGHT="3"
+ SRC="/.*resources/spacer/spacer.gif/"
+ CLASS="rich-spacer" />
+ <BR STYLE="-moz-user-modify: read-write;" />
+
+ <INPUT TYPE="button" VALUE="Clear Uploaded Data"
+ STYLE="-moz-user-modify: read-only;" />
+
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </FORM>
+ </DIV>
+ </DIV>
+ </test>
</tests>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/progressBar.xhtml
===================================================================
(Binary files differ)
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/progressBar.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/progressBar.xhtml.xml 2009-05-14 13:01:28 UTC (rev 15249)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/progressBar.xhtml.xml 2009-05-14 14:10:06 UTC (rev 15250)
@@ -7,9 +7,33 @@
STYLE="height: 13px; width: 60%;">
<DIV
STYLE="height: 13px; font-weight: bold; position: relative; text-align: center;">
- #{progressBarBean.currentValue} %
+ #{progressBarBean.currentValue} % </DIV>
+ </DIV>
</DIV>
-</DIV>
-</DIV>
- </test>
+ </test>
+ <test id="progressBar1">
+ <DIV CLASS="dr-pnl rich-panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="/background-image: url\(.*resources/common/background.gif\);/">
+ <SPAN CLASS="vpe-text">
+ Progress Bar
+ </SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <DIV
+ CLASS="rich-progress-bar-block rich-progress-bar-width rich-progress-bar-shell btn"
+ STYLE="color: red; text-align: left;">
+ <DIV CLASS="rich-progress-bar-height rich-progress-bar-uploaded null"
+ STYLE="color: red; width: 60%;">
+ </DIV>
+ </DIV>
+ <BUTTON STYLE="margin: 9px 0px 5px; -moz-user-modify: read-only;"
+ ID="button">
+ <SPAN CLASS="vpe-text">
+ Start Progress
+ </SPAN>
+ </BUTTON>
+ </DIV>
+ </DIV>
+ </test>
</tests>
\ No newline at end of file
15 years, 6 months
JBoss Tools SVN: r15249 - trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/taglib.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-05-14 09:01:28 -0400 (Thu, 14 May 2009)
New Revision: 15249
Added:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Added: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-05-14 13:01:28 UTC (rev 15249)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.taglib;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.taglib.IAttribute;
+
+/**
+ * Abstract implementation of IAttribute
+ * @author Alexey Kazakov
+ */
+public abstract class AbstractAttribute implements IAttribute {
+
+ protected String description;
+ protected String name;
+ protected boolean preferable;
+ protected boolean required;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#isPreferable()
+ */
+ public boolean isPreferable() {
+ return preferable;
+ }
+
+ /**
+ * @param preferable the preferable to set
+ */
+ public void setPreferable(boolean preferable) {
+ this.preferable = preferable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#isRequired()
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery, org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ public TextProposal[] getProposals(KbQuery query, IPageContext context) {
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ ELResolver[] resolvers = context.getElResolvers();
+ for (int i = 0; i < resolvers.length; i++) {
+ proposals.addAll(resolvers[i].getCompletions(query.getValue(), false, query.getValue().length(), context));
+ }
+ return proposals.toArray(new TextProposal[proposals.size()]);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 6 months
JBoss Tools SVN: r15248 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-05-14 08:45:12 -0400 (Thu, 14 May 2009)
New Revision: 15248
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java
Log:
Fixed Java 5.0 support
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java 2009-05-14 11:46:04 UTC (rev 15247)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java 2009-05-14 12:45:12 UTC (rev 15248)
@@ -82,7 +82,7 @@
return false;
}
if (childrenLength == 1
- && children.item(0).getNodeValue().trim().isEmpty()) {
+ && children.item(0).getNodeValue().trim().length()==0) {
return false;
}
15 years, 6 months
JBoss Tools SVN: r15247 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-05-14 07:46:04 -0400 (Thu, 14 May 2009)
New Revision: 15247
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/PositionSearcher.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4312
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/PositionSearcher.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/PositionSearcher.java 2009-05-14 08:03:37 UTC (rev 15246)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/PositionSearcher.java 2009-05-14 11:46:04 UTC (rev 15247)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.model.util;
+import java.util.StringTokenizer;
+
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
@@ -67,7 +69,7 @@
if(xml == null || xml.length() == 0) return;
if(xml.indexOf(".") < 0) {
String s = text.substring(startPosition, endPosition);
- int i1 = s.indexOf(xml);
+ int i1 = findAttrPosition(s, xml);
if(selectAttributeName) {
if(i1 < 0) return;
startPosition = startPosition + i1;
@@ -102,6 +104,31 @@
}
}
}
+
+ private int findAttrPosition(String s, String name) {
+ int i = s.indexOf(name);
+ if(i < 0) {
+ return -1;
+ }
+ StringTokenizer st = new StringTokenizer(s, "\"", true);
+ int pos = 0;
+ boolean inValue = false;
+ while(st.hasMoreTokens()) {
+ String t = st.nextToken();
+ if(t.equals("\"")) {
+ inValue = !inValue;
+ } else {
+ if(!inValue) {
+ int k = t.indexOf(name);
+ if(k >= 0) {
+ return pos + k;
+ }
+ }
+ }
+ pos += t.length();
+ }
+ return -1;
+ }
public int getStartPosition() {
return startPosition;
15 years, 6 months