List of usage examples for java.awt GridBagConstraints clone
public Object clone()
From source file:pipeline.parameter_cell_views.FloatRangeSlider.java
public FloatRangeSlider() { super();/* w ww .j a va2 s .c o m*/ addMouseWheelListener(e -> { int rotation = e.getWheelRotation(); float[] float_values = (float[]) (currentParameter.getValue()); currentValue0 = float_values[0]; currentValue1 = float_values[1]; minimum = float_values[2]; maximum = float_values[3]; float change = (currentValue1 - currentValue0 + 1) * rotation * Utils.getMouseWheelClickFactor(); currentValue0 += change; currentValue1 += change; if (!((e.getModifiers() & java.awt.event.InputEvent.ALT_MASK) > 0)) { if (currentValue1 > maximum) { float difference = currentValue1 - currentValue0; currentValue1 = maximum; currentValue0 = currentValue1 - difference; } if (currentValue0 < minimum) { float difference = currentValue1 - currentValue0; currentValue0 = minimum; currentValue1 = currentValue0 + difference; } } currentParameter.setValue(new float[] { currentValue0, currentValue1, minimum, maximum }); readInValuesFromParameter(); updateDisplays(); currentParameter.fireValueChanged(false, false, true); }); nf.setGroupingUsed(true); nf.setMaximumFractionDigits(5); nf.setMaximumIntegerDigits(10); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.weighty = 1.0; c.weightx = 1.0; c.gridwidth = 4; cForHistogram = (GridBagConstraints) c.clone(); panelForHistogram = new JPanel(); panelForHistogram.setPreferredSize(new Dimension(200, 150)); panelForHistogram.setLayout(new BorderLayout()); c.gridx = 0; c.gridy = 1;// 1 c.weighty = 0.0; c.weightx = 0.0; c.gridwidth = 4; add(Box.createRigidArea(new Dimension(0, 5)), c); slider = new RangeSlider(0, 20); slider.addChangeListener(new sliderListener()); c.gridx = 0; c.gridy = 2; c.weighty = 0.0; c.weightx = 0.0; c.gridwidth = 4; add(slider, c); c.gridx = 0; c.gridy = 3; c.weighty = 0.0; c.weightx = 1.0; c.gridwidth = 4; Component comp = Box.createRigidArea(new Dimension(0, 10)); ((JComponent) comp).setOpaque(true); add(comp, c); c.gridwidth = 1; final textBoxListener minMaxListener = new textBoxListener(); currentTextValue0 = new JTextField(""); currentTextValue1 = new JTextField(""); currentTextValue0.addActionListener(new textBoxListenerTriggersUpdate()); currentTextValue1.addActionListener(new textBoxListenerTriggersUpdate()); Font smallerFont = new Font(currentTextValue0.getFont().getName(), currentTextValue0.getFont().getStyle(), currentTextValue0.getFont().getSize() - 2); textMinimum = new JTextField("0"); textMinimum.setFont(smallerFont); textMinimum.addActionListener(minMaxListener); textMaximum = new JTextField("50"); textMaximum.setFont(smallerFont); textMaximum.addActionListener(minMaxListener); textMaximum.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { minMaxListener.actionPerformed(new ActionEvent(textMaximum, 0, "")); } }); textMinimum.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { minMaxListener.actionPerformed(new ActionEvent(textMinimum, 0, "")); } }); textValueFrame = new JPanel(); textValueFrame.setBackground(getBackground()); textValueFrame.setLayout(new GridBagLayout()); c.gridx = 0; c.gridy = 0; c.weighty = 1.0; c.weightx = 0.1; textValueFrame.add(textMinimum, c); c.gridx = 1; c.gridy = 0; c.weighty = 1.0; c.weightx = 0.3; textValueFrame.add(currentTextValue0, c); c.gridx = 2; c.gridy = 0; c.weighty = 1.0; c.weightx = 0.3; textValueFrame.add(currentTextValue1, c); c.gridx = 3; c.gridy = 0; c.weighty = 1.0; c.weightx = 0.1; textValueFrame.add(textMaximum, c); c.gridx = 0; c.gridy = 4; c.weighty = 0.0; c.weightx = 0.3; c.gridwidth = 4; add(textValueFrame, c); c.gridwidth = 1; parameterName = new JLabel("parameter"); c.gridx = 0; c.gridy = 5; c.weighty = 0.0; c.weightx = 0.01; c.gridwidth = 1; add(parameterName, c); resetMin = new JButton("Min"); resetMin.setActionCommand("Reset Min"); resetMin.addActionListener(new buttonListener()); resetMax = new JButton("Max"); resetMax.setActionCommand("Reset Max"); resetMax.addActionListener(new buttonListener()); resetRange = new JButton("MinMax"); resetRange.setActionCommand("Reset Range"); resetRange.addActionListener(new buttonListener()); c.gridx = 1; c.gridy = 5; c.weighty = 0.0; c.weightx = 0.2; c.gridwidth = 1; add(resetMin, c); c.gridx = 2; c.gridy = 5; c.weighty = 0.0; c.weightx = 0.2; c.gridwidth = 1; add(resetMax, c); c.gridx = 3; c.gridy = 5; c.weighty = 0.0; c.weightx = 0.2; c.gridwidth = 1; add(resetRange, c); // ,resetMax,resetRange; }
From source file:de.fhg.igd.iva.explorer.main.CompareViewPanel.java
protected void updateSelection() { KnownColormap colormap = (KnownColormap) mapsCombo.getSelectedItem(); cmView.setColormap(colormap);/*from w ww . j a va 2s . c o m*/ statsBars.removeAll(); Map<ColormapQuality, Double> row = table.row(colormap); Insets insets = new Insets(0, 0, 0, 0); Insets insets5 = new Insets(0, 5, 0, 0); GridBagConstraints gbcName = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, insets, 0, 0); GridBagConstraints gbcQual = new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcRank = new GridBagConstraints(2, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcStatL = new GridBagConstraints(3, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcStatR = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcStat = new GridBagConstraints(3, 0, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, insets5, 0, 0); statsBars.add(new JLabel("Name"), gbcName); statsBars.add(new JLabel("Score"), gbcQual); statsBars.add(new JLabel("Rank"), gbcRank); // maybe use a best/worst arrow down marker instead? unicode: \u2193 statsBars.add(new JLabel("\u2190Worse"), gbcStatL); statsBars.add(new JLabel("Better\u2192"), gbcStatR); GridBagConstraints gbcSpace = new GridBagConstraints(0, 1, 5, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0); JSeparator spacing = new JSeparator(SwingConstants.HORIZONTAL); statsBars.add(spacing, gbcSpace); int count = table.rowKeySet().size(); int rowIdx = 2; for (ColormapQuality metric : row.keySet()) { double quality = row.get(metric); DescriptiveStatistics stats = computeStats(metric); int index = Arrays.binarySearch(stats.getSortedValues(), quality); int rank = metric.moreIsBetter() ? count - index : index + 1; gbcName = (GridBagConstraints) gbcName.clone(); gbcQual = (GridBagConstraints) gbcQual.clone(); gbcRank = (GridBagConstraints) gbcRank.clone(); gbcStat = (GridBagConstraints) gbcStat.clone(); gbcName.gridy = rowIdx; gbcQual.gridy = rowIdx; gbcRank.gridy = rowIdx; gbcStat.gridy = rowIdx; statsBars.add(new JLabel(metric.getName()), gbcName); statsBars.add(new JLabel(String.format("%.2f", quality)), gbcQual); statsBars.add(new JLabel(Integer.toString(rank)), gbcRank); statsBars.add(new JStatBar(metric, stats, quality), gbcStat); rowIdx++; } // I find it strange that both revalidate and repaint must be explicitly called here revalidate(); repaint(); }
From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java
public void startup() { if (dialog != null) { dialog.toFront();/*from ww w . j a v a 2s .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_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();// ww w .j av a2 s .c om 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.kse.gui.dialogs.importexport.DImportKeyPairOpenSsl.java
private void initComponents() { GridBagConstraints gbcLbl = new GridBagConstraints(); gbcLbl.gridx = 0;//from w w w .java2 s . c o m gbcLbl.gridwidth = 3; gbcLbl.gridheight = 1; gbcLbl.insets = new Insets(5, 5, 5, 5); gbcLbl.anchor = GridBagConstraints.EAST; GridBagConstraints gbcEdCtrl = new GridBagConstraints(); gbcEdCtrl.gridx = 3; gbcEdCtrl.gridwidth = 3; gbcEdCtrl.gridheight = 1; gbcEdCtrl.insets = new Insets(5, 5, 5, 5); gbcEdCtrl.anchor = GridBagConstraints.WEST; jlEncrypted = new JLabel(res.getString("DImportKeyPairOpenSsl.jlEncrypted.text")); GridBagConstraints gbc_jlEncrypted = (GridBagConstraints) gbcLbl.clone(); gbc_jlEncrypted.gridy = 0; jcbEncrypted = new JCheckBox(); jcbEncrypted.setSelected(true); jcbEncrypted.setToolTipText(res.getString("DImportKeyPairOpenSsl.jcbEncrypted.tooltip")); GridBagConstraints gbc_jcbEncrypted = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jcbEncrypted.gridy = 0; jlPassword = new JLabel(res.getString("DImportKeyPairOpenSsl.jlPassword.text")); GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone(); gbc_jlPassword.gridy = 1; jpfPassword = new JPasswordField(15); jpfPassword.setToolTipText(res.getString("DImportKeyPairOpenSsl.jpfPassword.tooltip")); GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jpfPassword.gridy = 1; jlPrivateKey = new JLabel(res.getString("DImportKeyPairOpenSsl.jlPrivateKey.text")); GridBagConstraints gbc_jlPrivateKey = (GridBagConstraints) gbcLbl.clone(); gbc_jlPrivateKey.gridy = 2; jtfPrivateKeyPath = new JTextField(30); jtfPrivateKeyPath.setToolTipText(res.getString("DImportKeyPairOpenSsl.jtfPrivateKeyPath.tooltip")); GridBagConstraints gbc_jtfPrivateKeyPath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfPrivateKeyPath.gridy = 2; gbc_jtfPrivateKeyPath.gridwidth = 6; jbPrivateKeyBrowse = new JButton(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.text")); PlatformUtil.setMnemonic(jbPrivateKeyBrowse, res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.mnemonic").charAt(0)); jbPrivateKeyBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); privateKeyBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); jbPrivateKeyBrowse.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.tooltip")); GridBagConstraints gbc_jbPrivateKeyBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyBrowse.gridy = 2; gbc_jbPrivateKeyBrowse.gridx = 9; jbPrivateKeyDetails = new JButton(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.text")); jbPrivateKeyDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); privateKeyDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); PlatformUtil.setMnemonic(jbPrivateKeyDetails, res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.mnemonic").charAt(0)); jbPrivateKeyDetails.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.tooltip")); GridBagConstraints gbc_jbPrivateKeyDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyDetails.gridy = 2; gbc_jbPrivateKeyDetails.gridx = 12; jlCertificate = new JLabel(res.getString("DImportKeyPairOpenSsl.jlCertificate.text")); GridBagConstraints gbc_jlCertificate = (GridBagConstraints) gbcLbl.clone(); gbc_jlCertificate.gridy = 3; jtfCertificatePath = new JTextField(30); jtfCertificatePath.setToolTipText(res.getString("DImportKeyPairOpenSsl.jtfCertificatePath.tooltip")); GridBagConstraints gbc_jtfCertificatePath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfCertificatePath.gridy = 3; gbc_jtfCertificatePath.gridwidth = 6; jbCertificateBrowse = new JButton(res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.text")); jbCertificateBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); certificateBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); PlatformUtil.setMnemonic(jbCertificateBrowse, res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.mnemonic").charAt(0)); jbCertificateBrowse.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.tooltip")); GridBagConstraints gbc_jbCertificateBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateBrowse.gridy = 3; gbc_jbCertificateBrowse.gridx = 9; jbCertificateDetails = new JButton(res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.text")); jbCertificateDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); certificateDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); PlatformUtil.setMnemonic(jbCertificateDetails, res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.mnemonic").charAt(0)); jbCertificateDetails.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.tooltip")); GridBagConstraints gbc_jbCertificateDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateDetails.gridy = 3; gbc_jbCertificateDetails.gridx = 12; jpKeyPair = new JPanel(new GridBagLayout()); jpKeyPair.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()), new EmptyBorder(5, 5, 5, 5))); jpKeyPair.add(jlEncrypted, gbc_jlEncrypted); jpKeyPair.add(jcbEncrypted, gbc_jcbEncrypted); jpKeyPair.add(jlPassword, gbc_jlPassword); jpKeyPair.add(jpfPassword, gbc_jpfPassword); jpKeyPair.add(jlPrivateKey, gbc_jlPrivateKey); jpKeyPair.add(jtfPrivateKeyPath, gbc_jtfPrivateKeyPath); jpKeyPair.add(jbPrivateKeyBrowse, gbc_jbPrivateKeyBrowse); jpKeyPair.add(jbPrivateKeyDetails, gbc_jbPrivateKeyDetails); jpKeyPair.add(jlCertificate, gbc_jlCertificate); jpKeyPair.add(jtfCertificatePath, gbc_jtfCertificatePath); jpKeyPair.add(jbCertificateBrowse, gbc_jbCertificateBrowse); jpKeyPair.add(jbCertificateDetails, gbc_jbCertificateDetails); jcbEncrypted.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { if (jcbEncrypted.isSelected()) { jpfPassword.setEnabled(true); } else { jpfPassword.setEnabled(false); jpfPassword.setText(""); } } }); jbImport = new JButton(res.getString("DImportKeyPairOpenSsl.jbImport.text")); PlatformUtil.setMnemonic(jbImport, res.getString("DImportKeyPairOpenSsl.jbImport.mnemonic").charAt(0)); jbImport.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbImport.tooltip")); jbImport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); importPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); jbCancel = new JButton(res.getString("DImportKeyPairOpenSsl.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpButtons = PlatformUtil.createDialogButtonPanel(jbImport, jbCancel); getContentPane().setLayout(new BorderLayout()); getContentPane().add(jpKeyPair, BorderLayout.CENTER); getContentPane().add(jpButtons, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); setTitle(res.getString("DImportKeyPairOpenSsl.Title")); setResizable(false); getRootPane().setDefaultButton(jbImport); pack(); }
From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPkcs8.java
private void initComponents() { GridBagConstraints gbcLbl = new GridBagConstraints(); gbcLbl.gridx = 0;/*from w w w . ja v a2s . c o m*/ gbcLbl.gridwidth = 3; gbcLbl.gridheight = 1; gbcLbl.insets = new Insets(5, 5, 5, 5); gbcLbl.anchor = GridBagConstraints.EAST; GridBagConstraints gbcEdCtrl = new GridBagConstraints(); gbcEdCtrl.gridx = 3; gbcEdCtrl.gridwidth = 3; gbcEdCtrl.gridheight = 1; gbcEdCtrl.insets = new Insets(5, 5, 5, 5); gbcEdCtrl.anchor = GridBagConstraints.WEST; jlEncrypted = new JLabel(res.getString("DImportKeyPairPkcs8.jlEncrypted.text")); GridBagConstraints gbc_jlEncrypted = (GridBagConstraints) gbcLbl.clone(); gbc_jlEncrypted.gridy = 0; jcbEncrypted = new JCheckBox(); jcbEncrypted.setSelected(true); jcbEncrypted.setToolTipText(res.getString("DImportKeyPairPkcs8.jcbEncrypted.tooltip")); GridBagConstraints gbc_jcbEncrypted = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jcbEncrypted.gridy = 0; jlPassword = new JLabel(res.getString("DImportKeyPairPkcs8.jlPassword.text")); GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone(); gbc_jlPassword.gridy = 1; jpfPassword = new JPasswordField(15); jpfPassword.setToolTipText(res.getString("DImportKeyPairPkcs8.jpfPassword.tooltip")); GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jpfPassword.gridy = 1; jlPrivateKey = new JLabel(res.getString("DImportKeyPairPkcs8.jlPrivateKey.text")); GridBagConstraints gbc_jlPrivateKey = (GridBagConstraints) gbcLbl.clone(); gbc_jlPrivateKey.gridy = 2; jtfPrivateKeyPath = new JTextField(30); jtfPrivateKeyPath.setToolTipText(res.getString("DImportKeyPairPkcs8.jtfPrivateKeyPath.tooltip")); GridBagConstraints gbc_jtfPrivateKeyPath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfPrivateKeyPath.gridy = 2; gbc_jtfPrivateKeyPath.gridwidth = 6; jbPrivateKeyBrowse = new JButton(res.getString("DImportKeyPairPkcs8.jbPrivateKeyBrowse.text")); PlatformUtil.setMnemonic(jbPrivateKeyBrowse, res.getString("DImportKeyPairPkcs8.jbPrivateKeyBrowse.mnemonic").charAt(0)); jbPrivateKeyBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this); privateKeyBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPkcs8.this); } } }); jbPrivateKeyBrowse.setToolTipText(res.getString("DImportKeyPairPkcs8.jbPrivateKeyBrowse.tooltip")); GridBagConstraints gbc_jbPrivateKeyBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyBrowse.gridy = 2; gbc_jbPrivateKeyBrowse.gridx = 9; jbPrivateKeyDetails = new JButton(res.getString("DImportKeyPairPkcs8.jbPrivateKeyDetails.text")); jbPrivateKeyDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this); privateKeyDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPkcs8.this); } } }); PlatformUtil.setMnemonic(jbPrivateKeyDetails, res.getString("DImportKeyPairPkcs8.jbPrivateKeyDetails.mnemonic").charAt(0)); jbPrivateKeyDetails.setToolTipText(res.getString("DImportKeyPairPkcs8.jbPrivateKeyDetails.tooltip")); GridBagConstraints gbc_jbPrivateKeyDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyDetails.gridy = 2; gbc_jbPrivateKeyDetails.gridx = 12; jlCertificate = new JLabel(res.getString("DImportKeyPairPkcs8.jlCertificate.text")); GridBagConstraints gbc_jlCertificate = (GridBagConstraints) gbcLbl.clone(); gbc_jlCertificate.gridy = 3; jtfCertificatePath = new JTextField(30); jtfCertificatePath.setToolTipText(res.getString("DImportKeyPairPkcs8.jtfCertificatePath.tooltip")); GridBagConstraints gbc_jtfCertificatePath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfCertificatePath.gridy = 3; gbc_jtfCertificatePath.gridwidth = 6; jbCertificateBrowse = new JButton(res.getString("DImportKeyPairPkcs8.jbCertificateBrowse.text")); jbCertificateBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this); certificateBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPkcs8.this); } } }); PlatformUtil.setMnemonic(jbCertificateBrowse, res.getString("DImportKeyPairPkcs8.jbCertificateBrowse.mnemonic").charAt(0)); jbCertificateBrowse.setToolTipText(res.getString("DImportKeyPairPkcs8.jbCertificateBrowse.tooltip")); GridBagConstraints gbc_jbCertificateBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateBrowse.gridy = 3; gbc_jbCertificateBrowse.gridx = 9; jbCertificateDetails = new JButton(res.getString("DImportKeyPairPkcs8.jbCertificateDetails.text")); jbCertificateDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this); certificateDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPkcs8.this); } } }); PlatformUtil.setMnemonic(jbCertificateDetails, res.getString("DImportKeyPairPkcs8.jbCertificateDetails.mnemonic").charAt(0)); jbCertificateDetails.setToolTipText(res.getString("DImportKeyPairPkcs8.jbCertificateDetails.tooltip")); GridBagConstraints gbc_jbCertificateDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateDetails.gridy = 3; gbc_jbCertificateDetails.gridx = 12; jpKeyPair = new JPanel(new GridBagLayout()); jpKeyPair.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()), new EmptyBorder(5, 5, 5, 5))); jpKeyPair.add(jlEncrypted, gbc_jlEncrypted); jpKeyPair.add(jcbEncrypted, gbc_jcbEncrypted); jpKeyPair.add(jlPassword, gbc_jlPassword); jpKeyPair.add(jpfPassword, gbc_jpfPassword); jpKeyPair.add(jlPrivateKey, gbc_jlPrivateKey); jpKeyPair.add(jtfPrivateKeyPath, gbc_jtfPrivateKeyPath); jpKeyPair.add(jbPrivateKeyBrowse, gbc_jbPrivateKeyBrowse); jpKeyPair.add(jbPrivateKeyDetails, gbc_jbPrivateKeyDetails); jpKeyPair.add(jlCertificate, gbc_jlCertificate); jpKeyPair.add(jtfCertificatePath, gbc_jtfCertificatePath); jpKeyPair.add(jbCertificateBrowse, gbc_jbCertificateBrowse); jpKeyPair.add(jbCertificateDetails, gbc_jbCertificateDetails); jcbEncrypted.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { if (jcbEncrypted.isSelected()) { jpfPassword.setEnabled(true); } else { jpfPassword.setEnabled(false); jpfPassword.setText(""); } } }); jbImport = new JButton(res.getString("DImportKeyPairPkcs8.jbImport.text")); PlatformUtil.setMnemonic(jbImport, res.getString("DImportKeyPairPkcs8.jbImport.mnemonic").charAt(0)); jbImport.setToolTipText(res.getString("DImportKeyPairPkcs8.jbImport.tooltip")); jbImport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this); importPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPkcs8.this); } } }); jbCancel = new JButton(res.getString("DImportKeyPairPkcs8.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpButtons = PlatformUtil.createDialogButtonPanel(jbImport, jbCancel); getContentPane().setLayout(new BorderLayout()); getContentPane().add(jpKeyPair, BorderLayout.CENTER); getContentPane().add(jpButtons, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); setTitle(res.getString("DImportKeyPairPkcs8.Title")); setResizable(false); getRootPane().setDefaultButton(jbImport); pack(); }
From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPvk.java
private void initComponents() { GridBagConstraints gbcLbl = new GridBagConstraints(); gbcLbl.gridx = 0;/*from www .j a va 2 s .c om*/ gbcLbl.gridwidth = 3; gbcLbl.gridheight = 1; gbcLbl.insets = new Insets(5, 5, 5, 5); gbcLbl.anchor = GridBagConstraints.EAST; GridBagConstraints gbcEdCtrl = new GridBagConstraints(); gbcEdCtrl.gridx = 3; gbcEdCtrl.gridwidth = 3; gbcEdCtrl.gridheight = 1; gbcEdCtrl.insets = new Insets(5, 5, 5, 5); gbcEdCtrl.anchor = GridBagConstraints.WEST; jlEncrypted = new JLabel(res.getString("DImportKeyPairPvk.jlEncrypted.text")); GridBagConstraints gbc_jlEncrypted = (GridBagConstraints) gbcLbl.clone(); gbc_jlEncrypted.gridy = 0; jcbEncrypted = new JCheckBox(); jcbEncrypted.setSelected(true); jcbEncrypted.setToolTipText(res.getString("DImportKeyPairPvk.jcbEncrypted.tooltip")); GridBagConstraints gbc_jcbEncrypted = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jcbEncrypted.gridy = 0; jlPassword = new JLabel(res.getString("DImportKeyPairPvk.jlPassword.text")); GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone(); gbc_jlPassword.gridy = 1; jpfPassword = new JPasswordField(15); jpfPassword.setToolTipText(res.getString("DImportKeyPairPvk.jpfPassword.tooltip")); GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jpfPassword.gridy = 1; jlPrivateKey = new JLabel(res.getString("DImportKeyPairPvk.jlPrivateKey.text")); GridBagConstraints gbc_jlPrivateKey = (GridBagConstraints) gbcLbl.clone(); gbc_jlPrivateKey.gridy = 2; jtfPrivateKeyPath = new JTextField(30); jtfPrivateKeyPath.setToolTipText(res.getString("DImportKeyPairPvk.jtfPrivateKeyPath.tooltip")); GridBagConstraints gbc_jtfPrivateKeyPath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfPrivateKeyPath.gridy = 2; gbc_jtfPrivateKeyPath.gridwidth = 6; jbPrivateKeyBrowse = new JButton(res.getString("DImportKeyPairPvk.jbPrivateKeyBrowse.text")); PlatformUtil.setMnemonic(jbPrivateKeyBrowse, res.getString("DImportKeyPairPvk.jbPrivateKeyBrowse.mnemonic").charAt(0)); jbPrivateKeyBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPvk.this); privateKeyBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPvk.this); } } }); jbPrivateKeyBrowse.setToolTipText(res.getString("DImportKeyPairPvk.jbPrivateKeyBrowse.tooltip")); GridBagConstraints gbc_jbPrivateKeyBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyBrowse.gridy = 2; gbc_jbPrivateKeyBrowse.gridx = 9; jbPrivateKeyDetails = new JButton(res.getString("DImportKeyPairPvk.jbPrivateKeyDetails.text")); jbPrivateKeyDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPvk.this); privateKeyDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPvk.this); } } }); PlatformUtil.setMnemonic(jbPrivateKeyDetails, res.getString("DImportKeyPairPvk.jbPrivateKeyDetails.mnemonic").charAt(0)); jbPrivateKeyDetails.setToolTipText(res.getString("DImportKeyPairPvk.jbPrivateKeyDetails.tooltip")); GridBagConstraints gbc_jbPrivateKeyDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyDetails.gridy = 2; gbc_jbPrivateKeyDetails.gridx = 12; jlCertificate = new JLabel(res.getString("DImportKeyPairPvk.jlCertificate.text")); GridBagConstraints gbc_jlCertificate = (GridBagConstraints) gbcLbl.clone(); gbc_jlCertificate.gridy = 3; jtfCertificatePath = new JTextField(30); jtfCertificatePath.setToolTipText(res.getString("DImportKeyPairPvk.jtfCertificatePath.tooltip")); GridBagConstraints gbc_jtfCertificatePath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfCertificatePath.gridy = 3; gbc_jtfCertificatePath.gridwidth = 6; jbCertificateBrowse = new JButton(res.getString("DImportKeyPairPvk.jbCertificateBrowse.text")); jbCertificateBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPvk.this); certificateBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPvk.this); } } }); PlatformUtil.setMnemonic(jbCertificateBrowse, res.getString("DImportKeyPairPvk.jbCertificateBrowse.mnemonic").charAt(0)); jbCertificateBrowse.setToolTipText(res.getString("DImportKeyPairPvk.jbCertificateBrowse.tooltip")); GridBagConstraints gbc_jbCertificateBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateBrowse.gridy = 3; gbc_jbCertificateBrowse.gridx = 9; jbCertificateDetails = new JButton(res.getString("DImportKeyPairPvk.jbCertificateDetails.text")); jbCertificateDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPvk.this); certificateDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPvk.this); } } }); PlatformUtil.setMnemonic(jbCertificateDetails, res.getString("DImportKeyPairPvk.jbCertificateDetails.mnemonic").charAt(0)); jbCertificateDetails.setToolTipText(res.getString("DImportKeyPairPvk.jbCertificateDetails.tooltip")); GridBagConstraints gbc_jbCertificateDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateDetails.gridy = 3; gbc_jbCertificateDetails.gridx = 12; jpKeyPair = new JPanel(new GridBagLayout()); jpKeyPair.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()), new EmptyBorder(5, 5, 5, 5))); jpKeyPair.add(jlEncrypted, gbc_jlEncrypted); jpKeyPair.add(jcbEncrypted, gbc_jcbEncrypted); jpKeyPair.add(jlPassword, gbc_jlPassword); jpKeyPair.add(jpfPassword, gbc_jpfPassword); jpKeyPair.add(jlPrivateKey, gbc_jlPrivateKey); jpKeyPair.add(jtfPrivateKeyPath, gbc_jtfPrivateKeyPath); jpKeyPair.add(jbPrivateKeyBrowse, gbc_jbPrivateKeyBrowse); jpKeyPair.add(jbPrivateKeyDetails, gbc_jbPrivateKeyDetails); jpKeyPair.add(jlCertificate, gbc_jlCertificate); jpKeyPair.add(jtfCertificatePath, gbc_jtfCertificatePath); jpKeyPair.add(jbCertificateBrowse, gbc_jbCertificateBrowse); jpKeyPair.add(jbCertificateDetails, gbc_jbCertificateDetails); jcbEncrypted.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { if (jcbEncrypted.isSelected()) { jpfPassword.setEnabled(true); } else { jpfPassword.setEnabled(false); jpfPassword.setText(""); } } }); jbImport = new JButton(res.getString("DImportKeyPairPvk.jbImport.text")); PlatformUtil.setMnemonic(jbImport, res.getString("DImportKeyPairPvk.jbImport.mnemonic").charAt(0)); jbImport.setToolTipText(res.getString("DImportKeyPairPvk.jbImport.tooltip")); jbImport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairPvk.this); importPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairPvk.this); } } }); jbCancel = new JButton(res.getString("DImportKeyPairPvk.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpButtons = PlatformUtil.createDialogButtonPanel(jbImport, jbCancel); getContentPane().setLayout(new BorderLayout()); getContentPane().add(jpKeyPair, BorderLayout.CENTER); getContentPane().add(jpButtons, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); setTitle(res.getString("DImportKeyPairPvk.Title")); setResizable(false); getRootPane().setDefaultButton(jbImport); pack(); }
From source file:org.kse.gui.dialogs.sign.DSignMidlet.java
private void initComponents() { GridBagConstraints gbcLbl = new GridBagConstraints(); gbcLbl.gridx = 0;/*from ww w . ja v a2 s.c o m*/ gbcLbl.gridwidth = 1; gbcLbl.gridheight = 1; gbcLbl.insets = new Insets(5, 5, 5, 5); gbcLbl.anchor = GridBagConstraints.EAST; gbcLbl.weightx = 0; GridBagConstraints gbcCtrl = new GridBagConstraints(); gbcCtrl.gridx = 1; gbcCtrl.gridwidth = 1; gbcCtrl.gridheight = 1; gbcCtrl.insets = new Insets(5, 5, 5, 5); gbcCtrl.anchor = GridBagConstraints.WEST; gbcCtrl.fill = GridBagConstraints.NONE; gbcCtrl.weightx = 1; GridBagConstraints gbcBrws = new GridBagConstraints(); gbcBrws.gridx = 2; gbcBrws.gridwidth = 1; gbcBrws.gridheight = 1; gbcBrws.insets = new Insets(5, 5, 5, 5); gbcBrws.anchor = GridBagConstraints.WEST; gbcBrws.fill = GridBagConstraints.NONE; gbcBrws.weightx = 1; jlInputJad = new JLabel(res.getString("DSignMidlet.jlInputJad.text")); GridBagConstraints gbc_jlInputJad = (GridBagConstraints) gbcLbl.clone(); gbc_jlInputJad.gridy = 0; jtfInputJad = new JTextField(30); jtfInputJad.setCaretPosition(0); jtfInputJad.setToolTipText(res.getString("DSignMidlet.jtfInputJad.tooltip")); GridBagConstraints gbc_jtfInputJad = (GridBagConstraints) gbcCtrl.clone(); gbc_jtfInputJad.gridy = 0; jbInputJadBrowse = new JButton(res.getString("DSignMidlet.jbInputJadBrowse.text")); PlatformUtil.setMnemonic(jbInputJadBrowse, res.getString("DSignMidlet.jbInputJadBrowse.mnemonic").charAt(0)); jbInputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbInputJadBrowse.tooltip")); jbInputJadBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DSignMidlet.this); inputJadBrowsePressed(); } finally { CursorUtil.setCursorFree(DSignMidlet.this); } } }); GridBagConstraints gbc_jbInputJadBrowse = (GridBagConstraints) gbcBrws.clone(); gbc_jbInputJadBrowse.gridy = 0; jlSignDirectly = new JLabel(res.getString("DSignMidlet.jlSignDirectly.text")); GridBagConstraints gbc_jlSignDirectly = (GridBagConstraints) gbcLbl.clone(); gbc_jlSignDirectly.gridy = 1; jcbSignDirectly = new JCheckBox(); jcbSignDirectly.setSelected(true); jcbSignDirectly.setToolTipText(res.getString("DSignMidlet.jcbSignDirectly.tooltip")); GridBagConstraints gbc_jcbSignDirectly = (GridBagConstraints) gbcCtrl.clone(); gbc_jcbSignDirectly.gridy = 1; jcbSignDirectly.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { jtfOutputJad.setEnabled(!jcbSignDirectly.isSelected()); jbOutputJadBrowse.setEnabled(!jcbSignDirectly.isSelected()); } }); jlOutputJad = new JLabel(res.getString("DSignMidlet.jlOutputJad.text")); GridBagConstraints gbc_jlOutputJad = (GridBagConstraints) gbcLbl.clone(); gbc_jlOutputJad.gridy = 2; jtfOutputJad = new JTextField(30); jtfOutputJad.setEnabled(false); jtfOutputJad.setCaretPosition(0); jtfOutputJad.setToolTipText(res.getString("DSignMidlet.jtfOutputJad.tooltip")); GridBagConstraints gbc_jtfOutputJad = (GridBagConstraints) gbcCtrl.clone(); gbc_jtfOutputJad.gridy = 2; jbOutputJadBrowse = new JButton(res.getString("DSignMidlet.jbOutputJadBrowse.text")); PlatformUtil.setMnemonic(jbOutputJadBrowse, res.getString("DSignMidlet.jbOutputJadBrowse.mnemonic").charAt(0)); jbOutputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbOutputJadBrowse.tooltip")); jbOutputJadBrowse.setEnabled(false); jbOutputJadBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DSignMidlet.this); outputJadBrowsePressed(); } finally { CursorUtil.setCursorFree(DSignMidlet.this); } } }); GridBagConstraints gbc_jbOutputJadBrowse = (GridBagConstraints) gbcBrws.clone(); gbc_jbOutputJadBrowse.gridy = 2; jlJar = new JLabel(res.getString("DSignMidlet.jlJar.text")); GridBagConstraints gbc_jlJar = (GridBagConstraints) gbcLbl.clone(); gbc_jlJar.gridy = 3; jtfJar = new JTextField(30); jtfJar.setCaretPosition(0); jtfJar.setToolTipText(res.getString("DSignMidlet.jtfJar.tooltip")); GridBagConstraints gbc_jtfJar = (GridBagConstraints) gbcCtrl.clone(); gbc_jtfJar.gridy = 3; jbJarBrowse = new JButton(res.getString("DSignMidlet.jbJarBrowse.text")); PlatformUtil.setMnemonic(jbJarBrowse, res.getString("DSignMidlet.jbJarBrowse.mnemonic").charAt(0)); jbJarBrowse.setToolTipText(res.getString("DSignMidlet.jbJarBrowse.tooltip")); jbJarBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DSignMidlet.this); jarBrowsePressed(); } finally { CursorUtil.setCursorFree(DSignMidlet.this); } } }); GridBagConstraints gbc_jbJarBrowse = (GridBagConstraints) gbcBrws.clone(); gbc_jbJarBrowse.gridy = 3; jpOptions = new JPanel(new GridBagLayout()); jpOptions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder())); jpOptions.add(jlInputJad, gbc_jlInputJad); jpOptions.add(jtfInputJad, gbc_jtfInputJad); jpOptions.add(jbInputJadBrowse, gbc_jbInputJadBrowse); jpOptions.add(jlSignDirectly, gbc_jlSignDirectly); jpOptions.add(jcbSignDirectly, gbc_jcbSignDirectly); jpOptions.add(jlOutputJad, gbc_jlOutputJad); jpOptions.add(jtfOutputJad, gbc_jtfOutputJad); jpOptions.add(jbOutputJadBrowse, gbc_jbOutputJadBrowse); jpOptions.add(jlJar, gbc_jlJar); jpOptions.add(jtfJar, gbc_jtfJar); jpOptions.add(jbJarBrowse, gbc_jbJarBrowse); jbOK = new JButton(res.getString("DSignMidlet.jbOK.text")); jbOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); jbCancel = new JButton(res.getString("DSignMidlet.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false); getContentPane().setLayout(new BorderLayout()); getContentPane().add(jpOptions, BorderLayout.NORTH); getContentPane().add(jpButtons, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); setResizable(false); getRootPane().setDefaultButton(jbOK); pack(); }