List of usage examples for javax.swing.table TableColumn setCellRenderer
@BeanProperty(description = "The renderer to use for cell values.") public void setCellRenderer(TableCellRenderer cellRenderer)
TableCellRenderer
used by JTable
to draw individual values for this column. From source file:ar.edu.uns.cs.vyglab.arq.rockar.gui.JFrameControlPanel.java
public void clearJTable() { jTableMineralsModel = new RockTableModel(new String[] { DataCenter.langResource.getString("keyvalue_table"), DataCenter.langResource.getString("name_table"), DataCenter.langResource.getString("color_table"), DataCenter.langResource.getString("counted_table"), DataCenter.langResource.getString("area_table") }, 0); // jTableMineralsModel.addRow(new Object[] { // 0, "x?", Color.gray, 0, // "0.00" }); jTableMinerals = new JReadOnlyTable(); jScrollPaneMineralTable.setViewportView(jTableMinerals); jTableMinerals.setModel(jTableMineralsModel); jTableMinerals.setDefaultRenderer(Color.class, new ColorRenderer(true)); TableCellRenderer centerRenderer = new CenterRenderer(); TableColumn column = jTableMinerals.getColumnModel().getColumn(0); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(1); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(3); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(4); column.setCellRenderer(centerRenderer); }
From source file:logdruid.ui.table.StatRecordingEditorTable.java
public void setUpTypeColumn(JTable theTable, TableColumn TypeColumn) { // Set up the editor for the Type cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("word"); comboBox.addItem("string"); comboBox.addItem("long"); comboBox.addItem("double"); comboBox.addItem("date"); comboBox.addItem("percent"); TypeColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the Type cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); TypeColumn.setCellRenderer(renderer); }
From source file:logdruid.ui.table.EventRecordingEditorTable.java
public void setUpTypeColumn(JTable theTable, TableColumn typeColumn) { // Set up the editor for the type cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("word"); comboBox.addItem("string"); comboBox.addItem("long"); comboBox.addItem("double"); comboBox.addItem("date"); comboBox.addItem("percent"); typeColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the type cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); typeColumn.setCellRenderer(renderer); }
From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java
/** * When any aspect of the chart changes, this method should be called to set * the state of the editor. This will set up the correct result set as well * as display the correct editor in a new edit state. *///from w ww .ja v a2s .c o m void updateGUIFromChart() { if (updating) return; try { updating = true; xaxisLabelRotationSlider.setValue((int) chart.getXAxisLabelRotation()); xAxisAuto.setSelected(chart.isAutoXAxisRange()); yAxisAuto.setSelected(chart.isAutoYAxisRange()); xAxisMax.setEnabled(!chart.isAutoXAxisRange()); xAxisMin.setEnabled(!chart.isAutoXAxisRange()); yAxisMax.setEnabled(!chart.isAutoYAxisRange()); yAxisMin.setEnabled(!chart.isAutoYAxisRange()); xAxisMax.setValue(chart.getXAxisMaxRange()); yAxisMax.setValue(chart.getYAxisMaxRange()); xAxisMin.setValue(chart.getXAxisMinRange()); yAxisMin.setValue(chart.getYAxisMinRange()); gratuitousAnimationCheckbox.setSelected(chart.isGratuitouslyAnimated()); queryComboBox.setSelectedItem(chart.getQuery()); setSelectedChartType(chart.getType()); if (!skipTextFieldRefresh) { yaxisNameField.setText(chart.getYaxisName()); xaxisNameField.setText(chart.getXaxisName()); } if (chart.getQuery() != null && chart.getUnfilteredResultSet() != null) { if (currentHeaderCellRenderer != null) { currentHeaderCellRenderer.cleanup(); } if (chart.getType().getDatasetType() == DatasetType.CATEGORY) { currentHeaderCellRenderer = new CategoryChartHeaderRenderer(this, resultTable.getTableHeader(), defaultHeaderCellRenderer); resultTable.getTableHeader().setDefaultRenderer(currentHeaderCellRenderer); //Set control components visibility based on chart type if (chart.getType() == ChartType.PIE) { xaxisNameLabel.setVisible(false); xaxisNameField.setVisible(false); yaxisNameLabel.setVisible(false); yaxisNameField.setVisible(false); xaxisLabelRotationLabel.setVisible(false); xaxisLabelRotationSlider.setVisible(false); xAxisAuto.setVisible(false); xAxisAutoLabel.setVisible(false); xAxisMax.setVisible(false); xAxisMaxLabel.setVisible(false); xAxisMin.setVisible(false); xAxisMinLabel.setVisible(false); yAxisAuto.setVisible(false); yAxisAutoLabel.setVisible(false); yAxisMax.setVisible(false); yAxisMaxLabel.setVisible(false); yAxisMin.setVisible(false); yAxisMinLabel.setVisible(false); } else { xaxisNameLabel.setVisible(true); xaxisNameField.setVisible(true); yaxisNameLabel.setVisible(true); yaxisNameField.setVisible(true); xaxisLabelRotationLabel.setVisible(true); xaxisLabelRotationSlider.setVisible(true); yAxisAuto.setVisible(true); yAxisAutoLabel.setVisible(true); yAxisMax.setVisible(true); yAxisMaxLabel.setVisible(true); yAxisMin.setVisible(true); yAxisMinLabel.setVisible(true); xAxisAuto.setVisible(false); xAxisAutoLabel.setVisible(false); xAxisMax.setVisible(false); xAxisMaxLabel.setVisible(false); xAxisMin.setVisible(false); xAxisMinLabel.setVisible(false); } } else if (chart.getType().getDatasetType() == DatasetType.XY) { try { currentHeaderCellRenderer = new XYChartHeaderRenderer(this, resultTable.getTableHeader(), defaultHeaderCellRenderer); } catch (SQLException e) { showError(WabitUtils.getRootCause(e).getMessage()); return; } resultTable.getTableHeader().setDefaultRenderer(currentHeaderCellRenderer); xaxisNameLabel.setVisible(true); xaxisNameField.setVisible(true); yaxisNameLabel.setVisible(true); yaxisNameField.setVisible(true); xaxisLabelRotationLabel.setVisible(false); xaxisLabelRotationSlider.setVisible(false); xAxisAuto.setVisible(true); xAxisAutoLabel.setVisible(true); xAxisMax.setVisible(true); xAxisMaxLabel.setVisible(true); xAxisMin.setVisible(true); xAxisMinLabel.setVisible(true); } headerLegendContainer.removeAll(); headerLegendContainer.add(currentHeaderCellRenderer.getHeaderLegendComponent(), BorderLayout.NORTH); headerLegendContainer.revalidate(); headerLegendContainer.repaint(); if (chart.getLegendPosition() != null) { legendPositionComboBox.setSelectedItem(chart.getLegendPosition()); } else { legendPositionComboBox.setSelectedItem(LegendPosition.BOTTOM); } final ResultSetTableModel model = new ResultSetTableModel(chart.getUnfilteredResultSet()); resultTable.setModel(model); ChartTableCellRenderer cellRenderer = new ChartTableCellRenderer(chart); for (Enumeration<TableColumn> tableCols = resultTable.getColumnModel().getColumns(); tableCols .hasMoreElements();) { TableColumn tc = tableCols.nextElement(); tc.setCellRenderer(cellRenderer); } } else { if (currentHeaderCellRenderer != null) { currentHeaderCellRenderer.cleanup(); } resultTable.getTableHeader().setDefaultRenderer(defaultHeaderCellRenderer); } updateChartPreview(); } finally { updating = false; } }
From source file:net.sf.profiler4j.console.ProjectDialog.java
/** * This method initializes rulesTable//w ww .java 2s . c om * * @return javax.swing.JTable */ private JTable getRulesTable() { if (rulesTable == null) { rulesTable = new JTable(); rulesTable.setModel(ruleTableModel); rulesTable.setRowMargin(4); rulesTable.setRowHeight(24); rulesTable.setFont(new Font("Monospaced", Font.PLAIN, 14)); TableColumn c; c = rulesTable.getColumnModel().getColumn(0); c.setMinWidth(300); c = rulesTable.getColumnModel().getColumn(1); c.setMinWidth(80); c.setMaxWidth(80); JComboBox editorCb = new JComboBox(); for (Rule.Action a : Rule.Action.values()) { editorCb.addItem(a); } c.setCellEditor(new DefaultCellEditor(editorCb)); c.setCellRenderer(new DefaultTableCellRenderer() { Font font = new Font("Monospaced", Font.BOLD, 13); @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); Rule.Action r = (Rule.Action) value; setHorizontalAlignment(CENTER); setFont(font); if (r == Rule.Action.ACCEPT) { setBackground(Color.GREEN); } else { setBackground(Color.RED); } if (isSelected) { setForeground(Color.YELLOW); } else { setForeground(Color.BLACK); } return this; } }); } return rulesTable; }
From source file:ar.edu.uns.cs.vyglab.arq.rockar.gui.JFrameControlPanel.java
private void initGUI() { try {/* w ww. j a v a2 s .c o m*/ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setIconImage(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/splash/purple-monkey32.png")) .getImage()); this.setTitle("Rock.AR v2.0"); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { thisComponentResized(evt); } }); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { thisWindowClosed(evt); } }); { jPanelSouth = new JPanel(); BorderLayout jPanelSouthLayout = new BorderLayout(); getContentPane().add(jPanelSouth, BorderLayout.SOUTH); jPanelSouth.setLayout(jPanelSouthLayout); { jLabelInformation = new JLabel(); jPanelSouth.add(jLabelInformation, BorderLayout.CENTER); jLabelInformation.setText(DataCenter.langResource.getString("control_information_label")); jLabelInformation.setOpaque(true); jLabelInformation.setBackground(new java.awt.Color(241, 191, 101)); } } { jPanelCenter = new JPanel(); GridLayout jPanelCenterLayout = new GridLayout(1, 1); jPanelCenterLayout.setHgap(5); jPanelCenterLayout.setVgap(5); jPanelCenterLayout.setColumns(1); getContentPane().add(jPanelCenter, BorderLayout.CENTER); jPanelCenter.setLayout(jPanelCenterLayout); { jPanelWest = new JPanel(); BorderLayout jPanelWestLayout = new BorderLayout(); jPanelCenter.add(jPanelWest); jPanelWest.setLayout(jPanelWestLayout); jPanelWest.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); { jToolBarMineralTable = new JToolBar(); jToolBarMineralTable.setLayout(new FlowLayout(FlowLayout.LEFT)); jPanelWest.add(jToolBarMineralTable, BorderLayout.NORTH); jToolBarMineralTable.setFloatable(false); jToolBarMineralTable.setFocusable(false); { jButtonNew = new JButton(); jToolBarMineralTable.add(jButtonNew); jButtonNew.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/Actions-tab-new-icon.png"))); jButtonNew.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonNewActionPerformed(evt); } }); } { jButtonOpen = new JButton(); jToolBarMineralTable.add(jButtonOpen); jButtonOpen.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/open.png"))); jButtonOpen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonOpenActionPerformed(evt); } }); } { jButtonSave = new JButton(); jToolBarMineralTable.add(jButtonSave); jButtonSave.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/save.png"))); jButtonSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonSaveActionPerformed(evt); } }); } { jSeparator1 = new JSeparator(); jToolBarMineralTable.add(jSeparator1); jSeparator1.setOrientation(SwingConstants.VERTICAL); jSeparator1.setSize(5, 44); jSeparator1.setPreferredSize(new java.awt.Dimension(5, 44)); } { jButtonAdd = new JButton(); jToolBarMineralTable.add(jButtonAdd); jButtonAdd.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/add.png"))); jButtonAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonAddActionPerformed(evt); } }); } { jButtonEdit = new JButton(); jToolBarMineralTable.add(jButtonEdit); jButtonEdit.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/modify.png"))); jButtonEdit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonEditActionPerformed(evt); } }); } { jButtonRemove = new JButton(); jToolBarMineralTable.add(jButtonRemove); jButtonRemove.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/remove.png"))); jButtonRemove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonRemoveActionPerformed(evt); } }); } } { jLabelMineralTableInformation = new JLabel(); jPanelWest.add(jLabelMineralTableInformation, BorderLayout.SOUTH); jLabelMineralTableInformation .setText(DataCenter.langResource.getString("total_counted_table")); jLabelMineralTableInformation.setHorizontalAlignment(SwingConstants.LEFT); jLabelMineralTableInformation.setBackground(new java.awt.Color(255, 212, 133)); jLabelMineralTableInformation.setOpaque(true); } { jScrollPaneMineralTable = new JScrollPane(); jPanelWest.add(jScrollPaneMineralTable, BorderLayout.CENTER); { jTableMineralsModel = new RockTableModel( new String[] { DataCenter.langResource.getString("keyvalue_table"), DataCenter.langResource.getString("name_table"), DataCenter.langResource.getString("color_table"), DataCenter.langResource.getString("counted_table"), DataCenter.langResource.getString("area_table") }, 0); // jTableMineralsModel.addRow(new Object[] { // 0, "x?", Color.gray, 0, // "0.00" }); jTableMinerals = new JReadOnlyTable(); jScrollPaneMineralTable.setViewportView(jTableMinerals); jTableMinerals.setModel(jTableMineralsModel); jTableMinerals.setDefaultRenderer(Color.class, new ColorRenderer(true)); TableCellRenderer centerRenderer = new CenterRenderer(); TableColumn column = jTableMinerals.getColumnModel().getColumn(0); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(1); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(3); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(4); column.setCellRenderer(centerRenderer); } } } { jPanelEast = new JPanel(); jPanelCenter.add(jPanelEast); GridLayout jPanelEastLayout = new GridLayout(2, 1); jPanelEastLayout.setHgap(5); jPanelEastLayout.setVgap(5); jPanelEastLayout.setColumns(1); jPanelEast.setLayout(jPanelEastLayout); { jPanelTop = new JPanel(); BorderLayout jPanelTopLayout = new BorderLayout(); jPanelEast.add(jPanelTop); jPanelTop.setLayout(jPanelTopLayout); jPanelTop.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); { jToolBarStats = new JToolBar(); jPanelTop.add(jToolBarStats, BorderLayout.NORTH); jToolBarStats.setFloatable(false); jToolBarStats.setFocusable(false); { jButtonExportStats = new JButton(); jButtonExportStats.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveChartAsImage(); } }); //jToolBarStats.add(jButtonExportStats); jButtonExportStats.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/export-graph.png"))); } { jButtonExportExcel = new JButton(); //jToolBarStats.add(jButtonExportExcel); //jToolBarMineralTable.add(jButtonExportExcel); jButtonExportExcel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/excel-icon.png"))); jButtonExportExcel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { exportToExcel(); } }); } { jButtonExportAll = new JButton(); //jToolBarStats.add(jButtonExportAll); jButtonExportAll.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/Mimetypes-application-vnd-ms-excel-icon.png"))); } } { } } { jPanelBottom = new JPanel(); BorderLayout jPanelBottomLayout = new BorderLayout(); jPanelEast.add(jPanelBottom); jPanelBottom.setLayout(jPanelBottomLayout); jPanelBottom.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); { jToolBarOverview = new JToolBar(); jPanelBottom.add(jToolBarOverview, BorderLayout.NORTH); jToolBarOverview.setFloatable(false); jToolBarOverview.setFocusable(false); { jButtonExportOverview = new JButton(); jToolBarOverview.add(jButtonExportOverview); jButtonExportOverview.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/export-graph.png"))); jButtonExportOverview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { exportOverview(); } }); } } { jPanelOverviewContent = new JPanel(); jPanelBottom.add(jPanelOverviewContent, BorderLayout.CENTER); jPanelOverviewContent.setLayout(new GridBagLayout()); this.jLabelOverview = new JLabel(); jPanelOverviewContent.add(this.jLabelOverview); } } } } pack(); this.setSize(800, 600); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:edu.ku.brc.specify.utilapps.SetUpBuildDlg.java
public void createUI() { super.createUI(); Specify.setUpSystemProperties();// w w w . jav a 2 s.co m UIFieldFormatterMgr.setDoingLocal(true); driverList = DatabaseDriverInfo.getDriversList(); int inx = Collections.binarySearch(driverList, new DatabaseDriverInfo(dbDriverName, null, null, false, null)); drivers = createComboBox(driverList); drivers.setSelectedIndex(inx); catNumFmtList = (Vector<UIFieldFormatterIFace>) UIFieldFormatterMgr.getInstance() .getFormatterList(CollectionObject.class, "catalogNumber"); Collections.sort(catNumFmtList, new Comparator<UIFieldFormatterIFace>() { @Override public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) { return o1.getTitle().compareTo(o2.getTitle()); } }); for (UIFieldFormatterIFace fmt : catNumFmtList) { catNumFmtHash.put(fmt.getName(), fmt); } accNumFmtList = (Vector<UIFieldFormatterIFace>) UIFieldFormatterMgr.getInstance() .getFormatterList(Accession.class, "accessionNumber"); Collections.sort(accNumFmtList, new Comparator<UIFieldFormatterIFace>() { @Override public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) { return o1.getTitle().compareTo(o2.getTitle()); } }); for (UIFieldFormatterIFace fmt : accNumFmtList) { accNumFmtHash.put(fmt.getName(), fmt); } catNumGrpList = new Vector<String>(); catNumGrpList.add("None"); catNumGrpList.add("Cat Global"); catNumGrpList.add("Cat Test Group #1"); catNumGrpList.add("Cat Test Group #2"); for (DisciplineType d : DisciplineType.getDisciplineList()) { catNumGrpList.add("Cat " + d.getTitle() + " Group"); } accNumGrpList = new Vector<String>(); accNumGrpList.add("None"); accNumGrpList.add("Acc Global"); accNumGrpList.add("Acc Test Group #1"); accNumGrpList.add("Acc Test Group #2"); for (DisciplineType d : DisciplineType.getDisciplineList()) { accNumGrpList.add("Acc " + d.getTitle() + " Group"); } databaseNameTxt = addAutoSelect(createTextField(databaseName, 15)); dbUsernameTxtFld = addAutoSelect(createTextField(dbUser.first, 15)); dbPasswdTxtFld = addAutoSelect(createPasswordField(dbUser.second, 15)); saUsernameTxtFld = addAutoSelect(createTextField(saUser.first, 15)); saPasswdTxtFld = addAutoSelect(createPasswordField(saUser.second, 15)); usrUsernameTxtFld = addAutoSelect(createTextField(cmUser.first, 15)); usrPasswdTxtFld = addAutoSelect(createPasswordField(cmUser.second, 15)); extraCollectionsChk = createCheckBox("Create Extra Collections"); extraCollectionsChk.setSelected(true); PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p,10px,p,2px,p,10px,p,2px,p,p:g", UIHelper.createDuplicateJGoodiesDef("P", "2px", 9) + ",f:p:g,4px,p")); CellConstraints cc = new CellConstraints(); int y = 1; builder.addSeparator("Username and Passwords", cc.xyw(1, y, 12)); y += 2; builder.add(createLabel("IT Username:", SwingConstants.RIGHT), cc.xy(1, y)); builder.add(dbUsernameTxtFld, cc.xy(3, y)); builder.add(createLabel("Master Username:", SwingConstants.RIGHT), cc.xy(5, y)); builder.add(saUsernameTxtFld, cc.xy(7, y)); builder.add(createLabel("User Username:", SwingConstants.RIGHT), cc.xy(9, y)); builder.add(usrUsernameTxtFld, cc.xy(11, y)); y += 2; builder.add(createLabel("IT Password:", SwingConstants.RIGHT), cc.xy(1, y)); builder.add(dbPasswdTxtFld, cc.xy(3, y)); builder.add(createLabel("Master Password:", SwingConstants.RIGHT), cc.xy(5, y)); builder.add(saPasswdTxtFld, cc.xy(7, y)); builder.add(createLabel("User Password:", SwingConstants.RIGHT), cc.xy(9, y)); builder.add(usrPasswdTxtFld, cc.xy(11, y)); y += 2; builder.addSeparator("Database Info", cc.xyw(1, y, 12)); y += 2; builder.add(createLabel("Database Name:", SwingConstants.RIGHT), cc.xy(1, y)); builder.add(databaseNameTxt, cc.xy(3, y)); y += 2; builder.add(createLabel("Driver:", SwingConstants.RIGHT), cc.xy(1, y)); builder.add(drivers, cc.xy(3, y)); y += 2; builder.addSeparator("Collection Options", cc.xyw(1, y, 12)); y += 2; collChoiceList = loadPersistedChoices(); fillChoicesWithDefaults(); choiceTable = new JTable(new DisciplineSetupModel()); choiceTable.setRowHeight((new JComboBox()).getPreferredSize().height); TableColumn col = choiceTable.getColumnModel().getColumn(2); col.setCellEditor(new MyComboBoxEditor(catNumFmtList, catNumFmtHash)); col.setCellRenderer(new MyLabelRenderer(catNumFmtHash)); col = choiceTable.getColumnModel().getColumn(3); col.setCellEditor(new MyComboBoxStringEditor(catNumGrpList)); col = choiceTable.getColumnModel().getColumn(4); col.setCellEditor(new MyComboBoxEditor(accNumFmtList, accNumFmtHash)); col = choiceTable.getColumnModel().getColumn(5); col.setCellEditor(new MyComboBoxStringEditor(accNumGrpList)); //col.setCellRenderer(new MyComboBoxRenderer(catNumFmtList)); UIHelper.makeTableHeadersCentered(choiceTable, false); calcColumnWidths(choiceTable); builder.add(UIHelper.createScrollPane(choiceTable), cc.xywh(1, y, 12, 1)); y += 2; final JButton catGblBtn = createButton("Global Cat Nums"); final JButton accGblBtn = createButton("Global Acc Nums"); final JButton selectAllBtn = createButton("Select All"); final JButton deSelectAll = createButton("Deselect All"); final JButton defBtn = createButton("Revert"); PanelBuilder btnBar = new PanelBuilder( new FormLayout("f:p:g," + UIHelper.createDuplicateJGoodiesDef("p", "4px", 5), "p")); btnBar.add(catGblBtn, cc.xy(2, 1)); btnBar.add(accGblBtn, cc.xy(4, 1)); btnBar.add(selectAllBtn, cc.xy(6, 1)); btnBar.add(deSelectAll, cc.xy(8, 1)); btnBar.add(defBtn, cc.xy(10, 1)); builder.add(btnBar.getPanel(), cc.xywh(1, y, 12, 1)); y += 2; catGblBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setCatNumGroup("Cat Group"); } }); accGblBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setAccNumGroup("Acc Group"); } }); selectAllBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { selectAll(true); } }); deSelectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { selectAll(false); } }); cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { closeDlg(true); } }); okBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { saveChoices(collChoiceList); closeDlg(false); } }); defBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { resetDefaults(collChoiceList); } }); // make sure closing the window does the same thing as clicking cancel this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { cancelBtn.doClick(); } }); builder.setDefaultDialogBorder(); contentPanel = builder.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); pack(); Dimension size = getSize(); size.width = Math.max(size.width, 900); setSize(size); }
From source file:com.perl5.lang.htmlmason.idea.configuration.HTMLMasonSettingsConfigurable.java
protected void createCustomTagsComponent(FormBuilder builder) { myTagNameColumnInfo myTagNameColumnInfo = new myTagNameColumnInfo(); customTagsModel = new ListTableModel<HTMLMasonCustomTag>(myTagNameColumnInfo, new myTagRoleColumInfo()); myTagNameColumnInfo.setCustomTagsModel(customTagsModel); customTagsTable = new JBTable(customTagsModel); final TableColumn secondColumn = customTagsTable.getColumnModel().getColumn(1); ComboBoxTableRenderer<HTMLMasonCustomTagRole> roleComboBoxTableRenderer = new ComboBoxTableRenderer<HTMLMasonCustomTagRole>( HTMLMasonCustomTagRole.values()) { @Override/*from w w w . jav a2 s . co m*/ protected String getTextFor(@NotNull HTMLMasonCustomTagRole value) { return value.getTitle(); } @Override public boolean isCellEditable(EventObject event) { if (event instanceof MouseEvent) { return ((MouseEvent) event).getClickCount() >= 1; } return true; } }; secondColumn.setCellRenderer(roleComboBoxTableRenderer); secondColumn.setCellEditor(roleComboBoxTableRenderer); builder.addLabeledComponent(new JLabel("Custom tags that mimics built-in HTML::Mason tags:"), ToolbarDecorator.createDecorator(customTagsTable).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { final TableCellEditor cellEditor = customTagsTable.getCellEditor(); if (cellEditor != null) { cellEditor.stopCellEditing(); } final TableModel model = customTagsTable.getModel(); int indexToEdit = -1; for (HTMLMasonCustomTag entry : customTagsModel.getItems()) { if (StringUtil.isEmpty(entry.getText())) { indexToEdit = customTagsModel.indexOf(entry); break; } } if (indexToEdit == -1) { customTagsModel.addRow(new HTMLMasonCustomTag( "customTag" + customTagsModel.getItems().size(), HTMLMasonCustomTagRole.PERL)); indexToEdit = model.getRowCount() - 1; } TableUtil.editCellAt(customTagsTable, indexToEdit, 0); } }).disableDownAction().disableUpAction() .setPreferredSize(JBUI.size(0, PerlConfigurationUtil.WIDGET_HEIGHT)).createPanel()); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java
private void initContentSearchTable() { contentSearchTable// w w w.j a va 2s . c o m .setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Content Type", "Contains" }) { public boolean isCellEditable(int rowIndex, int columnIndex) { return true; } }); contentSearchTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); contentSearchTable.setDragEnabled(false); contentSearchTable.setSortable(false); contentSearchTable.getTableHeader().setReorderingAllowed(false); contentSearchTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { deleteContentSearchButton.setEnabled(getSelectedRow(contentSearchTable) != -1); } }); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { contentSearchTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } TableColumn column = contentSearchTable.getColumnModel().getColumn(0); column.setCellRenderer(new MirthComboBoxTableCellRenderer(ContentType.getDisplayValues())); column.setCellEditor(new MirthComboBoxTableCellEditor(contentSearchTable, ContentType.getDisplayValues(), 1, false, null)); column.setMinWidth(CONTENT_TYPE_COLUMN_WIDTH); column.setMaxWidth(CONTENT_TYPE_COLUMN_WIDTH); deleteContentSearchButton.setEnabled(false); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java
private void initMetaDataSearchTable() { metaDataSearchTable.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Metadata", "Operator", "Value", "Ignore Case" }) { public boolean isCellEditable(int rowIndex, int columnIndex) { if (columnIndex == 3 && cachedMetaDataColumns.get(getValueAt(rowIndex, 0)) .getType() != MetaDataColumnType.STRING) { return false; }/* w ww .j a v a2s . c o m*/ return true; } @Override public void setValueAt(Object value, int row, int column) { int metaDataColumnIndex = findColumn("Metadata"); int operatorColumnIndex = findColumn("Operator"); int valueColumnIndex = findColumn("Value"); int ignoreCaseColumnIndex = findColumn("Ignore Case"); if (column == valueColumnIndex) { MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(getValueAt(row, metaDataColumnIndex)); if (StringUtils.isNotEmpty((String) value)) { try { metaDataColumn.getType().castValue(value); } catch (MetaDataColumnException e) { parent.alertError(parent, "Invalid value for column type " + metaDataColumn.getType().toString()); return; } } } else if (column == metaDataColumnIndex) { if (!value.equals(getValueAt(row, metaDataColumnIndex))) { MetaDataSearchOperator operator = MetaDataSearchOperator.EQUAL; super.setValueAt(operator, row, operatorColumnIndex); MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(value); if (metaDataColumn.getType() != MetaDataColumnType.STRING) { super.setValueAt(Boolean.FALSE, row, ignoreCaseColumnIndex); } } super.setValueAt("", row, valueColumnIndex); } super.setValueAt(value, row, column); } }); metaDataSearchTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); metaDataSearchTable.setDragEnabled(false); metaDataSearchTable.setSortable(false); metaDataSearchTable.getTableHeader().setReorderingAllowed(false); addMetaDataSearchButton.setEnabled(!messageBrowser.getMetaDataColumns().isEmpty()); metaDataSearchTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { deleteMetaDataSearchButton.setEnabled(getSelectedRow(metaDataSearchTable) != -1); } }); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { metaDataSearchTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } List<MetaDataColumn> metaDataColumns = messageBrowser.getMetaDataColumns(); cachedMetaDataColumns.clear(); String[] metaDataNames = new String[metaDataColumns.size()]; for (int i = 0; i < metaDataColumns.size(); i++) { String columnName = metaDataColumns.get(i).getName(); metaDataNames[i] = columnName; cachedMetaDataColumns.put(columnName, metaDataColumns.get(i)); } MirthComboBoxTableCellEditor metaDataEditor = new MirthComboBoxTableCellEditor(metaDataSearchTable, metaDataNames, 1, false, null); metaDataEditor.getComboBox().setAutoResizeDropdown(true); TableColumn metaDataColumn = metaDataSearchTable.getColumnModel().getColumn(0); metaDataColumn.setCellRenderer(new MirthComboBoxTableCellRenderer(metaDataNames)); metaDataColumn.setCellEditor(metaDataEditor); metaDataColumn.setMinWidth(METADATA_NAME_COLUMN_WIDTH); metaDataColumn.setMaxWidth(METADATA_NAME_COLUMN_WIDTH * 2); metaDataColumn.setPreferredWidth(METADATA_NAME_COLUMN_WIDTH); // Need to create this custom editor since the combo box values are dynamic based on metadata column type. MirthComboBoxTableCellEditor operatorEditor = new MirthComboBoxTableCellEditor(metaDataSearchTable, MetaDataSearchOperator.values(), 1, false, null) { public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(table.getValueAt(row, 0)); comboBox.setModel(new DefaultComboBoxModel( MetaDataSearchOperator.valuesForColumnType(metaDataColumn.getType()))); return super.getTableCellEditorComponent(table, value, isSelected, row, column); } }; TableColumn operatorColumn = metaDataSearchTable.getColumnModel().getColumn(1); operatorColumn.setCellRenderer(new MirthComboBoxTableCellRenderer(MetaDataSearchOperator.values())); operatorColumn.setCellEditor(operatorEditor); operatorColumn.setMinWidth(METADATA_OPERATOR_COLUMN_WIDTH); operatorColumn.setMaxWidth(METADATA_OPERATOR_COLUMN_WIDTH); TableColumn caseColumn = metaDataSearchTable.getColumnModel().getColumn(3); caseColumn.setMinWidth(METADATA_CASE_COLUMN_WIDTH); caseColumn.setMaxWidth(METADATA_CASE_COLUMN_WIDTH); deleteMetaDataSearchButton.setEnabled(false); }