import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.RetargetAction;
+import org.eclipse.ui.editors.text.EncodingActionGroup;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-
/**
* Contributes interesting PHP actions to the desktop's Edit menu and the toolbar.
*/
protected PHPParserAction fParserAction;
protected ShowExternalPreviewAction fShowExternalPreviewAction;
+ private EncodingActionGroup fEncodingActionGroup;
/**
* Default constructor.
*/
ResourceBundle b = PHPEditorMessages.getResourceBundle();
fRetargetContentAssist = new RetargetAction(PHPdtActionConstants.CONTENT_ASSIST, PHPEditorMessages.getString("ContentAssistProposal.label")); //$NON-NLS-1$
- fRetargetContentAssist.setActionDefinitionId(
- PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ fRetargetContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
markAsPartListener(fRetargetContentAssist);
fContentAssist = new RetargetTextEditorAction(b, "ContentAssistProposal."); //$NON-NLS-1$
- fContentAssist.setActionDefinitionId(
- PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ fContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
fGotoMatchingBracket = new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$
- fGotoMatchingBracket.setActionDefinitionId(
- PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+ fGotoMatchingBracket.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
// fContentAssist.setImageDescriptor(JavaPluginImages.DESC_CLCL_CODE_ASSIST);
// fContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST);
fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
// fTogglePresentation = new PresentationAction();
+ // character encoding
+ fEncodingActionGroup = new EncodingActionGroup();
+
fParserAction = PHPParserAction.getInstance();
if (SWT.getPlatform().equals("win32")) {
super.contributeToMenu(menu);
- IMenuManager editMenu =
- menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+ IMenuManager editMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
if (editMenu != null) {
editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
editMenu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
-// editMenu.appendToGroup(
-// IContextMenuConstants.GROUP_GENERATE,
-// fRetargetContentAssist);
+ // editMenu.appendToGroup(
+ // IContextMenuConstants.GROUP_GENERATE,
+ // fRetargetContentAssist);
// MenuManager structureSelection= new MenuManager(JavaEditorMessages.getString("ExpandSelectionMenu.label"), "expandSelection"); //$NON-NLS-1$ //$NON-NLS-2$
// structureSelection.add(fStructureSelectEnclosingAction);
Iterator e = fPartListeners.iterator();
while (e.hasNext())
page.addPartListener((RetargetAction) e.next());
-
+ // character encoding
+ fEncodingActionGroup.fillActionBars(bars);
super.init(bars, page);
}
/*
super.init(bars);
IMenuManager menuManager = bars.getMenuManager();
- IMenuManager editMenu =
- menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+ IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
if (editMenu != null) {
editMenu.add(new Separator());
editMenu.add(fContentAssist);
// editMenu.add(fContentAssistTip);
}
- bars.setGlobalActionHandler(
- PHPdtActionConstants.CONTENT_ASSIST,
- fContentAssist);
+ bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST, fContentAssist);
// IToolBarManager toolBarManager = bars.getToolBarManager();
// if (toolBarManager != null) {
// toolBarManager.add(new Separator());
// }
}
- private void doSetActiveEditor(IEditorPart part) {
+ /*
+ * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
+ */
+ public void setActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
IActionBars bars = getActionBars();
fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
fContentAssistTip.setAction(getAction(textEditor, "ContentAssistTip")); //$NON-NLS-1$
- fGotoMatchingBracket.setAction(
- getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
+ fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
bars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
bars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
+ // character encoding
+ fEncodingActionGroup.retarget(textEditor);
- bars.setGlobalActionHandler(
- PHPdtActionConstants.COMMENT,
- getAction(textEditor, "Comment"));
- bars.setGlobalActionHandler(
- PHPdtActionConstants.UNCOMMENT,
- getAction(textEditor, "Uncomment"));
- bars.setGlobalActionHandler(
- PHPdtActionConstants.FORMAT,
- getAction(textEditor, "Format"));
+ bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment"));
+ bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment"));
+ bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(textEditor, "Format"));
if (part instanceof PHPEditor) {
PHPEditor phpEditor = (PHPEditor) part;
PHPeclipsePlugin.getDefault().setLastEditorFile(file);
fParserAction.setEditor(textEditor);
fParserAction.update();
- if (SWT.getPlatform().equals("win32")
- && textEditor instanceof AbstractTextEditor) {
+ if (SWT.getPlatform().equals("win32") && textEditor instanceof AbstractTextEditor) {
fShowExternalPreviewAction.setEditor(textEditor);
fShowExternalPreviewAction.update();
- IPreferenceStore store =
- PHPeclipsePlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
if (store.getBoolean(PHPeclipsePlugin.SHOW_EXTERNAL_PREVIEW_PREF)) {
IAction a = ShowExternalPreviewAction.getInstance();
if (a != null)
}
}
}
-
- }
-
- /*
- * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart part) {
- doSetActiveEditor(part);
}
/*
getPage().removePartListener((RetargetAction) e.next());
fPartListeners.clear();
- doSetActiveEditor(null);
+ setActiveEditor(null);
super.dispose();
}
}