@Override public void open() { FileObject fileObject = element.getFileObject(); if (fileObject != null) { GsfUtilities.open(fileObject, element.getOffset(), element.getName()); } else { Logger logger = Logger.getLogger(PHPTypeSearcher.class.getName()); logger.log(Level.INFO, String.format("%s: cannot find %s", PHPTypeSearcher.class.getName(), element.getFilenameUrl())); //NOI18N } }
@Override public void actionPerformed(ActionEvent caller, JTextComponent sourceComponent) { FileObject targetFO = findTargetFO(); if (targetFO != null && targetFO.isValid()) { GsfUtilities.open(targetFO, 0, ""); } }
@Override public void open() { FileObject fileObject = element.getFileObject(); if (fileObject == null) { NotifyDescriptor nd = new NotifyDescriptor.Message(NbBundle.getMessage(GroovyTypeSearcher.class, "FileDeleted"), NotifyDescriptor.Message.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(nd); // TODO: Try to remove the item from the index? Can't fix yet because the url is wiped // out by getFileObject (to avoid checking file existence multiple times; use a boolean // flag for that instead) } else { // TODO: Would be good to change offset to the start of the class decalaration instead // of zero. Unfortunatelly we don't have such an information in the index so far and // parsing whole AST for that is too expensive (see issue 183727 for background) GsfUtilities.open(fileObject, 0, element.getName()); } }
private void gotoAction(JTextComponent target, FileObject file) { // This should be a view. String ext = file.getExt(); boolean found = false; for (String e : RubyUtils.RUBY_VIEW_EXTS) { if (ext.equalsIgnoreCase(e)) { found = true; break; } } if (!RubyUtils.isRhtmlFile(file) && !found) { Utilities.setStatusBoldText(target, NbBundle.getMessage(GotoActionView.class, "AppliesToViews")); return; } FileObject controllerFile = RubyUtils.getRailsControllerFor(file); String action = getActionName(file); if (controllerFile == null) { notFound(target); return; } // TODO: Find the position of the #view method int offset = AstUtilities.findOffset(controllerFile, action); GsfUtilities.open(controllerFile, offset, "def " + action); // NOI18N }
public void open() { Node node = AstUtilities.getForeignNode(element); if (node != null) { GsfUtilities.open(element.getFileObject(), node.getPosition().getStartOffset(), element.getName()); return; } FileObject fileObject = element.getFileObject(); if (fileObject == null) { NotifyDescriptor nd = new NotifyDescriptor.Message(NbBundle.getMessage(RubyTypeSearcher.class, "FileDeleted"), NotifyDescriptor.Message.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(nd); // TODO: Try to remove the item from the index? Can't fix yet because the url is wiped // out by getFileObject (to avoid checking file existence multiple times; use a boolean // flag for that instead) return; } helper.open(fileObject, element); }
/** * Move from something like app/controllers/credit_card_controller.rb#debit() * to app/views/credit_card/debit.rhtml */ private void gotoView(JTextComponent target, FileObject file, String fileSuffix, String parentAppDir) { // This should be a view. if (!file.getName().endsWith(fileSuffix) && !isModel(file)) { Utilities.setStatusBoldText(target, NbBundle.getMessage(GotoActionView.class, "AppliesToActions")); return; } FileObject controllerFile = file; int offset = 0; // Find the offset of the file we're in, if any if (target.getCaret() != null) { offset = target.getCaret().getDot(); } // Get the name of the method corresponding to the offset String methodName = AstUtilities.getMethodName(controllerFile, offset); FileObject viewFile = RubyUtils.getRailsViewFor(file, methodName, fileSuffix, parentAppDir, false); if (viewFile == null) { notFound(target); } else { GsfUtilities.open(viewFile, 0, null); } }