List of usage examples for java.util.prefs Preferences userNodeForPackage
public static Preferences userNodeForPackage(Class<?> c)
From source file:com.vaadin.integration.maven.wscdn.CvalChecker.java
private CvalInfo getCachedLicenseInfo(String productName) { Preferences p = Preferences.userNodeForPackage(CvalInfo.class); String json = p.get(productName, ""); if (!json.isEmpty()) { try {/*from w ww .j a v a2 s .c om*/ CvalInfo info = parseJson(json); if (info != null) { return info; } } catch (RuntimeException e) { try { p.clear(); } catch (BackingStoreException ex) { Logger.getLogger(CvalChecker.class.getName()).log(Level.SEVERE, null, ex); } throw e; } } return null; }
From source file:com.mirth.connect.client.ui.editors.RuleBuilderPanel.java
public void setValues(ArrayList<String> values) { Object[][] tableData = new Object[values.size()][1]; valuesTable = new MirthTable(); for (int i = 0; i < values.size(); i++) { tableData[i][VALUE_COLUMN] = values.get(i); }/* w w w . j av a2 s . c om*/ valuesTable .setModel(new javax.swing.table.DefaultTableModel(tableData, new String[] { VALUE_COLUMN_NAME }) { boolean[] canEdit = new boolean[] { true }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); valuesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (getSelectedRow() != -1) { lastIndex = getSelectedRow(); deleteButton.setEnabled(true); } else { deleteButton.setEnabled(false); } rulePlugin.updateName(); } }); class RegExTableCellEditor extends TextFieldCellEditor { public boolean stopCellEditing() { parent.modified = true; deleteButton.setEnabled(true); boolean result = super.stopCellEditing(); /* * HACK: Cannot move this logic into valueChanged. We need to * update the name after stopping cell editing, because the * swingx update caused the ListSelectionListener to stop being * called when there was only one row and it was edited. */ rulePlugin.updateName(); return result; } @Override public boolean isCellEditable(EventObject evt) { boolean editable = super.isCellEditable(evt); if (editable) { deleteButton.setEnabled(false); } return editable; } @Override protected boolean valueChanged(String value) { return true; } } // Set the custom cell editor for the Destination Name column. valuesTable.getColumnModel().getColumn(valuesTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME)) .setCellEditor(new RegExTableCellEditor()); valuesTable.setCustomEditorControls(true); valuesTable.setSelectionMode(0); valuesTable.setRowSelectionAllowed(true); valuesTable.setRowHeight(UIConstants.ROW_HEIGHT); valuesTable.setDragEnabled(false); valuesTable.setOpaque(true); valuesTable.setSortable(false); valuesTable.getTableHeader().setReorderingAllowed(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); valuesTable.setHighlighters(highlighter); } valuesScrollPane.setViewportView(valuesTable); }
From source file:com.nbt.TileCanvas.java
public Preferences getPreferences() { String name = world.getName(); return Preferences.userNodeForPackage(getClass()).node(name); }
From source file:com.mirth.connect.client.ui.LibraryResourcesPanel.java
private void initComponents(Channel channel) { setBackground(UIConstants.BACKGROUND_COLOR); AbstractMutableTreeTableNode channelNode = new DefaultMutableTreeTableNode( new ConnectorEntry("Channel", -1, null)); AbstractMutableTreeTableNode channelScriptsNode = new DefaultMutableTreeTableNode( new ConnectorEntry("Channel Scripts", null, null)); channelScriptsNode/*from www .j a v a2s .com*/ .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Deploy Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Undeploy Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Preprocessor Script", null, null, false))); channelScriptsNode.add( new DefaultMutableTreeTableNode(new ConnectorEntry("Postprocessor Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Attachment Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Batch Script", null, null, false))); channelNode.add(channelScriptsNode); AbstractMutableTreeTableNode sourceConnectorNode = new DefaultMutableTreeTableNode( new ConnectorEntry("Source Connector", 0, channel.getSourceConnector().getTransportName())); sourceConnectorNode.add(new DefaultMutableTreeTableNode( new ConnectorEntry("Receiver", channel.getSourceConnector().getMetaDataId(), channel.getSourceConnector().getTransportName(), false))); sourceConnectorNode.add(new DefaultMutableTreeTableNode( new ConnectorEntry("Filter / Transformer Script", channel.getSourceConnector().getMetaDataId(), channel.getSourceConnector().getTransportName(), false))); channelNode.add(sourceConnectorNode); for (Connector destinationConnector : channel.getDestinationConnectors()) { AbstractMutableTreeTableNode destinationConnectorNode = new DefaultMutableTreeTableNode( new ConnectorEntry(destinationConnector.getName(), destinationConnector.getMetaDataId(), destinationConnector.getTransportName())); destinationConnectorNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Filter / Transformer Script", destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false))); destinationConnectorNode.add(new DefaultMutableTreeTableNode(new ConnectorEntry("Dispatcher", destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false))); destinationConnectorNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Response Transformer Script", destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false))); channelNode.add(destinationConnectorNode); } treeTable = new MirthTreeTable(); DefaultTreeTableModel model = new SortableTreeTableModel(channelNode); model.setColumnIdentifiers(Arrays.asList(new String[] { "Library Context" })); treeTable.setTreeTableModel(model); treeTable.setRootVisible(true); treeTable.setDragEnabled(false); treeTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); treeTable.getTreeSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); treeTable.setRowHeight(UIConstants.ROW_HEIGHT); treeTable.setFocusable(true); treeTable.setOpaque(true); treeTable.getTableHeader().setReorderingAllowed(false); treeTable.setEditable(false); treeTable.setSortable(false); treeTable.addTreeSelectionListener(this); treeTable.getSelectionModel().addListSelectionListener(this); treeTable.putClientProperty("JTree.lineStyle", "Horizontal"); treeTable.setShowGrid(true, true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { treeTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } final String toolTipText = "<html>Select which context(s) to include library resources in.<br/>Libraries can be included everywhere (the Channel node),<br/>on channel-level scripts (the Channel Scripts node), and<br/>on specific source or destination connectors.</html>"; treeTable.setTreeCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); setToolTipText(toolTipText); setEnabled(((ConnectorEntry) ((AbstractMutableTreeTableNode) value).getUserObject()).enabled); return this; } }); treeTable.setOpenIcon(null); treeTable.setClosedIcon(null); treeTable.setLeafIcon(null); treeTable.getColumnExt(0).setToolTipText(toolTipText); treeTableScrollPane = new JScrollPane(treeTable); resourceTable = new MirthTable(); resourceTable.setModel(new RefreshTableModel(new Object[] { "", "Name", "Type" }, 0) { @Override public boolean isCellEditable(int row, int column) { return column == SELECTED_COLUMN; } }); resourceTable.setDragEnabled(false); resourceTable.setRowSelectionAllowed(false); resourceTable.setRowHeight(UIConstants.ROW_HEIGHT); resourceTable.setFocusable(false); resourceTable.setOpaque(true); resourceTable.getTableHeader().setReorderingAllowed(false); resourceTable.setEditable(true); resourceTable.setSortable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { resourceTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMinWidth(20); resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMaxWidth(20); resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellRenderer(new CheckBoxRenderer()); resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellEditor(new CheckBoxEditor()); resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(75); resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200); resourceTableScrollPane = new JScrollPane(resourceTable); }
From source file:com.mirth.connect.client.ui.LibraryResourcesDialog.java
private void initComponents(Channel channel) { setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill", "", "[][]8[]8[]")); setBackground(UIConstants.BACKGROUND_COLOR); getContentPane().setBackground(getBackground()); AbstractMutableTreeTableNode channelNode = new DefaultMutableTreeTableNode( new ConnectorEntry("Channel", -1, null)); AbstractMutableTreeTableNode channelScriptsNode = new DefaultMutableTreeTableNode( new ConnectorEntry("Channel Scripts", null, null)); channelScriptsNode/*ww w . ja v a 2 s . com*/ .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Deploy Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Undeploy Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Preprocessor Script", null, null, false))); channelScriptsNode.add( new DefaultMutableTreeTableNode(new ConnectorEntry("Postprocessor Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Attachment Script", null, null, false))); channelScriptsNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Batch Script", null, null, false))); channelNode.add(channelScriptsNode); AbstractMutableTreeTableNode sourceConnectorNode = new DefaultMutableTreeTableNode( new ConnectorEntry("Source Connector", 0, channel.getSourceConnector().getTransportName())); sourceConnectorNode.add(new DefaultMutableTreeTableNode( new ConnectorEntry("Receiver", channel.getSourceConnector().getMetaDataId(), channel.getSourceConnector().getTransportName(), false))); sourceConnectorNode.add(new DefaultMutableTreeTableNode( new ConnectorEntry("Filter / Transformer Script", channel.getSourceConnector().getMetaDataId(), channel.getSourceConnector().getTransportName(), false))); channelNode.add(sourceConnectorNode); for (Connector destinationConnector : channel.getDestinationConnectors()) { AbstractMutableTreeTableNode destinationConnectorNode = new DefaultMutableTreeTableNode( new ConnectorEntry(destinationConnector.getName(), destinationConnector.getMetaDataId(), destinationConnector.getTransportName())); destinationConnectorNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Filter / Transformer Script", destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false))); destinationConnectorNode.add(new DefaultMutableTreeTableNode(new ConnectorEntry("Dispatcher", destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false))); destinationConnectorNode .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Response Transformer Script", destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false))); channelNode.add(destinationConnectorNode); } treeTable = new MirthTreeTable(); DefaultTreeTableModel model = new SortableTreeTableModel(channelNode); model.setColumnIdentifiers(Arrays.asList(new String[] { "Library Context" })); treeTable.setTreeTableModel(model); treeTable.setRootVisible(true); treeTable.setDragEnabled(false); treeTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); treeTable.getTreeSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); treeTable.setRowHeight(UIConstants.ROW_HEIGHT); treeTable.setFocusable(true); treeTable.setOpaque(true); treeTable.getTableHeader().setReorderingAllowed(false); treeTable.setEditable(false); treeTable.setSortable(false); treeTable.addTreeSelectionListener(this); treeTable.getSelectionModel().addListSelectionListener(this); treeTable.putClientProperty("JTree.lineStyle", "Horizontal"); treeTable.setShowGrid(true, true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { treeTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } final String toolTipText = "<html>Select which context(s) to include library resources in.<br/>Libraries can be included everywhere (the Channel node),<br/>on channel-level scripts (the Channel Scripts node), and<br/>on specific source or destination connectors.</html>"; treeTable.setTreeCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); setToolTipText(toolTipText); setEnabled(((ConnectorEntry) ((AbstractMutableTreeTableNode) value).getUserObject()).enabled); return this; } }); treeTable.setOpenIcon(null); treeTable.setClosedIcon(null); treeTable.setLeafIcon(null); treeTable.getColumnExt(0).setToolTipText(toolTipText); add(new JScrollPane(treeTable), "grow, h 60%"); resourceTable = new MirthTable(); resourceTable.setModel(new RefreshTableModel(new Object[] { "", "Name", "Type" }, 0) { @Override public boolean isCellEditable(int row, int column) { return column == SELECTED_COLUMN; } }); resourceTable.setDragEnabled(false); resourceTable.setRowSelectionAllowed(false); resourceTable.setRowHeight(UIConstants.ROW_HEIGHT); resourceTable.setFocusable(false); resourceTable.setOpaque(true); resourceTable.getTableHeader().setReorderingAllowed(false); resourceTable.setEditable(true); resourceTable.setSortable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { resourceTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMinWidth(20); resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMaxWidth(20); resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellRenderer(new CheckBoxRenderer()); resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellEditor(new CheckBoxEditor()); resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(75); resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200); add(new JScrollPane(resourceTable), "newline, grow, h 40%"); add(new JSeparator(), "newline, grow"); JPanel buttonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3")); buttonPanel.setBackground(getBackground()); okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okButtonActionPerformed(); } }); buttonPanel.add(okButton, "w 48!"); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelButtonActionPerformed(); } }); buttonPanel.add(cancelButton, "w 48!"); add(buttonPanel, "newline, right"); }
From source file:com.mirth.connect.client.ui.dependencies.ChannelDependenciesPanel.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); dependencyLabel = new JLabel("This channel depends upon:"); dependencyTreeTable = new MirthTreeTable(); DefaultTreeTableModel dependencyModel = new SortableTreeTableModel(); DefaultMutableTreeTableNode dependencyRootNode = new DefaultMutableTreeTableNode(); dependencyModel.setRoot(dependencyRootNode); dependencyTreeTable.setTreeTableModel(dependencyModel); dependencyTreeTable.setRootVisible(false); dependencyTreeTable.setDoubleBuffered(true); dependencyTreeTable.setDragEnabled(false); dependencyTreeTable.setRowSelectionAllowed(true); dependencyTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dependencyTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); dependencyTreeTable.setFocusable(true); dependencyTreeTable.setOpaque(true); dependencyTreeTable.setEditable(false); dependencyTreeTable.setSortable(true); dependencyTreeTable.putClientProperty("JTree.lineStyle", "Horizontal"); dependencyTreeTable.setAutoCreateColumnsFromModel(false); dependencyTreeTable.setShowGrid(true, true); dependencyTreeTable.setTableHeader(null); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { dependencyTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); }/*from ww w .j a v a2s . co m*/ dependencyTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependencyTreeTable)); dependencyTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (dependencyTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { dependencyTreeTable.clearSelection(); } } }); dependencyTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { boolean removeEnabled = false; int[] rows = dependencyTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]); if (selectedPath != null) { if (selectedPath.getPathCount() == 2) { removeEnabled = true; } } } dependencyRemoveButton.setEnabled(removeEnabled); } } }); dependencyScrollPane = new JScrollPane(dependencyTreeTable); dependencyExpandAllLabel = new JLabel("<html><u>Expand All</u></html>"); dependencyExpandAllLabel.setForeground(Color.BLUE); dependencyExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependencyExpandAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependencyTreeTable.expandAll(); } }); dependencyCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>"); dependencyCollapseAllLabel.setForeground(Color.BLUE); dependencyCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependencyCollapseAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependencyTreeTable.collapseAll(); } }); dependencyAddButton = new JButton("Add"); dependencyAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Map<String, String> allowedChannelsMap = getAllowedChannels(true); if (MapUtils.isNotEmpty(allowedChannelsMap)) { AddDialog dialog = new AddDialog(allowedChannelsMap, true); if (dialog.wasSaved()) { for (String dependencyId : dialog.getSelectedChannelIds()) { dependencies.add(new ChannelDependency(channel.getId(), dependencyId)); } updateTreeTable(true, dependencies); updateAddButton(); } } } }); dependencyRemoveButton = new JButton("Remove"); dependencyRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int[] rows = dependencyTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]); if (selectedPath != null && selectedPath.getPathCount() == 2) { Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath .getLastPathComponent()).getUserObject(); for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) { ChannelDependency dependency = it.next(); if (StringUtils.equals(channel.getId(), dependency.getDependentId()) && StringUtils.equals(pair.getLeft(), dependency.getDependencyId())) { it.remove(); } } updateTreeTable(true, dependencies); updateAddButton(); } } } }); dependencyRemoveButton.setEnabled(false); dependentLabel = new JLabel("This channel is depended upon by:"); dependentTreeTable = new MirthTreeTable(); DefaultTreeTableModel dependentModel = new SortableTreeTableModel(); DefaultMutableTreeTableNode dependentRootNode = new DefaultMutableTreeTableNode(); dependentModel.setRoot(dependentRootNode); dependentTreeTable.setTreeTableModel(dependentModel); dependentTreeTable.setRootVisible(false); dependentTreeTable.setDoubleBuffered(true); dependentTreeTable.setDragEnabled(false); dependentTreeTable.setRowSelectionAllowed(true); dependentTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dependentTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); dependentTreeTable.setFocusable(true); dependentTreeTable.setOpaque(true); dependentTreeTable.setEditable(false); dependentTreeTable.setSortable(true); dependentTreeTable.putClientProperty("JTree.lineStyle", "Horizontal"); dependentTreeTable.setAutoCreateColumnsFromModel(false); dependentTreeTable.setShowGrid(true, true); dependentTreeTable.setTableHeader(null); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { dependentTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } dependentTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependentTreeTable)); dependentTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (dependentTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { dependentTreeTable.clearSelection(); } } }); dependentTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { boolean removeEnabled = false; int[] rows = dependentTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]); if (selectedPath != null) { if (selectedPath.getPathCount() == 2) { removeEnabled = true; } } } dependentRemoveButton.setEnabled(removeEnabled); } } }); dependentScrollPane = new JScrollPane(dependentTreeTable); dependentExpandAllLabel = new JLabel("<html><u>Expand All</u></html>"); dependentExpandAllLabel.setForeground(Color.BLUE); dependentExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependentExpandAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependentTreeTable.expandAll(); } }); dependentCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>"); dependentCollapseAllLabel.setForeground(Color.BLUE); dependentCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependentCollapseAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependentTreeTable.collapseAll(); } }); dependentAddButton = new JButton("Add"); dependentAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Map<String, String> allowedChannelsMap = getAllowedChannels(false); if (MapUtils.isNotEmpty(allowedChannelsMap)) { AddDialog dialog = new AddDialog(allowedChannelsMap, false); if (dialog.wasSaved()) { for (String dependentId : dialog.getSelectedChannelIds()) { dependencies.add(new ChannelDependency(dependentId, channel.getId())); } updateTreeTable(false, dependencies); updateAddButton(); } } } }); dependentRemoveButton = new JButton("Remove"); dependentRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int[] rows = dependentTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]); if (selectedPath != null && selectedPath.getPathCount() == 2) { Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath .getLastPathComponent()).getUserObject(); for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) { ChannelDependency dependency = it.next(); if (StringUtils.equals(pair.getLeft(), dependency.getDependentId()) && StringUtils.equals(channel.getId(), dependency.getDependencyId())) { it.remove(); } } updateTreeTable(false, dependencies); updateAddButton(); } } } }); dependentRemoveButton.setEnabled(false); }
From source file:verdandi.ui.ProjectViewerPanel.java
private void exportProjects() { Preferences prefs = Preferences.userNodeForPackage(getClass()); File exportDir = new File(prefs.get("export.dir", System.getProperty("user.home"))); JFileChooser chooser = new JFileChooser(exportDir); chooser.setDialogTitle(RB.getString("projectviewer.export.filechooser.title")); chooser.setMultiSelectionEnabled(false); if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) { LOG.debug("User cancelled"); return;// w w w . jav a 2s .c om } int[] selectedProjects = projectTable.getSelectedRows(); if (selectedProjects.length == 0) { LOG.debug("NO row selected"); return; } List<CostUnit> projectsToExport = new ArrayList<CostUnit>(); for (int i = 0; i < selectedProjects.length; i++) { // int selModel = projectTable.getFilters().convertRowIndexToModel( // selectedProjects[i]); int selModel = selectedProjects[i]; CostUnit p = tableModel.getProject(selModel); LOG.debug("Adding project to export list: " + p); projectsToExport.add(p); } File exportFile = chooser.getSelectedFile(); LOG.debug("Exporting projects to " + exportFile.getAbsolutePath()); ObjectOutputStream listOut = null; try { listOut = new ObjectOutputStream(new FileOutputStream(exportFile)); listOut.writeObject(projectsToExport); } catch (FileNotFoundException e) { LOG.error("", e); } catch (IOException e) { LOG.error("", e); } finally { if (listOut != null) { try { listOut.close(); } catch (Throwable t) { LOG.error("Cannot close stream: ", t); } } } prefs.put("export.dir", exportFile.getParent()); try { prefs.flush(); } catch (BackingStoreException e) { LOG.error("Cannot write export file preference", e); } }
From source file:nu.nethome.home.impl.HomeServer.java
/** * @param fileName the fileName to set//from ww w . j av a 2s. c o m */ public void setFileName(String fileName) { if (activated && !fileName.equals(this.fileName)) { // Kind of ugly. If the user changes the save file name, we also save this as a system property // so we can find the name (file) again when the server is started. Preferences prefs = Preferences.userNodeForPackage(HomeManager.class); prefs.put("SaveFileName", fileName); } this.fileName = fileName; }
From source file:hr.fer.zemris.vhdllab.view.explorer.ProjectExplorerView.java
public Integer getHierarchyMode() { if (hierarchyMode == null) { Preferences preferences = Preferences.userNodeForPackage(ProjectExplorerView.class); hierarchyMode = preferences.getInt(PREFERENCES_HIERARCHY_MODE, HIERARCHY_X_USES_Y); }/*from ww w . j a v a2s . com*/ if (hierarchyMode != HIERARCHY_X_USES_Y && hierarchyMode != HIERARCHY_X_USED_BY_Y && hierarchyMode != HIERARCHY_FLAT) { hierarchyMode = HIERARCHY_X_USES_Y; } return hierarchyMode; }
From source file:com.mirth.connect.connectors.file.AdvancedSftpSettingsDialog.java
private void initComponents() { authenticationLabel = new JLabel("Authentication:"); usePasswordRadio = new JRadioButton("Password"); usePasswordRadio.setFocusable(false); usePasswordRadio.setBackground(new Color(255, 255, 255)); usePasswordRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); usePasswordRadio.setToolTipText("Select this option to use a password to gain access to the server."); usePasswordRadio.addActionListener(new ActionListener() { @Override/*from www.ja va 2 s.c o m*/ public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); usePrivateKeyRadio = new JRadioButton("Public Key"); usePrivateKeyRadio.setSelected(true); usePrivateKeyRadio.setFocusable(false); usePrivateKeyRadio.setBackground(UIConstants.BACKGROUND_COLOR); usePrivateKeyRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); usePrivateKeyRadio .setToolTipText("Select this option to use a public/private keypair to gain access to the server."); usePrivateKeyRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); useBothRadio = new JRadioButton("Both"); useBothRadio.setSelected(true); useBothRadio.setFocusable(false); useBothRadio.setBackground(UIConstants.BACKGROUND_COLOR); useBothRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useBothRadio.setToolTipText( "Select this option to use both a password and a public/private keypair to gain access to the server."); useBothRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); privateKeyButtonGroup = new ButtonGroup(); privateKeyButtonGroup.add(usePasswordRadio); privateKeyButtonGroup.add(usePrivateKeyRadio); privateKeyButtonGroup.add(useBothRadio); keyLocationLabel = new JLabel("Public/Private Key File:"); keyLocationField = new JTextField(); keyLocationField.setToolTipText( "The absolute file path of the public/private keypair used to gain access to the remote server."); passphraseLabel = new JLabel("Passphrase:"); passphraseField = new JPasswordField(); passphraseField.setToolTipText("The passphrase associated with the public/private keypair."); useKnownHostsLabel = new JLabel("Host Key Checking:"); useKnownHostsYesRadio = new JRadioButton("Yes"); useKnownHostsYesRadio.setFocusable(false); useKnownHostsYesRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsYesRadio.setToolTipText( "<html>Select this option to validate the server's host key within the provided<br>Known Hosts file. Known Hosts file is required.</html>"); useKnownHostsAskRadio = new JRadioButton("Ask"); useKnownHostsAskRadio.setFocusable(false); useKnownHostsAskRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsAskRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsAskRadio.setToolTipText( "<html>Select this option to ask the user to add the server's host key to the provided<br>Known Hosts file. Known Hosts file is optional.</html>"); useKnownHostsNoRadio = new JRadioButton("No"); useKnownHostsNoRadio.setSelected(true); useKnownHostsNoRadio.setFocusable(false); useKnownHostsNoRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsNoRadio.setToolTipText( "<html>Select this option to always add the server's host key to the provided<br>Known Hosts file. Known Hosts file is optional.</html>"); knownHostsButtonGroup = new ButtonGroup(); knownHostsButtonGroup.add(useKnownHostsYesRadio); knownHostsButtonGroup.add(useKnownHostsAskRadio); knownHostsButtonGroup.add(useKnownHostsNoRadio); knownHostsLocationLabel = new JLabel("Known Hosts File:"); knownHostsField = new JTextField(); knownHostsField .setToolTipText("The path to the local Known Hosts file used to authenticate the remote server."); configurationsLabel = new JLabel("Configuration Options:"); configurationsTable = new MirthTable(); Object[][] tableData = new Object[0][1]; configurationsTable.setModel(new RefreshTableModel(tableData, new String[] { "Name", "Value" })); configurationsTable.setOpaque(true); configurationsTable.getColumnModel() .getColumn(configurationsTable.getColumnModel().getColumnIndex(NAME_COLUMN_NAME)) .setCellEditor(new ConfigTableCellEditor(true)); configurationsTable.getColumnModel() .getColumn(configurationsTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME)) .setCellEditor(new ConfigTableCellEditor(false)); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); configurationsTable.setHighlighters(highlighter); } configurationsScrollPane = new JScrollPane(); configurationsScrollPane.getViewport().add(configurationsTable); newButton = new JButton("New"); newButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel(); Vector<String> row = new Vector<String>(); String header = "Property"; for (int i = 1; i <= configurationsTable.getRowCount() + 1; i++) { boolean exists = false; for (int index = 0; index < configurationsTable.getRowCount(); index++) { if (((String) configurationsTable.getValueAt(index, 0)).equalsIgnoreCase(header + i)) { exists = true; } } if (!exists) { row.add(header + i); break; } } model.addRow(row); int rowSelectionNumber = configurationsTable.getRowCount() - 1; configurationsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); Boolean enabled = deleteButton.isEnabled(); if (!enabled) { deleteButton.setEnabled(true); } } }); deleteButton = new JButton("Delete"); deleteButton.setEnabled(false); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int rowSelectionNumber = configurationsTable.getSelectedRow(); if (rowSelectionNumber > -1) { DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel(); model.removeRow(rowSelectionNumber); rowSelectionNumber--; if (rowSelectionNumber > -1) { configurationsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); } if (configurationsTable.getRowCount() == 0) { deleteButton.setEnabled(false); } } } }); okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okCancelButtonActionPerformed(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); authenticationRadioButtonActionPerformed(); }