List of usage examples for org.dom4j Node selectSingleNode
Node selectSingleNode(String xpathExpression);
selectSingleNode
evaluates an XPath expression and returns the result as a single Node
instance.
From source file:it.eng.spagobi.studio.chart.editors.model.chart.ChartModel.java
License:Mozilla Public License
/** * /*from w w w. ja va 2 s . c om*/ * @param chartSubType * @param configDocument * @param templateDocument * @throws Exception * * returns if sub type let series personalization, it is if config contains series personalization tag */ public boolean isSeriesPersonalization(String chartSubType) throws Exception { // check the type and search for the root String upperCaseNameSl = getType().toUpperCase(); String upperCaseNamePl = upperCaseNameSl + "S"; seriesColorPersonalization = false; seriesDrawPersonalization = false; seriesLabelPersonalization = false; seriesScalesPersonalization = false; seriesOrderColorPersonalization = false; // Get the node configuration Node specificConfig = configDocument.selectSingleNode( "//" + upperCaseNamePl + "/" + upperCaseNameSl + "[@name='" + chartSubType.trim() + "']"); Node seriesLabelsNode = specificConfig .selectSingleNode("//" + upperCaseNameSl + "[@name='" + chartSubType + "']/SERIES_LABELS"); if (seriesLabelsNode != null) { seriesLabelPersonalization = true; } Node seriesColorsNode = specificConfig .selectSingleNode("//" + upperCaseNameSl + "[@name='" + chartSubType + "']/SERIES_COLORS"); if (seriesColorsNode != null) { seriesColorPersonalization = true; } Node seriesDrawNode = specificConfig .selectSingleNode("//" + upperCaseNameSl + "[@name='" + chartSubType + "']/SERIES_DRAW"); if (seriesDrawNode != null) { seriesDrawPersonalization = true; } Node seriesScalesNode = specificConfig .selectSingleNode("//" + upperCaseNameSl + "[@name='" + chartSubType + "']/SERIES_SCALES"); if (seriesScalesNode != null) { seriesScalesPersonalization = true; } Node seriesOrderColorsNode = specificConfig .selectSingleNode("//" + upperCaseNameSl + "[@name='" + chartSubType + "']/SERIES_ORDER_COLORS"); if (seriesOrderColorsNode != null) { seriesOrderColorPersonalization = true; } if (seriesLabelPersonalization == true || seriesColorPersonalization == true || seriesDrawPersonalization == true || seriesScalesPersonalization == true) { logger.debug("Let series personalisation"); return true; } else { logger.debug("Does not let series personalization"); return false; } }
From source file:it.pdfsam.console.MainConsole.java
License:Open Source License
/** * Reads the input xml file and return a Collection of files * @param xml_file XML input file //from ww w. j a v a 2s . c om * @return Collection of files absolute path */ private Collection parseXmlFile(File xml_file) { List file_list = new ArrayList(); try { SAXReader reader = new SAXReader(); org.dom4j.Document document = reader.read(xml_file); List pdf_file_list = document.selectNodes("/filelist/file"); for (int i = 0; pdf_file_list != null && i < pdf_file_list.size(); i++) { Node pdf_node = (Node) pdf_file_list.get(i); file_list.add(pdf_node.selectSingleNode("@value").getText().trim()); } return file_list; } catch (Exception e) { return null; } }
From source file:it.pdfsam.GUI.MainGUI.java
License:Open Source License
public MainGUI() { runSplash();//ww w. j a v a 2s . co m config = Configuration.getInstance(); config.getMainConsole().addWorkDoneListener(this); theme_sel = new ThemeSelector(); try { File app_path = new File(URLDecoder .decode(getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8")); application_path = app_path.getParent(); setSplashStep("Loading configuration.."); config.setXmlConfigObject(new XMLConfig(application_path)); look_and_feel = theme_sel .getLAF(config.getXmlConfigObject().getXMLConfigValue("/pdfsam/settings/lookAndfeel/LAF")); if (ThemeSelector .isPlastic(config.getXmlConfigObject().getXMLConfigValue("/pdfsam/settings/lookAndfeel/LAF"))) { theme_sel.setTheme( config.getXmlConfigObject().getXMLConfigValue("/pdfsam/settings/lookAndfeel/theme")); } UIManager.setLookAndFeel(look_and_feel); String tmp_log_level = config.getXmlConfigObject().getXMLConfigValue("/pdfsam/settings/loglevel"); if (tmp_log_level != null && !tmp_log_level.equals("")) { config.setLogLevel(Integer.parseInt(tmp_log_level)); } else { config.setLogLevel(LogPanel.LOG_INFO); } setSplashStep("Loading i18n.."); Vector langs = new Vector(10, 5); Document document = XMLParser .parseXmlFile(this.getClass().getResource("/it/pdfsam/i18n/languages.xml")); List nodeList = document.selectNodes("/languages/language"); for (int i = 0; nodeList != null && i < nodeList.size(); i++) { Node langNode = ((Node) nodeList.get(i)); if (langNode != null) { langs.add(new ListItem(langNode.selectSingleNode("@value").getText(), langNode.selectSingleNode("@description").getText())); } } config.setLanguageList(langs); } catch (Exception e) { System.out.print(e.getMessage()); e.printStackTrace(); } ToolTipManager.sharedInstance().setDismissDelay(300000); initialize(); }
From source file:it.pdfsam.plugin.coverfooter.GUI.CoverFooterMainGUI.java
License:Open Source License
private void addTableRowsFromNode(Node file_node) { if (file_node != null) { boolean encrypt = false; String num_pages = ""; String page_selection = ""; File file_to_add = null;/*from w w w.j av a 2 s . com*/ try { Node file_name = (Node) file_node.selectSingleNode("@name"); if (file_name != null) { file_to_add = new File(file_name.getText()); } } catch (Exception ex) { file_to_add = null; fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } try { if (file_to_add != null) { PdfReader pdf_reader = new PdfReader(new RandomAccessFileOrArray(file_to_add.getAbsolutePath()), null); encrypt = pdf_reader.isEncrypted(); // we retrieve the total number of pages num_pages = Integer.toString(pdf_reader.getNumberOfPages()); pdf_reader.close(); } } catch (Exception ex) { num_pages = ex.getMessage(); } try { Node file_pages = (Node) file_node.selectSingleNode("@pageselection"); if (file_pages != null) { page_selection = file_pages.getText(); } else { page_selection = CoverFooterMainGUI.ALL_STRING; } } catch (Exception ex) { page_selection = CoverFooterMainGUI.ALL_STRING; } try { modello_cover_table.addRow(new CoverFooterItemType(file_to_add.getName(), file_to_add.getAbsolutePath(), num_pages, page_selection, encrypt)); fireLogPropertyChanged( GettextResource.gettext(i18n_messages, "File selected: ") + file_to_add.getName(), LogPanel.LOG_INFO); } catch (Exception ex) { fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } } }
From source file:it.pdfsam.plugin.coverfooter.GUI.CoverFooterMainGUI.java
License:Open Source License
public void loadJobNode(Node arg) throws LoadJobException { final Node arg0 = arg; final Thread loadnode_thread = new Thread(add_or_run_threads, "load") { private String wip_text; public void run() { try { Node cover_node = (Node) arg0.selectSingleNode("cover/@value"); if (cover_node != null) { cover_text_field.setText(cover_node.getText()); }/* ww w . ja v a 2 s .c o m*/ Node footer_node = (Node) arg0.selectSingleNode("footer/@value"); if (footer_node != null) { footer_text_field.setText(footer_node.getText()); } Node file_destination = (Node) arg0.selectSingleNode("destination/@value"); if (file_destination != null) { destination_text_field.setText(file_destination.getText()); } Node file_overwrite = (Node) arg0.selectSingleNode("overwrite/@value"); if (file_overwrite != null) { overwrite_checkbox.setSelected(file_overwrite.getText().equals("true")); } Node file_compressed = (Node) arg0.selectSingleNode("compressed/@value"); if (file_compressed != null) { output_compressed_check.setSelected(file_compressed.getText().equals("true")); } modello_cover_table.clearData(); List file_list = arg0.selectNodes("filelist/file"); wip_text = GettextResource.gettext(i18n_messages, "Please wait while reading ") + " ..."; addWipText(wip_text); for (int i = 0; file_list != null && i < file_list.size(); i++) { Node file_node = (Node) file_list.get(i); addTableRowsFromNode(file_node); } removeWipText(wip_text); fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "CoverAndFooter section loaded."), LogPanel.LOG_INFO); } catch (Exception ex) { fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } } }; loadnode_thread.start(); }
From source file:it.pdfsam.plugin.encrypt.GUI.EncryptMainGUI.java
License:Open Source License
public void loadJobNode(Node arg0) throws LoadJobException { try {//from w ww . j a v a 2 s . c om Node file_source = (Node) arg0.selectSingleNode("source/@value"); if (file_source != null) { source_text_field.setText(file_source.getText()); } Node allow_all = (Node) arg0.selectSingleNode("allowall/@value"); if (allow_all != null && allow_all.getText().equals("true")) { allowall_check.doClick(); } else { Node permissions = (Node) arg0.selectSingleNode("permissions"); if (permissions != null) { List listEnab = permissions.selectNodes("enabled"); for (int j = 0; listEnab != null && j < listEnab.size(); j++) { Node enabledNode = (Node) listEnab.get(j); if (enabledNode != null) { permissions_check[Integer.parseInt(enabledNode.selectSingleNode("@value").getText())] .doClick(); } } } } Node enc_type = (Node) arg0.selectSingleNode("enctype/@value"); if (enc_type != null) { encrypt_type.setSelectedItem((String) enc_type.getText()); } Node user_pwd = (Node) arg0.selectSingleNode("usrpwd/@value"); if (user_pwd != null) { user_pwd_field.setText(user_pwd.getText()); } Node owner_pwd = (Node) arg0.selectSingleNode("ownerpwd/@value"); if (owner_pwd != null) { owner_pwd_field.setText(owner_pwd.getText()); } Node file_destination = (Node) arg0.selectSingleNode("destination/@value"); if (file_destination != null) { dest_folder_text.setText(file_destination.getText()); choose_a_folder_radio.doClick(); } else { same_as_source_radio.doClick(); } Node file_overwrite = (Node) arg0.selectSingleNode("overwrite/@value"); if (file_overwrite != null) { overwrite_checkbox.setSelected(file_overwrite.getText().equals("true")); } Node file_compressed = (Node) arg0.selectSingleNode("compressed/@value"); if (file_compressed != null) { output_compressed_check.setSelected(file_compressed.getText().equals("true")); } Node file_prefix = (Node) arg0.selectSingleNode("prefix/@value"); if (file_prefix != null) { out_prefix_text.setText(file_prefix.getText()); } fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Encrypt section loaded."), LogPanel.LOG_INFO); } catch (Exception ex) { fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } }
From source file:it.pdfsam.plugin.merge.GUI.MergeMainGUI.java
License:Open Source License
private void addTableRowsFromNode(Node file_node) { if (file_node != null) { boolean encrypt = false; String num_pages = ""; String page_selection = ""; File file_to_add = null;/*ww w . ja v a2s . c o m*/ try { Node file_name = (Node) file_node.selectSingleNode("@name"); if (file_name != null) { file_to_add = new File(file_name.getText()); } } catch (Exception ex) { file_to_add = null; fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } try { if (file_to_add != null) { PdfReader pdf_reader = new PdfReader(new RandomAccessFileOrArray(file_to_add.getAbsolutePath()), null); encrypt = pdf_reader.isEncrypted(); // we retrieve the total number of pages num_pages = Integer.toString(pdf_reader.getNumberOfPages()); pdf_reader.close(); } } catch (Exception ex) { num_pages = ex.getMessage(); } try { Node file_pages = (Node) file_node.selectSingleNode("@pageselection"); if (file_pages != null) { page_selection = file_pages.getText(); } else { page_selection = MergeMainGUI.ALL_STRING; } } catch (Exception ex) { page_selection = MergeMainGUI.ALL_STRING; } try { modello_merge_table.addRow(new MergeItemType(file_to_add.getName(), file_to_add.getAbsolutePath(), num_pages, page_selection, encrypt)); fireLogPropertyChanged( GettextResource.gettext(i18n_messages, "File selected: ") + file_to_add.getName(), LogPanel.LOG_INFO); } catch (Exception ex) { fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } } }
From source file:it.pdfsam.plugin.merge.GUI.MergeMainGUI.java
License:Open Source License
public void loadJobNode(Node arg) throws LoadJobException { final Node arg0 = arg; final Thread loadnode_thread = new Thread(add_or_run_threads, "load") { private String wip_text; public void run() { try { Node file_destination = (Node) arg0.selectSingleNode("destination/@value"); if (file_destination != null) { destination_text_field.setText(file_destination.getText()); }//from ww w. jav a 2 s . c o m Node file_overwrite = (Node) arg0.selectSingleNode("overwrite/@value"); if (file_overwrite != null) { overwrite_checkbox.setSelected(file_overwrite.getText().equals("true")); } Node merge_type = (Node) arg0.selectSingleNode("merge_type/@value"); if (merge_type != null) { merge_type_check.setSelected(merge_type.getText().equals("true")); } modello_merge_table.clearData(); List file_list = arg0.selectNodes("filelist/file"); wip_text = GettextResource.gettext(i18n_messages, "Please wait while reading ") + " ..."; addWipText(wip_text); for (int i = 0; file_list != null && i < file_list.size(); i++) { Node file_node = (Node) file_list.get(i); addTableRowsFromNode(file_node); } Node file_compressed = (Node) arg0.selectSingleNode("compressed/@value"); if (file_compressed != null) { output_compressed_check.setSelected(file_compressed.getText().equals("true")); } removeWipText(wip_text); fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Merge section loaded."), LogPanel.LOG_INFO); } catch (Exception ex) { fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } } }; loadnode_thread.start(); }
From source file:it.pdfsam.plugin.mix.GUI.MixMainGUI.java
License:Open Source License
public void loadJobNode(Node arg) throws LoadJobException { final Node arg0 = arg; try {//from w ww . j a v a 2s . co m Node first_node = (Node) arg0.selectSingleNode("first/@value"); if (first_node != null) { first_text_field.setText(first_node.getText()); } Node second_node = (Node) arg0.selectSingleNode("second/@value"); if (second_node != null) { second_text_field.setText(second_node.getText()); } Node file_destination = (Node) arg0.selectSingleNode("destination/@value"); if (file_destination != null) { destination_text_field.setText(file_destination.getText()); } Node file_overwrite = (Node) arg0.selectSingleNode("overwrite/@value"); if (file_overwrite != null) { overwrite_checkbox.setSelected(file_overwrite.getText().equals("true")); } Node reverse_first = (Node) arg0.selectSingleNode("reverse_first/@value"); if (reverse_first != null) { reverse_first_checkbox.setSelected(reverse_first.getText().equals("true")); } Node reverse_second = (Node) arg0.selectSingleNode("reverse_second/@value"); if (reverse_second != null) { reverse_second_checkbox.setSelected(reverse_second.getText().equals("true")); } Node file_compressed = (Node) arg0.selectSingleNode("compressed/@value"); if (file_compressed != null) { output_compressed_check.setSelected(file_compressed.getText().equals("true")); } fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "AlternateMix section loaded."), LogPanel.LOG_INFO); } catch (Exception ex) { fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } }
From source file:it.pdfsam.plugin.split.GUI.SplitMainGUI.java
License:Open Source License
public void loadJobNode(Node arg0) throws LoadJobException { try {/* w w w . jav a2 s .c om*/ Node file_source = (Node) arg0.selectSingleNode("source/@value"); if (file_source != null) { source_text_field.setText(file_source.getText()); } Node split_option = (Node) arg0.selectSingleNode("split_option/@value"); if (split_option != null) { if (split_option.getText().equals(burst_radio.getSplitCommand())) burst_radio.doClick(); else if (split_option.getText().equals(every_n_radio.getSplitCommand())) every_n_radio.doClick(); else if (split_option.getText().equals(even_radio.getSplitCommand())) even_radio.doClick(); else if (split_option.getText().equals(odd_radio.getSplitCommand())) odd_radio.doClick(); else if (split_option.getText().equals(this_page_radio.getSplitCommand())) this_page_radio.doClick(); } Node split_npages = (Node) arg0.selectSingleNode("npages/@value"); if (split_npages != null) { n_pages_text_field.setText(split_npages.getText()); } Node split_thispage = (Node) arg0.selectSingleNode("thispage/@value"); if (split_thispage != null) { this_page_text_field.setText(split_thispage.getText()); } Node file_destination = (Node) arg0.selectSingleNode("destination/@value"); if (file_destination != null) { dest_folder_text.setText(file_destination.getText()); choose_a_folder_radio.doClick(); } else { same_as_source_radio.doClick(); } Node file_overwrite = (Node) arg0.selectSingleNode("overwrite/@value"); if (file_overwrite != null) { overwrite_checkbox.setSelected(file_overwrite.getText().equals("true")); } Node file_compressed = (Node) arg0.selectSingleNode("compressed/@value"); if (file_compressed != null) { output_compressed_check.setSelected(file_compressed.getText().equals("true")); } Node file_prefix = (Node) arg0.selectSingleNode("prefix/@value"); if (file_prefix != null) { out_prefix_text.setText(file_prefix.getText()); } fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Split section loaded."), LogPanel.LOG_INFO); } catch (Exception ex) { fireLogPropertyChanged(GettextResource.gettext(i18n_messages, "Error: ") + ex.getMessage(), LogPanel.LOG_ERROR); } }