List of usage examples for javax.swing DefaultCellEditor DefaultCellEditor
public DefaultCellEditor(final JComboBox<?> comboBox)
DefaultCellEditor
object that uses a combo box. From source file:com.diversityarrays.kdxplore.editing.EntityPropertiesTable.java
@Override public TableCellEditor getCellEditor(int row, int column) { EntityPropertiesTableModel<?> tatm = (EntityPropertiesTableModel<?>) getModel(); PropertyDescriptor pd = tatm.getPropertyDescriptor(row); Class<?> pdClass = pd.getPropertyType(); if (TraitNameStyle.class == pdClass) { if (Trial.class != tatm.entityClass) { throw new RuntimeException("Internal error: " + tatm.entityClass.getName()); }//from ww w . ja va2 s . c om Trial trial = (Trial) tatm.getEntity(); return TNS_Editor.create(trial); } if (Enum.class.isAssignableFrom(pdClass)) { if (PlotIdentOption.class.equals(pdClass)) { List<PlotIdentOption> list = new ArrayList<>(); for (PlotIdentOption pio : PlotIdentOption.values()) { if (PlotIdentOption.NO_X_Y_OR_PLOT_ID != pio) { list.add(pio); } } return new DefaultCellEditor( new JComboBox<PlotIdentOption>(list.toArray(new PlotIdentOption[list.size()]))); } else { @SuppressWarnings({ "rawtypes", "unchecked" }) Class<Enum> eclass = (Class<Enum>) pdClass; @SuppressWarnings({ "rawtypes", "unchecked" }) EnumSet allOf = EnumSet.allOf(eclass); return new DefaultCellEditor(new JComboBox<>(allOf.toArray())); } } return super.getCellEditor(row, column); }
From source file:de.mprengemann.intellij.plugin.androidicons.forms.AndroidBatchScaleImporter.java
private void initExportNameValidator() { table.getColumnModel().getColumn(5).setCellEditor(new DefaultCellEditor(new JTextField()) { @Override//www. ja va2 s . c o m public boolean stopCellEditing() { boolean result = super.stopCellEditing(); if (!result) { return false; } String value = (String) getCellEditorValue(); value = value.trim(); if ((StringUtils.isNotEmpty(value) && value.matches("[a-z0-9_.]*"))) { return super.stopCellEditing(); } ((JComponent) this.getComponent()).setBorder(new LineBorder(JBColor.RED)); return false; } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { ((JComponent) this.getComponent()).setBorder(table.getBorder()); return super.getTableCellEditorComponent(table, value, isSelected, row, column); } }); }
From source file:es.emergya.ui.plugins.AdminPanel.java
/** * /*www.j a v a 2 s . c o m*/ * @param columnNames * nombres de las columnas de la tabla * @param filterOptions * lista de opciones de un combobox. Si esta vacio entonces es un * textfield * @param noFiltrarAction * @param filtrarAction */ public void generateTable(String[] columnNames, Object[][] filterOptions, AdminPanel.NoFiltrarAction noFiltrarAction, AdminPanel.FiltrarAction filtrarAction) { if (columnNames == null) { columnNames = new String[] {}; } if (filterOptions == null) { filterOptions = new Object[][] {}; } String filterString = "["; for (Object[] o : filterOptions) { filterString += Arrays.toString(o) + " "; } filterString += "]"; log.debug("generateTable( columnNames = " + Arrays.toString(columnNames) + ", filterOptions = " + filterString + ")"); tablePanel.removeAll(); int columnNamesLength = columnNames.length; if (!getCanDelete()) columnNamesLength++; MyTableModel dataModel = new MyTableModel(1, columnNamesLength + 2) { private static final long serialVersionUID = 1348355328684460769L; @Override public boolean isCellEditable(int row, int column) { return column != 0 && !invisibleFilterCols.contains(column); } }; filters = new JTable(dataModel) { private static final long serialVersionUID = -8266991359840905405L; @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (isCellEditable(row, column) && column != getColumnCount() - 1) { if (c instanceof JTextField) { ((JTextField) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } else if (c instanceof JComboBox) { ((JComboBox) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } else if (c instanceof JLabel) { ((JLabel) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } } return c; } }; filters.setSurrendersFocusOnKeystroke(true); filters.setShowGrid(false); filters.setRowHeight(22); filters.setOpaque(false); for (Integer i = 0; i < filterOptions.length; i++) { final Object[] items = filterOptions[i]; if (items != null && items.length > 1) { setComboBoxEditor(i, items); } else { final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(new JTextField()); defaultCellEditor.setClickCountToStart(1); filters.getColumnModel().getColumn(i + 1).setCellEditor(defaultCellEditor); } } filters.setRowSelectionAllowed(false); filters.setDragEnabled(false); filters.setColumnSelectionAllowed(false); filters.setDefaultEditor(JButton.class, new JButtonCellEditor()); filters.setDefaultRenderer(Object.class, new DefaultTableRenderer() { private static final long serialVersionUID = -4811729559786534118L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (invisibleFilterCols.contains(column)) c = new JLabel(""); return c; } }); filters.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JButton b = (JButton) value; b.setBorderPainted(false); b.setContentAreaFilled(false); return b; } }); filters.setDefaultRenderer(JLabel.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return (JLabel) value; } }); filters.setDefaultEditor(JButton.class, new JButtonCellEditor()); filters.getModel().setValueAt(new JLabel(""), 0, 0); JButton jButton2 = new JButton(noFiltrarAction); JButton jButton = new JButton(filtrarAction); jButton.setBorderPainted(false); jButton2.setBorderPainted(false); jButton.setContentAreaFilled(false); jButton2.setContentAreaFilled(false); if (jButton.getIcon() != null) jButton.setPreferredSize( new Dimension(jButton.getIcon().getIconWidth(), jButton.getIcon().getIconHeight())); if (jButton2.getIcon() != null) jButton2.setPreferredSize( new Dimension(jButton2.getIcon().getIconWidth(), jButton2.getIcon().getIconHeight())); filters.getModel().setValueAt(jButton, 0, columnNamesLength - 1); filters.getColumnModel().getColumn(columnNamesLength - 1).setMinWidth(jButton.getWidth() + 24); filters.getModel().setValueAt(jButton2, 0, columnNamesLength); filters.getColumnModel().getColumn(columnNamesLength).setMinWidth(jButton2.getWidth() + 14); cuenta.setHorizontalAlignment(JLabel.CENTER); cuenta.setText("?/?"); filters.getModel().setValueAt(cuenta, 0, columnNamesLength + 1); tablePanel.add(filters, BorderLayout.NORTH); Vector<String> headers = new Vector<String>(); headers.add(""); headers.addAll(Arrays.asList(columnNames)); MyTableModel model = new MyTableModel(headers, 0); table = new JTable(model) { private static final long serialVersionUID = 949284378605881770L; private int highLightedRow = -1; private Rectangle dirtyRegion = null; public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); try { if (AdminPanel.this.myRendererColoring != null) c.setBackground(AdminPanel.this.myRendererColoring .getColor(AdminPanel.this.table.getValueAt(row, 1))); } catch (Throwable t) { log.error("Error al colorear la celda: " + t); } return c; } @Override protected void processMouseMotionEvent(MouseEvent e) { try { int row = rowAtPoint(e.getPoint()); Graphics g = getGraphics(); if (row == -1) { highLightedRow = -1; } // row changed if (highLightedRow != row) { if (null != dirtyRegion) { paintImmediately(dirtyRegion); } for (int j = 0; j < getRowCount(); j++) { if (row == j) { // highlight Rectangle firstRowRect = getCellRect(row, 0, false); Rectangle lastRowRect = getCellRect(row, getColumnCount() - 1, false); dirtyRegion = firstRowRect.union(lastRowRect); g.setColor(new Color(0xff, 0xff, 0, 100)); g.fillRect((int) dirtyRegion.getX(), (int) dirtyRegion.getY(), (int) dirtyRegion.getWidth(), (int) dirtyRegion.getHeight()); highLightedRow = row; } } } } catch (Exception ex) { } super.processMouseMotionEvent(e); } }; table.setRowHeight(22); table.setOpaque(false); // table.setAutoCreateRowSorter(true); table.setDragEnabled(false); table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setResizingAllowed(false); table.setDefaultEditor(JButton.class, new JButtonCellEditor()); table.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JButton b = (JButton) value; if (b != null) { b.setBorderPainted(false); b.setContentAreaFilled(false); } return b; } }); JScrollPane jScrollPane = new JScrollPane(table); jScrollPane.setOpaque(false); jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane.getViewport().setOpaque(false); tablePanel.add(jScrollPane, BorderLayout.CENTER); }
From source file:de.mprengemann.intellij.plugin.androidicons.forms.AndroidBatchScaleImporter.java
private void initTargetResolutions() { ComboBox targetResolutionComboBox = new ComboBox(); targetResolutionComboBox.addItem(Resolution.LDPI.getName()); targetResolutionComboBox.addItem(Resolution.MDPI.getName()); targetResolutionComboBox.addItem(Resolution.HDPI.getName()); targetResolutionComboBox.addItem(Resolution.XHDPI.getName()); targetResolutionComboBox.addItem(Resolution.XXHDPI.getName()); targetResolutionComboBox.addItem(Resolution.XXXHDPI.getName()); targetResolutionComboBox.setSelectedIndex(3); table.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(targetResolutionComboBox)); }
From source file:dk.dma.epd.common.prototype.gui.route.RoutePropertiesDialogCommon.java
/** * Initializes the user interface/*w ww . j a v a 2 s .c om*/ */ private void initGui() { Insets insets1 = new Insets(5, 5, 0, 5); Insets insets2 = new Insets(5, 25, 0, 5); Insets insets3 = new Insets(5, 5, 0, 0); Insets insets4 = new Insets(5, 0, 0, 5); Insets insets5 = new Insets(5, 5, 5, 5); Insets insets6 = new Insets(5, 25, 5, 5); Insets insets10 = new Insets(10, 10, 10, 10); JPanel content = new JPanel(new GridBagLayout()); getContentPane().add(content); // ******************************** // ** Route properties panel // ******************************** JPanel routeProps = new JPanel(new GridBagLayout()); routeProps.setBorder(new TitledBorder(new LineBorder(Color.black), "Route Properties")); content.add(routeProps, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets10, 0, 0)); // Auto-completion List<String> strings = new ArrayList<>(); strings.add("Copenhagen"); strings.add("Oslo"); AutoCompleteDecorator.decorate(originTxT, strings, false); AutoCompleteDecorator.decorate(destinationTxT, strings, false); // Column 1 widgets int gridY = 0; nameTxT.setEditable(!readOnlyRoute); nameTxT.getDocument().addDocumentListener(new TextFieldChangeListener(nameTxT)); routeProps.add(new JLabel("Name:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); routeProps.add(fixSize(nameTxT, 120), new GridBagConstraints(1, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); originTxT.setEditable(!readOnlyRoute); originTxT.getDocument().addDocumentListener(new TextFieldChangeListener(originTxT)); routeProps.add(new JLabel("Origin:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); routeProps.add(fixSize(originTxT, 120), new GridBagConstraints(1, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); destinationTxT.setEnabled(!readOnlyRoute); destinationTxT.getDocument().addDocumentListener(new TextFieldChangeListener(destinationTxT)); routeProps.add(new JLabel("Destination:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); routeProps.add(fixSize(destinationTxT, 120), new GridBagConstraints(1, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); distanceTxT.setEditable(false); routeProps.add(new JLabel("Total Distance:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); routeProps.add(fixSize(distanceTxT, 120), new GridBagConstraints(1, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); // Column 2 widgets gridY = 0; int h = (int) departurePicker.getPreferredSize().getHeight(); initDatePicker(departurePicker, departureSpinner); routeProps.add(new JLabel("Estimated Time of Departure:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add(fixSize(departurePicker, 120), new GridBagConstraints(3, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets3, 0, 0)); routeProps.add(fixSize(departureSpinner, 60, h), new GridBagConstraints(4, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets4, 0, 0)); initDatePicker(arrivalPicker, arrivalSpinner); routeProps.add(new JLabel("Estimated Time of Arrival:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add(fixSize(arrivalPicker, 120), new GridBagConstraints(3, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets3, 0, 0)); routeProps.add(fixSize(arrivalSpinner, 60, h), new GridBagConstraints(4, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets4, 0, 0)); inrouteTxT.setEditable(false); routeProps.add(new JLabel("Estimated Time in-route:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add(fixSize(inrouteTxT, 180), new GridBagConstraints(3, gridY++, 2, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); etaCalculationTime.setEnabled(!readOnlyRoute); etaCalculationTime.addActionListener(this); routeProps.add(new JLabel("Calculate TTG/ETA using:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets6, 0, 0)); routeProps.add(fixSize(etaCalculationTime, 180), new GridBagConstraints(3, gridY++, 2, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); allSpeeds.setEnabled(!readOnlyRoute); allSpeedsBtn.setEnabled(!readOnlyRoute); routeProps.add(new JLabel("Speed all legs: "), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add(fixSize(allSpeeds, 60), new GridBagConstraints(3, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets3, 0, 0)); routeProps.add(fixSize(allSpeedsBtn, 60, h), new GridBagConstraints(4, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets4, 0, 0)); routeProps.add(new JLabel(""), new GridBagConstraints(5, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets2, 0, 0)); // ******************************** // ** Route detail panel // ******************************** routeTableModel = createRouteTableModel(); routeDetailTable = new DeltaTable(routeTableModel, DELTA_START_COL_INDEX); routeDetailTable.setTableFont(routeDetailTable.getTableFont().deriveFont(10.0f)); routeDetailTable.setNonEditableBgColor(UIManager.getColor("Table.background").darker().darker()); routeDetailTable.addListSelectionListener(this); // Set the minimum column widths for (int x = 0; x < COL_MIN_WIDTHS.length; x++) { routeDetailTable.getColumn(x).setMinWidth(COL_MIN_WIDTHS[x]); } // Configure lock column routeDetailTable.fixColumnWidth(0, COL_MIN_WIDTHS[0]); routeDetailTable.getColumn(0).setCellRenderer(new LockTableCell.CustomBooleanCellRenderer()); routeDetailTable.getColumn(0).setCellEditor(new LockTableCell.CustomBooleanCellEditor()); // Configure ETA column routeDetailTable.getColumn(7).setCellEditor(new EtaEditor()); // Configure heading column JComboBox<Heading> headingCombo = new JComboBox<>(Heading.values()); headingCombo.setFont(headingCombo.getFont().deriveFont(10.0f)); routeDetailTable.getColumn(10).setCellEditor(new DefaultCellEditor(headingCombo)); JPanel routeTablePanel = new JPanel(new BorderLayout()); routeTablePanel.add(routeDetailTable, BorderLayout.CENTER); routeTablePanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Route Details")); content.add(routeTablePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, NORTHWEST, BOTH, insets10, 0, 0)); // ******************************** // ** Button panel // ******************************** JPanel btnPanel = new JPanel(new GridBagLayout()); content.add(btnPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, insets10, 0, 0)); btnZoomToRoute.addActionListener(this); btnZoomToWp.addActionListener(this); btnDelete.addActionListener(this); btnActivate.addActionListener(this); btnClose.addActionListener(this); cbVisible.addActionListener(this); allSpeedsBtn.addActionListener(this); getRootPane().setDefaultButton(btnClose); btnPanel.add(btnZoomToRoute, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add(btnZoomToWp, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add(btnDelete, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add(btnActivate, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add(cbVisible, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add(btnClose, new GridBagConstraints(5, 0, 1, 1, 1.0, 0.0, EAST, NONE, insets5, 0, 0)); }
From source file:de.mprengemann.intellij.plugin.androidicons.forms.AndroidBatchScaleImporter.java
private void initAssetResolutions() { ComboBox assetResolutionComboBox = new ComboBox(); assetResolutionComboBox.addItem(Resolution.LDPI.getName()); assetResolutionComboBox.addItem(Resolution.MDPI.getName()); assetResolutionComboBox.addItem(Resolution.HDPI.getName()); assetResolutionComboBox.addItem(Resolution.XHDPI.getName()); assetResolutionComboBox.addItem(Resolution.XXHDPI.getName()); assetResolutionComboBox.addItem(Resolution.XXXHDPI.getName()); assetResolutionComboBox.addItem(Resolution.OTHER.getName()); assetResolutionComboBox.setSelectedIndex(3); table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(assetResolutionComboBox)); }
From source file:mod.steps.stepmode.threads.forms.TransitionsChooser.java
private TableColumnModel initializeComboboxColumn() { ComboRowEditor rowEditor = new ComboRowEditor(tableTransitionsRepetitions); int rowsCount = this.tableModel.getRowCount(); for (int i = 0; i < rowsCount; i++) { String transitionId = (String) this.tableModel.getValueAt(i, 0); JComboBox comboBox = initializeNewComboBox(transitionId); rowEditor.setEditorAt(i, new DefaultCellEditor(comboBox)); }/*from ww w. j av a 2 s . c o m*/ tableTransitionsRepetitions.getColumn("Fire repetitions").setCellEditor(rowEditor); return this.tableTransitionsRepetitions.getColumnModel(); }
From source file:fll.subjective.SubjectiveFrame.java
private void createSubjectiveTable(final JTabbedPane tabbedPane, final ScoreCategory subjectiveCategory) { final SubjectiveTableModel tableModel = new SubjectiveTableModel(_scoreDocument, subjectiveCategory, _schedule, _scheduleColumnMappings); final JTable table = new JTable(tableModel); table.setDefaultRenderer(Date.class, DateRenderer.INSTANCE); // Make grid lines black (needed for Mac) table.setGridColor(Color.BLACK); // auto table sorter table.setAutoCreateRowSorter(true);//from ww w. jav a 2s . co m final String title = subjectiveCategory.getTitle(); _tables.put(title, table); final JScrollPane tableScroller = new JScrollPane(table); tableScroller.setPreferredSize(new Dimension(640, 480)); tabbedPane.addTab(title, tableScroller); table.setSelectionBackground(Color.YELLOW); setupTabReturnBehavior(table); int goalIndex = 0; for (final AbstractGoal goal : subjectiveCategory.getGoals()) { final TableColumn column = table.getColumnModel() .getColumn(goalIndex + tableModel.getNumColumnsLeftOfScores()); if (goal.isEnumerated()) { final Vector<String> posValues = new Vector<String>(); posValues.add(""); for (final EnumeratedValue posValue : goal.getSortedValues()) { posValues.add(posValue.getTitle()); } column.setCellEditor(new DefaultCellEditor(new JComboBox<String>(posValues))); } else { final JTextField editor = new SelectTextField(); column.setCellEditor(new DefaultCellEditor(editor)); } ++goalIndex; } }
From source file:Import.pnl_import_vcf.java
public void setMapTable(JTable table, DefaultTableModel model, String[] selectedFamilies, String[] selectedTableFamilies) { model.setRowCount(0);//from w w w. j av a2 s . c o m model.addColumn("Import Column"); model.addColumn("Map to"); TableColumn sportColumn = table.getColumnModel().getColumn(1); JComboBox comboBox = new JComboBox(); for (String a : selectedFamilies) { comboBox.addItem(a); } sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); for (String b : selectedTableFamilies) { String[] tmp = new String[1]; tmp[0] = b; model.addRow(tmp); } }
From source file:com.mirth.connect.plugins.httpauth.HttpAuthConnectorPropertiesPanel.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); typeLabel = new JLabel("Authentication Type:"); typeLabel.setHorizontalAlignment(SwingConstants.RIGHT); typeComboBox = new MirthComboBox(); typeComboBox.setModel(new DefaultComboBoxModel<AuthType>(AuthType.values())); typeComboBox.addActionListener(new ActionListener() { @Override//w ww . j a va2 s . com public void actionPerformed(ActionEvent evt) { authTypeChanged(); } }); typeComboBox.setToolTipText("Select the type of HTTP authentication to perform for incoming requests."); basicRealmLabel = new JLabel("Realm:"); basicRealmField = new MirthTextField(); basicRealmField.setToolTipText("The protection space for this server."); basicCredentialsLabel = new JLabel("Credentials:"); basicCredentialsPanel = new JPanel(); basicCredentialsPanel.setBackground(getBackground()); basicCredentialsTable = new MirthTable(); basicCredentialsTable.setModel(new RefreshTableModel(new String[] { "Username", "Password" }, 0)); basicCredentialsTable.setCustomEditorControls(true); basicCredentialsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); basicCredentialsTable.setRowSelectionAllowed(true); basicCredentialsTable.setRowHeight(UIConstants.ROW_HEIGHT); basicCredentialsTable.setDragEnabled(false); basicCredentialsTable.setOpaque(true); basicCredentialsTable.setSortable(false); basicCredentialsTable.getTableHeader().setReorderingAllowed(false); basicCredentialsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); basicCredentialsTable.setToolTipText( "<html>Username and password pairs to authenticate<br/>users with. At least one pair is required.</html>"); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); basicCredentialsTable.setHighlighters(highlighter); } CredentialsTableCellEditor basicCredentialsTableCellEditor = new CredentialsTableCellEditor( basicCredentialsTable); basicCredentialsTable.getColumnExt(0).setCellEditor(basicCredentialsTableCellEditor); basicCredentialsTable.getColumnExt(0).setToolTipText("The username to authenticate with."); basicCredentialsTable.getColumnExt(1).setCellRenderer(new PasswordCellRenderer()); basicCredentialsTable.getColumnExt(1).setCellEditor(new DefaultCellEditor(new JPasswordField())); basicCredentialsTable.getColumnExt(1).setToolTipText("The password to authenticate with."); basicCredentialsTableScrollPane = new JScrollPane(basicCredentialsTable); basicCredentialsNewButton = new MirthButton("New"); basicCredentialsNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int num = 0; String username; boolean found; do { num++; username = "user" + num; found = false; for (int row = 0; row < basicCredentialsTable.getModel().getRowCount(); row++) { if (StringUtils.equals(username, (String) basicCredentialsTable.getModel().getValueAt(row, 0))) { found = true; } } } while (found); ((DefaultTableModel) basicCredentialsTable.getModel()).addRow(new String[] { username, "" }); basicCredentialsTable.setRowSelectionInterval(basicCredentialsTable.getRowCount() - 1, basicCredentialsTable.getRowCount() - 1); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); basicCredentialsDeleteButton = new MirthButton("Delete"); basicCredentialsDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int selectedRow = getSelectedRow(basicCredentialsTable); if (selectedRow >= 0) { if (basicCredentialsTable.isEditing()) { basicCredentialsTable.getCellEditor().cancelCellEditing(); } ((DefaultTableModel) basicCredentialsTable.getModel()).removeRow(selectedRow); int rowCount = basicCredentialsTable.getRowCount(); if (selectedRow < rowCount) { basicCredentialsTable.setRowSelectionInterval(selectedRow, selectedRow); } else if (rowCount > 0) { basicCredentialsTable.setRowSelectionInterval(rowCount - 1, rowCount - 1); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); basicCredentialsTableCellEditor.setDeleteButton(basicCredentialsDeleteButton); digestRealmLabel = new JLabel("Realm:"); digestRealmField = new MirthTextField(); digestRealmField.setToolTipText("The protection space for this server."); digestAlgorithmLabel = new JLabel("Algorithms:"); ButtonGroup digestAlgorithmButtonGroup = new ButtonGroup(); String toolTipText = "<html>Specifies the digest algorithms supported by this server.<br/><b> - MD5:</b> The security data A1 will contain the username, realm, and password.<br/><b> - MD5-sess:</b> The security data A1 will also contain the server and client nonces.</html>"; digestAlgorithmMD5Radio = new MirthRadioButton(Algorithm.MD5.toString()); digestAlgorithmMD5Radio.setBackground(getBackground()); digestAlgorithmMD5Radio.setToolTipText(toolTipText); digestAlgorithmButtonGroup.add(digestAlgorithmMD5Radio); digestAlgorithmMD5SessRadio = new MirthRadioButton(Algorithm.MD5_SESS.toString()); digestAlgorithmMD5SessRadio.setBackground(getBackground()); digestAlgorithmMD5SessRadio.setToolTipText(toolTipText); digestAlgorithmButtonGroup.add(digestAlgorithmMD5SessRadio); digestAlgorithmBothRadio = new MirthRadioButton("Both"); digestAlgorithmBothRadio.setBackground(getBackground()); digestAlgorithmBothRadio.setToolTipText(toolTipText); digestAlgorithmButtonGroup.add(digestAlgorithmBothRadio); digestQOPLabel = new JLabel("QOP Modes:"); toolTipText = "<html>The quality of protection modes to support.<br/><b> - auth:</b> Regular auth with client nonce and count in the digest.<br/><b> - auth-int:</b> Same as auth, but also with message integrity protection enabled.</html>"; digestQOPAuthCheckBox = new MirthCheckBox(QOPMode.AUTH.toString()); digestQOPAuthCheckBox.setBackground(getBackground()); digestQOPAuthCheckBox.setToolTipText(toolTipText); digestQOPAuthIntCheckBox = new MirthCheckBox(QOPMode.AUTH_INT.toString()); digestQOPAuthIntCheckBox.setBackground(getBackground()); digestQOPAuthIntCheckBox.setToolTipText(toolTipText); digestOpaqueLabel = new JLabel("Opaque:"); digestOpaqueField = new MirthTextField(); digestOpaqueField.setToolTipText("A string of data that should be returned by the client unchanged."); digestCredentialsLabel = new JLabel("Credentials:"); digestCredentialsPanel = new JPanel(); digestCredentialsPanel.setBackground(getBackground()); digestCredentialsTable = new MirthTable(); digestCredentialsTable.setModel(new RefreshTableModel(new String[] { "Username", "Password" }, 0)); digestCredentialsTable.setCustomEditorControls(true); digestCredentialsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); digestCredentialsTable.setRowSelectionAllowed(true); digestCredentialsTable.setRowHeight(UIConstants.ROW_HEIGHT); digestCredentialsTable.setDragEnabled(false); digestCredentialsTable.setOpaque(true); digestCredentialsTable.setSortable(false); digestCredentialsTable.getTableHeader().setReorderingAllowed(false); digestCredentialsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); digestCredentialsTable.setToolTipText( "<html>Username and password pairs to authenticate<br/>users with. At least one pair is required.</html>"); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); digestCredentialsTable.setHighlighters(highlighter); } CredentialsTableCellEditor digestCredentialsTableCellEditor = new CredentialsTableCellEditor( digestCredentialsTable); digestCredentialsTable.getColumnExt(0).setCellEditor(digestCredentialsTableCellEditor); digestCredentialsTable.getColumnExt(0).setToolTipText("The username to authenticate with."); digestCredentialsTable.getColumnExt(1).setCellRenderer(new PasswordCellRenderer()); digestCredentialsTable.getColumnExt(1).setCellEditor(new DefaultCellEditor(new JPasswordField())); digestCredentialsTable.getColumnExt(1).setToolTipText("The password to authenticate with."); digestCredentialsTableScrollPane = new JScrollPane(digestCredentialsTable); digestCredentialsNewButton = new MirthButton("New"); digestCredentialsNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int num = 0; String username; boolean found; do { num++; username = "user" + num; found = false; for (int row = 0; row < digestCredentialsTable.getModel().getRowCount(); row++) { if (StringUtils.equals(username, (String) digestCredentialsTable.getModel().getValueAt(row, 0))) { found = true; } } } while (found); ((DefaultTableModel) digestCredentialsTable.getModel()).addRow(new String[] { username, "" }); digestCredentialsTable.setRowSelectionInterval(digestCredentialsTable.getRowCount() - 1, digestCredentialsTable.getRowCount() - 1); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); digestCredentialsDeleteButton = new MirthButton("Delete"); digestCredentialsDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int selectedRow = getSelectedRow(digestCredentialsTable); if (selectedRow >= 0) { if (digestCredentialsTable.isEditing()) { digestCredentialsTable.getCellEditor().cancelCellEditing(); } ((DefaultTableModel) digestCredentialsTable.getModel()).removeRow(selectedRow); int rowCount = digestCredentialsTable.getRowCount(); if (selectedRow < rowCount) { digestCredentialsTable.setRowSelectionInterval(selectedRow, selectedRow); } else if (rowCount > 0) { digestCredentialsTable.setRowSelectionInterval(rowCount - 1, rowCount - 1); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); digestCredentialsTableCellEditor.setDeleteButton(digestCredentialsDeleteButton); jsScriptLabel = new JLabel("Script:"); jsScriptField = new JTextField(); jsScriptField.setEditable(false); jsScriptField.setBackground(getBackground()); jsScriptField.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); jsScriptField.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { JavaScriptHttpAuthDialog dialog = new JavaScriptHttpAuthDialog(PlatformUI.MIRTH_FRAME, jsScript); if (dialog.wasSaved()) { PlatformUI.MIRTH_FRAME.setSaveEnabled(true); jsScript = dialog.getScript(); updateJSScriptField(); } } }); jsScriptField.setToolTipText( "<html>Click here to open the JavaScript editor dialog.<br/>The return value of this script is used to accept or reject requests.</html>"); customClassNameLabel = new JLabel("Class Name:"); customClassNameField = new MirthTextField(); customClassNameField .setToolTipText("The fully-qualified Java class name of the Authenticator class to use."); customPropertiesLabel = new JLabel("Properties:"); customPropertiesPanel = new JPanel(); customPropertiesPanel.setBackground(getBackground()); customPropertiesTable = new MirthTable(); customPropertiesTable.setModel(new RefreshTableModel(new String[] { "Name", "Value" }, 0)); customPropertiesTable.setCustomEditorControls(true); customPropertiesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); customPropertiesTable.setRowSelectionAllowed(true); customPropertiesTable.setRowHeight(UIConstants.ROW_HEIGHT); customPropertiesTable.setDragEnabled(false); customPropertiesTable.setOpaque(true); customPropertiesTable.setSortable(false); customPropertiesTable.getTableHeader().setReorderingAllowed(false); customPropertiesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); customPropertiesTable.setToolTipText( "Optional properties to pass into the Authenticator class when it is instantiated."); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); customPropertiesTable.setHighlighters(highlighter); } CredentialsTableCellEditor customPropertiesTableCellEditor = new CredentialsTableCellEditor( customPropertiesTable); customPropertiesTable.getColumnExt(0).setCellEditor(customPropertiesTableCellEditor); customPropertiesTable.getColumnExt(0).setToolTipText("The name of the property to include."); customPropertiesTable.getColumnExt(1).setToolTipText("The value of the property to include."); customPropertiesTableScrollPane = new JScrollPane(customPropertiesTable); customPropertiesNewButton = new MirthButton("New"); customPropertiesNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int num = 0; String name; boolean found; do { num++; name = "Property " + num; found = false; for (int row = 0; row < customPropertiesTable.getModel().getRowCount(); row++) { if (StringUtils.equals(name, (String) customPropertiesTable.getModel().getValueAt(row, 0))) { found = true; } } } while (found); ((DefaultTableModel) customPropertiesTable.getModel()).addRow(new String[] { name, "" }); customPropertiesTable.setRowSelectionInterval(customPropertiesTable.getRowCount() - 1, customPropertiesTable.getRowCount() - 1); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); customPropertiesDeleteButton = new MirthButton("Delete"); customPropertiesDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int selectedRow = getSelectedRow(customPropertiesTable); if (selectedRow >= 0) { if (customPropertiesTable.isEditing()) { customPropertiesTable.getCellEditor().cancelCellEditing(); } ((DefaultTableModel) customPropertiesTable.getModel()).removeRow(selectedRow); int rowCount = customPropertiesTable.getRowCount(); if (selectedRow < rowCount) { customPropertiesTable.setRowSelectionInterval(selectedRow, selectedRow); } else if (rowCount > 0) { customPropertiesTable.setRowSelectionInterval(rowCount - 1, rowCount - 1); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); customPropertiesTableCellEditor.setDeleteButton(customPropertiesDeleteButton); oauth2TokenLabel = new JLabel("Access Token Location:"); oauth2TokenLocationComboBox = new MirthComboBox(); oauth2TokenLocationComboBox.setModel(new DefaultComboBoxModel<TokenLocation>(TokenLocation.values())); oauth2TokenLocationComboBox .setToolTipText("Determines where the access token is located in client requests."); oauth2TokenField = new MirthTextField(); oauth2TokenField .setToolTipText("The header or query parameter to pass along with the verification request."); oauth2VerificationURLLabel = new JLabel("Verification URL:"); oauth2VerificationURLField = new MirthTextField(); oauth2VerificationURLField.setToolTipText( "<html>The HTTP URL to perform a GET request to for access<br/>token verification. If the response code is >= 400,<br/>the authentication attempt is rejected by the server.</html>"); for (ConnectorPropertiesPlugin connectorPropertiesPlugin : LoadedExtensions.getInstance() .getConnectorPropertiesPlugins().values()) { if (connectorPropertiesPlugin .isConnectorPropertiesPluginSupported(HttpAuthConnectorPluginProperties.PLUGIN_POINT)) { connectorPropertiesPanel = connectorPropertiesPlugin.getConnectorPropertiesPanel(); } } }