/** * Creates a new <code>OpenAction</code>. * * @param editor the Properties file editor which provides the context information for this action */ public OpenAction(PropertiesFileEditor editor) { super(editor.getEditorSite()); fEditor = editor; setText(PropertiesFileEditorMessages.OpenAction_label); setToolTipText(PropertiesFileEditorMessages.OpenAction_tooltip); // XXX: Must be removed once support for JARs is available (see class Javadoc for details). setEnabled(fEditor.getEditorInput() instanceof IFileEditorInput); }
private boolean checkEnabled(ITextSelection selection) { if (selection == null || selection.isEmpty()) return false; // XXX: Must be changed to IStorageEditorInput once support for JARs is available (see class // Javadoc for details) return fEditor.getEditorInput() instanceof IFileEditorInput; }
public void run(ITextSelection selection) { if (!checkEnabled(selection)) return; IRegion region = new Region(selection.getOffset(), selection.getLength()); PropertyKeyHyperlinkDetector detector = new PropertyKeyHyperlinkDetector(); detector.setContext(fEditor); IHyperlink[] hyperlinks = detector.detectHyperlinks(fEditor.internalGetSourceViewer(), region, false); if (hyperlinks != null && hyperlinks.length == 1) hyperlinks[0].open(); }