List of usage examples for javax.swing.event TableModelListener TableModelListener
TableModelListener
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSubtitleSettingsPanel.java
private void initComponents() { // data init/*from ww w . j a v a 2 s . com*/ List<String> enabledSubtitleProviders = settings.getTvShowSubtitleScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : TvShowList.getInstance().getAvailableSubtitleScrapers()) { SubtitleScraper subtitleScraper = new SubtitleScraper(scraper); if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) { subtitleScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(subtitleScraper); counter++; } // UI init setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelSubtitleScrapers = new JPanel(); panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill"); panelSubtitleScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), })); final JScrollPane scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill"); JPanel panelScraperDetails = new JPanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); } panelScraperOptions = new ScrollablePanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JScrollPane scrollPaneScraper = new JScrollPane(); panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ add(lblScraperLanguage, "2, 4, right, default"); cbScraperLanguage = new JComboBox(MediaLanguages.values()); add(cbScraperLanguage, "4, 4, fill, default"); initDataBindings(); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); SubtitleScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addTvShowSubtitleScraper(changedScraper.getScraperId()); } else { settings.removeTvShowSubtitleScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default tv show subtitle scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.ut.biolab.medsavant.client.region.RegionWizard.java
private AbstractWizardPage getGenesPage() { return new DefaultWizardPage(PAGENAME_GENES) { private static final int GENE_SELECTION_PANE_WIDTH = 350; private JPanel leftSide; private GeneSelectionPanel geneManiaResultsPanel; private Set<String> geneManiaGeneNames = null; {// ww w.j a v a2s. co m selectedGenesPanel = new GeneSelectionPanel(true, true); sourceGenesPanel = new GeneSelectionPanel(true, true); geneManiaResultsPanel = new GeneSelectionPanel(true, true) { @Override protected void dragAndDropAddGenes(Set<Gene> geneSet) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } @Override protected void dragAndDropRemoveKeys(Set<Object> keySet) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.removeRows(keys); sourceGenesPanel.removeRows(keys); } }; geneManiaResultsPanel.setOddRowColor(new Color(242, 249, 245)); runGeneManiaButton = new JButton("Run GeneMANIA"); runGeneManiaButton.setEnabled(!DirectorySettings.isGeneManiaInstalled()); ListSelectionListener selectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent lse) { int numSel = sourceGenesPanel.getNumSelected() + selectedGenesPanel.getNumSelected(); if (geneManiaGeneNames != null) { numSel += geneManiaResultsPanel.getNumSelected(); } if (GenemaniaInfoRetriever.isGeneManiaDownloading()) { runGeneManiaButton.setEnabled(false); } else { runGeneManiaButton.setEnabled(numSel > 0 || !DirectorySettings.isGeneManiaInstalled()); } } }; sourceGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener); selectedGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener); selectedGenesPanel.getTable().getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tme) { if (selectedGenesPanel.getData().length > 0) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }); selectedGenesPanel.setPreferredSize( new Dimension(GENE_SELECTION_PANE_WIDTH, selectedGenesPanel.getPreferredSize().height)); final JPanel outerLeftSide = new JPanel(); outerLeftSide.setLayout(new BoxLayout(outerLeftSide, BoxLayout.X_AXIS)); leftSide = new JPanel(); leftSide.setLayout(new BoxLayout(leftSide, BoxLayout.Y_AXIS)); leftSide.add(sourceGenesPanel); outerLeftSide.add(leftSide); final JPanel bg = new JPanel(); bg.setLayout(new BoxLayout(bg, BoxLayout.Y_AXIS)); JButton addButton = new JButton("Add "); JButton removeButton = new JButton("? Remove"); sourceGenesPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { sourceGenesPanel.moveSelectedItems(selectedGenesPanel); } } }); selectedGenesPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { if (geneManiaGeneNames != null) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); } selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } } }); geneManiaResultsPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel); sourceGenesPanel.moveItems(selectedGenesPanel, keys); } } }); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (geneManiaGeneNames != null) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel); sourceGenesPanel.moveItems(selectedGenesPanel, keys); } else { sourceGenesPanel.moveSelectedItems(selectedGenesPanel); } } }); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (geneManiaGeneNames != null) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); } selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } }); bg.add(Box.createVerticalGlue()); bg.add(addButton); bg.add(removeButton); bg.add(Box.createVerticalGlue()); outerLeftSide.add(bg); JPanel rightSide = new JPanel(); rightSide.setLayout(new BoxLayout(rightSide, BoxLayout.Y_AXIS)); rightSide.add(selectedGenesPanel); rightSide.add(runGeneManiaButton); final JSplitPane hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, outerLeftSide, rightSide); hsplitPane.setResizeWeight(1); addComponent(hsplitPane, true); if (!DirectorySettings.isGeneManiaInstalled()) { runGeneManiaButton.setText("Download GeneMANIA"); if (GenemaniaInfoRetriever.isGeneManiaDownloading()) { runGeneManiaButton.setEnabled(false); registerDownloadListener(); } } runGeneManiaButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (!DirectorySettings.isGeneManiaInstalled()) { int response = DialogUtils.askYesNo("Download GeneMANIA?", "GeneMANIA is not yet installed. Do you want to download and install it now?"); try { if (response == DialogUtils.OK) { runGeneManiaButton.setText("Run GeneMANIA"); runGeneManiaButton.setEnabled(false); registerDownloadListener(); /* DownloadTask dt = GenemaniaInfoRetriever.getGeneManiaDownloadTask(); dt.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("downloadState")) { DownloadTask.DownloadState ds = (DownloadTask.DownloadState) evt.getNewValue(); if (ds == DownloadTask.DownloadState.CANCELLED || ds == DownloadTask.DownloadState.FINISHED) { runGeneManiaButton.setEnabled( (selectedGenesPanel.getNumSelected() + sourceGenesPanel.getNumSelected()) > 0); } } } }); */ GenemaniaInfoRetriever.getGeneManiaDownloadTask().execute(); } } catch (IOException e) { DialogUtils.displayMessage("Error downloading GeneMANIA files"); LOG.error(e); } } else { final List<String> selectedGenes = new LinkedList<String>(); for (Gene g : selectedGenesPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } for (Gene g : sourceGenesPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } if (geneManiaGeneNames != null) { for (Gene g : geneManiaResultsPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } } final JButton closeGeneManiaButton = new JButton("? Close GeneMANIA results"); closeGeneManiaButton.setEnabled(false); final JPanel geneManiaContainingPanel = new JPanel(); geneManiaContainingPanel .setLayout(new BoxLayout(geneManiaContainingPanel, BoxLayout.Y_AXIS)); final SwingWorker geneManiaWorker = new SwingWorker() { private List<Object[]> results; @Override public void done() { Object[][] newdata = new Object[results.size()][4]; results.toArray(newdata); geneManiaResultsPanel.updateData(newdata); geneManiaResultsPanel.updateView(); geneManiaContainingPanel.removeAll(); geneManiaContainingPanel.add(geneManiaResultsPanel); geneManiaContainingPanel.revalidate(); geneManiaContainingPanel.repaint(); closeGeneManiaButton.setEnabled(true); } @Override public Object doInBackground() { try { GenemaniaInfoRetriever genemania = new GenemaniaInfoRetriever(); genemania.setGenes(selectedGenes); List<String> geneNameList = genemania.getRelatedGeneNamesByScore(); geneManiaGeneNames = new HashSet<String>(); geneManiaGeneNames.addAll(geneNameList); LOG.debug("Found " + geneNameList.size() + " related genes"); results = new ArrayList<Object[]>(geneNameList.size()); int i = 0; for (String gene : geneNameList) { if (isCancelled()) { return null; } Gene g = GeneSetFetcher.getInstance().getGeneDictionary().get(gene); if (g == null) { LOG.warn("No gene found for " + gene); } else if (!selectedGenesPanel.hasKey(g.getName())) { results.add(new Object[] { g.getName(), g.getChrom(), g.getStart(), g.getEnd() }); } } } catch (IOException e) { LOG.error(e); } catch (ApplicationException e) { LOG.error(e); } catch (DataStoreException e) { LOG.error(e); } catch (NoRelatedGenesInfoException e) { LOG.error(e); } return null; } }; leftSide.removeAll(); closeGeneManiaButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { geneManiaWorker.cancel(true); } catch (Exception e) { //genemania throws exceptions when cancelled } leftSide.removeAll(); leftSide.add(sourceGenesPanel); leftSide.validate(); leftSide.repaint(); geneManiaGeneNames = null; } }); JPanel closeButtonPanel = new JPanel(); closeButtonPanel.setLayout(new BoxLayout(closeButtonPanel, BoxLayout.X_AXIS)); closeButtonPanel.add(closeGeneManiaButton); closeButtonPanel.add(Box.createHorizontalGlue()); leftSide.add(closeButtonPanel); geneManiaContainingPanel.add(new WaitPanel("Querying GeneMANIA for related genes")); leftSide.add(geneManiaContainingPanel); leftSide.validate(); leftSide.repaint(); geneManiaWorker.execute(); } //end else }//end actionPerformed });//end ActionListener } @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); if (selectedGenesPanel.getNumSelected() > 0) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }; }
From source file:org.ut.biolab.medsavant.client.view.dialog.FamilySelector.java
private void initUI() { JPanel p = new JPanel(); ViewUtil.applyVerticalBoxLayout(p);// w ww. j a v a 2 s . c o m this.add(p); topPanel = ViewUtil.getClearPanel(); middlePanel = ViewUtil.getClearPanel(); bottomPanel = ViewUtil.getClearPanel(); p.add(topPanel); p.add(middlePanel); p.add(bottomPanel); // middle middlePanel.setLayout(new BorderLayout()); retriever = new FamilyReceiver(); stp = new SearchableTablePanel("Individuals", COLUMN_NAMES, COLUMN_CLASSES, HIDDEN_COLUMNS, true, true, Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW, Integer.MAX_VALUE, retriever); stp.setExportButtonVisible(false); middlePanel.add(stp, BorderLayout.CENTER); // bottom ViewUtil.applyVerticalBoxLayout(bottomPanel); numselections = ViewUtil.getTitleLabel("0 families selected"); JPanel text = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(text); JButton clearIndividuals = ViewUtil .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE)); clearIndividuals.setToolTipText("Clear selections"); clearIndividuals.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { clearSelections(); } }); text.add(numselections); text.add(Box.createHorizontalStrut(5)); text.add(clearIndividuals); bottomPanel.add(ViewUtil.centerHorizontally(text)); final JButton addAllIndividuals = ViewUtil.getSoftButton("Add All"); bottomPanel.add(addAllIndividuals); final JButton addIndividuals = ViewUtil.getSoftButton("Add Selected"); bottomPanel.add(addIndividuals); final JButton removeIndividuals = ViewUtil.getSoftButton("Remove Selected"); bottomPanel.add(removeIndividuals); final JButton removeAllIndividuals = ViewUtil.getSoftButton("Remove All"); bottomPanel.add(removeAllIndividuals); JPanel buttons = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(buttons); buttons.add(addAllIndividuals); buttons.add(addIndividuals); buttons.add(removeIndividuals); buttons.add(removeAllIndividuals); JPanel windowControlPanel = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(windowControlPanel); windowControlPanel.add(Box.createHorizontalGlue()); JButton cancel = new JButton("Cancel"); bottomPanel.add(ViewUtil.centerHorizontally(buttons)); ok = new JButton("OK"); bottomPanel.add(ViewUtil.alignRight(ok)); ok.setEnabled(false); windowControlPanel.add(cancel); windowControlPanel.add(ok); bottomPanel.add(windowControlPanel); final JDialog instance = this; ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { instance.setVisible(false); setIndividualsChosen(true); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { instance.setVisible(false); setIndividualsChosen(false || hasMadeSelections); } }); addIndividuals.setEnabled(false); removeIndividuals.setEnabled(false); stp.getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent lse) { if (!lse.getValueIsAdjusting()) { int rows[] = stp.getTable().getSelectedRows(); boolean someSelection = rows.length > 0; addIndividuals.setEnabled(someSelection); removeIndividuals.setEnabled(someSelection); if (someSelection) { addIndividuals.setText("Add Selected (" + rows.length + ")"); removeIndividuals.setText("Remove Selected (" + rows.length + ")"); } else { addIndividuals.setText("Add Selected"); removeIndividuals.setText("Remove Selected"); } } } }); stp.getTable().getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tme) { //addAllIndividuals.setText("Add All (" + stp.getTable().getModel().getRowCount() + ")"); //removeAllIndividuals.setText("Remove All (" + stp.getTable().getModel().getRowCount() + ")"); } }); ActionListener addAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { addSelections(false); } }; ActionListener addAllAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { addSelections(true); } }; ActionListener removeAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { removeSelections(false); } }; ActionListener removeAllAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { removeSelections(true); } }; addIndividuals.addActionListener(addAction); addAllIndividuals.addActionListener(addAllAction); removeIndividuals.addActionListener(removeAction); removeAllIndividuals.addActionListener(removeAllAction); this.pack(); this.setLocationRelativeTo(MedSavantFrame.getInstance()); }
From source file:org.ut.biolab.medsavant.client.view.dialog.IndividualSelector.java
private void initUI() { JPanel p = new JPanel(); ViewUtil.applyVerticalBoxLayout(p);/*from w w w .j a v a 2 s.c om*/ this.add(p); topPanel = ViewUtil.getClearPanel(); middlePanel = ViewUtil.getClearPanel(); bottomPanel = ViewUtil.getClearPanel(); p.add(topPanel); p.add(middlePanel); p.add(bottomPanel); // Only display the bottom panel for multiple patient selection if (onlyOnePatient) { bottomPanel.setVisible(false); } // middle middlePanel.setLayout(new BorderLayout()); individualsRetriever = new IndividualsReceiver(); individualsSTP = new SearchableTablePanel("Individuals", COLUMN_NAMES, COLUMN_CLASSES, HIDDEN_COLUMNS, true, true, Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW, Integer.MAX_VALUE, individualsRetriever); individualsSTP.setExportButtonVisible(false); //If patients or cohorts are edited, update the searchabletable. CacheController.getInstance().addListener(new Listener<ModificationType>() { @Override public void handleEvent(ModificationType event) { if (event == ModificationType.PATIENT || event == ModificationType.COHORT) { if (!individualsSTP.isUpdating()) { forceRefresh = true; individualsSTP.forceRefreshData(); } } } }); middlePanel.add(individualsSTP, BorderLayout.CENTER); // bottom ViewUtil.applyVerticalBoxLayout(bottomPanel); numselections = ViewUtil.getTitleLabel("0 individual(s) selected"); JPanel text = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(text); JButton clearIndividuals = ViewUtil .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE)); clearIndividuals.setToolTipText("Clear selections"); clearIndividuals.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { clearSelections(); } }); text.add(numselections); text.add(Box.createHorizontalStrut(5)); text.add(clearIndividuals); bottomPanel.add(ViewUtil.centerHorizontally(text)); final JButton addAllIndividuals = ViewUtil.getSoftButton("Add All"); bottomPanel.add(addAllIndividuals); final JButton addIndividuals = ViewUtil.getSoftButton("Add Selected"); bottomPanel.add(addIndividuals); final JButton removeIndividuals = ViewUtil.getSoftButton("Remove Selected"); bottomPanel.add(removeIndividuals); final JButton removeAllIndividuals = ViewUtil.getSoftButton("Remove All"); bottomPanel.add(removeAllIndividuals); JPanel buttons = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(buttons); buttons.add(addAllIndividuals); buttons.add(addIndividuals); buttons.add(removeIndividuals); buttons.add(removeAllIndividuals); JPanel windowControlPanel = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(windowControlPanel); windowControlPanel.add(Box.createHorizontalGlue()); JButton cancel = new JButton("Cancel"); bottomPanel.add(ViewUtil.centerHorizontally(buttons)); ok = new JButton("OK"); bottomPanel.add(ViewUtil.alignRight(ok)); ok.setEnabled(false); windowControlPanel.add(cancel); windowControlPanel.add(ok); bottomPanel.add(windowControlPanel); final JDialog instance = this; ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { instance.setVisible(false); setIndividualsChosen(true); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { instance.setVisible(false); setIndividualsChosen(false || hasMadeSelections); } }); addIndividuals.setEnabled(false); removeIndividuals.setEnabled(false); individualsSTP.getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent lse) { if (!lse.getValueIsAdjusting()) { int rows[] = individualsSTP.getTable().getSelectedRows(); boolean someSelection = rows.length > 0; addIndividuals.setEnabled(someSelection); removeIndividuals.setEnabled(someSelection); if (someSelection) { addIndividuals.setText("Add Selected (" + rows.length + ")"); removeIndividuals.setText("Remove Selected (" + rows.length + ")"); } else { addIndividuals.setText("Add Selected"); removeIndividuals.setText("Remove Selected"); } /* Close the dialog if only a single individual is requested. */ if (onlyOnePatient && rows.length == 1) { selectedRows.clear(); selectedHospitalIDs.clear(); int realRow = individualsSTP.getActualRowAt(rows[0]); selectedRows.add(realRow); Object[] o = individualsRetriever.getIndividuals().get(realRow); selectedHospitalIDs.add(o[INDEX_OF_HOSPITAL_ID].toString()); instance.setVisible(false); setIndividualsChosen(true); individualsSTP.getTable().clearSelection(); // if errors crop up, this line may be causing ListSelectionEvents - can be removed } } } }); individualsSTP.getTable().getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tme) { //addAllIndividuals.setText("Add All (" + stp.getTable().getModel().getRowCount() + ")"); //removeAllIndividuals.setText("Remove All (" + stp.getTable().getModel().getRowCount() + ")"); } }); ActionListener addAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { addSelections(false); } }; ActionListener addAllAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { addSelections(true); } }; ActionListener removeAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { removeSelections(false); } }; ActionListener removeAllAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { removeSelections(true); } }; addIndividuals.addActionListener(addAction); addAllIndividuals.addActionListener(addAllAction); removeIndividuals.addActionListener(removeAction); removeAllIndividuals.addActionListener(removeAllAction); this.pack(); this.setLocationRelativeTo(MedSavantFrame.getInstance()); }
From source file:pl.otros.logview.gui.LogViewPanelWrapper.java
private void addRowScroller() { dataTableModel.addTableModelListener(new TableModelListener() { @Override//www .j a va 2s . c o m public void tableChanged(final TableModelEvent e) { if (follow.isSelected() && e.getType() == TableModelEvent.INSERT) { final Runnable r = new Runnable() { @Override public void run() { try { JTable table = logViewPanel.getTable(); int row = table.getRowCount() - 1; if (row > 0) { Rectangle rect = table.getCellRect(row, 0, true); table.scrollRectToVisible(rect); table.clearSelection(); table.setRowSelectionInterval(row, row); } } catch (IllegalArgumentException iae) { // ignore..out of bounds iae.printStackTrace(); } } }; // Wait for JViewPort size update // TODO Find way to invoke this listener after viewport is notified about changes Runnable r2 = new Runnable() { @Override public void run() { try { Thread.sleep(300); } catch (InterruptedException ignore) { } SwingUtilities.invokeLater(r); } }; new Thread(r2).start(); } } }); }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private void initGui(final String initialPath) { this.setLayout(new BorderLayout()); JLabel pathLabel = new JLabel(Messages.getMessage("browser.location")); pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); pathField = new JTextField(80); pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f)); pathField.setToolTipText(Messages.getMessage("nav.pathTooltip")); GuiUtils.addBlinkOnFocusGain(pathField); pathLabel.setLabelFor(pathField);// ww w. j a v a 2 s .c o m pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0)); InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED); inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH"); inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) { @Override protected void performLongOperation(CheckBeforeActionResult actionResult) { try { FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim()); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); actionApproveDelegate.actionPerformed( // TODO: Does actionResult provide an ID for 2nd param here, // or should use a Random number? new ActionEvent(actionResult, (int) new java.util.Date().getTime(), "SELECTED_FILE")); return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(pathField.getText().trim()); } @Override protected boolean canGoUrl() { return true; } @Override protected boolean canExecuteDefaultAction() { return false; } }); actionFocusOnTable = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { tableFiles.requestFocusInWindow(); if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) { tableFiles.getSelectionModel().setSelectionInterval(0, 0); } } }; pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this); goUpButton = new JButton(goUpAction); BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this); JButton refreshButton = new JButton(refreshAction); JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName")); upperPanel.setRollover(true); upperPanel.add(pathLabel); upperPanel.add(pathField, "growx"); upperPanel.add(goUpButton); upperPanel.add(refreshButton); AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction( this); JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction); addCurrentLocationToFavoriteButton.setText(""); upperPanel.add(addCurrentLocationToFavoriteButton); previewComponent = new PreviewComponent(); vfsTableModel = new VfsTableModel(); tableFiles = new JTable(vfsTableModel); tableFiles.setFillsViewportHeight(true); tableFiles.getColumnModel().getColumn(0).setMinWidth(140); tableFiles.getColumnModel().getColumn(1).setMaxWidth(80); tableFiles.getColumnModel().getColumn(2).setMaxWidth(80); tableFiles.getColumnModel().getColumn(3).setMaxWidth(180); tableFiles.getColumnModel().getColumn(3).setMinWidth(120); sorter = new TableRowSorter<VfsTableModel>(vfsTableModel); final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator(); sorter.addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { RowSorterEvent.Type type = e.getType(); if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) { List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys(); for (RowSorter.SortKey sortKey : sortKeys) { if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) { fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder()); } } } } }); sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator); tableFiles.setRowSorter(sorter); tableFiles.setShowGrid(false); tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { try { selectionChanged(); } catch (FileSystemException e1) { LOGGER.error("Error during update state", e); } } }); tableFiles.setColumnSelectionAllowed(false); vfsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateStatusText(); } }); tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer()); tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer()); tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer()); tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer()); tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent)); JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]")); favoritesUserListModel = new MutableListModel<Favorite>(); List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations(); List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration); List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks(); for (Favorite favorite : favUser) { favoritesUserListModel.add(favorite); } favoritesUserListModel.addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { saveFavorites(); } @Override public void intervalRemoved(ListDataEvent e) { saveFavorites(); } @Override public void contentsChanged(ListDataEvent e) { saveFavorites(); } protected void saveFavorites() { FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList()); } }); favoritesUserList = new JList(favoritesUserListModel); favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList)); new MutableListDragListener(favoritesUserList); favoritesUserList.setCellRenderer(new FavoriteListCellRenderer()); favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter()); addOpenActionToList(favoritesUserList); addEditActionToList(favoritesUserList, favoritesUserListModel); favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction( Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) { @Override public void actionPerformed(ActionEvent e) { Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex()); if (!Favorite.Type.USER.equals(favorite.getType())) { return; } int response = JOptionPane.showConfirmDialog(VfsBrowser.this, Messages.getMessage("favorites.areYouSureToDeleteConnections"), Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { favoritesUserListModel.remove(favoritesUserList.getSelectedIndex()); } } }); InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED); favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE); ActionMap actionMap = tableFiles.getActionMap(); actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this)); actionMap.put(ACTION_GO_UP, goUpAction); actionMap.put(ACTION_APPROVE, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (actionApproveButton.isEnabled()) { actionApproveDelegate.actionPerformed(e); } } }); InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE); inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP); addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE); JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations)); favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer()); addOpenActionToList(favoriteSystemList); addPopupMenu(favoriteSystemList, ACTION_OPEN); favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter()); JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser)); addOpenActionToList(favoriteJVfsList); favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer()); addPopupMenu(favoriteJVfsList, ACTION_OPEN); favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter()); JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"), COMPUTER_ICON); favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList); favoritesSystemLocationsLabel .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0)); favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16"); favoritesPanel.add(favoriteSystemList, "growx"); JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"), Icons.getInstance().getStar()); favoritesFavoritesLabel.setLabelFor(favoritesUserList); favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0)); favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16"); favoritesPanel.add(favoritesUserList, "growx"); if (favoriteJVfsList.getModel().getSize() > 0) { JLabel favoritesJVfsFileChooser = getTitleListLabel( Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null); favoritesJVfsFileChooser.setDisplayedMnemonic( Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0)); favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList); favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16"); favoritesPanel.add(favoriteJVfsList, "growx"); } tableFiles.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null); } } }); tableFiles.addKeyListener(new QuickSearchKeyAdapter()); cardLayout = new CardLayout(); tablePanel = new JPanel(cardLayout); loadingProgressBar = new JProgressBar(); loadingProgressBar.setStringPainted(true); loadingProgressBar.setString(Messages.getMessage("browser.loading")); loadingProgressBar.setIndeterminate(true); loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline()); skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks")); skipCheckingLinksButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (taskContext != null) { taskContext.setStop(skipCheckingLinksButton.isSelected()); } } }); showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden); showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip")); showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0)); Font tmpFont = showHidCheckBox.getFont(); showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f)); showHidCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUiFilters(); } }); final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText"); filterField = new JTextField("", 16); filterField.setForeground(filterField.getDisabledTextColor()); filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip")); PromptSupport.setPrompt(defaultFilterText, filterField); filterField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { documentChanged(); } void documentChanged() { if (filterField.getText().length() == 0) { updateUiFilters(); } } @Override public void removeUpdate(DocumentEvent e) { documentChanged(); } @Override public void changedUpdate(DocumentEvent e) { documentChanged(); } }); filterField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { updateUiFilters(); } }); AbstractAction actionClearRegexFilter = new AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) { @Override public void actionPerformed(ActionEvent e) { filterField.setText(""); } }; filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_CLEAR_REGEX_FILTER); JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter")); nameFilterLabel.setLabelFor(filterField); nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0)); sorter.setRowFilter(createFilter()); statusLabel = new JLabel(); actionApproveButton = new JButton(); actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD)); actionCancelButton = new JButton(); ActionMap browserActionMap = this.getActionMap(); browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { filterField.requestFocus(); filterField.selectAll(); GuiUtils.blinkComponent(filterField); } }); browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField)); browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox)); browserActionMap.put(ACTION_REFRESH, refreshAction); browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction); browserActionMap.put(ACTION_GO_UP, goUpAction); browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles)); InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER); browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN); browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES); browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP); browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE); //DO layout // create the layer for the panel using our custom layerUI tableScrollPane = new JScrollPane(tableFiles); JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout()); tableScrollPaneWithFilter.add(tableScrollPane); JToolBar filtersToolbar = new JToolBar("Filters"); filtersToolbar.setFloatable(false); filtersToolbar.setBorderPainted(true); tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH); filtersToolbar.add(nameFilterLabel); filtersToolbar.add(filterField); filtersToolbar.add(showHidCheckBox); JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, tableScrollPaneWithFilter, previewComponent); tableWithPreviewPane.setOneTouchExpandable(true); JPanel loadingPanel = new JPanel(new MigLayout()); loadingPanel.add(loadingIconLabel, "right"); loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap"); loadingPanel.add(skipCheckingLinksButton, "span, right"); tablePanel.add(loadingPanel, LOADING); tablePanel.add(tableWithPreviewPane, TABLE); JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel), tablePanel); jSplitPane.setOneTouchExpandable(true); jSplitPane.setDividerLocation(180); JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", "")); southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); southPanel.add(statusLabel); southPanel.add(actionApproveButton); southPanel.add(actionCancelButton); this.add(upperPanel, BorderLayout.NORTH); this.add(jSplitPane, BorderLayout.CENTER); this.add(southPanel, BorderLayout.SOUTH); try { selectionChanged(); } catch (FileSystemException e) { LOGGER.error("Can't initialize default selection mode", e); } // Why this not done in EDT? // Is it assume that constructor is invoked from an EDT? try { if (initialPath == null) { goToUrl(VFSUtils.getUserHome()); } else { try { FileObject resolveFile = VFSUtils.resolveFileObject(initialPath); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); targetFileSelected = true; return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(initialPath); } } catch (FileSystemException e1) { LOGGER.error("Can't initialize default location", e1); } showTable(); }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Singleton pattern : private constructor Use instead. *///from w w w.ja v a 2 s.c om private MMMainFrame() { super(NODE_NAME, false, true, false, true); instancing = true; // -------------- // INITIALIZATION // -------------- _sysConfigFile = ""; _isConfigLoaded = false; _root = PluginPreferences.getPreferences().node(NODE_NAME); final MainFrame mainFrame = Icy.getMainInterface().getMainFrame(); // -------------- // PROGRESS FRAME // -------------- ThreadUtil.invokeLater(new Runnable() { @Override public void run() { _progressFrame = new IcyFrame("", false, false, false, false); _progressBar = new JProgressBar(); _progressBar.setString("Please wait while loading..."); _progressBar.setStringPainted(true); _progressBar.setIndeterminate(true); _progressBar.setMinimum(0); _progressBar.setMaximum(1000); _progressBar.setBounds(50, 50, 100, 30); _progressFrame.setSize(300, 100); _progressFrame.setResizable(false); _progressFrame.add(_progressBar); _progressFrame.addToMainDesktopPane(); loadConfig(true); if (_sysConfigFile == "") { instancing = false; return; } ThreadUtil.bgRun(new Runnable() { @Override public void run() { while (!_isConfigLoaded) { if (!instancing) return; try { Thread.sleep(10); } catch (InterruptedException e) { } } ThreadUtil.invokeLater(new Runnable() { @Override public void run() { // -------------------- // START INITIALIZATION // -------------------- if (_progressBar != null) getContentPane().remove(_progressBar); if (mCore == null) { close(); return; } // ReportingUtils.setCore(mCore); _afMgr = new AutofocusManager(MMMainFrame.this); acqMgr = new AcquisitionManager(); PositionList posList = new PositionList(); _camera_label = MMCoreJ.getG_Keyword_CameraName(); if (_camera_label == null) _camera_label = ""; try { setPositionList(posList); } catch (MMScriptException e1) { e1.printStackTrace(); } posListDlg_ = new PositionListDlg(mCore, MMMainFrame.this, _posList, null, dlg); posListDlg_.setModalityType(ModalityType.APPLICATION_MODAL); callback = new EventCallBackManager(); mCore.registerCallback(callback); engine_ = new AcquisitionWrapperEngineIcy(); engine_.setParentGUI(MMMainFrame.this); engine_.setCore(mCore, getAutofocusManager()); engine_.setPositionList(getPositionList()); setSystemMenuCallback(new MenuCallback() { @Override public JMenu getMenu() { JMenu toReturn = MMMainFrame.this.getDefaultSystemMenu(); JMenuItem hconfig = new JMenuItem("Configuration Wizard"); hconfig.setIcon(new IcyIcon("cog", MENU_ICON_SIZE)); hconfig.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!_pluginListEmpty && !ConfirmDialog.confirm("Are you sure ?", "<html>Loading the Configuration Wizard will unload all the devices and pause all running acquisitions.</br> Are you sure you want to continue ?</html>")) return; notifyConfigAboutToChange(null); try { mCore.unloadAllDevices(); } catch (Exception e1) { e1.printStackTrace(); } String previous_config = _sysConfigFile; ConfiguratorDlg2 configurator = new ConfiguratorDlg2(mCore, _sysConfigFile); configurator.setVisible(true); String res = configurator.getFileName(); if (_sysConfigFile == "" || _sysConfigFile == res || res == "") { _sysConfigFile = previous_config; loadConfig(); } refreshGUI(); notifyConfigChanged(null); } }); JMenuItem menuPxSizeConfigItem = new JMenuItem("Pixel Size Config"); menuPxSizeConfigItem.setIcon(new IcyIcon("link", MENU_ICON_SIZE)); menuPxSizeConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); menuPxSizeConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CalibrationListDlg dlg = new CalibrationListDlg(mCore); dlg.setDefaultCloseOperation(2); dlg.setParentGUI(MMMainFrame.this); dlg.setVisible(true); dlg.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { super.windowClosed(e); notifyConfigChanged(null); } }); notifyConfigAboutToChange(null); } }); JMenuItem loadConfigItem = new JMenuItem("Load Configuration"); loadConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); loadConfigItem.setIcon(new IcyIcon("folder_open", MENU_ICON_SIZE)); loadConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadConfig(); initializeGUI(); refreshGUI(); } }); JMenuItem saveConfigItem = new JMenuItem("Save Configuration"); saveConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); saveConfigItem.setIcon(new IcyIcon("save", MENU_ICON_SIZE)); saveConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveConfig(); } }); JMenuItem advancedConfigItem = new JMenuItem("Advanced Configuration"); advancedConfigItem.setIcon(new IcyIcon("wrench_plus", MENU_ICON_SIZE)); advancedConfigItem.addActionListener(new ActionListener() { /** */ @Override public void actionPerformed(ActionEvent e) { new ToolTipFrame( "<html><h3>About Advanced Config</h3><p>Advanced Configuration is a tool " + "in which you fill some data <br/>about your configuration that some " + "plugins may need to access to.<br/> Exemple: the real values of the magnification" + "of your objectives.</p></html>", "MM4IcyAdvancedConfig"); if (advancedDlg == null) advancedDlg = new AdvancedConfigurationDialog(); advancedDlg.setVisible(!advancedDlg.isVisible()); advancedDlg.setLocationRelativeTo(mainFrame); } }); JMenuItem loadPresetConfigItem = new JMenuItem( "Load Configuration Presets"); loadPresetConfigItem.setIcon(new IcyIcon("doc_import", MENU_ICON_SIZE)); loadPresetConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { notifyConfigAboutToChange(null); loadPresets(); notifyConfigChanged(null); } }); JMenuItem savePresetConfigItem = new JMenuItem( "Save Configuration Presets"); savePresetConfigItem.setIcon(new IcyIcon("doc_export", MENU_ICON_SIZE)); savePresetConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { savePresets(); } }); JMenuItem aboutItem = new JMenuItem("About"); aboutItem.setIcon(new IcyIcon("info", MENU_ICON_SIZE)); aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JDialog dialog = new JDialog(mainFrame, "About"); JPanel panel_container = new JPanel(); panel_container .setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); JPanel center = new JPanel(new BorderLayout()); final JLabel value = new JLabel("<html><body>" + "<h2>About</h2><p>Micro-Manager for Icy is being developed by Thomas Provoost." + "<br/>Copyright 2011, Institut Pasteur</p><br/>" + "<p>This plugin is based on Micro-Manager v1.4.6. which is developed under the following license:<br/>" + "<i>This software is distributed free of charge in the hope that it will be<br/>" + "useful, but WITHOUT ANY WARRANTY; without even the implied<br/>" + "warranty of merchantability or fitness for a particular purpose. In no<br/>" + "event shall the copyright owner or contributors be liable for any direct,<br/>" + "indirect, incidental spacial, examplary, or consequential damages.<br/>" + "Copyright University of California San Francisco, 2007, 2008, 2009,<br/>" + "2010. All rights reserved.</i>" + "</p>" + "</body></html>"); JLabel link = new JLabel( "<html><a href=\"\">For more information, please follow this link.</a></html>"); link.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseevent) { NetworkUtil.openBrowser( "http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager"); } }); value.setSize(new Dimension(50, 18)); value.setAlignmentX(SwingConstants.HORIZONTAL); value.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0)); center.add(value, BorderLayout.CENTER); center.add(link, BorderLayout.SOUTH); JPanel panel_south = new JPanel(); panel_south.setLayout(new BoxLayout(panel_south, BoxLayout.X_AXIS)); JButton btn = new JButton("OK"); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { dialog.dispose(); } }); panel_south.add(Box.createHorizontalGlue()); panel_south.add(btn); panel_south.add(Box.createHorizontalGlue()); dialog.setLayout(new BorderLayout()); panel_container.setLayout(new BorderLayout()); panel_container.add(center, BorderLayout.CENTER); panel_container.add(panel_south, BorderLayout.SOUTH); dialog.add(panel_container, BorderLayout.CENTER); dialog.setResizable(false); dialog.setVisible(true); dialog.pack(); dialog.setLocation( (int) mainFrame.getSize().getWidth() / 2 - dialog.getWidth() / 2, (int) mainFrame.getSize().getHeight() / 2 - dialog.getHeight() / 2); dialog.setLocationRelativeTo(mainFrame); } }); JMenuItem propertyBrowserItem = new JMenuItem("Property Browser"); propertyBrowserItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, SHORTCUTKEY_MASK)); propertyBrowserItem.setIcon(new IcyIcon("db", MENU_ICON_SIZE)); propertyBrowserItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editor.setVisible(!editor.isVisible()); } }); int idx = 0; toReturn.insert(hconfig, idx++); toReturn.insert(loadConfigItem, idx++); toReturn.insert(saveConfigItem, idx++); toReturn.insert(advancedConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(loadPresetConfigItem, idx++); toReturn.insert(savePresetConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(propertyBrowserItem, idx++); toReturn.insert(menuPxSizeConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(aboutItem, idx++); return toReturn; } }); saveConfigButton_ = new JButton("Save Button"); // SETUP _groupPad = new ConfigGroupPad(); _groupPad.setParentGUI(MMMainFrame.this); _groupPad.setFont(new Font("", 0, 10)); _groupPad.setCore(mCore); _groupPad.setParentGUI(MMMainFrame.this); _groupButtonsPanel = new ConfigButtonsPanel(); _groupButtonsPanel.setCore(mCore); _groupButtonsPanel.setGUI(MMMainFrame.this); _groupButtonsPanel.setConfigPad(_groupPad); // LEFT PART OF INTERFACE _panelConfig = new JPanel(); _panelConfig.setLayout(new BoxLayout(_panelConfig, BoxLayout.Y_AXIS)); _panelConfig.add(_groupPad, BorderLayout.CENTER); _panelConfig.add(_groupButtonsPanel, BorderLayout.SOUTH); _panelConfig.setPreferredSize(new Dimension(300, 300)); // MIDDLE PART OF INTERFACE _panel_cameraSettings = new JPanel(); _panel_cameraSettings.setLayout(new GridLayout(5, 2)); _panel_cameraSettings.setMinimumSize(new Dimension(100, 200)); _txtExposure = new JTextField(); try { mCore.setExposure(90.0D); _txtExposure.setText(String.valueOf(mCore.getExposure())); } catch (Exception e2) { _txtExposure.setText("90"); } _txtExposure.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); _txtExposure.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent keyevent) { if (keyevent.getKeyCode() == KeyEvent.VK_ENTER) setExposure(); } }); _panel_cameraSettings.add(new JLabel("Exposure [ms]: ")); _panel_cameraSettings.add(_txtExposure); _combo_binning = new JComboBox(); _combo_binning.setMaximumRowCount(4); _combo_binning.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); _combo_binning.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { changeBinning(); } }); _panel_cameraSettings.add(new JLabel("Binning: ")); _panel_cameraSettings.add(_combo_binning); _combo_shutters = new JComboBox(); _combo_shutters.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { if (_combo_shutters.getSelectedItem() != null) { mCore.setShutterDevice((String) _combo_shutters.getSelectedItem()); _prefs.put(PREF_SHUTTER, (String) _combo_shutters .getItemAt(_combo_shutters.getSelectedIndex())); } } catch (Exception e) { e.printStackTrace(); } } }); _combo_shutters.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); _panel_cameraSettings.add(new JLabel("Shutter : ")); _panel_cameraSettings.add(_combo_shutters); ActionListener action_listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateHistogram(); } }; _cbAbsoluteHisto = new JCheckBox(); _cbAbsoluteHisto.addActionListener(action_listener); _cbAbsoluteHisto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { _comboBitDepth.setEnabled(_cbAbsoluteHisto.isSelected()); _prefs.putBoolean(PREF_ABS_HIST, _cbAbsoluteHisto.isSelected()); } }); _panel_cameraSettings.add(new JLabel("Display absolute histogram ?")); _panel_cameraSettings.add(_cbAbsoluteHisto); _comboBitDepth = new JComboBox(new String[] { "8-bit", "9-bit", "10-bit", "11-bit", "12-bit", "13-bit", "14-bit", "15-bit", "16-bit" }); _comboBitDepth.addActionListener(action_listener); _comboBitDepth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { _prefs.putInt(PREF_BITDEPTH, _comboBitDepth.getSelectedIndex()); } }); _comboBitDepth.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); _comboBitDepth.setEnabled(false); _panel_cameraSettings.add(new JLabel("Select your bit depth for abs. hitogram: ")); _panel_cameraSettings.add(_comboBitDepth); // Acquisition _panelAcquisitions = new JPanel(); _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS)); // Color settings _panelColorChooser = new JPanel(); _panelColorChooser.setLayout(new BoxLayout(_panelColorChooser, BoxLayout.Y_AXIS)); painterPreferences = MicroscopePainterPreferences.getInstance(); painterPreferences.setPreferences(_prefs.node("paintersPreferences")); painterPreferences.loadColors(); HashMap<String, Color> allColors = painterPreferences.getColors(); String[] allKeys = (String[]) allColors.keySet().toArray(new String[0]); String[] columnNames = { "Painter", "Color", "Transparency" }; Object[][] data = new Object[allKeys.length][3]; for (int i = 0; i < allKeys.length; ++i) { final int actualRow = i; String actualKey = allKeys[i].toString(); data[i][0] = actualKey; data[i][1] = allColors.get(actualKey); final JSlider slider = new JSlider(0, 255, allColors.get(actualKey).getAlpha()); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent changeevent) { painterTable.setValueAt(slider, actualRow, 2); } }); data[i][2] = slider; } final AbstractTableModel tableModel = new JTableEvolvedModel(columnNames, data); painterTable = new JTable(tableModel); painterTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tablemodelevent) { if (tablemodelevent.getType() == TableModelEvent.UPDATE) { int row = tablemodelevent.getFirstRow(); int col = tablemodelevent.getColumn(); String columnName = tableModel.getColumnName(col); String painterName = (String) tableModel.getValueAt(row, 0); if (columnName.contains("Color")) { // New color value int alpha = painterPreferences.getColor(painterName).getAlpha(); Color coloNew = (Color) tableModel.getValueAt(row, 1); painterPreferences.setColor(painterName, new Color(coloNew.getRed(), coloNew.getGreen(), coloNew.getBlue(), alpha)); } else if (columnName.contains("Transparency")) { // New alpha value Color c = painterPreferences.getColor(painterName); int alphaValue = ((JSlider) tableModel.getValueAt(row, 2)) .getValue(); painterPreferences.setColor(painterName, new Color(c.getRed(), c.getGreen(), c.getBlue(), alphaValue)); } /* * for (int i = 0; i < * tableModel.getRowCount(); ++i) { try { * String painterName = (String) * tableModel.getValueAt(i, 0); Color c = * (Color) tableModel.getValueAt(i, 1); int * alphaValue; if (ASpinnerChanged && * tablemodelevent.getFirstRow() == i) { * alphaValue = ((JSlider) * tableModel.getValueAt(i, 2)).getValue(); * } else { alphaValue = * painterPreferences.getColor * (painterPreferences * .getPainterName(i)).getAlpha(); } * painterPreferences.setColor(painterName, * new Color(c.getRed(), c.getGreen(), * c.getBlue(), alphaValue)); } catch * (Exception e) { System.out.println( * "error with painter table update"); } } */ } } }); painterTable.setPreferredScrollableViewportSize(new Dimension(500, 70)); painterTable.setFillsViewportHeight(true); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(painterTable); // Set up renderer and editor for the Favorite Color // column. painterTable.setDefaultRenderer(Color.class, new ColorRenderer(true)); painterTable.setDefaultEditor(Color.class, new ColorEditor()); painterTable.setDefaultRenderer(JSlider.class, new SliderRenderer(0, 255)); painterTable.setDefaultEditor(JSlider.class, new SliderEditor()); _panelColorChooser.add(scrollPane); _panelColorChooser.add(Box.createVerticalGlue()); _mainPanel = new JPanel(); _mainPanel.setLayout(new BorderLayout()); // EDITOR // will refresh the data and verify if any change // occurs. // editor = new PropertyEditor(MMMainFrame.this); // editor.setCore(mCore); // editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); // editor.addToMainDesktopPane(); // editor.refresh(); // editor.start(); editor = new PropertyEditor(); editor.setGui(MMMainFrame.this); editor.setCore(mCore); editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); // editor.addToMainDesktopPane(); // editor.refresh(); // editor.start(); add(_mainPanel); initializeGUI(); loadPreferences(); refreshGUI(); setResizable(true); addToMainDesktopPane(); instanced = true; instancing = false; _singleton = MMMainFrame.this; setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addFrameListener(new IcyFrameAdapter() { @Override public void icyFrameClosing(IcyFrameEvent e) { customClose(); } }); acceptListener = new AcceptListener() { @Override public boolean accept(Object source) { close(); return _pluginListEmpty; } }; adapter = new MainAdapter() { @Override public void sequenceOpened(MainEvent event) { updateHistogram(); } }; Icy.getMainInterface().addCanExitListener(acceptListener); Icy.getMainInterface().addListener(adapter); } }); } }); } }); }
From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java
public FiltersPanel() { initComponents();//from ww w . jav a 2s . c o m filterTypeResolver = createFilterTypeResolver(); filterFormResolver = createFilterFormResolver(); ManufactorModelAdapter manufactorModelAdapter = new ManufactorModelAdapter(); List<Manufactor> theManufactors = carsService.getAllManufactors(); for (Manufactor manufactor : theManufactors) { manufactorModelAdapter.addManufactor(manufactor); } manufactors = new SelectionInList<ManufactorModel>(manufactorModelAdapter.getList()); series = new SelectionInList<SeriaModel>(); cbManufactors.setModel(new ComboBoxAdapter<ManufactorModel>(manufactors)); cbManufactors.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ManufactorModel manufactorModel = (ManufactorModel) e.getItem(); reReadSeries(manufactorModel.getManufactorIds()); } } }); cbSeria.setModel(new ComboBoxAdapter<SeriaModel>(series)); tblAllMotors.setModel(new BigMotorTableAdapter(allMotors)); tblAllMotors.setRowSorter(new BigMotorTableSorter((BigMotorTableAdapter) tblAllMotors.getModel())); tblAllMotors.setRowHeight(20); tblAllMotors.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { adjustButtonsEnabled(); } }); tblMotors.setModel(new BigMotorTableAdapter(motors)); tblMotors.setRowSorter(new BigMotorTableSorter((BigMotorTableAdapter) tblMotors.getModel())); tblMotors.setRowHeight(20); tblMotors.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { adjustButtonsEnabled(); } }); final BigFilterTableAdapter tblFiltersAdapter = new BigFilterTableAdapter(filters, filterTypeResolver, filterFormResolver); tblFiltersAdapter.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (e.getType() == TableModelEvent.UPDATE) { BigFilterTableAdapter adapter = (BigFilterTableAdapter) e.getSource(); int row = e.getFirstRow(); Filter filter = adapter.getRow(row); filtersService.updateFilter(filter); } } }); tblFilters.setUpdateSelectionOnSort(true); tblFilters.setModel(tblFiltersAdapter); tblFilters.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } adjustButtonsEnabled(); Long filterId = getSelectedFilterId(); reReadMotors(filterId); reReadOes(filterId); } }); tblFilters.setRowHeight(20); tblAllOes.setModel(new OeModelTableModel(allOes)); tblAllOes.setRowHeight(20); tblAllOes.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { adjustButtonsEnabled(); } }); tblOes.setModel(new OeModelTableModel(oes)); tblOes.setRowHeight(20); tblOes.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { adjustButtonsEnabled(); } }); // ?? ? ? if (System.getProperty("catalog.mode.fromMann") != null && System.getProperty("catalog.mode.fromMann").equals("1")) { tblFilters.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.FILTER)); tblMotors.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.AMOTOR)); tblAllMotors.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.AMOTOR)); tblOes.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.OE)); tblAllOes.setDefaultRenderer(Object.class, new MannTablesCellRenderer(MannTablesCellRenderer.OE)); } else { tblFilters.setDefaultRenderer(Object.class, new FilterTableCellRenderer()); } adjustButtonsEnabled(); // globalHotkeys(); }