public XMLTree(Document document) { super(); init(document.getRootElement()); revalidate(); }
setRowHeight(0); getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION); setShowsRootHandles(true); setEditable(false); setModel(new DefaultTreeModel(createTreeNode(content))); setCellRenderer(new DefaultTreeCellRenderer() { setAllNodesExpanded(); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) {
/** * Show the detailed enactor progress report as a tree */ public void showProgressReport() { String progressReport = ""; try { progressReport = workflowInstance.getProgressReportXMLString(); // JEditTextArea display = new JEditTextArea(new // TextAreaDefaults()); // display.setText(progressReport); // display.setTokenMarker(new XMLTokenMarker()); // display.setEditable(false); // display.setPreferredSize(new Dimension(0,0)); // tabs.add("Process report", display); tabs.add("Progress report", new JScrollPane(new XMLTree( progressReport, false))); } catch (Exception ex) { // } }
protected void paintComponent(Graphics g) { final int width = getWidth(); final int height = getHeight(); Graphics2D g2d = (Graphics2D) g; Paint oldPaint = g2d.getPaint(); g2d.setPaint(new GradientPaint(0, 0, col, width, 0, col2)); g2d.fillRect(0, 0, width, height); g2d.setPaint(oldPaint); super.paintComponent(g); } }
private XMLNode createTreeNode(Content content) { XMLNode node = new XMLNode(content); if (content instanceof Parent) { Parent parent = (Parent) content; Iterator children = parent.getContent().iterator(); while (children.hasNext()) { Object child = children.next(); if (child instanceof Element) { node.add(createTreeNode((Content) child)); } else if (textSizeLimit != 0 && child instanceof Text) { Text text = (Text) child; if (!text.getTextNormalize().equals("")) { node.add(createTreeNode(text)); } } } } return node; } }
public void setWorkflowInputs(Map<String, DataThing> inputs) throws InputsNotMatchingException { if (panel == null) { // Initialize getPanel(); } populateInputs(inputs); scrollPane.setViewportView(new XMLTree(DataThingXMLFactory .getDataDocument(inputs))); }
public JComponent getComponent(RendererRegistry renderers, DataThing dataThing) throws RendererException { DataThing copy = new DataThing(dataThing); copy.getMetadata().setMIMETypes( Arrays.asList(strip(dataThing.getMetadata().getMIMETypes()))); try { return new XMLTree((String) dataThing.getDataObject()); } catch (Exception ex) { throw new RendererException(ex); } } }
public XMLTree(String text, boolean limit) throws IOException, JDOMException { if (!limit) { textSizeLimit = -1; } Document document = new SAXBuilder(false).build(new StringReader(text)); init(document.getRootElement()); revalidate(); }
private void expandAll(JTree tree, TreePath parent, boolean expand) { synchronized (this.getModel()) { // Traverse children // Ignores nodes who's userObject is a Processor type to // avoid overloading the UI with nodes at startup. TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements();) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } // Expansion or collapse must be done bottom-up if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } }
/** * Build a new XMLTree from the supplied String containing XML. * * @param text * @throws IOException * @throws JDOMException */ public XMLTree(String text) throws IOException, JDOMException { super(); Document document = new SAXBuilder(false).build(new StringReader(text)); init(document.getRootElement()); revalidate(); }