List of usage examples for java.util.prefs Preferences userNodeForPackage
public static Preferences userNodeForPackage(Class<?> c)
From source file:com.mirth.connect.connectors.ws.WebServiceSender.java
private void setAttachments(List<List<String>> attachments) { List<String> attachmentIds = attachments.get(0); List<String> attachmentContents = attachments.get(1); List<String> attachmentTypes = attachments.get(2); Object[][] tableData = new Object[attachmentIds.size()][3]; attachmentsTable = new MirthTable(); for (int i = 0; i < attachmentIds.size(); i++) { tableData[i][ID_COLUMN_NUMBER] = attachmentIds.get(i); tableData[i][CONTENT_COLUMN_NUMBER] = attachmentContents.get(i); tableData[i][MIME_TYPE_COLUMN_NUMBER] = attachmentTypes.get(i); }//from w w w . j ava 2s . c o m attachmentsTable.setModel(new javax.swing.table.DefaultTableModel(tableData, new String[] { ID_COLUMN_NAME, CONTENT_COLUMN_NAME, MIME_TYPE_COLUMN_NAME }) { boolean[] canEdit = new boolean[] { true, true, true }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); attachmentsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (attachmentsTable.getSelectedModelIndex() != -1) { deleteButton.setEnabled(true); } else { deleteButton.setEnabled(false); } } }); class AttachmentsTableCellEditor extends TextFieldCellEditor { boolean checkUnique; public AttachmentsTableCellEditor(boolean checkUnique) { super(); this.checkUnique = checkUnique; } public boolean checkUnique(String value) { boolean exists = false; for (int i = 0; i < attachmentsTable.getModel().getRowCount(); i++) { if (((String) attachmentsTable.getModel().getValueAt(i, ID_COLUMN_NUMBER)) .equalsIgnoreCase(value)) { exists = true; } } return exists; } @Override public boolean isCellEditable(EventObject evt) { boolean editable = super.isCellEditable(evt); if (editable) { deleteButton.setEnabled(false); } return editable; } @Override protected boolean valueChanged(String value) { deleteButton.setEnabled(true); if (checkUnique && (value.length() == 0 || checkUnique(value))) { return false; } parent.setSaveEnabled(true); return true; } } attachmentsTable.getColumnModel().getColumn(attachmentsTable.getColumnModelIndex(ID_COLUMN_NAME)) .setCellEditor(new AttachmentsTableCellEditor(true)); attachmentsTable.getColumnModel().getColumn(attachmentsTable.getColumnModelIndex(CONTENT_COLUMN_NAME)) .setCellEditor(new AttachmentsTableCellEditor(false)); attachmentsTable.getColumnModel().getColumn(attachmentsTable.getColumnModelIndex(MIME_TYPE_COLUMN_NAME)) .setCellEditor(new AttachmentsTableCellEditor(false)); attachmentsTable.setCustomEditorControls(true); attachmentsTable.setSelectionMode(0); attachmentsTable.setRowSelectionAllowed(true); attachmentsTable.setRowHeight(UIConstants.ROW_HEIGHT); attachmentsTable.setDragEnabled(true); attachmentsTable.setTransferHandler(new TransferHandler() { protected Transferable createTransferable(JComponent c) { try { MirthTable table = ((MirthTable) (c)); if (table == null) { return null; } int currRow = table.convertRowIndexToModel(table.getSelectedRow()); String text = ""; if (currRow >= 0 && currRow < table.getModel().getRowCount()) { text = (String) table.getModel().getValueAt(currRow, ID_COLUMN_NUMBER); } text = "<inc:Include href=\"cid:" + text + "\" xmlns:inc=\"http://www.w3.org/2004/08/xop/include\"/>"; return new StringSelection(text); } catch (ClassCastException cce) { return null; } } public int getSourceActions(JComponent c) { return COPY; } public boolean canImport(JComponent c, DataFlavor[] df) { return false; } }); attachmentsTable.setOpaque(true); attachmentsTable.setSortable(true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); attachmentsTable.setHighlighters(highlighter); } attachmentsPane.setViewportView(attachmentsTable); deleteButton.setEnabled(false); }
From source file:com.mirth.connect.client.ui.ChannelSetup.java
/** * Makes the destination table with a parameter that is true if a new destination should be * added as well.//ww w . j ava2 s . co m */ public void makeDestinationTable(boolean addNew) { List<Connector> destinationConnectors; Object[][] tableData; int tableSize; destinationConnectors = currentChannel.getDestinationConnectors(); tableSize = destinationConnectors.size(); if (addNew) { tableSize++; } int chain = 1; tableData = new Object[tableSize][5]; for (int i = 0; i < tableSize; i++) { if (tableSize - 1 == i && addNew) { Connector connector = makeNewConnector(true); // Set the default inbound and outbound dataType and properties String dataType = currentChannel.getSourceConnector().getTransformer().getOutboundDataType(); // Use a different properties object for the inbound and outbound DataTypeProperties defaultInboundProperties = LoadedExtensions.getInstance().getDataTypePlugins() .get(dataType).getDefaultProperties(); DataTypeProperties defaultOutboundProperties = LoadedExtensions.getInstance().getDataTypePlugins() .get(dataType).getDefaultProperties(); DataTypeProperties defaultResponseInboundProperties = LoadedExtensions.getInstance() .getDataTypePlugins().get(dataType).getDefaultProperties(); DataTypeProperties defaultResponseOutboundProperties = LoadedExtensions.getInstance() .getDataTypePlugins().get(dataType).getDefaultProperties(); connector.getTransformer().setInboundDataType(dataType); connector.getTransformer().setInboundProperties(defaultInboundProperties); connector.getTransformer().setOutboundDataType(dataType); connector.getTransformer().setOutboundProperties(defaultOutboundProperties); connector.getResponseTransformer().setInboundDataType(dataType); connector.getResponseTransformer().setInboundProperties(defaultResponseInboundProperties); connector.getResponseTransformer().setOutboundDataType(dataType); connector.getResponseTransformer().setOutboundProperties(defaultResponseOutboundProperties); connector.setName(getNewDestinationName(tableSize)); connector.setTransportName(DESTINATION_DEFAULT); // We need to add the destination first so that the metadata ID is initialized. currentChannel.addDestination(connector); if (connector.isEnabled()) { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_blue.png")), UIConstants.ENABLED_STATUS); } else { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_black.png")), UIConstants.DISABLED_STATUS); } tableData[i][1] = connector.getName(); tableData[i][2] = connector.getMetaDataId(); tableData[i][3] = new ConnectorTypeData(destinationConnectors.get(i).getTransportName()); if (i > 0 && !connector.isWaitForPrevious()) { chain++; } tableData[i][4] = chain; } else { if (destinationConnectors.get(i).isEnabled()) { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_blue.png")), UIConstants.ENABLED_STATUS); } else { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_black.png")), UIConstants.DISABLED_STATUS); } tableData[i][1] = destinationConnectors.get(i).getName(); tableData[i][2] = destinationConnectors.get(i).getMetaDataId(); tableData[i][3] = new ConnectorTypeData(destinationConnectors.get(i).getTransportName()); if (i > 0 && !destinationConnectors.get(i).isWaitForPrevious()) { chain++; } tableData[i][4] = chain; } } destinationTable = new MirthTable(); destinationTable.setModel(new javax.swing.table.DefaultTableModel(tableData, new String[] { STATUS_COLUMN_NAME, DESTINATION_COLUMN_NAME, METADATA_COLUMN_NAME, CONNECTOR_TYPE_COLUMN_NAME, DESTINATION_CHAIN_COLUMN_NAME }) { boolean[] canEdit = new boolean[] { false, true, false, false, false }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); destinationTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // Set the custom cell editor for the Destination Name column. destinationTable.getColumnModel() .getColumn(destinationTable.getColumnModel().getColumnIndex(DESTINATION_COLUMN_NAME)) .setCellEditor(new DestinationTableCellEditor()); destinationTable.setCustomEditorControls(true); // Must set the maximum width on columns that should be packed. destinationTable.getColumnExt(STATUS_COLUMN_NAME).setMaxWidth(UIConstants.MAX_WIDTH); destinationTable.getColumnExt(STATUS_COLUMN_NAME).setMinWidth(UIConstants.MIN_WIDTH); // Set the cell renderer for the status column. destinationTable.getColumnExt(STATUS_COLUMN_NAME).setCellRenderer(new ImageCellRenderer()); // Set the maximum width and cell renderer for the metadata ID column destinationTable.getColumnExt(METADATA_COLUMN_NAME).setMaxWidth(UIConstants.METADATA_ID_COLUMN_WIDTH); destinationTable.getColumnExt(METADATA_COLUMN_NAME).setMinWidth(UIConstants.METADATA_ID_COLUMN_WIDTH); destinationTable.getColumnExt(METADATA_COLUMN_NAME) .setCellRenderer(new NumberCellRenderer(SwingConstants.CENTER, false)); // Set the cell renderer for the destination connector type destinationTable.getColumnExt(CONNECTOR_TYPE_COLUMN_NAME).setCellRenderer(new ConnectorTypeCellRenderer()); // Set the cell renderer and the max width for the destination chain column destinationTable.getColumnExt(DESTINATION_CHAIN_COLUMN_NAME) .setCellRenderer(new NumberCellRenderer(SwingConstants.CENTER, false)); destinationTable.getColumnExt(DESTINATION_CHAIN_COLUMN_NAME).setMaxWidth(50); destinationTable.setSelectionMode(0); destinationTable.setRowSelectionAllowed(true); destinationTable.setRowHeight(UIConstants.ROW_HEIGHT); destinationTable.setFocusable(true); destinationTable.setSortable(false); destinationTable.getTableHeader().setReorderingAllowed(false); destinationTable.setOpaque(true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); destinationTable.setHighlighters(highlighter); } // This action is called when a new selection is made on the destination // table. destinationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { if (lastModelIndex != -1 && lastModelIndex != destinationTable.getRowCount() && !isDeleting) { Connector destinationConnector = currentChannel.getDestinationConnectors() .get(lastModelIndex); ConnectorProperties props = destinationConnectorPanel.getProperties(); ((DestinationConnectorPropertiesInterface) props).getDestinationConnectorProperties() .setResourceIds(resourceIds.get(destinationConnector.getMetaDataId())); destinationConnector.setProperties(props); } if (!loadConnector()) { if (lastModelIndex == destinationTable.getRowCount()) { destinationTable.setRowSelectionInterval(lastModelIndex - 1, lastModelIndex - 1); } else { destinationTable.setRowSelectionInterval(lastModelIndex, lastModelIndex); } } else { lastModelIndex = destinationTable.getSelectedModelIndex(); } /* * Loading the connector may have updated the current destination with incorrect * properties, so after updating lastModelIndex we need to update the * destination panel again. */ saveDestinationPanel(); checkVisibleDestinationTasks(); } } }); destinationTable.requestFocus(); // Mouse listener for trigger-button popup on the table. destinationTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { checkSelectionAndPopupMenu(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { checkSelectionAndPopupMenu(evt); } }); // Checks to see what to set the new row selection to based on // last index and if a new destination was added. int last = lastModelIndex; // Select each destination in turn so that the connector types can be decorated for (int row = 0; row < destinationTable.getRowCount(); row++) { destinationTable.setRowSelectionInterval(row, row); destinationConnectorPanel.decorateConnectorType(); } if (addNew) { destinationTable.setRowSelectionInterval(destinationTable.getRowCount() - 1, destinationTable.getRowCount() - 1); } else if (last == -1) { destinationTable.setRowSelectionInterval(0, 0); // Makes sure the } // event is called // when the table is // created. else if (last == destinationTable.getRowCount()) { destinationTable.setRowSelectionInterval(last - 1, last - 1); } else { destinationTable.setRowSelectionInterval(last, last); } destinationTablePane.setViewportView(destinationTable); destinationTablePane.setWheelScrollingEnabled(true); // Key Listener trigger for DEL destinationTable.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { parent.doDeleteDestination(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); destinationTable.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { destinationTablePane.getMouseWheelListeners()[0].mouseWheelMoved(e); } }); }
From source file:com.github.fritaly.dualcommander.DualCommander.java
@Override public void windowClosing(WindowEvent e) { try {/* w ww. j a va 2s .c o m*/ if (logger.isDebugEnabled()) { logger.debug("Saving preferences ..."); } // Save the program state final Preferences prefs = Preferences.userNodeForPackage(this.getClass()); this.leftPane.saveState(prefs.node("left.panel")); this.rightPane.saveState(prefs.node("right.panel")); this.preferences.saveState(prefs.node("user.preferences")); prefs.sync(); if (logger.isInfoEnabled()) { logger.info("Saved preferences"); } } catch (BackingStoreException e1) { // Not a big deal } }
From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java
public void makeFilterTable() { filterTable = new MirthTable(); filterTable.setModel(new DefaultTableModel(new String[] { "#", "Operator", "Name", "Type", "Data" }, 0) { public boolean isCellEditable(int rowIndex, int columnIndex) { boolean[] canEdit; FilterRulePlugin plugin;/*from w w w . ja v a 2s . c om*/ try { plugin = getPlugin((String) filterTableModel.getValueAt(rowIndex, RULE_TYPE_COL)); canEdit = new boolean[] { false, true, plugin.isNameEditable(), true, true }; } catch (Exception e) { canEdit = new boolean[] { false, true, true, true, true }; } return canEdit[columnIndex]; } }); filterTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); filterTableModel = (DefaultTableModel) filterTable.getModel(); filterTable.getColumnModel().getColumn(RULE_NAME_COL).setCellEditor(new EditorTableCellEditor(this)); filterTable.setCustomEditorControls(true); // Set the combobox editor on the operator column, and add action // listener MirthComboBoxTableCellEditor comboBoxOp = new MirthComboBoxTableCellEditor(filterTable, comboBoxValues, 2, true, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { modified = true; updateOperations(); } }); // Set the combobox editor on the type column, and add action listener String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getFilterRulePlugins().size()]; FilterRulePlugin[] pluginArray = LoadedExtensions.getInstance().getFilterRulePlugins().values() .toArray(new FilterRulePlugin[0]); for (int i = 0; i < pluginArray.length; i++) { defaultComboBoxValues[i] = pluginArray[i].getPluginPointName(); } MirthComboBoxTableCellEditor comboBoxType = new MirthComboBoxTableCellEditor(filterTable, defaultComboBoxValues, 2, true, new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (filterTable.getEditingRow() != -1) { int row = getSelectedRow(); String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString(); String previousType = (String) filterTable.getValueAt(row, RULE_TYPE_COL); if (selectedType.equalsIgnoreCase(previousType)) { return; } modified = true; FilterRulePlugin plugin; try { if (rulePanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption( PlatformUI.MIRTH_FRAME, "Are you sure you would like to change this filter rule and lose all of the current filter data?")) { ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType); return; } plugin = getPlugin(selectedType); plugin.initData(); filterTableModel.setValueAt(plugin.getNewName(), row, RULE_NAME_COL); rulePanel.showCard(selectedType); updateTaskPane(selectedType); updateCodePanel(selectedType); } catch (Exception e) { parent.alertThrowable(parent, e); } } } }); filterTable.setSelectionMode(0); // only select one row at a time filterTable.getColumnExt(RULE_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH); filterTable.getColumnExt(RULE_OP_COL).setMaxWidth(UIConstants.MAX_WIDTH); filterTable.getColumnExt(RULE_NUMBER_COL).setPreferredWidth(30); filterTable.getColumnExt(RULE_OP_COL).setPreferredWidth(60); filterTable.getColumnExt(RULE_NUMBER_COL).setCellRenderer(new CenterCellRenderer()); filterTable.getColumnExt(RULE_OP_COL).setCellEditor(comboBoxOp); filterTable.getColumnExt(RULE_OP_COL).setCellRenderer(new MirthComboBoxTableCellRenderer(comboBoxValues) { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value instanceof String && value.equals("")) { value = null; } else if (value != null) { value = value.toString(); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }); filterTable.getColumnExt(RULE_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH); filterTable.getColumnExt(RULE_TYPE_COL).setMinWidth(120); filterTable.getColumnExt(RULE_TYPE_COL).setPreferredWidth(120); filterTable.getColumnExt(RULE_TYPE_COL).setCellEditor(comboBoxType); filterTable.getColumnExt(RULE_TYPE_COL) .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues)); filterTable.getColumnExt(RULE_DATA_COL).setVisible(false); filterTable.setRowHeight(UIConstants.ROW_HEIGHT); filterTable.packTable(UIConstants.COL_MARGIN); filterTable.setSortable(false); filterTable.setOpaque(true); filterTable.setRowSelectionAllowed(true); filterTable.setDragEnabled(false); filterTable.getTableHeader().setReorderingAllowed(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); filterTable.setHighlighters(highlighter); } filterTable.setDropTarget(dropTarget); filterTablePane.setDropTarget(dropTarget); filterTable.setBorder(BorderFactory.createEmptyBorder()); filterTablePane.setBorder(BorderFactory.createEmptyBorder()); filterTablePane.setViewportView(filterTable); filterTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { checkSelectionAndPopupMenu(evt); } public void mouseReleased(MouseEvent evt) { checkSelectionAndPopupMenu(evt); } }); filterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (!updating && !evt.getValueIsAdjusting()) { FilterListSelected(evt); updateCodePanel(null); } } }); filterTable.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { deleteRule(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
private void saveRecentPatchFileList() { StringBuilder sb = new StringBuilder(128); if (recentPatchFileList != null) { int k = recentPatchFileList.listModel.getSize() - 1; for (int index = 0; index <= k; index++) { File file = recentPatchFileList.listModel.getElementAt(k - index); if (sb.length() > 0) { sb.append(File.pathSeparator); }/* w ww. j av a2s .c om*/ String fp = file.getPath(); System.out.println(fp + " Path Length = " + fp.length()); sb.append(file.getPath()); System.out.println("RUFL Length = " + sb.length()); } Preferences p = Preferences.userNodeForPackage(RecentFileList.class); p.put("RecentPatchFileList.fileList", sb.toString()); } }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
private void loadRecentPatchFileList() { Preferences p = Preferences.userNodeForPackage(RecentFileList.class); String listOfFiles = p.get("RecentPatchFileList.fileList", null); if (fc == null) { String savedPath = prefs.get("MRUPatchFolder", ""); File MRUPatchFolder = new File(savedPath); fc = new JFileChooser(MRUPatchFolder); recentPatchFileList = new RecentFileList(fc); if (listOfFiles != null) { String[] files = listOfFiles.split(File.pathSeparator); for (String fileRef : files) { File file = new File(fileRef); if (file.exists()) { recentPatchFileList.listModel.add(file); }/*w w w .j a va2 s .c om*/ } } fc.setAccessory(recentPatchFileList); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); } }
From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java
public void makeTransformerTable() { transformerTable = new MirthTable(); transformerTable.setBorder(BorderFactory.createEmptyBorder()); // Data Column is hidden transformerTable.setModel(new DefaultTableModel(new String[] { "#", "Name", "Type", "Data" }, 0) { public boolean isCellEditable(int rowIndex, int columnIndex) { boolean[] canEdit; TransformerStepPlugin plugin; try { plugin = getPlugin((String) transformerTableModel.getValueAt(rowIndex, STEP_TYPE_COL)); canEdit = new boolean[] { false, plugin.isNameEditable(), true, true }; } catch (Exception e) { canEdit = new boolean[] { false, false, true, true }; }/*w w w . ja v a2s .c o m*/ return canEdit[columnIndex]; } }); transformerTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); transformerTableModel = (DefaultTableModel) transformerTable.getModel(); transformerTable.getColumnModel().getColumn(STEP_NAME_COL).setCellEditor(new EditorTableCellEditor(this)); transformerTable.setCustomEditorControls(true); // Set the combobox editor on the type column, and add action listener String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getTransformerStepPlugins() .size()]; TransformerStepPlugin[] pluginArray = LoadedExtensions.getInstance().getTransformerStepPlugins().values() .toArray(new TransformerStepPlugin[0]); for (int i = 0; i < pluginArray.length; i++) { defaultComboBoxValues[i] = pluginArray[i].getPluginPointName(); } MirthComboBoxTableCellEditor comboBox = new MirthComboBoxTableCellEditor(transformerTable, defaultComboBoxValues, 2, true, new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (transformerTable.getEditingRow() != -1) { int row = getSelectedRow(); String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString(); String previousType = (String) transformerTable.getValueAt(row, STEP_TYPE_COL); if (selectedType.equalsIgnoreCase(previousType)) { return; } modified = true; invalidVar = false; TransformerStepPlugin plugin = null; try { if (stepPanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption( PlatformUI.MIRTH_FRAME, "Are you sure you would like to change this transformer step and lose all of the current transformer data?")) { ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType); return; } plugin = getPlugin(selectedType); plugin.initData(); transformerTableModel.setValueAt(plugin.getNewName(), row, STEP_NAME_COL); stepPanel.showCard(selectedType); updateTaskPane(selectedType); updateCodePanel(selectedType); } catch (Exception e) { parent.alertThrowable(PlatformUI.MIRTH_FRAME, e); } } } }); transformerTable.setSelectionMode(0); // only select one row at a time transformerTable.getColumnExt(STEP_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH); transformerTable.getColumnExt(STEP_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH); transformerTable.getColumnExt(STEP_TYPE_COL).setMinWidth(120); transformerTable.getColumnExt(STEP_NUMBER_COL).setPreferredWidth(30); transformerTable.getColumnExt(STEP_TYPE_COL).setPreferredWidth(120); transformerTable.getColumnExt(STEP_NUMBER_COL).setCellRenderer(new CenterCellRenderer()); transformerTable.getColumnExt(STEP_TYPE_COL).setCellEditor(comboBox); transformerTable.getColumnExt(STEP_TYPE_COL) .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues)); transformerTable.getColumnExt(STEP_DATA_COL).setVisible(false); transformerTable.setRowHeight(UIConstants.ROW_HEIGHT); transformerTable.packTable(UIConstants.COL_MARGIN); transformerTable.setSortable(false); transformerTable.setOpaque(true); transformerTable.setRowSelectionAllowed(true); transformerTable.setDragEnabled(false); transformerTable.getTableHeader().setReorderingAllowed(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); transformerTable.setHighlighters(highlighter); } transformerTable.setDropTarget(dropTarget); transformerTablePane.setDropTarget(dropTarget); transformerTable.setBorder(BorderFactory.createEmptyBorder()); transformerTablePane.setBorder(BorderFactory.createEmptyBorder()); transformerTablePane.setViewportView(transformerTable); // listen for mouse clicks on the actual table transformerTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { checkSelectionAndPopupMenu(evt); } public void mouseReleased(MouseEvent evt) { checkSelectionAndPopupMenu(evt); } }); transformerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (!updating && !evt.getValueIsAdjusting()) { TransformerListSelected(evt); updateCodePanel(null); } } }); transformerTable.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { deleteStep(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); }
From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java
/** * Creates the table with all of the information given after being filtered by the specified * 'filter'/*from www.j a v a 2 s . c o m*/ */ private void makeEventTable() { updateEventTable(null); eventTable.setSelectionMode(0); eventTable.setMirthColumnControlEnabled(true); eventTable.restoreColumnPreferences(); eventTable.getColumnExt(EVENT_LEVEL_COLUMN_NAME) .setCellRenderer(new ImageCellRenderer(SwingConstants.CENTER)); eventTable.getColumnExt(EVENT_OUTCOME_COLUMN_NAME) .setCellRenderer(new ImageCellRenderer(SwingConstants.CENTER)); eventTable.getColumnExt(EVENT_ID_COLUMN_NAME).setVisible(false); DateCellRenderer dateCellRenderer = new DateCellRenderer(); dateCellRenderer.setDateFormat(new SimpleDateFormat(DATE_FORMAT)); eventTable.getColumnExt(EVENT_DATE_COLUMN_NAME).setCellRenderer(dateCellRenderer); eventTable.getColumnExt(EVENT_DATE_COLUMN_NAME).setMinWidth(140); eventTable.getColumnExt(EVENT_DATE_COLUMN_NAME).setMaxWidth(140); eventTable.getColumnExt(EVENT_LEVEL_COLUMN_NAME).setMinWidth(50); eventTable.getColumnExt(EVENT_LEVEL_COLUMN_NAME).setMaxWidth(50); eventTable.getColumnExt(EVENT_SERVER_ID_COLUMN_NAME).setMinWidth(220); eventTable.getColumnExt(EVENT_SERVER_ID_COLUMN_NAME).setMaxWidth(220); eventTable.getColumnExt(EVENT_OUTCOME_COLUMN_NAME).setMinWidth(65); eventTable.getColumnExt(EVENT_OUTCOME_COLUMN_NAME).setMaxWidth(65); eventTable.setRowHeight(UIConstants.ROW_HEIGHT); eventTable.setOpaque(true); eventTable.setRowSelectionAllowed(true); deselectRows(); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); eventTable.setHighlighters(highlighter); } eventPane.setViewportView(eventTable); eventSplitPane.setLeftComponent(eventPane); eventTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { EventListSelected(evt); } }); eventTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { checkSelectionAndPopupMenu(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { checkSelectionAndPopupMenu(evt); } }); // Set highlighter. if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); eventTable.setHighlighters(highlighter); } }
From source file:fll.subjective.SubjectiveFrame.java
/** * Set the initial directory preference. This supports opening new file * dialogs to a (hopefully) better default in the user's next session. * /* www. j a va 2 s . c o m*/ * @param dir the File for the directory in which file dialogs should open */ private static void setInitialDirectory(final File dir) { // Store only directories final File directory; if (dir.isDirectory()) { directory = dir; } else { directory = dir.getParentFile(); } final Preferences preferences = Preferences.userNodeForPackage(SubjectiveFrame.class); final String previousPath = preferences.get(INITIAL_DIRECTORY_PREFERENCE_KEY, null); if (!directory.toString().equals(previousPath)) { preferences.put(INITIAL_DIRECTORY_PREFERENCE_KEY, directory.toString()); } }