private void notFound(JTextComponent target) { Utilities.setStatusBoldText(target, NbBundle.getMessage(GotoActionView.class, "ControllerNotFound")); }
private void actionPerformed(final JTextComponent target, final FileObject fo) { if (fo != null) { // TODO - Look up project and complain if it's not a Rails project // See if it's a controller: if (fo.getName().endsWith("_controller")) { // NOI18N gotoView(target, fo, "_controller", "controllers"); // NOI18N } else if (fo.getName().endsWith("_helper")) { // NOI18N gotoView(target, fo, "_helper", "helpers"); // NOI18N } else if (isModel(fo)) { // possibly an action mailer model class gotoView(target, fo, "", "models"); // NOI18N } else { if (RubyUtils.isRhtmlFile(fo)) { gotoAction(target, fo); } else { String ext = fo.getExt(); for (String e : RubyUtils.RUBY_VIEW_EXTS) { if (ext.equalsIgnoreCase(e)) { gotoAction(target, fo); return; } } Utilities.setStatusBoldText(target, NbBundle.getMessage(GotoActionView.class, "AppliesToControllers")); } } } }
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 static void invokeInstantRename(JTextComponent target) { try { final int caret = target.getCaretPosition(); Document doc = target.getDocument(); DataObject dobj = NbEditorUtilities.getDataObject(doc); CsmFile file = CsmUtilities.getCsmFile(dobj, false, false); if (file == null) { Utilities.setStatusBoldText(target, getString("no-instant-rename")); // NOI18N return; } CsmReference ref = CsmReferenceResolver.getDefault().findReference(file, doc, caret); if (ref == null) { Utilities.setStatusBoldText(target, getString("no-instant-rename")); // NOI18N return; } boolean doFullRename = true; if (allowInstantRename(ref, dobj.getPrimaryFile())) { Collection<CsmReference> changePoints = computeChangePoints(ref); if (!changePoints.isEmpty()) { doFullRename = false; doInstantRename(changePoints, target, caret); } } if (doFullRename) { doFullRename(dobj, target); } } catch (BadLocationException e) { Exceptions.printStackTrace(e); } }
/** * 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); } }
private static void doFullRename(DataObject dobj, JTextComponent target) { EditorCookie ec = dobj.getCookie(EditorCookie.class); Node n = dobj.getNodeDelegate(); if (n == null) { Utilities.setStatusBoldText(target, getString("no-instant-rename")); // NOI18N return; } InstanceContent ic = new InstanceContent(); if (ec != null) { ic.add(ec); } ic.add(n); Lookup actionContext = new AbstractLookup(ic); Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(actionContext); a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT); }
mostRecentMessage = message; if (isError()) { org.netbeans.editor.Utilities.setStatusBoldText(pane, message); } else {
Utilities.setStatusBoldText(target, "Cannot perform rename here."); Utilities.setStatusBoldText(target, "Scanning In Progress"); Utilities.setStatusBoldText(target, message[0]);
: LocaleSupport.getString(WRAP_START_LOCALE); Utilities.setStatusBoldText(c, msg); } else { Utilities.setStatusText(c, msg); Utilities.setStatusBoldText(c, exp + LocaleSupport.getString( NOT_FOUND_LOCALE));
msg += back ? LocaleSupport.getString(WRAP_END_LOCALE) : LocaleSupport.getString(WRAP_START_LOCALE); Utilities.setStatusBoldText(c, msg); Utilities.setStatusBoldText(c, exp + LocaleSupport.getString(NOT_FOUND_LOCALE));