📄 taghandler.java
字号:
*/ public void showCardLevelTagsEditor() { if (CardTagsCreated) { CardLevelTags.doDoubleClick(); } } /** * Checks if the anchor tag is fully selected in the GraphicsPane, if so * allows the AnchorTagDesigner to be called from a popup menu. */ public void checkAnchor() { JTextPane thepane; if (focusControl == null) { thepane = gp; } else thepane = focusControl; int start = -1; int end = -1; try { start = thepane.getSelectionStart(); end = thepane.getSelectionEnd(); } catch (NullPointerException noposerr) { ControlEditAnchor.setEnabled(false); } if ((getRunLength(thepane, start, end, "anchor")) && (start > -1) && (end > -1)) ControlEditAnchor.setEnabled(true); else ControlEditAnchor.setEnabled(false); } /////////////////////////////////////////////////////////////////////////// // TagHandler popup menu handlers ////////////////////////////////////////////////////////////////////////// private void ControlCut_actionPerformed(ActionEvent e) { gp.cut(); } private void ControlCopy_actionPerformed(ActionEvent e) { gp.copy(); } private void ControlPaste_actionPerformed(ActionEvent e) { gp.paste(); } private void ControlInsertColumn_actionPerformed(ActionEvent e) { table t = (table) controlContainer; t.addColumn(); } private void ControlInsertRow_actionPerformed(ActionEvent e) { table t = (table) controlContainer; t.addRow(); } private void ControlDeleteColumn_actionPerformed(ActionEvent e) { table t = (table) controlContainer; t.removeColumn(); } private void ControlDeleteRow_actionPerformed(ActionEvent e) { table t = (table) controlContainer; t.removeRow(); } /** * Displays the appropriate properties based on what is selected. */ private void ControlProperties_actionPerformed(ActionEvent e) { GraphicalControlsProperties gcp = new GraphicalControlsProperties(); JTextPane thepane; if (focusControl == null) { thepane = gp; } else thepane = focusControl; int start = -1; int end = -1; try { start = thepane.getSelectionStart(); end = thepane.getSelectionEnd(); } catch (NullPointerException noposerr) {} int tabcounter = 0; if (type == 0) { //show image pane type = -1; img tmpimg = (img) controlContainer; String[] data = tmpimg.getProperties(); gcp.showImgPanel(data[0], data[1], data[7], data[2], data[3], data[4], data[5], data[6], data[8]); tabcounter++; } if (type == 1) { // show the input pane type = -1; input tmpinput = (input) controlContainer; String[] data = tmpinput.getProperties(); gcp.showInputPanel(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10]); tabcounter++; } if (type == 2) { // show the table pane type = -1; table tmptable = (table) controlContainer; String[] data = tmptable.getProperties(); gcp.showTablePanel(data[0], data[1], data[2], data[3], data[4]); tabcounter++; } if (type == 3) { // show the select pane type = -1; select tmpselect = (select) controlContainer; String[] data = tmpselect.getProperties(); gcp.showSelectPanel(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); tabcounter++; } if (type == 4) { // show the var pane type = -1; variable tmpvar = (variable) controlContainer; String data = tmpvar.getProperties(); gcp.showVarPanel(data); tabcounter++; } if (type == 5) { // show the do pane type = -1; doTag tmpdo = (doTag) controlContainer; String[] data = tmpdo.getProperties(); gcp.showDoPanel(data[0], data[1], data[2], data[3], data[4]); tabcounter++; } if ((start > -1) && (end > -1)) { thepane.setCaretPosition(start); thepane.setSelectionEnd(start); } AttributeSet set = thepane.getCharacterAttributes(); if (type == -1) { if (!(set.getAttribute("a") == null)) { if (getRunLength(thepane, start, end, "a")) { SimpleAttributeSet tag = new SimpleAttributeSet(set); SimpleAttributeSet attributes = (SimpleAttributeSet) tag.getAttribute("a"); String href = ""; try { href = (String) attributes.getAttribute("href"); } catch (NullPointerException nohref) {} String title = ""; try { title = (String) attributes.getAttribute("title"); } catch (NullPointerException notitle) {} String accesskey = ""; try { accesskey = (String) attributes.getAttribute("accesskey"); } catch (NullPointerException notitle) {} String extra = ""; try { extra = (String) attributes.getAttribute("extra"); } catch (NullPointerException noextra) {} gcp.showAPanel(href, title, accesskey, extra); tabcounter++; } } if (!(set.getAttribute("anchor") == null)) { if (getRunLength(thepane, start, end, "anchor")) { SimpleAttributeSet tag = new SimpleAttributeSet(set); SimpleAttributeSet attributes = (SimpleAttributeSet) tag.getAttribute("anchor"); String title = ""; try { title = (String) attributes.getAttribute("title"); } catch (NullPointerException notitle) {} String accesskey = ""; try { accesskey = (String) attributes.getAttribute("accesskey"); System.out.println("set: " + accesskey); } catch (NullPointerException notitle) {} String extra = ""; try { extra = (String) attributes.getAttribute("extra"); } catch (NullPointerException noextra) {} gcp.showAnchorPanel(title, accesskey, extra); tabcounter++; } } if (!(set.getAttribute("fieldset") == null)) { if (getRunLength(thepane, start, end, "fieldset")) { SimpleAttributeSet tag = new SimpleAttributeSet(set); SimpleAttributeSet attributes = (SimpleAttributeSet) tag.getAttribute("fieldset"); String title = ""; try { title = (String) attributes.getAttribute("title"); } catch (NullPointerException notitle) {} String extra = ""; try { extra = (String) attributes.getAttribute("extra"); } catch (NullPointerException noextra) {} gcp.showFieldsetPanel(title, extra); tabcounter++; } } } tabcounter++; // get P properties SimpleAttributeSet pset = new SimpleAttributeSet(gp.getParagraphAttributes()); String align = ""; String mode = ""; String extra = ""; String xmlspace = ""; if (!(pset.getAttribute("align") == null)) align = (String) pset.getAttribute("align"); if (!(pset.getAttribute("mode") == null)) mode = (String) pset.getAttribute("mode"); if (!(pset.getAttribute("xmlspace") == null)) xmlspace = (String) pset.getAttribute("xmlspace"); if (!(pset.getAttribute("extra") == null)) extra = (String) pset.getAttribute("extra"); if (pset.containsAttribute("pre", "")) gcp.showPrePanel(xmlspace, extra); else gcp.showPPanel(align, mode, extra); if (tabcounter > 0) { gcp.show(); Vector dialogData = new Vector(); try { dialogData = gcp.getData(); if ((start > -1) && (end > -1)) { thepane.requestFocus(); thepane.setSelectionStart(start); thepane.setSelectionEnd(end); } // process the data if (tabcounter == 1) { // only one tab, simple vector, name of tab last item in vector processProperties(dialogData, set, thepane); } else { // several tabs, so its a vector of vector objects try { for (int x = 0; x < dialogData.size(); x++) processProperties((Vector) dialogData.get(x), set, thepane); } catch (NullPointerException nullerr) {} catch (ClassCastException cle) {} } } catch (NullPointerException nodata) {} } } /** * Displays the AnchorDesigner dialog box. */ private void ControlEditAnchor_actionPerformed(ActionEvent e) { JTextPane thepane; if (focusControl == null) { thepane = gp; } else thepane = focusControl; int start = -1; int end = -1; try { start = thepane.getSelectionStart(); end = thepane.getSelectionEnd(); } catch (NullPointerException noposerr) {} if ((start > -1) && (end > -1)) { thepane.setCaretPosition(start); thepane.setSelectionEnd(start); } SimpleAttributeSet aset = new SimpleAttributeSet(thepane.getCharacterAttributes()); SimpleAttributeSet set = new SimpleAttributeSet((AttributeSet) aset.getAttribute("anchor")); AnchorTagDesigner atd = new AnchorTagDesigner(set); if (atd.getButtonPressed()) { SimpleAttributeSet attrib = atd.getData(); atd.dispose(); if ((start > -1) && (end > -1)) { thepane.requestFocus(); thepane.setSelectionStart(start); thepane.setSelectionEnd(end); } else thepane.requestFocus(); set.removeAttribute("go"); set.removeAttribute("prev"); set.removeAttribute("refresh"); set.addAttributes(attrib); aset.removeAttribute("anchor"); aset.addAttribute("anchor", set); thepane.setCharacterAttributes(aset, false); } } /** * Important when working with tables since it allows for deleting * and inserting of table rows and columns via the popup menu. */ private void ControlPopupMenu_popupMenuWillBecomeVisible(PopupMenuEvent e) { ControlDeleteRow.setEnabled(false); ControlDeleteColumn.setEnabled(false); ControlInsertRow.setEnabled(false); ControlInsertColumn.setEnabled(false); JTextPane thepane; if (focusControl == null) { thepane = gp; } else thepane = focusControl; int start = -1; int end = -1; try { start = thepane.getSelectionStart(); end = thepane.getSelectionEnd(); } catch (NullPointerException noposerr) {} AttributeSet attribs; if ((start == -1) && (end == -1)) attribs = thepane.getCharacterAttributes(); else { attribs = (AttributeSet) ((StyledDocument) thepane.getDocument()).getCharacterElement(start); } if (AnchorTagFound) ControlEditAnchor.setEnabled(true); else ControlEditAnchor.setEnabled(false); ControlProperties.setEnabled(true); } private void ControlPopupMenu_popupMenuWillBecomeInvisible(PopupMenuEvent e) {} //////////////////////////////////////////////////////////////////////////// ///// TagHandler helper functions //////////////////////////////////////////////////////////////////////////// /** * disables the Toolbar controls based on the type of attribute. * @String type - the type of attribute such as a or fieldset. */ private void disableControls(String type) { if ((type.equals("a")) || (type.equals("anchor"))) { Menu.getItem(1).setEnabled(false); Menu.getItem(2).setEnabled(fal
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -