List of usage examples for org.dom4j Node getText
String getText();
Returns the text of this node.
From source file:com.magicpwd._bean.mpro.GuidBean.java
License:Open Source License
public void exptCardActionPerformed(java.awt.event.ActionEvent evt) { if (processing) { return;/*from www .ja va 2 s. c om*/ } processing = true; if (fileTM == null) { fileTM = new FileTM("card", Pattern.compile("[^.]+[.]amc$", Pattern.CASE_INSENSITIVE), false); pm_CardMenu = new javax.swing.JPopupMenu(); mu_HtmMenu = new javax.swing.JMenu("HTM"); mu_TxtMenu = new javax.swing.JMenu("TXT"); mu_PngMenu = new javax.swing.JMenu("PNG"); mu_SvgMenu = new javax.swing.JMenu("SVG"); al_Listener = new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { cardItemActionPerformed(evt); } }; } if (fileTM.checkModified()) { pm_CardMenu.removeAll(); mu_HtmMenu.removeAll(); pm_CardMenu.add(mu_HtmMenu); mu_TxtMenu.removeAll(); pm_CardMenu.add(mu_TxtMenu); mu_PngMenu.removeAll(); pm_CardMenu.add(mu_PngMenu); mu_SvgMenu.removeAll(); pm_CardMenu.add(mu_SvgMenu); SAXReader reader = new SAXReader(); javax.swing.JMenuItem item; for (java.io.File cardFile : fileTM.getFileList()) { try { Document doc = reader.read(cardFile); Node name = doc.selectSingleNode("/magicpwd/base/name"); item = new javax.swing.JMenuItem(); item.addActionListener(al_Listener); item.setText(name != null ? name.getText() : cardFile.getName()); Node type = doc.selectSingleNode("/magicpwd/base/type"); if (type != null) { String text = (type.getText() + "").trim().toLowerCase(); if (ConsEnv.CARD_HTM.equals(text)) { item.setActionCommand(ConsEnv.CARD_HTM + '/' + cardFile.getPath()); mu_HtmMenu.add(item); continue; } if (ConsEnv.CARD_TXT.equals(text)) { item.setActionCommand(ConsEnv.CARD_TXT + '/' + cardFile.getPath()); mu_TxtMenu.add(item); continue; } if (ConsEnv.CARD_PNG.equals(text)) { item.setActionCommand(ConsEnv.CARD_PNG + '/' + cardFile.getPath()); mu_PngMenu.add(item); continue; } if (ConsEnv.CARD_SVG.equals(text)) { item.setActionCommand(ConsEnv.CARD_SVG + '/' + cardFile.getPath()); mu_SvgMenu.add(item); continue; } } item.setActionCommand(ConsEnv.CARD_ALL + '/' + cardFile.getPath()); pm_CardMenu.add(item); } catch (Exception exp) { processing = false; Logs.exception(exp); Lang.showMesg(mainPtn, null, exp.getLocalizedMessage()); return; } } } pm_CardMenu.show(bt_ExptCard, 0, bt_ExptCard.getPreferredSize().height); processing = false; }
From source file:com.magicpwd._bean.mwiz.GuidBean.java
License:Open Source License
public void exptCardActionPerformed(java.awt.event.ActionEvent evt) { if (processing) { return;/* w w w . j a v a 2s .co m*/ } processing = true; if (fileTM == null) { fileTM = new FileTM("card", Pattern.compile("[^.]+[.]amc$", Pattern.CASE_INSENSITIVE), false); pm_CardMenu = new javax.swing.JPopupMenu(); mu_HtmMenu = new javax.swing.JMenu("HTM"); mu_TxtMenu = new javax.swing.JMenu("TXT"); mu_PngMenu = new javax.swing.JMenu("PNG"); mu_SvgMenu = new javax.swing.JMenu("SVG"); al_Listener = new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { cardItemActionPerformed(evt); } }; } if (fileTM.checkModified()) { pm_CardMenu.removeAll(); mu_HtmMenu.removeAll(); pm_CardMenu.add(mu_HtmMenu); mu_TxtMenu.removeAll(); pm_CardMenu.add(mu_TxtMenu); mu_PngMenu.removeAll(); pm_CardMenu.add(mu_PngMenu); mu_SvgMenu.removeAll(); pm_CardMenu.add(mu_SvgMenu); SAXReader reader = new SAXReader(); javax.swing.JMenuItem item; for (java.io.File cardFile : fileTM.getFileList()) { try { Document doc = reader.read(cardFile); Node name = doc.selectSingleNode("/magicpwd/base/name"); item = new javax.swing.JMenuItem(); item.addActionListener(al_Listener); item.setText(name != null ? name.getText() : cardFile.getName()); Node type = doc.selectSingleNode("/magicpwd/base/type"); if (type != null) { String text = (type.getText() + "").trim().toLowerCase(); if (ConsEnv.CARD_HTM.equals(text)) { item.setActionCommand(ConsEnv.CARD_HTM + '/' + cardFile.getPath()); mu_HtmMenu.add(item); continue; } if (ConsEnv.CARD_TXT.equals(text)) { item.setActionCommand(ConsEnv.CARD_TXT + '/' + cardFile.getPath()); mu_TxtMenu.add(item); continue; } if (ConsEnv.CARD_PNG.equals(text)) { item.setActionCommand(ConsEnv.CARD_PNG + '/' + cardFile.getPath()); mu_PngMenu.add(item); continue; } if (ConsEnv.CARD_SVG.equals(text)) { item.setActionCommand(ConsEnv.CARD_SVG + '/' + cardFile.getPath()); mu_SvgMenu.add(item); continue; } } item.setActionCommand(ConsEnv.CARD_ALL + '/' + cardFile.getPath()); pm_CardMenu.add(item); } catch (Exception exp) { processing = false; Logs.exception(exp); Lang.showMesg(normPtn, null, exp.getLocalizedMessage()); return; } } } pm_CardMenu.show(bt_ExptCard, 0, bt_ExptCard.getPreferredSize().height); processing = false; }
From source file:com.magicpwd._util.Card.java
License:Open Source License
public java.io.File exportHtm(java.io.File src, java.io.File dst) throws Exception { Document doc = new SAXReader().read(src); Node node = doc.selectSingleNode("/magicpwd/card/template-res"); String text;//from w w w .j a v a2 s .c o m if (node != null) { text = node.getText(); if (Char.isValidate(text)) { java.io.File tmp = new java.io.File(text); File.copy(tmp, new java.io.File(dst, tmp.getName()), true); } } node = doc.selectSingleNode("/magicpwd/card/template-uri"); if (node == null) { return null; } text = node.getText(); if (!Char.isValidate(text)) { return null; } return text(text, dst, ".htm"); }
From source file:com.magicpwd._util.Card.java
License:Open Source License
public java.io.File exportTxt(java.io.File src, java.io.File dst) throws Exception { Document doc = new SAXReader().read(src); Node node = doc.selectSingleNode("/magicpwd/card/template-uri"); if (node == null) { return null; }/*from ww w.ja v a2 s .com*/ String text = node.getText(); if (!Char.isValidate(text)) { return null; } return text(text, dst, ".txt"); }
From source file:com.magicpwd._util.Card.java
License:Open Source License
public java.io.File exportSvg(java.io.File src, java.io.File dst) throws Exception { Document doc = new SAXReader().read(src); Node node = doc.selectSingleNode("/magicpwd/card/template-uri"); if (node == null) { return null; }/*from w w w. j av a 2 s . c om*/ String text = node.getText(); if (!Char.isValidate(text)) { return null; } return text(text, dst, ".svg"); }
From source file:com.magicpwd._util.Card.java
License:Open Source License
public java.io.File exportAll(java.io.File src, java.io.File dst) throws Exception { Document doc = new SAXReader().read(src); Node node = doc.selectSingleNode("/magicpwd/card/template-res"); String text;/*from w w w . j ava2 s. c o m*/ if (node != null) { text = node.getText(); if (Char.isValidate(text)) { java.io.File tmp = new java.io.File(text); File.copy(tmp, new java.io.File(dst, tmp.getName()), true); } } node = doc.selectSingleNode("/magicpwd/card/template-uri"); if (node == null) { return null; } text = node.getText(); if (!Char.isValidate(text)) { return null; } int si = text.lastIndexOf('/'); int di = text.lastIndexOf('.'); String ext = ""; if (di > si) { ext = text.substring(di); } return text(text, dst, ext); }
From source file:com.magicpwd._util.Card.java
License:Open Source License
private static void drawString(Node node, Graphics2D g2d) throws Exception { if (node == null) { return;/* w w w .j a v a 2s . c om*/ } String text = node.getText(); if (!Char.isValidate(text)) { return; } g2d.setFont(getFont(node)); g2d.setPaint(getPaint(node)); g2d.drawString(text, getInteger(node, "x", 0), getInteger(node, "y", 0)); }
From source file:com.magicpwd._util.Card.java
License:Open Source License
private static void drawImage(Node node, Graphics2D g2d) throws Exception { if (node == null) { return;/*from w w w . j a va2 s . co m*/ } String text = node.getText(); if (!Char.isValidate(text)) { return; } BufferedImage img = ImageIO.read(File.open4Read(text)); g2d.drawImage(img, getInteger(node, "x", 0), getInteger(node, "y", 0), getInteger(node, "width", img.getWidth()), getInteger(node, "height", img.getHeight()), null); }
From source file:com.magicpwd._util.Util.java
License:Open Source License
public static boolean checkUpdate(String sid, String ver) throws Exception { if (!Char.isValidate(sid, 8)) { throw new IOException("??"); }//from w w w. j av a2 s .c o m if (!Char.isValidate(ver)) { throw new IOException("??"); } // ? Document document = new SAXReader().read(new URL(ConsEnv.HOMEPAGE + "soft/soft0001.ashx?sid=" + sid)); Node node = document.selectSingleNode("/amonsoft/version"); if (node == null) { throw new Exception("???"); } // ? String tmp = node.getText(); if (!Char.isValidate(tmp)) { return false; } tmp = tmp.toUpperCase().replaceAll("\\s+", ""); if (tmp.charAt(0) == 'V') { tmp = tmp.substring(1); } String[] newVer = tmp.split("\\."); // ?? ver = ver.toUpperCase().replaceAll("\\s+", ""); if (ver.charAt(0) == 'V') { ver = ver.substring(1); } String[] oldVer = ver.split("\\."); if (newVer == null || newVer.length != 4 || newVer.length != oldVer.length) { return false; } for (int i = 0; i < newVer.length; i += 1) { if (oldVer[i].length() < newVer[i].length()) { return true; } int x = oldVer[i].compareTo(newVer[i]); if (x > 0) { return false; } if (x < 0) { return true; } } return false; }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.message.MMXPubSubItem.java
License:Apache License
private void parsePayload(Element payloadElement) { if (payloadElement != null) { Document d = payloadElement.getDocument(); Node mmxPayloadNode = d.selectSingleNode( String.format("/*[name()='%s']/*[name()='%s']", Constants.MMX_ELEMENT, Constants.MMX_PAYLOAD)); if (mmxPayloadNode != null) { String mtype = mmxPayloadNode.valueOf("@mtype"); String stamp = DateFormatUtils.format(new DateTime(mmxPayloadNode.valueOf("@stamp")).toDate(), "yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC")); String data = mmxPayloadNode.getText(); payload = new MMXPubSubPayload(mtype, stamp, data); }// w w w . j a v a2s .c o m Node mmxMetaNode = d.selectSingleNode( String.format("/*[name()='%s']/*[name()='%s']", Constants.MMX_ELEMENT, Constants.MMX_META)); if (mmxMetaNode != null) { meta = getMapFromJsonString(mmxMetaNode.getText()); } } }