Author: dazarov
Date: 2009-06-21 14:34:45 -0400 (Sun, 21 Jun 2009)
New Revision: 16103
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java
Log:
Rename Seam Context Variable
https://jira.jboss.org/jira/browse/JBIDE-1077 Added popup
menu to jsp, xhtml, xml and properties editors
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2009-06-20 14:22:56
UTC (rev 16102)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2009-06-21 18:34:45
UTC (rev 16103)
@@ -37,7 +37,8 @@
org.eclipse.ltk.core.refactoring,
org.eclipse.ltk.ui.refactoring,
org.jboss.ide.eclipse.as.core,
- org.jboss.tools.jsf
+ org.jboss.tools.jsf,
+ org.jboss.tools.jst.web.ui;bundle-version="2.0.0"
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.seam.ui,
org.jboss.tools.seam.ui.actions,
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-06-20 14:22:56 UTC (rev
16102)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-06-21 18:34:45 UTC (rev
16103)
@@ -541,10 +541,14 @@
<!-- Refactorng -->
<extension
point="org.eclipse.ui.menus">
- <menuContribution
+ <!--menuContribution
class="org.jboss.tools.seam.ui.refactoring.SeamRefactorContributionFactory"
locationURI="popup:#CompilationUnitEditorContext?after=org.eclipse.jdt.ui.refactoring.menu">
- </menuContribution>
+ </menuContribution-->
+ <menuContribution
+
class="org.jboss.tools.seam.ui.refactoring.SeamRefactorContributionFactory"
+ locationURI="popup:org.eclipse.ui.popup.any?after=save">
+ </menuContribution>
</extension>
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java 2009-06-20
14:22:56 UTC (rev 16102)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java 2009-06-21
18:34:45 UTC (rev 16103)
@@ -32,17 +32,17 @@
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.internal.services.IWorkbenchLocationService;
import org.eclipse.ui.menus.AbstractContributionFactory;
import org.eclipse.ui.menus.IContributionRoot;
@@ -64,9 +64,12 @@
import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
import org.jboss.tools.common.el.core.parser.ELParser;
import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.propertieseditor.PropertiesCompoundEditor;
import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jst.web.ui.editors.WebCompoundEditor;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
@@ -110,8 +113,6 @@
public void createContributionItems(IServiceLocator serviceLocator,
IContributionRoot additions) {
- //System.out.println("createContributionItems");
-
if(serviceLocator.hasService(IWorkbenchLocationService.class)){
IWorkbenchLocationService service =
(IWorkbenchLocationService)serviceLocator.getService(IWorkbenchLocationService.class);
editor = service.getWorkbenchWindow().getActivePage().getActiveEditor();
@@ -120,18 +121,32 @@
if(!(editor.getEditorInput() instanceof FileEditorInput))
return;
+ FileEditorInput input = (FileEditorInput)editor.getEditorInput();
+
+ editorFile = input.getFile();
+ String ext = editorFile.getFileExtension();
+
+ if (!JAVA_EXT.equalsIgnoreCase(ext)
+ && !XML_EXT.equalsIgnoreCase(ext)
+ && !XHTML_EXT.equalsIgnoreCase(ext)
+ && !JSP_EXT.equalsIgnoreCase(ext)
+ && !PROPERTIES_EXT.equalsIgnoreCase(ext))
+ return;
+
MenuManager mm = new MenuManager(SeamUIMessages.SEAM_REFACTOR);
mm.setVisible(true);
- FileEditorInput input = (FileEditorInput)editor.getEditorInput();
+ boolean separatorIsAdded = false;
- editorFile = input.getFile();
-
- ISeamComponent component = getComponent(editorFile);
- if(component != null){
- mm.add(new RenameSeamComponentAction());
-
- additions.addContributionItem(mm, null);
+ if(JAVA_EXT.equalsIgnoreCase(ext)){
+ ISeamComponent component = getComponent(editorFile);
+ if(component != null){
+ mm.add(new RenameSeamComponentAction());
+
+ additions.addContributionItem(new Separator(), null);
+ additions.addContributionItem(mm, null);
+ separatorIsAdded = true;
+ }
}
ISelection sel = editor.getEditorSite().getSelectionProvider().getSelection();
@@ -139,6 +154,19 @@
if(sel == null || sel.isEmpty())
return;
+ if(sel instanceof StructuredSelection){
+ if(editor instanceof PropertiesCompoundEditor){
+ sel =
((PropertiesCompoundEditor)editor).getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }else if(editor instanceof EditorPartWrapper){
+ EditorPartWrapper wrapperEditor = (EditorPartWrapper)editor;
+ if(wrapperEditor.getEditor() instanceof WebCompoundEditor){
+ WebCompoundEditor xmlEditor = (WebCompoundEditor)wrapperEditor.getEditor();
+ sel = xmlEditor.getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }
+ }else if(editor instanceof WebCompoundEditor)
+ sel =
((WebCompoundEditor)editor).getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }
+
if(sel instanceof TextSelection){
TextSelection selection = (TextSelection)sel;
@@ -154,8 +182,9 @@
boolean status = false;
- String ext = editorFile.getFileExtension();
+
if(JAVA_EXT.equalsIgnoreCase(ext)){
+ // check - whether selected component's name or not
// if(checkNameAnnotation(selection)){
// mm.add(new RenameSeamComponentAction());
//
@@ -170,6 +199,8 @@
if(status){
mm.add(new RenameSeamContextVariableAction());
+ if(!separatorIsAdded)
+ additions.addContributionItem(new Separator(), null);
additions.addContributionItem(mm, null);
}
}
@@ -260,7 +291,7 @@
if (model instanceof IDOMModel) {
IDOMModel domModel = (IDOMModel) model;
IDOMDocument document = domModel.getDocument();
- scanChildNodes(file, document, selection);
+ return scanChildNodes(file, document, selection);
}
} catch (CoreException e) {
SeamCorePlugin.getDefault().logError(e);
@@ -274,20 +305,29 @@
return false;
}
- private void scanChildNodes(IFile file, Node parent, TextSelection selection) {
+ private boolean scanChildNodes(IFile file, Node parent, TextSelection selection) {
+ boolean status = false;
NodeList children = parent.getChildNodes();
for(int i=0; i<children.getLength(); i++) {
Node curentValidatedNode = children.item(i);
if(Node.ELEMENT_NODE == curentValidatedNode.getNodeType()) {
- scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, selection);
+ status = scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, selection);
+ if(status)
+ return status;
} else if(Node.TEXT_NODE == curentValidatedNode.getNodeType()) {
- scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_CONTENT, selection);
+ status = scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_CONTENT, selection);
+ if(status)
+ return status;
}
- scanChildNodes(file, curentValidatedNode, selection);
+ status = scanChildNodes(file, curentValidatedNode, selection);
+ if(status)
+ return status;
}
+ return false;
}
- private void scanNodeContent(IFile file, IStructuredDocumentRegion node, String
regionType, TextSelection selection) {
+ private boolean scanNodeContent(IFile file, IStructuredDocumentRegion node, String
regionType, TextSelection selection) {
+ boolean status = false;
ITextRegionList regions = node.getRegions();
for(int i=0; i<regions.size(); i++) {
ITextRegion region = regions.get(i);
@@ -295,10 +335,13 @@
String text = node.getFullText(region);
if(text.indexOf("{")>-1) { //$NON-NLS-1$
int offset = node.getStartOffset() + region.getStart();
- scanString(file, text, offset, selection);
+ status = scanString(file, text, offset, selection);
+ if(status)
+ return status;
}
}
}
+ return false;
}
private boolean checkContextVariableInProperties(IFile file, String content,
TextSelection selection){