List of usage examples for javax.swing.tree DefaultTreeCellRenderer DefaultTreeCellRenderer
public DefaultTreeCellRenderer()
From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java
private void setupTree() { XulTreeNode topNode = new XulTreeNode("placeholder", null); //$NON-NLS-1$ for (XulComponent c : getRootChildren().getChildNodes()) { XulTreeItem item = (XulTreeItem) c; XulTreeNode node = createNode(item); if (node != null) { topNode.add(node);/*from w w w.ja v a 2 s. com*/ } } treeModel = new XulTreeModel(topNode); tree.setModel(treeModel); tree.setRootVisible(false); DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); renderer.setLeafIcon(null); renderer.setClosedIcon(null); renderer.setOpenIcon(null); tree.setCellRenderer(renderer); tree.setShowsRootHandles(true); this.setExpanded(this.getExpanded()); }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
public FileExporterSettingsPanel(JDialog jDialog) { timeSettings.setFormatForDisplayTime( PickerUtilities.createFormatterFromPatternString("HH:mm:ss", timeSettings.getLocale())); timeSettings.setFormatForMenuTimes(//from w w w .ja v a 2 s.c o m PickerUtilities.createFormatterFromPatternString("HH:mm", timeSettings.getLocale())); initComponents(); rootNode = new DefaultMutableTreeNode(new Item(ROOTNODE, ROOTNODE, ItemType.RULE_SET)); trRuleList.setModel(new DefaultTreeModel(rootNode)); this.jDialog = jDialog; attributeListModel = (DefaultListModel<String>) lsAttributeList.getModel(); rootDirectoryChooser .setCurrentDirectory(rootDirectoryChooser.getFileSystemView().getParentDirectory(new File("C:\\"))); //NON-NLS rootDirectoryChooser.setAcceptAllFileFilterUsed(false); rootDirectoryChooser.setDialogTitle(NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ChooseRootDirectory")); rootDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); reportDirectoryChooser.setCurrentDirectory( reportDirectoryChooser.getFileSystemView().getParentDirectory(new File("C:\\"))); //NON-NLS reportDirectoryChooser.setAcceptAllFileFilterUsed(false); reportDirectoryChooser.setDialogTitle(NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ChooseReportDirectory")); reportDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Add text prompt to the text box fields TextPrompt textPromptRuleName = new TextPrompt( NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.RuleName"), tbRuleName); textPromptRuleName.setForeground(Color.LIGHT_GRAY); textPromptRuleName.changeAlpha(0.9f); TextPrompt textPromptRootDirectory = new TextPrompt( NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.RootDirectory"), tbRootDirectory); textPromptRootDirectory.setForeground(Color.LIGHT_GRAY); textPromptRootDirectory.changeAlpha(0.9f); TextPrompt textPromptReportDirectory = new TextPrompt( NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ReportDirectory"), tbReportDirectory); textPromptReportDirectory.setForeground(Color.LIGHT_GRAY); textPromptReportDirectory.changeAlpha(0.9f); TextPrompt textPromptReportAttributeValue = new TextPrompt( NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.AttributeValue"), tbAttributeValue); textPromptReportAttributeValue.setForeground(Color.LIGHT_GRAY); textPromptReportAttributeValue.changeAlpha(0.9f); for (SizeUnit item : SizeUnit.values()) { comboBoxFileSizeUnits.addItem(item.toString()); } for (RelationalOp item : RelationalOp.values()) { comboBoxFileSizeComparison.addItem(item.getSymbol()); comboBoxAttributeComparison.addItem(item.getSymbol()); } comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER.getLabel()); comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.LONG.getLabel()); comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE.getLabel()); comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING.getLabel()); comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME.getLabel()); comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.BYTE.getLabel()); comboBoxValueType.addItem(UNSET); load(); trRuleList.setCellRenderer(new DefaultTreeCellRenderer() { private static final long serialVersionUID = 1L; private final ImageIcon ruleSetIcon = new ImageIcon( ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/ruleset-icon.png", false)); private final ImageIcon ruleIcon = new ImageIcon(ImageUtilities .loadImage("org/sleuthkit/autopsy/experimental/images/extracted_content.png", false)); private final ImageIcon sizeIcon = new ImageIcon( ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/file-size-16.png", false)); private final ImageIcon artifactIcon = new ImageIcon( ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/artifact-icon.png", false)); private final ImageIcon mimetypeIcon = new ImageIcon( ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/mime-icon.png", false)); private final ImageIcon otherIcon = new ImageIcon( ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/knownbad-icon.png", false)); @Override public Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value, boolean selected, boolean expanded, boolean isLeaf, int row, boolean focused) { Component component = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused); Icon icon; switch (((Item) ((DefaultMutableTreeNode) value).getUserObject()).getItemType()) { case ARTIFACT_CLAUSE: icon = artifactIcon; break; case MIME_TYPE_CLAUSE: icon = mimetypeIcon; break; case RULE: icon = ruleIcon; break; case SIZE_CLAUSE: icon = sizeIcon; break; case RULE_SET: icon = ruleSetIcon; break; default: icon = otherIcon; break; } setIcon(icon); return component; } }); populateMimeTypes(); populateArtifacts(); populateAttributes(); populateRuleTree(); tbRuleName.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { setSaveButton(); } @Override public void removeUpdate(DocumentEvent e) { setSaveButton(); } @Override public void insertUpdate(DocumentEvent e) { setSaveButton(); } }); comboBoxMimeValue.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() { @Override public void focusGained(FocusEvent e) { comboBoxMimeValue.showPopup(); comboBoxMimeValue.getEditor().selectAll(); } @Override public void focusLost(FocusEvent e) { // do nothing } }); comboBoxArtifactName.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() { @Override public void focusGained(FocusEvent e) { comboBoxArtifactName.showPopup(); comboBoxArtifactName.getEditor().selectAll(); } @Override public void focusLost(FocusEvent e) { // do nothing } }); comboBoxAttributeName.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() { @Override public void focusGained(FocusEvent e) { comboBoxAttributeName.showPopup(); comboBoxAttributeName.getEditor().selectAll(); } @Override public void focusLost(FocusEvent e) { // do nothing } }); comboBoxMimeTypeComparison.addItem(RelationalOp.Equals.getSymbol()); comboBoxMimeTypeComparison.addItem(RelationalOp.NotEquals.getSymbol()); treeSelectionModel = trRuleList.getSelectionModel(); defaultTreeModel = (DefaultTreeModel) trRuleList.getModel(); bnDeleteRule.setEnabled(false); String selectedAttribute = comboBoxAttributeName.getSelectedItem().toString(); comboBoxValueType.setSelectedItem(selectedAttribute); localRule = makeRuleFromUserInput(); listSelectionListener = this::lsAttributeListValueChanged; lsAttributeList.addListSelectionListener(listSelectionListener); treeSelectionListener = this::trRuleListValueChanged; trRuleList.addTreeSelectionListener(treeSelectionListener); setDeleteAttributeButton(); setSaveButton(); }