Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 109468 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (+20 lines)
Lines 63-65 Link Here
63
AddBookmark.tooltip=Add Bookmark...
63
AddBookmark.tooltip=Add Bookmark...
64
## EL Error Message
64
## EL Error Message
65
JSPEL_Syntax_Error=JSP EL Syntax Error
65
JSPEL_Syntax_Error=JSP EL Syntax Error
66
##
67
CleanupDocument_label=Cleanup Document...
68
CleanupDocument_tooltip=Cleanup Document
69
ToggleComment_label=Toggle Comment
70
ToggleComment_tooltip=Toggle Comment
71
AddBlockComment_label=Add Block Comment
72
AddBlockComment_tooltip=Add Block Comment
73
RemoveBlockComment_label=Remove Block Comment
74
RemoveBlockComment_tooltip=Remove Block Comment
75
FindOccurrences_label=Occurrences in File
76
RenameElement_label=Rename
77
MoveElement_label=Move
78
StructureSelectEnclosing_label=Enclosing Element
79
StructureSelectEnclosing_tooltip=Expand selection to include enclosing element
80
StructureSelectNext_label=Next Element
81
StructureSelectNext_tooltip=Expand selection to include next sibling
82
StructureSelectPrevious_label=Previous Element
83
StructureSelectPrevious_tooltip=Expand selection to include previous sibling
84
StructureSelectHistory_label=Restore Last Selection
85
StructureSelectHistory_tooltip=Restore last selection
(-)plugin.xml (-23 / +122 lines)
Lines 8-14 Link Here
8
			icon="icons//full/obj16/sourceEditor.gif"
8
			icon="icons//full/obj16/sourceEditor.gif"
9
			extensions="jsp, jsf, jspf, jspx, tag, tagf"
9
			extensions="jsp, jsf, jspf, jspx, tag, tagf"
10
			contributorClass="org.eclipse.jst.jsp.ui.internal.editor.ActionContributorJSP"
10
			contributorClass="org.eclipse.jst.jsp.ui.internal.editor.ActionContributorJSP"
11
			class="org.eclipse.jst.jsp.ui.internal.editor.StructuredTextEditorJSP"
11
			class="org.eclipse.wst.sse.ui.internal.StructuredTextEditor"
12
			symbolicFontName="org.eclipse.wst.sse.ui.textfont"
12
			symbolicFontName="org.eclipse.wst.sse.ui.textfont"
13
			id="org.eclipse.jst.jsp.core.jspsource.source">
13
			id="org.eclipse.jst.jsp.core.jspsource.source">
14
			<contentTypeBinding
14
			<contentTypeBinding
Lines 277-315 Link Here
277
	<!-- JSP Editor specific actions                                                          -->
277
	<!-- JSP Editor specific actions                                                          -->
278
	<!--======================================================================================-->
278
	<!--======================================================================================-->
279
	<extension point="org.eclipse.ui.commands">
279
	<extension point="org.eclipse.ui.commands">
280
		<scope
281
			name="%scope.structured.text.editor.jsp.name"
282
			parent="org.eclipse.ui.textEditorScope"
283
			description="%scope.structured.text.editor.jsp.description"
284
			id="org.eclipse.jst.jsp.ui.structured.text.editor.jsp.scope" />
285
286
		<!-- dmw 6/6 removed from 'scope'      parentId="org.eclipse.ui.textEditorScope" -->
287
		<!-- rename refactor -->
280
		<!-- rename refactor -->
288
		<command
281
		<command
289
			name="%command.jsp.refactor.rename.name"
282
			name="%command.jsp.refactor.rename.name"
290
			description="%command.jsp.refactor.rename.description"
283
			description="%command.jsp.refactor.rename.description"
291
			category="org.eclipse.ui.category.edit"
284
			categoryId="org.eclipse.ui.category.edit"
292
			id="org.eclipse.jst.jsp.ui.refactor.rename" />
285
			id="org.eclipse.jst.jsp.ui.refactor.rename" />
293
286
294
		<keyBinding
295
			string="Alt+Shift+R"
296
			scope="org.eclipse.jst.jsp.ui.structured.text.editor.jsp.scope"
297
			command="org.eclipse.jst.jsp.ui.refactor.rename"
298
			configuration="org.eclipse.ui.defaultAcceleratorConfiguration" />
299
300
		<!-- move refactor -->
287
		<!-- move refactor -->
301
		<command
288
		<command
302
			name="%command.jsp.refactor.move.name"
289
			name="%command.jsp.refactor.move.name"
303
			description="%command.jsp.refactor.move.description"
290
			description="%command.jsp.refactor.move.description"
304
			category="org.eclipse.ui.category.edit"
291
			categoryId="org.eclipse.ui.category.edit"
305
			id="org.eclipse.jst.jsp.ui.refactor.move" />
292
			id="org.eclipse.jst.jsp.ui.refactor.move" />
293
	</extension>
294
	
295
	<!-- Keybinding scope for jsp source editor -->
296
	<extension point="org.eclipse.ui.contexts">
297
		<context
298
			name="%scope.structured.text.editor.jsp.name"
299
			parentId="org.eclipse.ui.textEditorScope"
300
			description="%scope.structured.text.editor.jsp.description"
301
			id="org.eclipse.jst.jsp.ui.structured.text.editor.jsp.scope">
302
		</context>
303
	</extension>
304
	
305
	<!-- Keybindings for jsp source editor -->
306
	<extension point="org.eclipse.ui.bindings">
307
		<!-- rename refactor -->
308
		<key
309
			sequence="Alt+Shift+R"
310
			contextId="org.eclipse.jst.jsp.ui.structured.text.editor.jsp.scope"
311
			commandId="org.eclipse.jst.jsp.ui.refactor.rename"
312
			schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
313
		</key>
306
314
307
		<keyBinding
315
		<!-- move refactor -->
308
			string="Alt+Shift+V"
316
		<key
309
			scope="org.eclipse.jst.jsp.ui.structured.text.editor.jsp.scope"
317
			sequence="Alt+Shift+V"
310
			command="org.eclipse.jst.jsp.ui.refactor.move"
318
			contextId="org.eclipse.jst.jsp.ui.structured.text.editor.jsp.scope"
311
			configuration="org.eclipse.ui.defaultAcceleratorConfiguration" />
319
			commandId="org.eclipse.jst.jsp.ui.refactor.move"
312
320
			schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
321
		</key>
313
	</extension>
322
	</extension>
314
323
315
	<!--======================================================================================-->
324
	<!--======================================================================================-->
Lines 434-438 Link Here
434
		</viewerContribution>
443
		</viewerContribution>
435
	</extension>
444
	</extension>
436
445
437
446
	<extension point="org.eclipse.ui.editorActions">
447
		<editorContribution
448
			id="org.eclipse.jst.jsp.core.jspsource.source.editorActions"
449
			targetID="org.eclipse.jst.jsp.core.jspsource.source">
450
			<action
451
				id="CleanupDocument"
452
				label="%CleanupDocument_label"
453
				definitionId="org.eclipse.wst.sse.ui.cleanup.document"
454
				tooltip="%CleanupDocument_tooltip"
455
				class="org.eclipse.wst.html.ui.internal.edit.ui.CleanupActionHTMLDelegate"
456
				actionID="CleanupDocument">
457
			</action>
458
			<action
459
				id="ToggleComment"
460
				label="%ToggleComment_label"
461
				definitionId="org.eclipse.wst.sse.ui.toggle.comment"
462
				tooltip="%ToggleComment_tooltip"
463
				class="org.eclipse.wst.xml.ui.internal.actions.ToggleCommentActionXMLDelegate"
464
				actionID="ToggleComment">
465
			</action>
466
			<action
467
				id="AddBlockComment"
468
				label="%AddBlockComment_label"
469
				definitionId="org.eclipse.wst.sse.ui.add.block.comment"
470
				tooltip="%AddBlockComment_tooltip"
471
				class="org.eclipse.wst.xml.ui.internal.actions.AddBlockCommentActionXMLDelegate"
472
				actionID="AddBlockComment">
473
			</action>
474
			<action
475
				id="RemoveBlockComment"
476
				label="%RemoveBlockComment_label"
477
				definitionId="org.eclipse.wst.sse.ui.remove.block.comment"
478
				tooltip="%RemoveBlockComment_tooltip"
479
				class="org.eclipse.wst.xml.ui.internal.actions.RemoveBlockCommentActionXMLDelegate"
480
				actionID="RemoveBlockComment">
481
			</action>
482
			<action
483
				id="RenameElement"
484
				label="%RenameElement_label"
485
				definitionId="org.eclipse.jst.jsp.ui.refactor.rename"
486
				class="org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameElementActionDelegate"
487
				actionID="RenameElement">
488
			</action>
489
			<action
490
				id="MoveElement"
491
				label="%MoveElement_label"
492
				definitionId="org.eclipse.jst.jsp.ui.refactor.move"
493
				class="org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPMoveElementActionDelegate"
494
				actionID="MoveElement">
495
			</action>
496
			<action
497
				id="FindOccurrences"
498
				label="%FindOccurrences_label"
499
				definitionId="org.eclipse.wst.sse.ui.search.find.occurrences"
500
				class="org.eclipse.jst.jsp.ui.internal.java.search.JSPFindOccurrencesActionDelegate"
501
				actionID="FindOccurrences">
502
			</action>
503
			<action
504
				id="StructureSelectEnclosing"
505
				label="%StructureSelectEnclosing_label"
506
				definitionId="org.eclipse.wst.sse.ui.structure.select.enclosing"
507
				tooltip="%StructureSelectEnclosing_tooltip"
508
				class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectEnclosingXMLActionDelegate"
509
				actionID="StructureSelectEnclosing">
510
			</action>
511
			<action
512
				id="StructureSelectNext"
513
				label="%StructureSelectNext_label"
514
				definitionId="org.eclipse.wst.sse.ui.structure.select.next"
515
				tooltip="%StructureSelectNext_tooltip"
516
				class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectNextXMLActionDelegate"
517
				actionID="StructureSelectNext">
518
			</action>
519
			<action
520
				id="StructureSelectPrevious"
521
				label="%StructureSelectPrevious_label"
522
				definitionId="org.eclipse.wst.sse.ui.structure.select.previous"
523
				tooltip="%StructureSelectPrevious_tooltip"
524
				class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectPreviousXMLActionDelegate"
525
				actionID="StructureSelectPrevious">
526
			</action>
527
			<action
528
				id="StructureSelectHistory"
529
				label="%StructureSelectHistory_label"
530
				definitionId="org.eclipse.wst.sse.ui.structure.select.last"
531
				tooltip="%StructureSelectHistory_tooltip"
532
				class="org.eclipse.wst.sse.ui.internal.selection.StructuredSelectHistoryActionDelegate"
533
				actionID="StructureSelectHistory">
534
			</action>
535
		</editorContribution>
536
	</extension>
438
</plugin>
537
</plugin>
(-)src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties (-8 / +8 lines)
Lines 15-23 Link Here
15
## Welcome!
15
## Welcome!
16
Sample_JSP_doc=<%@ page \n\tlanguage=\"java\" \n\tcontentType=\"text/html; charset=ISO-8859-1\"\n%>\n<jsp:include flush=\"true\" page=\"titleBar.jsp\"/>\n\n<%-- Use below tags ONLY for JSP 1.1 --%>\n<%\n\tSystem.out.println(\"Welcome!\");\n%>\n<%-- Use below tags ONLY for JSP 1.2 --%>\n<jsp:scriptlet>\n\tSystem.out.println(\"Welcome!\");\n</jsp:scriptlet>
16
Sample_JSP_doc=<%@ page \n\tlanguage=\"java\" \n\tcontentType=\"text/html; charset=ISO-8859-1\"\n%>\n<jsp:include flush=\"true\" page=\"titleBar.jsp\"/>\n\n<%-- Use below tags ONLY for JSP 1.1 --%>\n<%\n\tSystem.out.println(\"Welcome!\");\n%>\n<%-- Use below tags ONLY for JSP 1.2 --%>\n<jsp:scriptlet>\n\tSystem.out.println(\"Welcome!\");\n</jsp:scriptlet>
17
JSP_Delimiters_UI_=JSP Delimiters
17
JSP_Delimiters_UI_=JSP Delimiters
18
Refactor_label=R&efactor
18
Refactor_label=Refactor
19
RenameElement_label=Re&name
19
RenameElement_label=Rename
20
MoveElement_label=Mo&ve
20
MoveElement_label=Move
21
MoveElementWizard=Move the selected elements
21
MoveElementWizard=Move the selected elements
22
#
22
#
23
OK=OK
23
OK=OK
Lines 45-63 Link Here
45
NewJSPTemplatesWizardPage_5=Preview
45
NewJSPTemplatesWizardPage_5=Preview
46
NewJSPTemplatesWizardPage_6=Templates are 'New JSP' templates found in the <a>JSP Templates</a> preference page.
46
NewJSPTemplatesWizardPage_6=Templates are 'New JSP' templates found in the <a>JSP Templates</a> preference page.
47
# Copied from sse.ui
47
# Copied from sse.ui
48
CleanupDocument_label=C&leanup Document...
48
CleanupDocument_label=Cleanup Document...
49
CleanupDocument_tooltip=Cleanup Document
49
CleanupDocument_tooltip=Cleanup Document
50
CleanupDocument_description=Cleanup Document
50
CleanupDocument_description=Cleanup Document
51
ToggleComment_label=Togg&le Comment
51
ToggleComment_label=Toggle Comment
52
ToggleComment_tooltip=Toggle Comment
52
ToggleComment_tooltip=Toggle Comment
53
ToggleComment_description=Toggle Comment
53
ToggleComment_description=Toggle Comment
54
AddBlockComment_label=Add &Block Comment
54
AddBlockComment_label=Add Block Comment
55
AddBlockComment_tooltip=Add Block Comment
55
AddBlockComment_tooltip=Add Block Comment
56
AddBlockComment_description=Add Block Comment
56
AddBlockComment_description=Add Block Comment
57
RemoveBlockComment_label=Remove Bloc&k Comment
57
RemoveBlockComment_label=Remove Block Comment
58
RemoveBlockComment_tooltip=Remove Block Comment
58
RemoveBlockComment_tooltip=Remove Block Comment
59
RemoveBlockComment_description=Remove Block Comment
59
RemoveBlockComment_description=Remove Block Comment
60
FindOccurrences_label=O&ccurrences in File
60
FindOccurrences_label=Occurrences in File
61
OccurrencesSearchQuery_0={0} - {1} Occurrences in {2}
61
OccurrencesSearchQuery_0={0} - {1} Occurrences in {2}
62
OccurrencesSearchQuery_2=file
62
OccurrencesSearchQuery_2=file
63
Content_Assist_not_availab_UI_=Content Assist not available at the current location
63
Content_Assist_not_availab_UI_=Content Assist not available at the current location
(-)src/org/eclipse/jst/jsp/ui/internal/editor/StructuredTextEditorJSP.java (+4 lines)
Lines 32-37 Link Here
32
import org.eclipse.wst.xml.ui.internal.actions.RemoveBlockCommentActionXML;
32
import org.eclipse.wst.xml.ui.internal.actions.RemoveBlockCommentActionXML;
33
import org.eclipse.wst.xml.ui.internal.actions.ToggleCommentActionXML;
33
import org.eclipse.wst.xml.ui.internal.actions.ToggleCommentActionXML;
34
34
35
/**
36
 * @deprecated JSP editor is created from StructuredTextEditor with
37
 *             JSP configurations
38
 */
35
public class StructuredTextEditorJSP extends StructuredTextEditor {
39
public class StructuredTextEditorJSP extends StructuredTextEditor {
36
	private final static String UNDERSCORE = "_"; //$NON-NLS-1$
40
	private final static String UNDERSCORE = "_"; //$NON-NLS-1$
37
	
41
	
(-)src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMoveElementAction.java (-1 / +2 lines)
Lines 41-47 Link Here
41
 * Still relies heavily on internal API
41
 * Still relies heavily on internal API
42
 * will change post 3.0 with public move support
42
 * will change post 3.0 with public move support
43
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817 
43
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817 
44
 * @author pavery
44
 * 
45
 * @deprecated use JSPMoveElementActionDelegate instead
45
 */
46
 */
46
public class JSPMoveElementAction extends TextEditorAction {
47
public class JSPMoveElementAction extends TextEditorAction {
47
48
(-)src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPRenameElementAction.java (-1 / +1 lines)
Lines 28-34 Link Here
28
/**
28
/**
29
 * A TextEditorAction that launches JDT rename element wizard
29
 * A TextEditorAction that launches JDT rename element wizard
30
 * 
30
 * 
31
 * @author pavery
31
 * @deprecated use JSPRenameElementActionDelegate instead
32
 */
32
 */
33
public class JSPRenameElementAction extends TextEditorAction {
33
public class JSPRenameElementAction extends TextEditorAction {
34
34
(-)src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesAction.java (-1 / +1 lines)
Lines 36-42 Link Here
36
 * Finds occurrences of Java elements in a JSP file using JSPSearchSupport.
36
 * Finds occurrences of Java elements in a JSP file using JSPSearchSupport.
37
 * </p>
37
 * </p>
38
 * 
38
 * 
39
 * @author pavery
39
 * @deprecated use JSPFindOccurrencesProcessor instead
40
 */
40
 */
41
public class JSPFindOccurrencesAction extends BasicFindOccurrencesAction implements IJavaSearchConstants {
41
public class JSPFindOccurrencesAction extends BasicFindOccurrencesAction implements IJavaSearchConstants {
42
42
(-)src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java (+153 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
13
package org.eclipse.jst.jsp.ui.internal.java.refactoring;
14
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.jdt.core.IJavaElement;
17
import org.eclipse.jdt.core.JavaModelException;
18
import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
19
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
20
import org.eclipse.jdt.internal.ui.refactoring.reorg.CreateTargetQueries;
21
import org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveWizard;
22
import org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgQueries;
23
import org.eclipse.jface.action.IAction;
24
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jst.jsp.ui.internal.JSPUIMessages;
26
import org.eclipse.jst.jsp.ui.internal.Logger;
27
import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring;
28
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
29
import org.eclipse.swt.widgets.Event;
30
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.IActionDelegate2;
32
import org.eclipse.ui.IEditorActionDelegate;
33
import org.eclipse.ui.IEditorPart;
34
import org.eclipse.ui.IViewActionDelegate;
35
import org.eclipse.ui.IViewPart;
36
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.texteditor.ITextEditor;
38
import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil;
39
40
/**
41
 * An action delegate that launches JDT move element wizard
42
 * 
43
 * Still relies heavily on internal API
44
 * will change post 3.0 with public move support
45
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817 
46
 */
47
public class JSPMoveElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
48
	private IEditorPart fEditor;
49
50
	public void setActiveEditor(IAction action, IEditorPart targetEditor) {
51
		fEditor = targetEditor;
52
	}
53
54
	public void dispose() {
55
		// nulling out just in case
56
		fEditor = null;
57
	}
58
59
	public void init(IAction action) {
60
		if (action != null) {
61
			action.setText(JSPUIMessages.MoveElement_label);
62
			action.setToolTipText(JSPUIMessages.MoveElement_label);
63
		}
64
	}
65
66
	public void runWithEvent(IAction action, Event event) {
67
		run(action);
68
	}
69
70
	public void run(IAction action) {
71
		IJavaElement[] elements = getSelectedElements();
72
		if (elements.length > 0) {
73
74
			// need to check if it's movable
75
			try {
76
				JavaMoveProcessor processor = JavaMoveProcessor.create(getResources(elements), elements/*
77
																										 * ,
78
																										 * getCodeGenerationSettings()
79
																										 */);
80
				Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
81
82
				MoveRefactoring refactoring = new MoveRefactoring(processor);
83
84
				RefactoringWizard wizard = createWizard(refactoring);
85
86
				/*
87
				 * We want to get the shell from the refactoring dialog but
88
				 * it's not known at this point, so we pass the wizard and
89
				 * then, once the dialog is open, we will have access to its
90
				 * shell.
91
				 */
92
93
				processor.setCreateTargetQueries(new CreateTargetQueries(wizard));
94
				processor.setReorgQueries(new ReorgQueries(wizard));
95
				// String openRefactoringWizMsg =
96
				// RefactoringMessages.getString("OpenRefactoringWizardAction.refactoring");
97
				// //$NON-NLS-1$
98
				String openRefactoringWizMsg = JSPUIMessages.MoveElementWizard; // "Move
99
																				// the
100
																				// selected
101
																				// elements";
102
																				// //$NON-NLS-1$
103
				new RefactoringStarter().activate(refactoring, wizard, parent, openRefactoringWizMsg, true);
104
105
				PlatformStatusLineUtil.clearStatusLine();
106
107
			}
108
			catch (JavaModelException e) {
109
				Logger.logException(e);
110
			}
111
		}
112
		else {
113
			PlatformStatusLineUtil.displayErrorMessage(JSPUIMessages.JSPMoveElementAction_0); //$NON-NLS-1$
114
		}
115
	}
116
117
	public void selectionChanged(IAction action, ISelection selection) {
118
		PlatformStatusLineUtil.clearStatusLine();
119
	}
120
121
	public void init(IViewPart view) {
122
		// do nothing
123
	}
124
125
	private IJavaElement[] getSelectedElements() {
126
127
		IJavaElement[] elements = new IJavaElement[0];
128
		if (fEditor instanceof ITextEditor)
129
			elements = JSPJavaSelectionProvider.getSelection((ITextEditor) fEditor);
130
		return elements;
131
	}
132
133
	private IResource[] getResources(IJavaElement[] elements) {
134
		IResource[] resources = new IResource[elements.length];
135
		for (int i = 0; i < elements.length; i++) {
136
			try {
137
				resources[i] = elements[i].getPrimaryElement().getCorrespondingResource();// elements[i].getResource();
138
			}
139
			catch (JavaModelException e) {
140
				Logger.logException(e);
141
			}
142
		}
143
		return resources;
144
	}
145
	
146
	/**
147
	 * will change post 3.0 with public move support
148
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817
149
	 */
150
	private RefactoringWizard createWizard(MoveRefactoring refactoring) {
151
		return new ReorgMoveWizard(refactoring);
152
	}
153
}
(-)src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
13
package org.eclipse.jst.jsp.ui.internal.java.refactoring;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.jdt.core.IJavaElement;
17
import org.eclipse.jdt.core.IMethod;
18
import org.eclipse.jdt.core.IPackageFragment;
19
import org.eclipse.jdt.core.IType;
20
import org.eclipse.jdt.ui.refactoring.RenameSupport;
21
import org.eclipse.jface.action.IAction;
22
import org.eclipse.jface.viewers.ISelection;
23
import org.eclipse.jst.jsp.ui.internal.JSPUIMessages;
24
import org.eclipse.jst.jsp.ui.internal.Logger;
25
import org.eclipse.swt.widgets.Event;
26
import org.eclipse.ui.IActionDelegate2;
27
import org.eclipse.ui.IEditorActionDelegate;
28
import org.eclipse.ui.IEditorPart;
29
import org.eclipse.ui.IViewActionDelegate;
30
import org.eclipse.ui.IViewPart;
31
import org.eclipse.ui.PlatformUI;
32
import org.eclipse.ui.texteditor.ITextEditor;
33
import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil;
34
35
/**
36
 * An action delegate that launches JDT rename element wizard
37
 */
38
public class JSPRenameElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
39
	private IEditorPart fEditor;
40
	
41
	public void setActiveEditor(IAction action, IEditorPart targetEditor) {
42
		fEditor = targetEditor;
43
	}
44
45
	public void dispose() {
46
		// nulling out just in case
47
		fEditor = null;
48
	}
49
50
	public void init(IAction action) {
51
		if (action != null) {
52
			action.setText(JSPUIMessages.RenameElement_label);
53
			action.setToolTipText(JSPUIMessages.RenameElement_label);
54
		}
55
	}
56
57
	public void runWithEvent(IAction action, Event event) {
58
		run(action);
59
	}
60
	
61
	public void run(IAction action) {
62
		IJavaElement element = getSelectedElement();
63
		if(element != null) {
64
			RenameSupport renameSupport = null;
65
			try {
66
				switch(element.getElementType()) {
67
					case IJavaElement.TYPE:
68
						renameSupport= RenameSupport.create((IType)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
69
						break;
70
					case IJavaElement.METHOD:
71
						renameSupport= RenameSupport.create((IMethod)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
72
						break;
73
					case IJavaElement.PACKAGE_FRAGMENT:
74
						renameSupport= RenameSupport.create((IPackageFragment)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
75
						break;
76
				}
77
				if(renameSupport != null) {
78
					renameSupport.openDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
79
					PlatformStatusLineUtil.clearStatusLine();
80
				}
81
			}
82
			catch (CoreException e) {
83
				Logger.logException(e);
84
			}
85
		}
86
		else  {
87
			PlatformStatusLineUtil.displayErrorMessage(JSPUIMessages.JSPRenameElementAction_0); //$NON-NLS-1$
88
			PlatformStatusLineUtil.addOneTimeClearListener();
89
		}
90
	}
91
	
92
	public void selectionChanged(IAction action, ISelection selection) {
93
		PlatformStatusLineUtil.clearStatusLine();
94
	}
95
96
	public void init(IViewPart view) {
97
		// do nothing
98
	}
99
100
	private IJavaElement getSelectedElement() {
101
		IJavaElement element = null;
102
		if (fEditor instanceof ITextEditor) {
103
			IJavaElement[] elements = JSPJavaSelectionProvider.getSelection((ITextEditor)fEditor);
104
			if (elements.length == 1)
105
				element = elements[0];
106
		}
107
		return element;
108
	}
109
}
(-)src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesActionDelegate.java (+40 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
13
package org.eclipse.jst.jsp.ui.internal.java.search;
14
15
import java.util.ArrayList;
16
import java.util.List;
17
18
import org.eclipse.wst.html.ui.internal.search.HTMLFindOccurrencesProcessor;
19
import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesActionDelegate;
20
21
/**
22
 * Sets up FindOccurrencesActionDelegate for jsp find occurrences processors
23
 */
24
public class JSPFindOccurrencesActionDelegate extends FindOccurrencesActionDelegate {
25
	private List fProcessors;
26
27
	protected List getProcessors() {
28
		if (fProcessors == null) {
29
			fProcessors = new ArrayList();
30
			HTMLFindOccurrencesProcessor htmlProcessor = new HTMLFindOccurrencesProcessor();
31
			fProcessors.add(htmlProcessor);
32
//			 temporary, workaround to disable function, since using the function 
33
//			 can easily cause deadlock to occur.
34
//					 See https://bugs.eclipse.org/bugs/show_bug.cgi?id=103662
35
//			JSPFindOccurrencesProcessor jspProcessor = new JSPFindOccurrencesProcessor();
36
//			fProcessors.add(jspProcessor);
37
		}
38
		return fProcessors;
39
	}
40
}
(-)src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
13
package org.eclipse.jst.jsp.ui.internal.java.search;
14
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.jdt.core.IJavaElement;
17
import org.eclipse.jface.text.IDocument;
18
import org.eclipse.jface.text.ITextSelection;
19
import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation;
20
import org.eclipse.jst.jsp.core.internal.java.JSPTranslation;
21
import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter;
22
import org.eclipse.jst.jsp.core.internal.provisional.text.IJSPPartitionTypes;
23
import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts;
24
import org.eclipse.search.ui.ISearchQuery;
25
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
26
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
27
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
28
import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor;
29
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
30
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
31
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
32
33
/**
34
 * Configures a FindOccurrencesProcessor with JSP partitions and regions
35
 */
36
public class JSPFindOccurrencesProcessor extends FindOccurrencesProcessor {
37
38
	protected String[] getPartitionTypes() {
39
		return new String[]{IJSPPartitionTypes.JSP_DEFAULT, IJSPPartitionTypes.JSP_CONTENT_JAVA};
40
	}
41
42
	protected String[] getRegionTypes() {
43
		return new String[]{DOMRegionContext.BLOCK_TEXT, DOMJSPRegionContexts.JSP_CONTENT};
44
	}
45
46
	protected ISearchQuery getSearchQuery(IFile file, IStructuredDocument document, String regionText, String regionType, ITextSelection textSelection) {
47
		return new JSPSearchQuery(file, getJavaElement(document, textSelection));
48
	}
49
50
	private IJavaElement getJavaElement(IDocument document, ITextSelection textSelection) {
51
		IJavaElement[] elements = getJavaElementsForCurrentSelection(document, textSelection);
52
		return elements.length > 0 ? elements[0] : null;
53
	}
54
55
	/**
56
	 * uses JSPTranslation to get currently selected Java elements.
57
	 * 
58
	 * @return currently selected IJavaElements
59
	 */
60
	private IJavaElement[] getJavaElementsForCurrentSelection(IDocument document, ITextSelection selection) {
61
		IJavaElement[] elements = new IJavaElement[0];
62
		// get JSP translation object for this viewer's document
63
		IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
64
		try {
65
			if (model != null && model instanceof IDOMModel) {
66
				IDOMDocument xmlDoc = ((IDOMModel) model).getDocument();
67
				JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
68
				if (adapter != null) {
69
					JSPTranslation translation = adapter.getJSPTranslation();
70
71
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102211
72
					elements = translation.getElementsFromJspRange(selection.getOffset(), selection.getOffset() + selection.getLength());
73
				}
74
			}
75
		}
76
		finally {
77
			if (model != null)
78
				model.releaseFromRead();
79
		}
80
		return elements;
81
	}
82
}

Return to bug 109468