@Override protected final void actionPerformed(PhpModule phpModule) { // called via shortcut if (!CakePhpUtils.isCakePHP(phpModule)) { return; } JTextComponent editor = EditorRegistry.lastFocusedComponent(); if (editor == null) { return; } Document document = editor.getDocument(); if (document == null) { return; } FileObject fileObject = NbEditorUtilities.getFileObject(document); if (fileObject == null) { return; } // get go to files CakePhpGoToStatusFactory factory = CakePhpGoToStatusFactory.getInstance(); CakePhpGoToStatus status = factory.create(fileObject, editor.getCaretPosition()); final List<GoToItem> items = getGoToItems(status); if (items == null || items.isEmpty()) { return; } // if there are multiple items, show popup list if (items.size() == 1 && !CakePreferences.isShowPopupForOneItem(phpModule)) { for (GoToItem item : items) { UiUtils.open(item.getFileObject(), item.getOffset()); return; } } // show popup try { Rectangle rectangle = editor.modelToView(editor.getCaretPosition()); final Point point = new Point(rectangle.x, rectangle.y + rectangle.height); SwingUtilities.convertPointToScreen(point, editor); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { String title = getPopupTitle(); if (title == null) { title = ""; // NOI18N } PopupUtil.showPopup(new GoToPopup(title, items), title, point.x, point.y, true, 0); } }); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } }
@Override public boolean goToView() { EditorSupport editorSupport = Lookup.getDefault().lookup(EditorSupport.class); PhpBaseElement phpElement = editorSupport.getElement(fo, offset); if (phpElement == null) { return false; } FileObject view = EditorUtils.getView(fo, phpElement); if (view != null) { UiUtils.open(view, DEFAULT_OFFSET); return true; } return false; }