Author: dazarov
Date: 2010-04-07 12:53:10 -0400 (Wed, 07 Apr 2010)
New Revision: 21326
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5927
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-04-07
15:57:05 UTC (rev 21325)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-04-07
16:53:10 UTC (rev 21326)
@@ -14,5 +14,5 @@
CDI_UI_IMAGESIMAGE_NAME_CANNOT_BE_NULL=Image name cannot be null.
CDI_REFACTOR_CONTRIBUTOR_MENU_NAME=CDI Refactor
CDI_REFACTOR_CONTRIBUTOR_ERROR=Error
-CDI_REFACTOR_CONTRIBUTOR_RENAME_NAMED_BEAN_ACTION_NAME=Rename Named Bean
+CDI_REFACTOR_CONTRIBUTOR_RENAME_NAMED_BEAN_ACTION_NAME=Rename ''{0}''
Named Bean
RENAME_NAMED_BEAN_WIZARD_FIELD_NAME=@Named Bean Name
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java 2010-04-07
15:57:05 UTC (rev 21325)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java 2010-04-07
16:53:10 UTC (rev 21326)
@@ -30,6 +30,7 @@
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
+import org.eclipse.ltk.internal.core.refactoring.Messages;
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
@@ -56,9 +57,6 @@
private static final String ANNOTATION_NAMED = "javax.inject.Named";
//$NON-NLS-1$
private static final String JAVA_EXT = "java"; //$NON-NLS-1$
- static private IFile editorFile;
- static private TextSelection selection;
- private IEditorPart editor;
private Shell shell;
public CDIRefactorContributionFactory(){
@@ -75,7 +73,7 @@
if(serviceLocator.hasService(IWorkbenchLocationService.class)){
IWorkbenchLocationService service =
(IWorkbenchLocationService)serviceLocator.getService(IWorkbenchLocationService.class);
- editor = service.getWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = service.getWorkbenchWindow().getActivePage().getActiveEditor();
shell = service.getWorkbench().getActiveWorkbenchWindow().getShell();
if(!(editor.getEditorInput() instanceof FileEditorInput))
@@ -83,7 +81,7 @@
FileEditorInput input = (FileEditorInput)editor.getEditorInput();
- editorFile = input.getFile();
+ IFile editorFile = input.getFile();
String ext = editorFile.getFileExtension();
if (!JAVA_EXT.equalsIgnoreCase(ext) )
@@ -91,24 +89,20 @@
if(CDICorePlugin.getCDI(editorFile.getProject(), true) == null)
return;
-
+
MenuManager mm = new MenuManager(CDIUIMessages.CDI_REFACTOR_CONTRIBUTOR_MENU_NAME);
mm.setVisible(true);
- boolean separatorIsAdded = false;
-
if(JAVA_EXT.equalsIgnoreCase(ext)){
- selection =
(TextSelection)editor.getEditorSite().getSelectionProvider().getSelection();
+ TextSelection selection =
(TextSelection)editor.getEditorSite().getSelectionProvider().getSelection();
IBean bean = getBean(editorFile, selection);
if(bean != null){
- mm.add(new RenameNamedBeanAction());
+ mm.add(new RenameNamedBeanAction(bean));
additions.addContributionItem(new Separator(), null);
additions.addContributionItem(mm, null);
- separatorIsAdded = true;
}
}
-
}
}
@@ -193,14 +187,15 @@
}
class RenameNamedBeanAction extends Action{
- public RenameNamedBeanAction(){
- super(CDIUIMessages.CDI_REFACTOR_CONTRIBUTOR_RENAME_NAMED_BEAN_ACTION_NAME);
+ IBean bean;
+ public RenameNamedBeanAction(IBean bean){
+ super(Messages.format(CDIUIMessages.CDI_REFACTOR_CONTRIBUTOR_RENAME_NAMED_BEAN_ACTION_NAME,
bean.getName()));
+ this.bean = bean;
}
public void run(){
saveAndBuild();
- IBean bean = getBean(editorFile, selection);
invokeRenameNamedBeanWizard(bean, shell);
}
}