📄 dispatch.java
字号:
public static int dispatchFileSaveAs(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String fname = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_FILE_SAVE_AS); s.getBuffer().save(s.view, fname, true); try {Thread.currentThread().sleep(35);} catch (InterruptedException e){} VFSManager.waitForRequests(); return(i); } // unused to be deleted public static int dispatchMoveDirectory(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, Protocol.PPC_STRING_VALUE); String oldname = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_STRING_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, Protocol.PPC_STRING_VALUE); String newname = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_STRING_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_MOVE_DIRECTORY); int confirm = JOptionPane.showConfirmDialog( s.getProbableParent(data.callerComponent), "\tCan I move directory\n"+oldname+"\n\tto\n"+newname, "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (confirm == JOptionPane.YES_OPTION) { File ff = new File(oldname); ff.renameTo(new File(newname)); } return(i); } public static int dispatchMoveFileAs(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String fname = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_MOVE_FILE_AS); File ff = new File(fname); ff.getParentFile().mkdirs(); File oldfile = new File(s.getBuffer().getPath()); oldfile.delete(); if (s.getBuffer().save(s.view, fname, true)) { // sleeping is a hack fixing jEdit dead-lock problem try {Thread.currentThread().sleep(35);} catch (InterruptedException e){} VFSManager.waitForRequests(); Buffer oldb = jEdit.getBuffer(oldfile.getAbsolutePath()); if (oldb!=null && oldb!=s.getBuffer()) { jEdit.closeBuffer(s.view, oldb); } try {Thread.currentThread().sleep(15);} catch (InterruptedException e){} VFSManager.waitForRequests(); } else { throw new XrefException("can not move the file"); } return(i); } public static int dispatchGoto(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { i = parseXmlTagHandleMessages(ss, i, len,data); if (currentTag.equals(Protocol.PPC_OFFSET_POSITION)) { String path = ss.substring(i, i+attrLen); int offset = attrOffset; i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_OFFSET_POSITION); s.moveToPosition(s.getParentView(data.callerComponent), path, offset); } else { protocolCheckEq(currentTag, Protocol.PPC_LC_POSITION); String path = ss.substring(i, i+attrLen); int line = attrLine; int col = attrCol; i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_LC_POSITION); s.moveToPosition(s.getParentView(data.callerComponent), path, line, col); } i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_GOTO); return(i); } public static int dispatchPreCheck(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String str = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_REFACTORING_PRECHECK); editorPreCheck(str); return(i); } public static int dispatchString(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, Protocol.PPC_STRING_VALUE); stringVal = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_STRING_VALUE); return(i); } public static int dispatchReplacement(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { i = dispatchString(ss, i, len, data); String str = stringVal; i = dispatchString(ss, i, len, data); String with = stringVal; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_REFACTORING_REPLACEMENT); editorReplace(str, with); return(i); } public static int dispatchDisplayResolution(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String message = ss.substring(i, i+attrLen); boolean cont = attrContinue!=0; i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_DISPLAY_RESOLUTION); // Frame did not work, as it looses pointer to s.view //&if (cont) { new ResolutionDialog(message, attrMType, data, cont); //&} else { //&new ResolutionFrame(message, attrMType, data, cont); //&throw new XrefAbortException(); //&} return(i); } public static int dispatchDisplayOrUpdateBrowser(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String message = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_DISPLAY_OR_UPDATE_BROWSER); s.showAndUpdateBrowser(s.getParentView(data.callerComponent)); return(i); }/*& // old way of displaying class tree public static int dispatchDisplayClassTree(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { XrefCharBuffer tree = new XrefCharBuffer(); int minLine = 1000000; int cline = -1; String prefix; int callerLine = 0; clearAttributes(); i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_CLASS)) { String ctclass = ss.substring(i, i+attrLen); i += attrLen; cline ++; if (cline != 0) tree.append("\n"); if (attrBase==1) { prefix = ">>"; if (callerLine==0) callerLine = cline; } else { prefix = " "; } if (attrTreeUp==1) { tree.append(prefix + attrTreeDeps + "(" + ctclass + ") "); } else { tree.append(prefix + attrTreeDeps + ctclass + " "); } if (minLine>attrLine) minLine = attrLine; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_CLASS); clearAttributes(); i = parseXmlTagHandleMessages(ss, i, len,data); } protocolCheckEq(currentTag, "/"+Protocol.PPC_DISPLAY_CLASS_TREE); new DockableClassTree(s.getParentFrame(data.callerComponent), tree.toString(), data, minLine, callerLine); return(i); } &*/ public static int dispatchDisplayClassTree(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { XrefTreeNode [] tt = new XrefTreeNode[s.XREF_MAX_TREE_DEEP]; tt[0] = new XrefTreeNode("root", null, 0,0,0, false,false,false,false,false,false); i = dispatchParseOneSymbolClassHierarchy(ss, i, len, data, tt, ""); protocolCheckEq(currentTag, "/"+Protocol.PPC_DISPLAY_CLASS_TREE); s.view.getDockableWindowManager().showDockableWindow(s.dockableClassTreeWindowName); DockableClassTree ctViewer = s.getClassTreeViewer(s.view); ctViewer.setTree(tt[0]); return(i); } static int dispatchParseOneSymbolClassHierarchy(XrefCharBuffer ss, int i, int len, DispatchData data, XrefTreeNode [] tt, String symbol) throws Exception { tt[1] = new XrefTreeNode(symbol, tt[0], 0,0,0, false,false,false,true,false,false); clearAttributes(); i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_CLASS)) { String ctclass = ss.substring(i, i+attrLen); i += attrLen; int deep = attrIndent+2; s.assertt(deep < s.XREF_MAX_TREE_DEEP); tt[deep] = new XrefTreeNode(ctclass, tt[deep-1], attrLine, attrRefn, attrDRefn, attrBase==1,attrSelected==1,attrInterface==1, false,attrDefinition==1, false); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_CLASS); clearAttributes(); i = parseXmlTagHandleMessages(ss, i, len,data); } return(i); } static int dispatchParseTreeDescription(XrefCharBuffer ss, int i, int len, DispatchData data, XrefTreeNode [] tt) throws Exception { tt[0] = new XrefTreeNode("root", null, 0,0,0, false,false,false,false,false,false); XrefTreeNode nonVirtuals = new XrefTreeNode(s.XREF_NON_MEMBER_SYMBOL_NAME, tt[0], 0, 0, 0, false,false,false,true,false,false); i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_VIRTUAL_SYMBOL) || currentTag.equals(Protocol.PPC_SYMBOL)) { String symbol = ss.substring(i, i+attrLen); i += attrLen; if (currentTag.equals(Protocol.PPC_SYMBOL)) { new XrefTreeNode(symbol, nonVirtuals, attrLine, attrRefn, attrDRefn, attrBase==1,attrSelected==1,attrInterface==1, false,attrDefinition==1, false); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_SYMBOL); clearAttributes(); i = parseXmlTagHandleMessages(ss, i, len,data); } else { i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_VIRTUAL_SYMBOL); i = dispatchParseOneSymbolClassHierarchy(ss, i, len, data, tt, symbol); } } if (nonVirtuals.subNodes.size()==0) tt[0].removeSubNode(nonVirtuals); return(i); } public static int dispatchSymbolResolution(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { XrefTreeNode [] tt = new XrefTreeNode[s.XREF_MAX_TREE_DEEP]; i = dispatchParseTreeDescription(ss, i, len, data, tt); protocolCheckEq(currentTag, "/"+Protocol.PPC_SYMBOL_RESOLUTION); BrowserTopPanel bpanel = s.getParentBrowserTopPanel(data.callerComponent); s.assertt(bpanel!=null); bpanel.treePanel.xtree.setTree(tt[0]); return(i); } public static int dispatchReferenceList(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { boolean firstFlag = true; XrefCharBuffer refs = new XrefCharBuffer(); int crefn = attrVal; i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_SRC_LINE)) { if (! firstFlag) refs.append("\n"); firstFlag = false; for(int j=0; j<attrRefn; j++) { if (j!=0) refs.append("\n"); refs.append(ss, i, attrLen); } i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_SRC_LINE); i = parseXmlTagHandleMessages(ss, i, len,data); } protocolCheckEq(currentTag, "/"+Protocol.PPC_REFERENCE_LIST); BrowserTopPanel bpanel = s.getParentBrowserTopPanel(data.callerComponent); s.assertt(bpanel!=null); bpanel.referencesPanel.reflist.setRefs(refs.toString(), crefn); return(i); } public static int dispatchUpdateCurrentReference(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { int val = attrVal; i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_UPDATE_CURRENT_REFERENCE); BrowserTopPanel bpanel = s.getParentBrowserTopPanel(data.callerComponent); s.assertt(bpanel!=null); bpanel.referencesPanel.reflist.setCurrentRef(val); return(i); } public static int dispatchProgress(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { // TDODO!!! //&ProgressMonitor progress = new ProgressMonitor(s.getProbableParent(data.callerComponent), "Updating references", null, 0, 100); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_PROGRESS); //&progress.close(); return(i); } public static int dispatchUpdateReport(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { // O.K. skip everything until end of report // TODO, do this seriously, counting eventual nestings i += attrLen; clearAttributes(); i = parseXmlTag(ss, i, len); while (i<len && ! currentTag.equals("/"+Protocol.PPC_UPDATE_REPORT)) { i += attrLen; clearAttributes(); i = parseXmlTag(ss, i, len); // make an exception and report fatal error, as task is exited now if (currentTag.equals(Protocol.PPC_FATAL_ERROR)) { i = dispatchFatalError(ss, i, len, data); } } protocolCheckEq(currentTag, "/"+Protocol.PPC_UPDATE_REPORT); return(i); } public static int dispatchVersionMismatch(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String taskVersion = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTag(ss, i, len); protocolCheckEq(currentTag, "/"+Protocol.PPC_VERSION_MISMATCH); s.checkVersionCorrespondance(taskVersion, data); return(i); } public static int dispatchBrowseUrl(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String message = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_BROWSE_URL); browseUrlIfConfirmed(message, data); //&new HelpViewer(message); return(i); } public static int dispatchSingleCompletion(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String completion = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_SINGLE_COMPLETION); int caret = s.getCaretPosition(); s.insertCompletion(s.getBuffer(), caret, completion); return(i); } public static int dispatchFqtCompletion(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String completion = ss.substring(i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_FQT_COMPLETION); int caret = s.getCaretPosition(); CompletionDialog.insertFqtCompletion(s.getBuffer(), caret, completion); return(i); } public static int dispatchCompletionList(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { boolean firstFlag = true; XrefCharBuffer completions = new XrefCharBuffer(); i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_MULTIPLE_COMPLETION_LINE)) { if (! firstFlag) completions.append("\n"); firstFlag = false; completions.append(ss, i, attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_MULTIPLE_COMPLETION_LINE); i = parseXmlTagHandleMessages(ss, i, len,data); } protocolCheckEq(currentTag, "/"+Protocol.PPC_MULTIPLE_COMPLETIONS); CompletionDialog.showCompletionDialog(completions.toString(), data, attrNoFocus); return(i); } public static int dispatchFullCompletionList(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { int ci, max; ci = 0; max = attrNumber; CompletionDialog3 cd = CompletionDialog3.initCompletionDialog(data, max, attrNoFocus); i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_MULTIPLE_COMPLETION_LINE)) { s.assertt(ci < max); cd.lns[ci] = new CompletionDialog3.LineData(cd.completions.bufi, cd.completions.bufi + attrVal, attrVClass); cd.completions.append(ss, i, attrLen);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -