public void update() { setEnabled((getResource() != null || getEncodingSupport() != null) && !getTextEditor().isDirty()); }
/** * Creates a new action for the given text editor. The action configures its * visual representation from the given resource bundle. * * @param bundle the resource bundle * @param prefix a prefix to be prepended to the various resource keys * (described in <code>ResourceAction</code> constructor), or * <code>null</code> if none * @param editor the text editor * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) */ public ChangeEncodingAction(ResourceBundle bundle, String prefix, ITextEditor editor) { super(bundle, prefix, editor); String key= "dialog.title"; //$NON-NLS-1$; if (prefix != null && prefix.length() > 0) key= prefix + key; fDialogTitle= getString(bundle, key, null); }
public void run() { final IResource resource= getResource(); final Shell parentShell= getTextEditor().getSite().getShell(); final IEncodingSupport encodingSupport= getEncodingSupport(); if (resource == null && encodingSupport == null) { MessageDialog.openInformation(parentShell, fDialogTitle, TextEditorMessages.ChangeEncodingAction_message_noEncodingSupport);
private void contributeChangeEncodingAction(MergeSourceViewer viewer) { IAction action = new ChangeEncodingAction(getTextEditorAdapter()); viewer.addAction(MergeSourceViewer.CHANGE_ENCODING_ID, action); }
/** * Gets the editor's encoding support. * * @return the resource being edited or <code>null</code>s */ private IEncodingSupport getEncodingSupport() { if (getTextEditor() != null) return (IEncodingSupport)getTextEditor().getAdapter(IEncodingSupport.class); return null; } }
/** * update all actions independent of their type * */ public void updateActions() { Iterator<IAction> e= fActions.values().iterator(); while (e.hasNext()) { IAction next = e.next(); if (next instanceof MergeViewerAction) { MergeViewerAction action = (MergeViewerAction) next; action.update(); } else if (next instanceof FindReplaceAction) { FindReplaceAction action = (FindReplaceAction) next; action.update(); } else if (next instanceof ChangeEncodingAction) { ChangeEncodingAction action = (ChangeEncodingAction) next; action.update(); } } }
@Override public void run() { final IResource resource= getResource(); final Shell parentShell= getTextEditor().getSite().getShell(); final IEncodingSupport encodingSupport= getEncodingSupport(); if (resource == null && encodingSupport == null) { MessageDialog.openInformation(parentShell, fDialogTitle, TextEditorMessages.ChangeEncodingAction_message_noEncodingSupport);
setAction(IDEActionFactory.ADD_TASK.getId(), action); action= new ChangeEncodingAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ChangeEncodingAction.", this); //$NON-NLS-1$ action.setHelpContextId(ITextEditorHelpContextIds.CHANGE_ENCODING); action.setActionDefinitionId(ITextEditorActionDefinitionIds.CHANGE_ENCODING);
/** * Gets the editor's encoding support. * * @return the resource being edited or <code>null</code>s */ private IEncodingSupport getEncodingSupport() { if (getTextEditor() != null) return getTextEditor().getAdapter(IEncodingSupport.class); return null; } }
@Override public void update() { setEnabled((getResource() != null || getEncodingSupport() != null) && !getTextEditor().isDirty()); }
setAction(IDEActionFactory.ADD_TASK.getId(), action); action= new ChangeEncodingAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ChangeEncodingAction.", this); //$NON-NLS-1$ action.setHelpContextId(ITextEditorHelpContextIds.CHANGE_ENCODING); action.setActionDefinitionId(ITextEditorActionDefinitionIds.CHANGE_ENCODING);
/** * Gets the resource which is being edited in the editor. * * @return the resource being edited or <code>null</code>s */ private IResource getResource() { if (getTextEditor() != null && getTextEditor().getEditorInput() != null) return getTextEditor().getEditorInput().getAdapter(IResource.class); return null; }
/** * Creates a new action for the given text editor. The action configures its visual * representation from the given resource bundle. * * @param bundle the resource bundle * @param prefix a prefix to be prepended to the various resource keys (described in * <code>ResourceAction</code> constructor), or <code>null</code> if none * @param editor the text editor * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) */ public ChangeEncodingAction(ResourceBundle bundle, String prefix, ITextEditor editor) { super(bundle, prefix, editor); String key= "dialog.title"; //$NON-NLS-1$; if (prefix != null && prefix.length() > 0) key= prefix + key; fDialogTitle= getString(bundle, key, null); }
/** * Gets the resource which is being edited in the editor. * * @return the resource being edited or <code>null</code>s */ private IResource getResource() { if (getTextEditor() != null && getTextEditor().getEditorInput() != null) return (IResource)getTextEditor().getEditorInput().getAdapter(IResource.class); return null; }