List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener
ListSelectionListener
From source file:org.apache.cayenne.modeler.editor.ObjEntityRelationshipTab.java
private void initController() { mediator.addObjEntityDisplayListener(this); mediator.addObjEntityListener(this); mediator.addObjRelationshipListener(this); ActionListener resolver = new ActionListener() { public void actionPerformed(ActionEvent e) { int row = table.getSelectedRow(); if (row < 0) { return; }// w w w. j a va2 s . co m ObjRelationshipTableModel model = (ObjRelationshipTableModel) table.getModel(); new ObjRelationshipInfo(mediator, model.getRelationship(row)).startupAction(); /** * This is required for a table to be updated properly */ table.cancelEditing(); // need to refresh selected row... do this by unselecting/selecting the // row table.getSelectionModel().clearSelection(); table.select(row); } }; resolve.addActionListener(resolver); resolveMenu.addActionListener(resolver); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { processExistingSelection(e); } }); mediator.getApplication().getActionManager().setupCutCopyPaste(table, CutRelationshipAction.class, CopyRelationshipAction.class); }
From source file:org.colombbus.tangara.EditorFrame.java
/** * This method initializes console//from w w w. j ava2 s . c o m * * @return org.colombbus.tangara.Console */ private LogConsole getConsole() { if (console == null) { console = new LogConsole(this); console.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (toProgramLabel != null) { if (console.isCodeSelected()) { if (!toProgramLabel.isEnabled()) { toProgramLabel.setEnabled(true); toProgramLabel.setIcon(new ImageIcon( getClass().getResource("/org/colombbus/tangara/to_program.png"))); //$NON-NLS-1$ } } else if (toProgramLabel.isEnabled()) { toProgramLabel.setEnabled(false); toProgramLabel.setIcon(new ImageIcon( getClass().getResource("/org/colombbus/tangara/to_program_off.png"))); //$NON-NLS-1$ } } } }); } return console; }
From source file:org.eclim.installer.step.VimStep.java
/** * {@inheritDoc}/*from w w w.ja v a2 s .c o m*/ * @see org.formic.wizard.WizardStep#displayed() */ public void displayed() { if (!rtpAttempted) { rtpAttempted = true; setBusy(true); try { runtimePath = (String[]) Worker.post(new Task() { public Object run() throws Exception { setGvimProperty(); return getVimRuntimePath(); } }); // filter out dirs the user doesn't have permission write to. ArrayList<String> filtered = new ArrayList<String>(); if (runtimePath != null) { for (String path : runtimePath) { if (new File(path).canWrite()) { if (Installer.isUninstall()) { File eclimDir = new File(path + "/eclim"); if (eclimDir.exists()) { if (eclimDir.canWrite()) { filtered.add(path); } else { logger.warn(path + "/eclim is not writable by the current user"); } } } else { filtered.add(path); } } } } String[] rtp = filtered.toArray(new String[filtered.size()]); if (rtp == null || rtp.length == 0) { if (!Installer.isUninstall()) { if (!homeVimCreatePrompted) { createUserVimFiles("No suitable vim files directory found."); } else { GuiDialogs.showWarning( "Your vim install is still reporting no\n" + "suitable vim files directories.\n" + "You will need to manually specify one."); } } } else { if (rtp.length == 1) { fileChooser.getTextField().setText(rtp[0]); // try to discourage windows users from installing eclim files in // their vim installation. if (new File(rtp[0] + "/gvim.exe").exists()) { createUserVimFiles("No user vim files directory found."); } } else { dirList = new JList(rtp); dirList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollPane = new JScrollPane(dirList); panel.add(scrollPane, "span, grow"); dirList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { fileChooser.getTextField().setText((String) dirList.getSelectedValue()); } } }); dirList.setSelectedIndex(0); } } } catch (Exception e) { e.printStackTrace(); } setBusy(false); fileChooser.getTextField().grabFocus(); } }
From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java
public void startup() { if (dialog != null) { dialog.toFront();/*from w w w. j av a2 s . c o m*/ return; } NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED); NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED); NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS); NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT); NodeList.COLUMN_DETAILS = TextUtils.getText(PLUGINS_TIME_LIST_XML_DETAILS); NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE); NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES); dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal /* modal */); String windowTitle; if (showAllNodes) { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES; } else { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE; } dialog.setTitle(TextUtils.getText(windowTitle)); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final WindowAdapter windowListener = new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { mFilterTextSearchField.getEditor().selectAll(); } @Override public void windowClosing(final WindowEvent event) { disposeDialog(); } }; dialog.addWindowListener(windowListener); dialog.addWindowFocusListener(windowListener); UITools.addEscapeActionToDialog(dialog, new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }); final Container contentPane = dialog.getContentPane(); final GridBagLayout gbl = new GridBagLayout(); contentPane.setLayout(gbl); final GridBagConstraints layoutConstraints = new GridBagConstraints(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.weightx = 0.0; layoutConstraints.weighty = 0.0; layoutConstraints.anchor = GridBagConstraints.WEST; layoutConstraints.fill = GridBagConstraints.HORIZONTAL; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints); layoutConstraints.gridwidth = 1; layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(matchCase, layoutConstraints); layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInFind, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextSearchField), layoutConstraints); layoutConstraints.gridy++; layoutConstraints.weightx = 0.0; layoutConstraints.gridwidth = 1; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints); layoutConstraints.gridx = 5; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInReplace, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextReplaceField), layoutConstraints); dateRenderer = new DateRenderer(); textRenderer = new TextRenderer(); iconsRenderer = new IconsRenderer(); tableView = new FlatNodeTable(); tableView.addKeyListener(new FlatNodeTableKeyListener()); tableView.addMouseListener(new FlatNodeTableMouseAdapter()); tableView.getTableHeader().setReorderingAllowed(false); tableModel = updateModel(); mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(tableModel, new int[] { NodeList.NODE_TEXT_COLUMN, NodeList.NODE_DETAILS_COLUMN, NodeList.NODE_NOTES_COLUMN }); sorter = new TableSorter(mFlatNodeTableFilterModel); tableView.setModel(sorter); sorter.setTableHeader(tableView.getTableHeader()); sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR); sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING); final JScrollPane pane = new JScrollPane(tableView); UITools.setScrollbarIncrement(pane); layoutConstraints.gridy++; GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone(); tableConstraints.weightx = 1; tableConstraints.weighty = 10; tableConstraints.fill = GridBagConstraints.BOTH; contentPane.add(pane, tableConstraints); mTreeLabel = new JLabel(); layoutConstraints.gridy++; GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone(); treeConstraints.fill = GridBagConstraints.BOTH; @SuppressWarnings("serial") JScrollPane scrollPane = new JScrollPane(mTreeLabel) { @Override public boolean isValidateRoot() { return false; } }; contentPane.add(scrollPane, treeConstraints); final AbstractAction exportAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Export")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { exportSelectedRowsAndClose(); } }; final JButton exportButton = new JButton(exportAction); final AbstractAction replaceAllAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new HolderAccessor(false)); } }; final JButton replaceAllButton = new JButton(replaceAllAction); final AbstractAction replaceSelectedAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new HolderAccessor(true)); } }; final JButton replaceSelectedButton = new JButton(replaceSelectedAction); final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { selectSelectedRows(); } }; final JButton gotoButton = new JButton(gotoAction); final AbstractAction disposeAction = new AbstractAction( TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }; final JButton cancelButton = new JButton(disposeAction); /* Initial State */ gotoAction.setEnabled(false); exportAction.setEnabled(false); replaceSelectedAction.setEnabled(false); final Box bar = Box.createHorizontalBox(); bar.add(Box.createHorizontalGlue()); bar.add(cancelButton); bar.add(exportButton); bar.add(replaceAllButton); bar.add(replaceSelectedButton); bar.add(gotoButton); bar.add(Box.createHorizontalGlue()); layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(bar), layoutConstraints); final JMenuBar menuBar = new JMenuBar(); final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions")); final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction, replaceAllAction, exportAction, disposeAction }; for (int i = 0; i < actionList.length; i++) { final AbstractAction action = actionList[i]; final JMenuItem item = menu.add(action); item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE)); } menuBar.add(menu); dialog.setJMenuBar(menuBar); final ListSelectionModel rowSM = tableView.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); final boolean enable = !(lsm.isSelectionEmpty()); replaceSelectedAction.setEnabled(enable); gotoAction.setEnabled(enable); exportAction.setEnabled(enable); } }); rowSM.addListSelectionListener(new ListSelectionListener() { String getNodeText(final NodeModel node) { return TextController.getController().getShortText(node) + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode()))); } public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { mTreeLabel.setText(""); return; } final int selectedRow = lsm.getLeadSelectionIndex(); final NodeModel mindMapNode = getMindMapNode(selectedRow); mTreeLabel.setText(getNodeText(mindMapNode)); } }); final String marshalled = ResourceController.getResourceController() .getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY); final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog); final WindowConfigurationStorage storage = result; if (storage != null) { tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int column = 0; for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage) .getListTimeWindowColumnSettingList()) { tableView.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth()); sorter.setSortingStatus(column, setting.getColumnSorting()); column++; } } mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(), matchCase.isSelected(), useRegexInFind.isSelected()); dialog.setVisible(true); }
From source file:org.freeplane.view.swing.features.time.mindmapmode.NodeList.java
public void startup() { if (dialog != null) { dialog.toFront();// w ww. ja v a 2 s .co m return; } NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED); NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED); NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS); NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT); NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE); NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES); dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal /* modal */); String windowTitle; if (showAllNodes) { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES; } else { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE; } dialog.setTitle(TextUtils.getText(windowTitle)); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final WindowAdapter windowListener = new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { mFilterTextSearchField.getEditor().selectAll(); } @Override public void windowClosing(final WindowEvent event) { disposeDialog(); } }; dialog.addWindowListener(windowListener); dialog.addWindowFocusListener(windowListener); UITools.addEscapeActionToDialog(dialog, new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }); final Container contentPane = dialog.getContentPane(); final GridBagLayout gbl = new GridBagLayout(); contentPane.setLayout(gbl); final GridBagConstraints layoutConstraints = new GridBagConstraints(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.weightx = 0.0; layoutConstraints.weighty = 0.0; layoutConstraints.anchor = GridBagConstraints.WEST; layoutConstraints.fill = GridBagConstraints.HORIZONTAL; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints); layoutConstraints.gridwidth = 1; layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(matchCase, layoutConstraints); layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInFind, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextSearchField), layoutConstraints); layoutConstraints.gridy++; layoutConstraints.weightx = 0.0; layoutConstraints.gridwidth = 1; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints); layoutConstraints.gridx = 5; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInReplace, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextReplaceField), layoutConstraints); dateRenderer = new DateRenderer(); nodeRenderer = new NodeRenderer(); notesRenderer = new NotesRenderer(); iconsRenderer = new IconsRenderer(); timeTable = new FlatNodeTable(); timeTable.addKeyListener(new FlatNodeTableKeyListener()); timeTable.addMouseListener(new FlatNodeTableMouseAdapter()); timeTable.getTableHeader().setReorderingAllowed(false); timeTableModel = updateModel(); mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(timeTableModel, NodeList.NODE_TEXT_COLUMN); sorter = new TableSorter(mFlatNodeTableFilterModel); timeTable.setModel(sorter); sorter.setTableHeader(timeTable.getTableHeader()); sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR); sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING); final JScrollPane pane = new JScrollPane(timeTable); UITools.setScrollbarIncrement(pane); layoutConstraints.gridy++; GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone(); tableConstraints.weightx = 1; tableConstraints.weighty = 10; tableConstraints.fill = GridBagConstraints.BOTH; contentPane.add(pane, tableConstraints); mTreeLabel = new JLabel(); layoutConstraints.gridy++; GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone(); treeConstraints.fill = GridBagConstraints.BOTH; @SuppressWarnings("serial") JScrollPane scrollPane = new JScrollPane(mTreeLabel) { @Override public boolean isValidateRoot() { return false; } }; contentPane.add(scrollPane, treeConstraints); final AbstractAction exportAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Export")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { exportSelectedRowsAndClose(); } }; final JButton exportButton = new JButton(exportAction); final AbstractAction replaceAllAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new ReplaceAllInfo()); } }; final JButton replaceAllButton = new JButton(replaceAllAction); final AbstractAction replaceSelectedAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new ReplaceSelectedInfo()); } }; final JButton replaceSelectedButton = new JButton(replaceSelectedAction); final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { selectSelectedRows(); } }; final JButton gotoButton = new JButton(gotoAction); final AbstractAction disposeAction = new AbstractAction( TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }; final JButton cancelButton = new JButton(disposeAction); /* Initial State */ gotoAction.setEnabled(false); exportAction.setEnabled(false); replaceSelectedAction.setEnabled(false); final Box bar = Box.createHorizontalBox(); bar.add(Box.createHorizontalGlue()); bar.add(cancelButton); bar.add(exportButton); bar.add(replaceAllButton); bar.add(replaceSelectedButton); bar.add(gotoButton); bar.add(Box.createHorizontalGlue()); layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(bar), layoutConstraints); final JMenuBar menuBar = new JMenuBar(); final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions")); final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction, replaceAllAction, exportAction, disposeAction }; for (int i = 0; i < actionList.length; i++) { final AbstractAction action = actionList[i]; final JMenuItem item = menu.add(action); item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE)); } menuBar.add(menu); dialog.setJMenuBar(menuBar); final ListSelectionModel rowSM = timeTable.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); final boolean enable = !(lsm.isSelectionEmpty()); replaceSelectedAction.setEnabled(enable); gotoAction.setEnabled(enable); exportAction.setEnabled(enable); } }); rowSM.addListSelectionListener(new ListSelectionListener() { String getNodeText(final NodeModel node) { return TextController.getController().getShortText(node) + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode()))); } public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { mTreeLabel.setText(""); return; } final int selectedRow = lsm.getLeadSelectionIndex(); final NodeModel mindMapNode = getMindMapNode(selectedRow); mTreeLabel.setText(getNodeText(mindMapNode)); } }); final String marshalled = ResourceController.getResourceController() .getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY); final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog); final WindowConfigurationStorage storage = result; if (storage != null) { timeTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int column = 0; for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage) .getListTimeWindowColumnSettingList()) { timeTable.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth()); sorter.setSortingStatus(column, setting.getColumnSorting()); column++; } } mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(), matchCase.isSelected(), useRegexInFind.isSelected()); dialog.setVisible(true); }
From source file:org.genedb.jogra.plugins.TermRationaliser.java
private Box createRationaliserPanel(final String name, final RationaliserJList rjlist) { int preferredHeight = 500; //change accordingly int preferredWidth = 500; Toolkit tk = Toolkit.getDefaultToolkit(); Dimension size = tk.getScreenSize(); int textboxHeight = 10; //change accordingly int textboxWidth = size.width; Box box = Box.createVerticalBox(); box.add(new JLabel(name)); JTextField searchField = new JTextField(20); //Search field on top /* We don't want this textfield's height to expand when * the Rationaliser is dragged to exapnd. So we set it's * height to what we want and the width to the width of * the screen /*from w w w.ja v a 2 s . c o m*/ */ searchField.setMaximumSize(new Dimension(textboxWidth, textboxHeight)); rjlist.installJTextField(searchField); box.add(searchField); JScrollPane scrollPane = new JScrollPane(); //scroll pane scrollPane.setViewportView(rjlist); scrollPane.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); box.add(scrollPane); TitledBorder sysidBorder = BorderFactory.createTitledBorder("Systematic IDs"); //systematic ID box sysidBorder.setTitleColor(Color.DARK_GRAY); final JTextArea idField = new JTextArea(1, 1); idField.setMaximumSize(new Dimension(textboxWidth, textboxHeight)); idField.setEditable(false); idField.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); idField.setForeground(Color.DARK_GRAY); JScrollPane scroll = new JScrollPane(idField); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); Box sysidBox = Box.createVerticalBox(); sysidBox.add(scroll /*idField*/); sysidBox.setBorder(sysidBorder); box.add(sysidBox); rjlist.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Term highlightedTerm = (Term) rjlist.getSelectedValue(); if (highlightedTerm != null) { /* For each list, call the relevant methods * to get the systematic IDs. Then for the * right list, add the term name in the * text box below */ if (name.equals(FROM_LIST_NAME)) { idField.setText(StringUtils.collectionToCommaDelimitedString( termService.getSystematicIDs(highlightedTerm, selectedTaxons))); } else if (name.equals(TO_LIST_NAME)) { idField.setText(StringUtils.collectionToCommaDelimitedString( termService.getSystematicIDs(highlightedTerm, null))); /* We allow the user to edit the term name */ textField.setText(highlightedTerm.getName()); } } } }); return box; }
From source file:org.geworkbench.components.lincs.LincsInterface.java
public LincsInterface() { final String lincsCwbFileName = this.getClass().getPackage().getName().replace(".", FilePathnameUtils.FILE_SEPARATOR) + FilePathnameUtils.FILE_SEPARATOR + "Lincs.cwb.xml"; setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // temp do this, if data is there, then may be take out hideColumnList.add("P-value"); add(queryTypePanel);/* w w w. ja v a 2s. c o m*/ add(queryConditionPanel1); add(queryConditionPanel2); add(queryCommandPanel); experimental.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(experimental); group.add(computational); queryTypePanel.add(new JLabel("Query Type")); queryTypePanel.add(experimental); queryTypePanel.add(computational); queryTypePanel.add(new JLabel(" ")); JLabel viewLicenseLabel = new JLabel("<html><font color=blue><u><b>View License</b></u></font></html>"); ; queryTypePanel.add(viewLicenseLabel); viewLicenseLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { viewLicense_actionPerformed(lincsCwbFileName); } }); String url = getLincsWsdlUrl(); // String url = // "http://localhost:8080/axis2/services/LincsService?wsdl"; lincs = new Lincs(url, null, null); queryConditionPanel1.setLayout(new GridLayout(2, 7)); final JLabel tissueTypeLabel = new JLabel("Tissue Type"); final JLabel cellLineLabel = new JLabel("Cell Line"); final JLabel drug1Label = new JLabel("Drug 1"); final JLabel drug2Label = new JLabel("Drug 2"); final JLabel assayTypeLabel = new JLabel("Assay Type"); final JLabel synergyMeasurementLabel = new JLabel("Synergy Measurement Type"); final JLabel similarityAlgorithmLabel = new JLabel("Similarity Algorithm"); final JLabel blankLabel = new JLabel(""); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(drug1Label); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(blankLabel); queryConditionPanel1.add(tissueTypeLabel); queryConditionPanel1.add(cellLineLabel); queryConditionPanel1.add(drug1Search); queryConditionPanel1.add(drug2Label); queryConditionPanel1.add(assayTypeLabel); queryConditionPanel1.add(synergyMeasurementLabel); queryConditionPanel1.add(new JLabel("")); queryConditionPanel2.setLayout(new GridLayout(1, 7)); List<String> tissueTypeList = null; List<String> drug1List = null; List<String> assayTypeList = null; List<String> synergyMeasuremetnTypeList = null; List<String> similarityAlgorithmList = null; try { tissueTypeList = addAll(lincs.getAllTissueNames()); drug1List = addAll(lincs.getCompound1NamesFromExperimental(null, null)); assayTypeList = addAll(lincs.getAllAssayTypeNames()); synergyMeasuremetnTypeList = addAll(lincs.getAllMeasurementTypeNames()); similarityAlgorithmList = addAll(lincs.getALLSimilarAlgorithmNames()); } catch (Exception ex) { log.error(ex.getMessage()); } tissueTypeBox = new JList(); final JScrollPane tissueTypeBoxPanel = buildJListPanel(tissueTypeList, tissueTypeBox); cellLineBox = new JList(); final JScrollPane cellLineBoxPanel = buildJListPanel(null, cellLineBox); cellLineBox.setEnabled(false); final JScrollPane drug1BoxPanel = buildFilterJListPanel(drug1List, drug1Box); drug2Box = new JList(); final JScrollPane drug2BoxPanel = buildJListPanel(null, drug2Box); drug2Box.setEnabled(false); assayTypeBox = new JList(); final JScrollPane assayTypeBoxPanel = buildJListPanel(assayTypeList, assayTypeBox); synergyMeasurementTypeBox = new JList(); final JScrollPane synergyMeasuremetnTypeBoxPanel = buildJListPanel(synergyMeasuremetnTypeList, synergyMeasurementTypeBox); similarityAlgorithmTypeBox = new JList(); final JScrollPane similarityAlgorithmTypeBoxPanel = buildJListPanel(similarityAlgorithmList, similarityAlgorithmTypeBox); onlyTitration = new JCheckBox("Only with titration"); queryConditionPanel2.add(tissueTypeBoxPanel); queryConditionPanel2.add(cellLineBoxPanel); queryConditionPanel2.add(drug1BoxPanel); queryConditionPanel2.add(drug2BoxPanel); queryConditionPanel2.add(assayTypeBoxPanel); queryConditionPanel2.add(synergyMeasuremetnTypeBoxPanel); queryConditionPanel2.add(onlyTitration); // dynamic dependency parts tissueTypeBox.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { List<String> selectedTissueList = getSelectedValues(tissueTypeBox); List<String> cellLineDataList = null; List<String> drug1DataList = null; try { cellLineDataList = addAll(lincs.getAllCellLineNamesForTissueTypes(selectedTissueList)); if (experimental.isSelected() == true) drug1DataList = addAll( lincs.getCompound1NamesFromExperimental(selectedTissueList, null)); else drug1DataList = addAll( lincs.getCompound1NamesFromComputational(selectedTissueList, null)); } catch (Exception ex) { log.error(ex.getMessage()); } if (tissueTypeBox.getSelectedValues() != null && tissueTypeBox.getSelectedValues().length > 0) cellLineBox.setModel(new LincsListModel(cellLineDataList)); else cellLineBox.setModel(new LincsListModel(null)); cellLineBox.setEnabled(true); cellLineBox.clearSelection(); drug1Box.removeAllItems(); for (int i = 0; i < drug1DataList.size(); i++) drug1Box.addItem(drug1DataList.get(i)); drug1Box.clearSelection(); drug2Box.clearSelection(); drug2Box.setModel(new LincsListModel(null)); drug2Box.setEnabled(false); cellLineBox.ensureIndexIsVisible(0); drug1Box.ensureIndexIsVisible(0); } } }); // dynamic dependency parts cellLineBox.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { List<String> selectedTissueList = getSelectedValues(tissueTypeBox); List<String> selectedCellLineList = getSelectedValues(cellLineBox); List<String> drug1DataList = null; try { if (experimental.isSelected() == true) drug1DataList = addAll(lincs.getCompound1NamesFromExperimental(selectedTissueList, selectedCellLineList)); else drug1DataList = addAll(lincs.getCompound1NamesFromComputational(selectedTissueList, selectedCellLineList)); } catch (Exception ex) { log.error(ex.getMessage()); } drug1Box.removeAllItems(); for (int i = 0; i < drug1DataList.size(); i++) drug1Box.addItem(drug1DataList.get(i)); drug1Box.ensureIndexIsVisible(0); drug1Box.clearSelection(); drug2Box.clearSelection(); drug2Box.setModel(new LincsListModel(null)); drug2Box.setEnabled(false); } } }); // dynamic dependency parts drug1Box.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { List<String> selectedTissueList = getSelectedValues(tissueTypeBox); List<String> selectedCellLineList = getSelectedValues(cellLineBox); List<String> selectedDrug1List = getSelectedValues(drug1Box); List<String> drug2DataList = null; try { if (experimental.isSelected() == true) drug2DataList = addAll(lincs.getCompound2NamesFromExperimental(selectedTissueList, selectedCellLineList, selectedDrug1List)); else drug2DataList = addAll(lincs.getCompound2NamesFromComputational(selectedTissueList, selectedCellLineList, selectedDrug1List)); } catch (Exception ex) { log.error(ex.getMessage()); } if (drug1Box.getSelectedValues() != null && drug1Box.getSelectedValues().length > 0) drug2Box.setModel(new LincsListModel(drug2DataList)); else drug2Box.setModel(new LincsListModel(null)); drug2Box.setEnabled(true); drug2Box.ensureIndexIsVisible(0); } } }); maxResult = new JCheckBox("Max results"); maxResultNumber = new JTextField("10", 10); searchButton = new JButton("Search"); resetButton = new JButton("Reset"); colorGradient = new JCheckBox("Color gradient for Score"); queryCommandPanel.add(maxResult); queryCommandPanel.add(maxResultNumber); queryCommandPanel.add(searchButton); queryCommandPanel.add(resetButton); queryCommandPanel.add(colorGradient); resultTable = new TableViewer(experimentalColumnNames, null, hideColumnList); add(resultTable); add(resultProcessingPanel); queryResultPanel.setLayout(new BorderLayout()); // queryResultPanel.add(new JScrollPane(resultTable), // BorderLayout.CENTER); plotOptions = new JComboBox(new String[] { HEATMAP, NETWORK }); JButton plotButton = new JButton("Plot"); final JCheckBox limitNetwork = new JCheckBox("Limit network to multiply-connected pairs"); limitNetwork.setEnabled(false); limitNetwork.setVisible(false); JButton exportButton = new JButton("Export"); exportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { List<String> hideColumns = new ArrayList<String>(); hideColumns.add("Include"); TableViewer.export(resultTable.getTable(), hideColumns, resultTable); } }); resultProcessingPanel.add(new JLabel("Plot options:")); resultProcessingPanel.add(plotOptions); resultProcessingPanel.add(plotButton); resultProcessingPanel.add(limitNetwork); resultProcessingPanel.add(exportButton); plotOptions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (plotOptions.getSelectedItem().toString().equals(HEATMAP)) { limitNetwork.setEnabled(false); } else if (plotOptions.getSelectedItem().toString().equals(NETWORK)) { limitNetwork.setEnabled(true); } } }); plotButton.addActionListener(plotListener); colorGradient.addActionListener(colorGradientListener); computational.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { queryConditionPanel1.remove(blankLabel); queryConditionPanel1.remove(assayTypeLabel); queryConditionPanel1.remove(synergyMeasurementLabel); queryConditionPanel2.remove(assayTypeBoxPanel); queryConditionPanel2.remove(synergyMeasuremetnTypeBoxPanel); queryConditionPanel1.add(similarityAlgorithmLabel, 10); queryConditionPanel2.add(similarityAlgorithmTypeBoxPanel, 4); queryConditionPanel1.updateUI(); queryConditionPanel2.updateUI(); onlyTitration.setEnabled(false); reset(); } }); experimental.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { queryConditionPanel1.remove(similarityAlgorithmLabel); queryConditionPanel2.remove(similarityAlgorithmTypeBoxPanel); queryConditionPanel1.add(blankLabel, 6); queryConditionPanel1.add(assayTypeLabel, 11); queryConditionPanel1.add(synergyMeasurementLabel, 12); queryConditionPanel2.add(assayTypeBoxPanel, 4); queryConditionPanel2.add(synergyMeasuremetnTypeBoxPanel, 5); queryConditionPanel1.updateUI(); queryConditionPanel2.updateUI(); onlyTitration.setEnabled(true); reset(); } }); searchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int rowLimit = 0; List<String> tissueTypes = getSelectedValues(tissueTypeBox); List<String> cellLineNames = getSelectedValues(cellLineBox); List<String> drug1Names = getSelectedValues(drug1Box); List<String> drug2Names = getSelectedValues(drug2Box); if (maxResult.isSelected()) { try { rowLimit = new Integer(maxResultNumber.getText().trim()).intValue(); } catch (NumberFormatException nbe) { JOptionPane.showMessageDialog(null, "Please enter a number."); maxResultNumber.requestFocus(); return; } } if ((drug1Names == null || drug1Names.isEmpty()) && (drug2Names == null || drug2Names.isEmpty())) { JOptionPane.showMessageDialog(null, "Please select at least one drug constraint, multiple drugs can be selected."); return; } AbstractAnalysis selectedAnalysis = new LincsSearchAnalysis(); String dataSetName = null; if (experimental.isSelected()) { selectedAnalysis.setLabel("LINCS Experimental Query"); dataSetName = "LINCS Data"; } else { selectedAnalysis.setLabel("LINCS Computational Query"); dataSetName = "LINCS Data"; } final AnalysisInvokedEvent invokeEvent = new AnalysisInvokedEvent(selectedAnalysis, dataSetName); publishAnalysisInvokedEvent(invokeEvent); try { if (experimental.isSelected()) { List<String> assayTypes = getSelectedValues(assayTypeBox); List<String> measurementTypes = getSelectedValues(synergyMeasurementTypeBox); List<ExperimentalData> dataList = lincs.getExperimentalData(tissueTypes, cellLineNames, drug1Names, drug2Names, measurementTypes, assayTypes, onlyTitration.isSelected(), rowLimit); Object[][] objects = convertExperimentalData(dataList); updateResultTable(objects); } else { List<String> similarityAlgorithmTypes = getSelectedValues(similarityAlgorithmTypeBox); List<ComputationalData> dataList = lincs.getComputationalData(tissueTypes, cellLineNames, drug1Names, drug2Names, similarityAlgorithmTypes, rowLimit); Object[][] objects = convertComputationalData(dataList); updateResultTable(objects); } publishAnalysisCompleteEvent(new AnalysisCompleteEvent(invokeEvent)); } catch (Exception ex) { log.error(ex.getMessage()); publishAnalysisAbortEvent(new AnalysisAbortEvent(invokeEvent)); } if (resultTable.getData() == null || resultTable.getData().length == 0) { JOptionPane.showMessageDialog(null, "There is no row in the database for your query.", "Empty Set", JOptionPane.INFORMATION_MESSAGE); return; } freeVariables = getFreeVariables(); } }); resetButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java
/** * Set up the GUI/*w w w . j av a2s .c om*/ * * @param void * @return void */ private void initComponents() { frame = new JFrame("geWorkbench - Component Configuration Manager"); topPanel = new JPanel(); displayLabel = new JLabel(); String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED }; displayComboBox = new JComboBox(displayChoices); showByTypeLabel = new JLabel(); String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2]; showByTypeChoices[0] = SHOW_BY_TYPE_ALL; int index = 1; for (String s : PluginComponent.categoryList) { showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); index++; } ; showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS; Arrays.sort(showByTypeChoices); showByTypeComboBox = new JComboBox(showByTypeChoices); showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length); keywordSearchLabel = new JLabel("Keyword search:"); keywordSearchField = new JTextField("Enter Text"); splitPane = new JSplitPane(); scrollPaneForTextPane = new JScrollPane(); textPane = new JTextPane(); bottompanel = new JPanel(); CellConstraints cc = new CellConstraints(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { ccmWindow = null; } }); viewLicenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewLicense_actionPerformed(e); } }); applyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyCcmSelections_actionPerformed(e); } }); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetCcmSelections_actionPerformed(e); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeCcmSelections_actionPerformed(e); } }); //======== frame ======== { Container frameContentPane = frame.getContentPane(); frameContentPane.setLayout(new BorderLayout()); //======== outerPanel ======== { frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); //======== topPanel ======== { FormLayout topPanelLayout = new FormLayout( " 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, 64dlu, 32dlu", "center:25dlu"); topPanel.setLayout(topPanelLayout); //---- displayLabel ---- displayLabel.setText("Display:"); topPanel.add(displayLabel, cc.xy(2, 1)); //======== scrollPaneForTopList1 ======== { //---- displayComboBox ---- ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setLoadedFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; displayComboBox.addActionListener(actionListener); } topPanel.add(displayComboBox, cc.xy(4, 1)); //---- showByTypeLabel ---- showByTypeLabel.setText("Show by type:"); topPanel.add(showByTypeLabel, cc.xy(6, 1)); //======== scrollPaneForTopList2 ======== { //---- showByTypeComboBox ---- ActionListener actionListener2 = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setTypeFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; showByTypeComboBox.addActionListener(actionListener2); } topPanel.add(showByTypeComboBox, cc.xy(8, 1)); //---- topLabel3 ---- topPanel.add(keywordSearchLabel, cc.xy(10, 1)); //======== scrollPaneForTopList3 ======== { // ---- keywordSearchField ---- KeyListener actionListener3 = new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { String text = keywordSearchField.getText(); ccmTableModel.setKeywordFilterValue(text); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } public void keyTyped(KeyEvent e) { } }; keywordSearchField.setText("Enter Text"); keywordSearchField.addKeyListener(actionListener3); } topPanel.add(keywordSearchField, cc.xy(12, 1)); } // Top Panel frameContentPane.add(topPanel, BorderLayout.NORTH); //======== splitPane ======== { splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setResizeWeight(0.5); //======== scrollPaneForTable ======== { //---- table ---- ccmTableModel = new CCMTableModel(manager); setOriginalChoices(); table = new JTable(ccmTableModel); sorter = new TableRowSorter<CCMTableModel>(ccmTableModel); table.setRowSorter(sorter); table.setDefaultRenderer(Object.class, new CellRenderer()); table.setDefaultRenderer(CCMTableModel.ImageLink.class, new ImageLinkRenderer()); table.setDefaultRenderer(CCMTableModel.HyperLink.class, new HyperLinkRenderer()); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ListSelectionModel cellSM = table.getSelectionModel(); cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cellSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { boolean adjusting = e.getValueIsAdjusting(); if (adjusting) { return; } int selectedRow = table.getSelectedRow(); ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { textPane.setText(" "); } else { String description = (String) ccmTableModel.getValueAt( table.convertRowIndexToModel(selectedRow), CCMTableModel.DESCRIPTION_INDEX); textPane.setText(description); if (textPane.getCaretPosition() > 1) { textPane.setCaretPosition(1); } } } }); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent event) { launchBrowser(); } }); TableColumn column = table.getColumnModel().getColumn(CCMTableModel.SELECTION_INDEX); column.setMaxWidth(50); column = table.getColumnModel().getColumn(CCMTableModel.VERSION_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel.TUTORIAL_URL_INDEX); column.setMaxWidth(70); column = table.getColumnModel().getColumn(CCMTableModel.TOOL_URL_INDEX); column.setMaxWidth(70); scrollPaneForTable = new JScrollPane(table); } splitPane.setTopComponent(scrollPaneForTable); //======== scrollPaneForTextPane ======== { //---- textPane ---- textPane.setEditable(false); scrollPaneForTextPane.setViewportView(textPane); } splitPane.setBottomComponent(scrollPaneForTextPane); } //======== splitPane ========. frameContentPane.add(splitPane, BorderLayout.CENTER); //======== bottompanel ======== { bottompanel.setLayout(new FormLayout("20dlu," + "default, 4dlu, " + // view License "default,200dlu, " + // Apply "default, 4dlu, " + // Reset "default, 4dlu, " + // Cancel "default " // Close , "center:25dlu")); viewLicenseButton.setText("View License"); bottompanel.add(viewLicenseButton, cc.xy(2, 1)); //---- applyButton ---- applyButton.setText("Apply"); bottompanel.add(applyButton, cc.xy(6, 1)); //---- resetButton ---- resetButton.setText("Reset"); bottompanel.add(resetButton, cc.xy(8, 1)); //---- closeButton ---- closeButton.setText("Close"); bottompanel.add(closeButton, cc.xy(10, 1)); } //======== bottompanel ========. frameContentPane.add(bottompanel, BorderLayout.SOUTH); } //======== outerPanel ======== frame.pack(); frame.setLocationRelativeTo(frame.getOwner()); } // ============ frame ============ topPanel.setVisible(true); splitPane.setVisible(true); scrollPaneForTable.setVisible(true); table.setVisible(true); scrollPaneForTextPane.setVisible(true); textPane.setVisible(true); bottompanel.setVisible(true); sorter.setRowFilter(combinedFilter); frame.setVisible(true); splitPane.setDividerLocation(.7d); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java
/** * Set up the GUI// w w w . java 2 s. c om * * @param void * @return void */ private void initComponents() { frame = new JFrame("geWorkbench - Component Configuration Manager"); topPanel = new JPanel(); displayLabel = new JLabel(); String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED }; displayComboBox = new JComboBox(displayChoices); showByTypeLabel = new JLabel(); String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2]; showByTypeChoices[0] = SHOW_BY_TYPE_ALL; int index = 1; for (String s : PluginComponent.categoryList) { showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); index++; } ; showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS; Arrays.sort(showByTypeChoices); showByTypeComboBox = new JComboBox(showByTypeChoices); showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length); keywordSearchLabel = new JLabel("Keyword search:"); keywordSearchField = new JTextField("Enter Text"); splitPane = new JSplitPane(); scrollPaneForTextPane = new JScrollPane(); textPane = new JTextPane(); bottompanel = new JPanel(); CellConstraints cc = new CellConstraints(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { ccmWindow = null; } }); viewLicenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewLicense_actionPerformed(e); } }); applyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyCcmSelections_actionPerformed(e); } }); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetCcmSelections_actionPerformed(e); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeCcmSelections_actionPerformed(e); } }); componentUpdateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { componentRemoteUpdate_actionPerformed(e); } }); //======== frame ======== { Container frameContentPane = frame.getContentPane(); frameContentPane.setLayout(new BorderLayout()); //======== outerPanel ======== { frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); //======== topPanel ======== { FormLayout topPanelLayout = new FormLayout( " 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, 64dlu, 32dlu", "center:25dlu"); topPanel.setLayout(topPanelLayout); //---- displayLabel ---- displayLabel.setText("Display:"); topPanel.add(displayLabel, cc.xy(2, 1)); //======== scrollPaneForTopList1 ======== { //---- displayComboBox ---- ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setLoadedFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; displayComboBox.addActionListener(actionListener); } topPanel.add(displayComboBox, cc.xy(4, 1)); //---- showByTypeLabel ---- showByTypeLabel.setText("Show by type:"); topPanel.add(showByTypeLabel, cc.xy(6, 1)); //======== scrollPaneForTopList2 ======== { //---- showByTypeComboBox ---- ActionListener actionListener2 = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setTypeFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; showByTypeComboBox.addActionListener(actionListener2); } topPanel.add(showByTypeComboBox, cc.xy(8, 1)); //---- topLabel3 ---- topPanel.add(keywordSearchLabel, cc.xy(10, 1)); //======== scrollPaneForTopList3 ======== { // ---- keywordSearchField ---- KeyListener actionListener3 = new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { String text = keywordSearchField.getText(); ccmTableModel.setKeywordFilterValue(text); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } public void keyTyped(KeyEvent e) { } }; keywordSearchField.setText("Enter Text"); keywordSearchField.addKeyListener(actionListener3); } topPanel.add(keywordSearchField, cc.xy(12, 1)); } // Top Panel frameContentPane.add(topPanel, BorderLayout.NORTH); //======== splitPane ======== { splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setResizeWeight(0.5); //======== scrollPaneForTable ======== { //---- table ---- ccmTableModel = new CCMTableModel2(manager.componentConfigurationManager); setOriginalChoices(); table = new JTable(ccmTableModel); sorter = new TableRowSorter<CCMTableModel2>(ccmTableModel); table.setRowSorter(sorter); table.setDefaultRenderer(Object.class, new CellRenderer()); table.setDefaultRenderer(CCMTableModel2.ImageLink.class, new ImageLinkRenderer()); table.setDefaultRenderer(CCMTableModel2.HyperLink.class, new HyperLinkRenderer()); table.setDefaultRenderer(CCMTableModel2.DownloadLink.class, new DownloadLinkRenderer()); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ListSelectionModel cellSM = table.getSelectionModel(); cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cellSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { boolean adjusting = e.getValueIsAdjusting(); if (adjusting) { return; } int[] selectedRow = table.getSelectedRows(); ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { textPane.setText(" "); } else { String description = (String) ccmTableModel.getValueAt( table.convertRowIndexToModel(selectedRow[0]), CCMTableModel2.DESCRIPTION_INDEX); textPane.setText(description); if (textPane.getCaretPosition() > 1) { textPane.setCaretPosition(1); } } if (table.getSelectedRow() >= 0) { int modelColumn = table.convertColumnIndexToModel(table.getSelectedColumn()); if (modelColumn == CCMTableModel2.AVAILABLE_UPDATE_INDEX) installRemoteComponent(); else launchBrowser(); } } }); TableColumn column = table.getColumnModel().getColumn(CCMTableModel2.SELECTION_INDEX); column.setMaxWidth(50); column = table.getColumnModel().getColumn(CCMTableModel2.VERSION_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel2.AVAILABLE_UPDATE_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel2.TUTORIAL_URL_INDEX_2); column.setMaxWidth(70); column = table.getColumnModel().getColumn(CCMTableModel2.TOOL_URL_INDEX_2); column.setMaxWidth(70); scrollPaneForTable = new JScrollPane(table); } splitPane.setTopComponent(scrollPaneForTable); //======== scrollPaneForTextPane ======== { //---- textPane ---- textPane.setEditable(false); scrollPaneForTextPane.setViewportView(textPane); } splitPane.setBottomComponent(scrollPaneForTextPane); } //======== splitPane ========. frameContentPane.add(splitPane, BorderLayout.CENTER); //======== bottompanel ======== { bottompanel.setLayout(new FormLayout("20dlu," + "default, 4dlu, " + // view License "default,100dlu, " + // Component Update "default, 4dlu, " + // Apply "default, 4dlu, " + // Reset "default, 4dlu, " + // Cancel "default " // Close , "center:25dlu")); viewLicenseButton.setText("View License"); bottompanel.add(viewLicenseButton, cc.xy(2, 1)); //---- componentUpdateButton ---- bottompanel.add(componentUpdateButton, cc.xy(6, 1)); //---- applyButton ---- applyButton.setText("Apply"); bottompanel.add(applyButton, cc.xy(8, 1)); //---- resetButton ---- resetButton.setText("Reset"); bottompanel.add(resetButton, cc.xy(10, 1)); //---- closeButton ---- closeButton.setText("Close"); bottompanel.add(closeButton, cc.xy(12, 1)); } //======== bottompanel ========. frameContentPane.add(bottompanel, BorderLayout.SOUTH); } //======== outerPanel ======== frame.pack(); frame.setLocationRelativeTo(frame.getOwner()); } // ============ frame ============ topPanel.setVisible(true); splitPane.setVisible(true); scrollPaneForTable.setVisible(true); table.setVisible(true); scrollPaneForTextPane.setVisible(true); textPane.setVisible(true); bottompanel.setVisible(true); sorter.setRowFilter(combinedFilter); frame.setVisible(true); splitPane.setDividerLocation(.7d); }
From source file:org.gitools.ui.app.analysis.groupcomparison.wizard.GroupComparisonGroupingPage.java
public GroupComparisonGroupingPage(Heatmap heatmap, DimensionGroupEnum groupingType) { super();//ww w . ja va 2 s . co m this.heatmap = heatmap; this.groupingType = groupingType; setLogo(IconUtils.getImageIconResourceScaledByHeight(IconNames.LOGO_METHOD, 96)); layerCb.setModel(new DefaultComboBoxModel(heatmap.getLayers().getIds())); layerCb.setSelectedItem(heatmap.getLayers().getTopLayer().getId()); groupsTable.setModel(tableModel); setTitle("Group selection"); TableColumnModel columnModel = groupsTable.getColumnModel(); columnModel.getColumn(2).setPreferredWidth(50); columnModel.getColumn(2).setCellEditor(new SpinnerCellEditor(new SpinnerNumberModel())); columnModel.getColumn(2).getCellEditor().addCellEditorListener(new CellEditorListener() { @Override public void editingStopped(ChangeEvent e) { tableModel.fireTableDataChanged(); } @Override public void editingCanceled(ChangeEvent e) { tableModel.fireTableDataChanged(); } }); groupsTable.setRowHeight(25); groupsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateControls(); } }); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeSelected(); } }); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (getSelectedGroupingType().equals(DimensionGroupEnum.Annotation)) { //TODO: create Dialog with removedItems } else if (getSelectedGroupingType().equals(DimensionGroupEnum.Free)) { createFreeGroup(); } else if (getSelectedGroupingType().equals(DimensionGroupEnum.Value)) { createValueGroup(); } updateControls(); } }); dimensionCb.setModel(new DefaultComboBoxModel(new String[] { "Columns", "Rows" })); mergeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performMerge(); } }); splitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performSplit(); } }); dimensionCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { initGroups(); } }); ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { initGroups(); } }; annotationRadioButton.addActionListener(listener); valueRadioButton.addActionListener(listener); noConstraintRadioButton.addActionListener(listener); ActionListener nullConversionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateControls(); } }; nullDiscardRadioButton.addActionListener(nullConversionListener); nullConversionRadioButton.addActionListener(nullConversionListener); nullConversionTextArea.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { updateControls(); } @Override public void removeUpdate(DocumentEvent e) { updateControls(); } @Override public void changedUpdate(DocumentEvent e) { updateControls(); } }); updateControls(); layerCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateControls(); } }); }