List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener
ListSelectionListener
From source file:com.mirth.connect.client.ui.DashboardPanel.java
/** * Makes the status table with all current server information. *///from w w w .ja v a 2 s.com public void makeStatusTable() { List<String> columns = new ArrayList<String>(); for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) { if (plugin.isDisplayFirst()) { columns.add(plugin.getColumnHeader()); } } columns.addAll(Arrays.asList(defaultColumns)); for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) { if (!plugin.isDisplayFirst()) { columns.add(plugin.getColumnHeader()); } } DashboardTreeTableModel model = new DashboardTreeTableModel(); model.setColumnIdentifiers(columns); model.setNodeFactory(new DefaultDashboardTableNodeFactory()); for (DashboardTablePlugin plugin : LoadedExtensions.getInstance().getDashboardTablePlugins().values()) { dashboardTable = plugin.getTable(); if (dashboardTable != null) { break; } } defaultVisibleColumns.addAll(columns); if (dashboardTable == null) { dashboardTable = new MirthTreeTable("dashboardPanel", defaultVisibleColumns); } dashboardTable.setColumnFactory(new DashboardTableColumnFactory()); dashboardTable.setTreeTableModel(model); dashboardTable.setDoubleBuffered(true); dashboardTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); dashboardTable.setHorizontalScrollEnabled(true); dashboardTable.packTable(UIConstants.COL_MARGIN); dashboardTable.setRowHeight(UIConstants.ROW_HEIGHT); dashboardTable.setOpaque(true); dashboardTable.setRowSelectionAllowed(true); dashboardTable.setSortable(true); dashboardTable.putClientProperty("JTree.lineStyle", "Horizontal"); dashboardTable.setAutoCreateColumnsFromModel(false); dashboardTable.setShowGrid(true, true); dashboardTable.restoreColumnPreferences(); dashboardTable.setMirthColumnControlEnabled(true); dashboardTable.setTreeCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); TreePath path = dashboardTable.getPathForRow(row); if (path != null) { AbstractDashboardTableNode node = ((AbstractDashboardTableNode) path.getLastPathComponent()); if (node.isGroupNode()) { setIcon(UIConstants.ICON_GROUP); } else { DashboardStatus status = node.getDashboardStatus(); if (status.getStatusType() == StatusType.CHANNEL) { setIcon(UIConstants.ICON_CHANNEL); } else { setIcon(UIConstants.ICON_CONNECTOR); } } } return label; } }); dashboardTable.setLeafIcon(UIConstants.ICON_CONNECTOR); dashboardTable.setOpenIcon(UIConstants.ICON_CHANNEL); dashboardTable.setClosedIcon(UIConstants.ICON_CHANNEL); dashboardTableScrollPane.setViewportView(dashboardTable); dashboardTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent event) { checkSelectionAndPopupMenu(event); } @Override public void mouseReleased(MouseEvent event) { checkSelectionAndPopupMenu(event); } @Override public void mouseClicked(MouseEvent event) { int clickedRow = dashboardTable.rowAtPoint(new Point(event.getX(), event.getY())); if (clickedRow == -1) { return; } TreePath path = dashboardTable.getPathForRow(clickedRow); if (path != null && ((AbstractDashboardTableNode) path.getLastPathComponent()).isGroupNode()) { return; } if (event.getClickCount() >= 2 && dashboardTable.getSelectedRowCount() == 1 && dashboardTable.getSelectedRow() == clickedRow) { parent.doShowMessages(); } } }); dashboardTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { /* * MIRTH-3199: Only update the panel plugin if the selection is finished. This does * mean that the logs aren't updated live when adding to or removing from a * currently adjusting selection, but it's much more efficient when it comes to the * number of requests being done from the client. Plus, it actually will still * update while a selection is adjusting if the refresh interval on the dashboard * elapses. We can change this so that plugins are updated during a selection * adjustment, but it would first require a major rewrite of the connection log / * status column plugin. */ updatePopupMenu(!event.getValueIsAdjusting()); } }); }
From source file:com.mirth.connect.connectors.ws.WebServiceSender.java
public void setHeaderProperties(Map<String, List<String>> properties) { int size = 0; for (List<String> list : properties.values()) { size += list.size();//ww w. java2 s. c om } Object[][] tableData = new Object[size][2]; headersTable = new MirthTable(); int j = 0; Iterator i = properties.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); for (String keyValue : (List<String>) entry.getValue()) { tableData[j][NAME_COLUMN] = (String) entry.getKey(); tableData[j][VALUE_COLUMN] = keyValue; j++; } } headersTable.setModel(new javax.swing.table.DefaultTableModel(tableData, new String[] { NAME_COLUMN_NAME, VALUE_COLUMN_NAME }) { boolean[] canEdit = new boolean[] { true, true }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); headersTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (getSelectedRow(headersTable) != -1) { headerLastIndex = getSelectedRow(headersTable); headersDeleteButton.setEnabled(true); } else { headersDeleteButton.setEnabled(false); } } }); class WebServiceTableCellEditor extends TextFieldCellEditor { boolean checkProperties; public WebServiceTableCellEditor(boolean checkProperties) { super(); this.checkProperties = checkProperties; } @Override public boolean isCellEditable(EventObject evt) { boolean editable = super.isCellEditable(evt); if (editable) { headersDeleteButton.setEnabled(false); } return editable; } @Override protected boolean valueChanged(String value) { headersDeleteButton.setEnabled(true); if (checkProperties && (value.length() == 0)) { return false; } parent.setSaveEnabled(true); return true; } } headersTable.getColumnModel().getColumn(headersTable.getColumnModel().getColumnIndex(NAME_COLUMN_NAME)) .setCellEditor(new WebServiceTableCellEditor(true)); headersTable.getColumnModel().getColumn(headersTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME)) .setCellEditor(new WebServiceTableCellEditor(false)); headersTable.setCustomEditorControls(true); headersTable.setSelectionMode(0); headersTable.setRowSelectionAllowed(true); headersTable.setRowHeight(UIConstants.ROW_HEIGHT); headersTable.setDragEnabled(false); headersTable.setOpaque(true); headersTable.setSortable(false); headersTable.getTableHeader().setReorderingAllowed(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); headersTable.setHighlighters(highlighter); } headersPane.setViewportView(headersTable); }
From source file:com._17od.upm.gui.MainWindow.java
private void addComponentsToPane() { // Ensure the layout manager is a BorderLayout if (!(getContentPane().getLayout() instanceof GridBagLayout)) { getContentPane().setLayout(new GridBagLayout()); }/* w w w . j av a 2s. c om*/ // Create the menubar setJMenuBar(createMenuBar()); GridBagConstraints c = new GridBagConstraints(); // The toolbar Row c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; Component toolbar = createToolBar(); getContentPane().add(toolbar, c); // Keep the frame background color consistent getContentPane().setBackground(toolbar.getBackground()); // The seperator Row c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(new JSeparator(), c); // The search field row searchIcon = new JLabel(Util.loadImage("search.gif")); searchIcon.setDisabledIcon(Util.loadImage("search_d.gif")); searchIcon.setEnabled(false); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchIcon, c); searchField = new JTextField(15); searchField.setEnabled(false); searchField.setMinimumSize(searchField.getPreferredSize()); searchField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { // This method never seems to be called } public void insertUpdate(DocumentEvent e) { dbActions.filter(); } public void removeUpdate(DocumentEvent e) { dbActions.filter(); } }); searchField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { dbActions.resetSearch(); } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { // If the user hits the enter key in the search field and // there's only one item // in the listview then open that item (this code assumes // that the one item in // the listview has already been selected. this is done // automatically in the // DatabaseActions.filter() method) if (accountsListview.getModel().getSize() == 1) { viewAccountMenuItem.doClick(); } } } }); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchField, c); resetSearchButton = new JButton(Util.loadImage("stop.gif")); resetSearchButton.setDisabledIcon(Util.loadImage("stop_d.gif")); resetSearchButton.setEnabled(false); resetSearchButton.setToolTipText(Translator.translate(RESET_SEARCH_TXT)); resetSearchButton.setActionCommand(RESET_SEARCH_TXT); resetSearchButton.addActionListener(this); resetSearchButton.setBorder(BorderFactory.createEmptyBorder()); resetSearchButton.setFocusable(false); c.gridx = 2; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(resetSearchButton, c); // The accounts listview row accountsListview = new JList(); accountsListview.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); accountsListview.setSelectedIndex(0); accountsListview.setVisibleRowCount(10); accountsListview.setModel(new SortedListModel()); JScrollPane accountsScrollList = new JScrollPane(accountsListview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); accountsListview.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { // If the listview gets focus, there is one ore more items in // the listview and there is nothing // already selected, then select the first item in the list if (accountsListview.getModel().getSize() > 0 && accountsListview.getSelectedIndex() == -1) { accountsListview.setSelectionInterval(0, 0); } } }); accountsListview.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { dbActions.setButtonState(); } }); accountsListview.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { viewAccountMenuItem.doClick(); } } }); accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { viewAccountMenuItem.doClick(); } } }); // Create a shortcut to delete account functionality with DEL(delete) // key accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { try { dbActions.reloadDatabaseBefore(new DeleteAccountAction()); } catch (InvalidPasswordException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ProblemReadingDatabaseFile e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 1; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; getContentPane().add(accountsScrollList, c); // The "File Changed" panel c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 0, 1); c.ipadx = 3; c.ipady = 3; c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; databaseFileChangedPanel = new JPanel(); databaseFileChangedPanel.setLayout(new BoxLayout(databaseFileChangedPanel, BoxLayout.X_AXIS)); databaseFileChangedPanel.setBackground(new Color(249, 172, 60)); databaseFileChangedPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); JLabel fileChangedLabel = new JLabel("Database file changed"); fileChangedLabel.setAlignmentX(LEFT_ALIGNMENT); databaseFileChangedPanel.add(fileChangedLabel); databaseFileChangedPanel.add(Box.createHorizontalGlue()); JButton reloadButton = new JButton("Reload"); reloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { dbActions.reloadDatabaseFromDisk(); } catch (Exception ex) { dbActions.errorHandler(ex); } } }); databaseFileChangedPanel.add(reloadButton); databaseFileChangedPanel.setVisible(false); getContentPane().add(databaseFileChangedPanel, c); // Add the statusbar c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(statusBar, c); }
From source file:com.vladsch.idea.multimarkdown.settings.MultiMarkdownSettingsPanel.java
public MultiMarkdownSettingsPanel() { clearCustomCssButton.addActionListener(new ActionListener() { @Override//from w w w.j a va 2 s. c om public void actionPerformed(ActionEvent e) { textCustomCss.setText(""); } }); btnLoadDefault.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //String cssFileText = MultiMarkdownGlobalSettings.getInstance().getCssFileText(htmlThemeComboBox.getSelectedIndex()); //String base64Css = Base64.encodeBase64URLSafeString(MultiMarkdownGlobalSettings.getInstance().getCssText().getBytes(Charset.forName("utf-8"))); //String cssText = new String(Base64.decodeBase64(base64Css), Charset.forName("utf-8")); MultiMarkdownGlobalSettings settings = MultiMarkdownGlobalSettings.getInstance(); textCustomCss.setText((useOldPreviewCheckBox.isSelected() ? settings.getCssFileText(htmlThemeList.getSelectedIndex(), false) : (includesColorsCheckBox.isSelected() ? settings.getCssFileText(htmlThemeList.getSelectedIndex(), true) : "") + (includesLayoutCssCheckBox.isSelected() ? settings.getLayoutCssFileText() : "") + (includesHljsCssCheckBox.isSelected() && useHighlightJsCheckBox.isSelected() ? settings.getHljsCssFileText(htmlThemeList.getSelectedIndex(), true) : ""))); } }); showHtmlTextCheckBox.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { showHtmlTextStateChanged(); } }); showHtmlTextCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showHtmlTextStateChanged(); } }); focusEditorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textCustomCss.requestFocus(); } }); ItemListener itemListener1 = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateCustomCssControls(); } }; useCustomCssCheckBox.addItemListener(itemListener1); useHighlightJsCheckBox.addItemListener(itemListener1); textCustomCss.addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { super.documentChanged(e); updateCustomCssControls(); } }); if (MultiMarkdownGlobalSettings.getInstance().fxPreviewFailedBuild.isFailedBuild()) { // set it and disable useOldPreviewCheckBox.setSelected(true); useOldPreviewCheckBox.setEnabled(false); } updateUseOldPreviewControls(); ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateUseOldPreviewControls(); } }; useOldPreviewCheckBox.addItemListener(itemListener); includesColorsCheckBox.addItemListener(itemListener); includesHljsCssCheckBox.addItemListener(itemListener); includesLayoutCssCheckBox.addItemListener(itemListener); if (htmlThemeComboBox instanceof ComboBox) { ((JComboBox) htmlThemeComboBox).addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (((JComboBox) htmlThemeComboBox).getSelectedIndex() != htmlThemeList.getSelectedIndex()) { htmlThemeList.setSelectedIndex(((JComboBox) htmlThemeComboBox).getSelectedIndex()); } } }); htmlThemeList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (((JComboBox) htmlThemeComboBox).getSelectedIndex() != htmlThemeList.getSelectedIndex()) { ((JComboBox) htmlThemeComboBox).setSelectedIndex(htmlThemeList.getSelectedIndex()); } } }); } //tippingJarEditorPane.setText("" + // "<html>\n" + // " <head>\n" + // " <style>\n" + // " td { text-align: right; margin 0; padding 0 10px !important; }\n" + // " td.pic { width: 0; }\n" + // " p, table, tr, body, div { margin: 0 !important; padding: 0 !important; }\n" + // " table { /*border: 1px solid black;*/ width: 100%; float: right !important; }\n" + // " </style>\n" + // " </head>\n" + // " <body>\n" + // " <table>\n" + // " <tr>\n" + // " <td><b>If you like my work then please feel free to tip me.<br>I will view it as a show of appreciation and as a reward for my effort.</b></td>\n" + // " <td class=\"pic\"><a href=\"http://flattr.com/thing/4603764/vschidea-multimarkdown-on-GitHub\" title=\"Donate monthly to vsch using Flattr\"><img src=\"https://raw.githubusercontent.com/vsch/idea-multimarkdown/master/assets/images/flattr-tips.png\" border=\"0\" width=\"43\" height=\"53\" alt=\"Donate monthly to vsch using Flattr\" /></a></td>\n" + // " <td class=\"pic\"><a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NR7DAGTC8CXLU\" title=\"Donate once-off to vsch using Paypal\"><img src=\"https://raw.githubusercontent.com/vsch/idea-multimarkdown/master/assets/images/paypal-tips.png\" border=\"0\" width=\"43\" height=\"53\" alt=\"Donate once-off to vsch using Paypal\" /></a></td>\n" + // " </tr>\n" + // " </table>\n" + // " </body>\n" + // "</html>\n" + // ""); String htmlText = ""; try { htmlText = Resources.toString(getClass().getResource("/com/vladsch/idea/multimarkdown/NOTICE.html"), Charsets.UTF_8); } catch (IOException ex) { ex.printStackTrace(); } MultiMarkdownPreviewEditor.setStyleSheet(noticesEditorPane); noticesEditorPane.setText(htmlText); //tippingJarEditorPane.addHyperlinkListener(listener); noticesEditorPane.addHyperlinkListener(SettingsPanelImpl.getHyperLinkListenerBrowseUrl()); // we don't change these githubWikiLinksCheckBox.setEnabled(false); //githubWikiLinksLabel.setVisible(false); }
From source file:edu.ku.brc.specify.config.ResourceImportExportDlg.java
@Override public void createUI() { this.setHelpContext("Import"); super.createUI(); CellConstraints cc = new CellConstraints(); levelCBX = createComboBox();//w w w . java 2s . c o m DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); for (SpAppResourceDir curDir : contextMgr.getSpAppResourceList()) { SpAppResourceDir dir; if (curDir.getId() != null) { dir = session.get(SpAppResourceDir.class, curDir.getId()); dir.setTitle(curDir.getTitle()); // Force Load dir.getSpAppResources().size(); dir.getSpPersistedAppResources().size(); dir.getSpPersistedViewSets().size(); for (SpAppResource appRes : curDir.getSpAppResources()) { if (appRes.getId() == null) { dir.getSpAppResources().add(appRes); } } for (SpViewSetObj vso : curDir.getSpViewSets()) { if (vso.getId() == null) { dir.getSpViewSets().add(vso); } } } else { dir = (SpAppResourceDir) curDir.clone(); } dirs.add(dir); levelCBX.addItem(dir); } } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ResourceImportExportDlg.class, ex); } finally { if (session != null) { session.close(); } } PanelBuilder centerPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "p,10px,p")); centerPB.add(createLabel(UIRegistry.getLocalizedMessage("RIE_USR_LBL", userName)), cc.xy(2, 1)); centerPB.add(levelCBX, cc.xy(2, 3)); tabbedPane = new JTabbedPane(); PanelBuilder viewPanel = new PanelBuilder(new FormLayout("f:p:g,10px,f:p:g", "p,2px,f:p:g")); viewPanel.add(createLabel(getResourceString("RIE_VIEWSETS"), SwingConstants.CENTER), cc.xy(1, 1)); viewSetsList = new JList(viewSetsModel); viewSetsList.setCellRenderer(new ARListRenderer()); JScrollPane sp = new JScrollPane(viewSetsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(1, 3)); viewPanel.add(createLabel(getResourceString("RIE_VIEWS"), SwingConstants.CENTER), cc.xy(3, 1)); viewsList = new JList(viewsModel); viewsList.setCellRenderer(new ViewRenderer()); sp = new JScrollPane(viewsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(3, 3)); viewsList.setEnabled(false); PanelBuilder resPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,p")); resPane.add(createLabel(getResourceString("RIE_OTHER_RES"), SwingConstants.CENTER), cc.xy(1, 1)); resList = new JList(resModel); resList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(resList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); resPane.add(sp, cc.xy(1, 3)); PanelBuilder repPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g")); repPane.add(createLabel(getResourceString("RIE_REPORT_RES"), SwingConstants.CENTER), cc.xy(1, 1)); repList = new JList(repModel); repList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); repList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(repList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); repPane.add(sp, cc.xy(1, 3)); boolean addResourcesPanel = AppPreferences.getLocalPrefs().getBoolean("ADD_IMP_RES", false); viewsPanel = viewPanel.getPanel(); tabbedPane.addTab(getResourceString("RIE_VIEWSETS"), viewsPanel); if (addResourcesPanel) { resPanel = resPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_OTHER_RES"), resPanel); } repPanel = repPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_REPORT_RES"), repPanel); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p")); pb.add(centerPB.getPanel(), cc.xy(1, 1)); pb.add(tabbedPane, cc.xy(1, 3)); exportBtn = createButton(getResourceString("RIE_EXPORT")); importBtn = createButton(getResourceString("RIE_IMPORT")); revertBtn = createButton(getResourceString("RIE_REVERT")); PanelBuilder btnPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g,p,f:p:g,p,f:p:g", "p,10px")); btnPB.add(exportBtn, cc.xy(2, 1)); btnPB.add(importBtn, cc.xy(4, 1)); btnPB.add(revertBtn, cc.xy(6, 1)); pb.add(btnPB.getPanel(), cc.xy(1, 5)); pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Component selectedComp = tabbedPane.getSelectedComponent(); if (selectedComp != null) { if (selectedComp == viewsPanel) { viewSetsList.setSelectedIndex(-1); } else if (selectedComp == resPanel) { resList.setSelectedIndex(-1); } else { repList.setSelectedIndex(-1); } //revertBtn.setVisible(selectedComp != repPanel); } enableUI(); // JGoodies Resizes the panel in the Dialog and // partially hides the buttons, this fixes that. Dimension size = ResourceImportExportDlg.this.getSize(); //ResourceImportExportDlg.this.pack(); //Dimension newSize = ResourceImportExportDlg.this.getSize(); Dimension newSize = ResourceImportExportDlg.this.getPreferredSize(); size.height = newSize.height; ResourceImportExportDlg.this.setSize(size); } }); levelCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { levelSelected(); } }); } }); levelCBX.setSelectedIndex(0); pack(); exportBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exportResource(); } }); importBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importResource(); } }); revertBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { revertResource(); } }); viewSetsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (viewSetsList.getSelectedIndex() > -1) { resList.clearSelection(); repList.clearSelection(); } fillViewsList(); enableUI(); } } }); resList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); repList.clearSelection(); } enableUI(); } } }); repList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); resList.clearSelection(); } enableUI(); } } }); pack(); }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * Export data //from w ww. j av a 2 s . c o m */ protected void exportSingleLocale() { statusBar.setText(getResourceString("SchemaLocalizerFrame.EXPORTING")); //$NON-NLS-1$ statusBar.paintImmediately(statusBar.getBounds()); schemaLocPanel.getAllDataFromUI(); if (localizableIO.hasChanged()) { if (UIRegistry.askYesNoLocalized("SAVE", "CANCEL", UIRegistry.getResourceString("SchemaLocalizerFrame.NEEDS_SAVING"), "SAVE") == JOptionPane.YES_NO_OPTION) { localizableIO.save(); } else { return; } } Vector<Locale> stdLocales = SchemaI18NService.getInstance().getStdLocaleList(false); final JList list = new JList(stdLocales); list.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { setText(((Locale) value).getDisplayName()); } return this; } }); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g")); pb.add(UIHelper.createScrollPane(list), (new CellConstraints()).xy(1, 1)); pb.setDefaultDialogBorder(); final CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(), getResourceString("SchemaLocalizerFrame.CHOOSE_LOCALE"), true, pb.getPanel()); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { dlg.getOkBtn().setEnabled(list.getSelectedValue() != null); } } }); dlg.createUI(); dlg.getOkBtn().setEnabled(false); UIHelper.centerAndShow(dlg); if (!dlg.isCancelled()) { Locale locale = (Locale) list.getSelectedValue(); if (locale != null) { FileDialog fileDlg = new FileDialog((Frame) UIRegistry.getTopWindow(), getResourceString("SchemaLocalizerFrame.SVFILENAME"), FileDialog.SAVE); fileDlg.setVisible(true); String fileName = fileDlg.getFile(); if (StringUtils.isNotEmpty(fileName)) { File outFile = new File(fileDlg.getDirectory() + File.separator + fileName); boolean savedOK = localizableIO.exportSingleLanguageToDirectory(outFile, locale); if (savedOK) { String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTEDTO", locale.getDisplayName(), outFile.getAbsolutePath()); UIRegistry.displayInfoMsgDlg(msg); } else { String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTING_ERR", outFile.getAbsolutePath()); UIRegistry.showError(msg); } } } } }
From source file:com.mirth.connect.connectors.http.HttpSender.java
public void setHeaders(Map<String, List<String>> properties) { int size = 0; for (List<String> property : properties.values()) { size += property.size();/*from w w w.j a v a2 s.c o m*/ } Object[][] tableData = new Object[size][2]; headersTable = new MirthTable(); int j = 0; Iterator i = properties.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); for (String keyValue : (List<String>) entry.getValue()) { tableData[j][NAME_COLUMN] = (String) entry.getKey(); tableData[j][VALUE_COLUMN] = keyValue; j++; } } headersTable.setModel(new javax.swing.table.DefaultTableModel(tableData, new String[] { NAME_COLUMN_NAME, VALUE_COLUMN_NAME }) { boolean[] canEdit = new boolean[] { true, true }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); headersTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (getSelectedRow(headersTable) != -1) { headerLastIndex = getSelectedRow(headersTable); headersDeleteButton.setEnabled(true); } else { headersDeleteButton.setEnabled(false); } } }); class HTTPTableCellEditor extends TextFieldCellEditor { boolean checkProperties; public HTTPTableCellEditor(boolean checkProperties) { super(); this.checkProperties = checkProperties; } public boolean checkUniqueProperty(String property) { boolean exists = false; for (int i = 0; i < headersTable.getRowCount(); i++) { if (headersTable.getValueAt(i, NAME_COLUMN) != null && ((String) headersTable.getValueAt(i, NAME_COLUMN)).equalsIgnoreCase(property)) { exists = true; } } return exists; } @Override public boolean isCellEditable(EventObject evt) { boolean editable = super.isCellEditable(evt); if (editable) { headersDeleteButton.setEnabled(false); } return editable; } @Override protected boolean valueChanged(String value) { headersDeleteButton.setEnabled(true); if (checkProperties && (value.length() == 0)) { return false; } parent.setSaveEnabled(true); return true; } } headersTable.getColumnModel().getColumn(headersTable.getColumnModel().getColumnIndex(NAME_COLUMN_NAME)) .setCellEditor(new HTTPTableCellEditor(true)); headersTable.getColumnModel().getColumn(headersTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME)) .setCellEditor(new HTTPTableCellEditor(false)); headersTable.setCustomEditorControls(true); headersTable.setSelectionMode(0); headersTable.setRowSelectionAllowed(true); headersTable.setRowHeight(UIConstants.ROW_HEIGHT); headersTable.setDragEnabled(false); headersTable.setOpaque(true); headersTable.setSortable(false); headersTable.getTableHeader().setReorderingAllowed(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); headersTable.setHighlighters(highlighter); } headersPane.setViewportView(headersTable); }
From source file:edu.ku.brc.specify.conversion.SpecifyDBConverter.java
/** * @return/*from w ww. ja v a 2s. c o m*/ * @throws SQLException */ public Pair<String, String> chooseTable(final String title, final String subTitle, final boolean doSp5DBs) throws SQLException { MySQLDMBSUserMgr mgr = new MySQLDMBSUserMgr(); Vector<DBNamePair> availPairs = new Vector<DBNamePair>(); if (mgr.connectToDBMS(itUsrPwd.first, itUsrPwd.second, hostName)) { BasicSQLUtils.setSkipTrackExceptions(true); //String sql = String.format("SELECT DISTINCT `COLUMNS`.TABLE_SCHEMA FROM `COLUMNS` WHERE `COLUMNS`.TABLE_NAME = '%s'", doSp5DBs ? "collectionobjectcatalog" : "taxon"); Connection conn = mgr.getConnection(); Vector<Object[]> dbNames = BasicSQLUtils.query(conn, "show databases"); for (Object[] row : dbNames) { String dbName = row[0].toString(); //System.out.print("Database Found ["+dbName+"] "); conn.setCatalog(dbName); boolean isSp5DB = false; Vector<Object[]> tables = BasicSQLUtils.query(conn, "show tables"); for (Object[] tblRow : tables) { String tableName = tblRow[0].toString(); if (tableName.equalsIgnoreCase("usysversion")) { isSp5DB = true; break; } } if ((!isSp5DB && doSp5DBs) || (isSp5DB && !doSp5DBs)) { continue; } // make all table names lowercase try { Integer count = BasicSQLUtils.getCount(conn, "select COUNT(*) FROM collection"); if (count == null) { for (Object[] tblRow : tables) { String tableName = tblRow[0].toString(); if (!tableName.equals(tableName.toLowerCase())) { BasicSQLUtils.update(conn, "RENAME TABLE " + tableName + " TO " + tableName.toLowerCase()); } } } } catch (Exception ex) { ex.printStackTrace(); } Vector<Object> tableDesc = BasicSQLUtils.querySingleCol(conn, "select CollectionName FROM collection"); if (tableDesc.size() > 0) { String collName = tableDesc.get(0).toString(); availPairs.add(new DBNamePair(collName, row[0].toString())); } } Collections.sort(availPairs, new Comparator<Pair<String, String>>() { @Override public int compare(Pair<String, String> o1, Pair<String, String> o2) { return o1.second.compareTo(o2.second); } }); mgr.close(); BasicSQLUtils.setSkipTrackExceptions(false); final JList list = new JList(availPairs); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g")); pb.add(UIHelper.createLabel(subTitle), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(list, true), cc.xy(1, 3)); pb.setDefaultDialogBorder(); final CustomDialog dlg = new CustomDialog(null, title, true, pb.getPanel()); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { dlg.getOkBtn().setEnabled(list.getSelectedIndex() > -1); } } }); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { dlg.getOkBtn().setEnabled(list.getSelectedIndex() > -1); dlg.getOkBtn().doClick(); } } }); dlg.createUI(); dlg.pack(); Dimension d = dlg.getPreferredSize(); d.height = 700; dlg.setSize(d); UIHelper.centerAndShow(dlg); if (dlg.isCancelled()) { return null; } return namePairToConvert = (DBNamePair) list.getSelectedValue(); } return null; }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * //from ww w . ja va 2s . c o m */ private void createUI() { IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$ System.setProperty("edu.ku.brc.ui.db.PickListDBAdapterFactory", //$NON-NLS-1$ "edu.ku.brc.specify.tools.StrLocPickListFactory"); // Needed By the Auto Cosmplete UI //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); fileList = new JList(fileModel = new DefaultListModel()); termList = new JList(model = new ItemModel(null)); srcLbl = setTAReadOnly(UIHelper.createTextArea(3, 40)); //srcLbl.setBorder(new LineBorder(srcLbl.getForeground())); textField = UIHelper.createTextField(40); comment = setTAReadOnly(UIHelper.createTextArea(3, 40)); /*textField.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { hasChanged = true; } });*/ statusBar = new JStatusBar(); statusBar.setSectionText(1, " "); //$NON-NLS-1$ //$NON-NLS-2$ UIRegistry.setStatusBar(statusBar); srcLbl.setEditable(false); rsController = new ResultSetController(null, false, false, false, "", 1, true); transBtn = UIHelper.createButton(getResourceString("StrLocalizerApp.Translate")); transBtn.setVisible(false); PanelBuilder pbr = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,4px,p,4px,p,4px,p,4px,p,4px,p")); //pbr.add(UIHelper.createLabel(getResourceString("StrLocalizerApp.FileLbl")), cc.xy(1, 1)); //fileLbl = UIHelper.createLabel(" "); //pbr.add(fileLbl, cc.xy(3, 1)); int y = 1; pbr.addSeparator("Item", cc.xyw(1, y, 3)); y += 2; pbr.add(UIHelper.createLabel("English:", SwingConstants.RIGHT), cc.xy(1, y)); pbr.add(srcLbl, cc.xy(3, y)); y += 2; pbr.add(UIHelper.createFormLabel("Comment", SwingConstants.RIGHT), cc.xy(1, y)); pbr.add(comment, cc.xy(3, y)); y += 2; destLbl = UIHelper.createFormLabel("", SwingConstants.RIGHT);//destLanguage.getDisplayName()); pbr.add(destLbl, cc.xy(1, y)); pbr.add(textField, cc.xy(3, y)); y += 2; pbr.add(rsController.getPanel(), cc.xyw(1, y, 3)); y += 2; pbr.add(transBtn, cc.xy(1, y)); JScrollPane sp = UIHelper.createScrollPane(termList); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,10px,p")); pb.addSeparator("Localize", cc.xy(1, 1)); pb.add(sp, cc.xy(1, 3)); pb.add(pbr.getPanel(), cc.xy(1, 5)); pb.setDefaultDialogBorder(); ResultSetController.setBackStopRS(rsController); PanelBuilder fpb = new PanelBuilder(new FormLayout("8px,f:p:g", "p,4px,f:p:g")); JScrollPane filesp = UIHelper.createScrollPane(fileList); fpb.add(UIHelper.createLabel("Files", SwingConstants.CENTER), cc.xy(2, 1)); fpb.add(filesp, cc.xy(2, 3)); setLayout(new BorderLayout()); add(fpb.getPanel(), BorderLayout.WEST); add(pb.getPanel(), BorderLayout.CENTER); add(statusBar, BorderLayout.SOUTH); mainPane = this; textField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { checkForChange(); } }); termList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { itemSelected(); } } }); fileList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fileSelected(); } } }); transBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String txt = srcLbl.getText(); String newText = translate(txt); if (StringUtils.isNotEmpty(newText)) { newText = newText.replace("'", "'"); textField.setText(newText); L10NItem entry = (L10NItem) termList.getSelectedValue(); entry.setValue(textField.getText()); } } }); rscListener = new ResultSetControllerListener() { @Override public void newRecordAdded() { } @Override public void indexChanged(int newIndex) { termList.setSelectedIndex(newIndex); } @Override public boolean indexAboutToChange(int oldIndex, int newIndex) { return true; } }; rsController.addListener(rscListener); }
From source file:edu.ku.brc.specify.datamodel.busrules.DeterminationBusRules.java
@Override public void initialize(Viewable viewableArg) { super.initialize(viewableArg); if (formViewObj != null) { GetSetValueIFace taxonField = (GetSetValueIFace) formViewObj.getControlByName("taxon"); if (taxonField instanceof ValComboBoxFromQuery) { final ValComboBoxFromQuery parentCBX = (ValComboBoxFromQuery) taxonField; final Component altNameComp = formViewObj.getControlByName("alternateName"); if (nameChangeKL == null) { nameChangeKL = new KeyAdapter() { @Override/*from w w w. ja v a 2 s . co m*/ public void keyTyped(final KeyEvent e) { SwingUtilities.invokeLater(new Runnable() { // @Override public void run() { nameChanged(e, parentCBX, altNameComp); } }); } }; } if (parentCBX != null) { parentCBX.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e == null || !e.getValueIsAdjusting()) { taxonChanged(parentCBX, altNameComp); } } }); addListenerIfNecessary(nameChangeKL, parentCBX); } if (altNameComp != null) { addListenerIfNecessary(nameChangeKL, altNameComp); } } } }