List of usage examples for javax.swing KeyStroke getKeyStroke
public static KeyStroke getKeyStroke(int keyCode, int modifiers)
From source file:dmh.kuebiko.view.NoteStackFrame.java
/** * Initialize the contents of the frame. The contents of this method was * generated by Window Builder Pro./*from ww w. j a v a 2s .c o m*/ */ private void initialize() { setTitle(buildTitle()); setBounds(100, 100, 450, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE }; getContentPane().setLayout(gridBagLayout); horizontalStrut = Box.createHorizontalStrut(20); horizontalStrut.setMinimumSize(new Dimension(3, 0)); horizontalStrut.setPreferredSize(new Dimension(3, 0)); horizontalStrut.setSize(new Dimension(3, 0)); GridBagConstraints gbc_horizontalStrut = new GridBagConstraints(); gbc_horizontalStrut.insets = new Insets(0, 0, 0, 0); gbc_horizontalStrut.gridx = 0; gbc_horizontalStrut.gridy = 0; getContentPane().add(horizontalStrut, gbc_horizontalStrut); GridBagConstraints gbc_stateImageLabel = new GridBagConstraints(); gbc_stateImageLabel.insets = new Insets(0, 0, 0, 0); gbc_stateImageLabel.anchor = GridBagConstraints.EAST; gbc_stateImageLabel.gridx = 1; gbc_stateImageLabel.gridy = 0; stateImageLabel.setBorder(null); stateImageLabel.setHorizontalAlignment(SwingConstants.CENTER); getContentPane().add(stateImageLabel, gbc_stateImageLabel); searchText = new JTextField(); GridBagConstraints gbc_searchText = new GridBagConstraints(); gbc_searchText.insets = new Insets(0, 0, 0, 0); gbc_searchText.fill = GridBagConstraints.HORIZONTAL; gbc_searchText.gridx = 2; gbc_searchText.gridy = 0; getContentPane().add(searchText, gbc_searchText); searchText.setColumns(10); if (SystemUtils.IS_OS_MAC_OSX) { // Make the text field look like the standard Mac OS X search // box control. searchText.putClientProperty("JTextField.variant", "search"); } splitPane = new JSplitPane(); splitPane.setBorder(null); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); GridBagConstraints gbc_splitPane = new GridBagConstraints(); gbc_splitPane.gridwidth = 3; gbc_splitPane.gridheight = 4; gbc_splitPane.insets = new Insets(0, 0, 0, 0); gbc_splitPane.fill = GridBagConstraints.BOTH; gbc_splitPane.gridx = 0; gbc_splitPane.gridy = 1; getContentPane().add(splitPane, gbc_splitPane); notePanel = new NotePanel(); notePanel.getHuxleyUiManager().setOnTextChangeCallback(new Callback<Boolean>() { @Override public void callback(Boolean input) { toggleUnsavedChangeIndicator(input); } }); splitPane.setRightComponent(notePanel); noteTableScroll = new JScrollPane(); noteTableScroll.setMinimumSize(new Dimension(23, 100)); splitPane.setLeftComponent(noteTableScroll); noteTable = newNoteTable(); noteTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); noteTableScroll.setViewportView(noteTable); ActionObserverUtil.registerEnMass(actionMngr, observable, notePanel.getHuxleyUiManager().getTextAction(TextAction.INSERT_DATE)); insertDateMenuItem = new JMenuItem(actionMngr.getAction(InsertDynamicTextAction.class)); insertDateMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); textMenu.add(insertDateMenuItem); }
From source file:jpad.MainEditor.java
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); mainTextArea = new javax.swing.JTextArea(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); openMenuItem = new javax.swing.JMenuItem(); saveMenuItem = new javax.swing.JMenuItem(); saveAsMenuItem = new javax.swing.JMenuItem(); seperator_OpenAndExit = new javax.swing.JPopupMenu.Separator(); exitMenuItem = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); textWrapMenuItem = new javax.swing.JCheckBoxMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setTitle("JPad"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt);/*from www.j a v a 2 s . c om*/ } }); mainTextArea.setColumns(20); mainTextArea.setLineWrap(true); mainTextArea.setRows(5); jScrollPane1.setViewportView(mainTextArea); textChanged(); jMenu1.setText("File"); openMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); openMenuItem.setText("Open..."); openMenuItem.setToolTipText("Open a file"); openMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openMenuItemActionPerformed(evt); } }); jMenu1.add(openMenuItem); saveMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); saveMenuItem.setText("Save..."); saveMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveMenuItemActionPerformed(evt); } }); jMenu1.add(saveMenuItem); saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, (java.awt.event.InputEvent.SHIFT_MASK | (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())))); saveAsMenuItem.setText("Save As..."); saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveAsMenuItemActionPerformed(evt); } }); jMenu1.add(saveAsMenuItem); jMenu1.add(seperator_OpenAndExit); exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK)); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitMenuItemActionPerformed(evt); } }); jMenu1.add(exitMenuItem); if (_isOSX) { exitMenuItem.getParent().remove(exitMenuItem); } jMenuBar1.add(jMenu1); jMenu2.setText("Edit"); textWrapMenuItem.setText("Text Wrap"); textWrapMenuItem.setToolTipText("Enables or disables text wrap"); textWrapMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { textWrapMenuItemActionPerformed(evt); } }); jMenu2.add(textWrapMenuItem); if (mainTextArea.getLineWrap() == true) { textWrapMenuItem.setSelected(true); } else { textWrapMenuItem.setSelected(false); } jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 581, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)); pack(); }
From source file:com.qspin.qtaste.ui.xmleditor.TestRequirementEditor.java
private void genUI() { getActionMap().put("Save", new SaveAction()); getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), "Save"); m_TestRequirementTable = new JTable() { @Override//from w ww .j a v a 2 s. c o m public String getToolTipText(MouseEvent e) { Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); if (colIndex < 0) { return null; } return convertObjectToToolTip(getValueAt(rowIndex, colIndex)); } // overwrite cell content when typing on a selected cell @Override public Component prepareEditor(TableCellEditor editor, int row, int column) { Component c = super.prepareEditor(editor, row, column); if (c instanceof JTextComponent) { ((JTextField) c).selectAll(); } return c; } // select entire rows when selecting first column (row id) @Override public void columnSelectionChanged(ListSelectionEvent e) { if (e.getFirstIndex() == 0 && e.getValueIsAdjusting()) { setColumnSelectionInterval(1, getColumnCount() - 1); } else { super.columnSelectionChanged(e); } } }; m_TestRequirementTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); m_TestRequirementModel = new TestRequirementTableModel(); m_TestRequirementTable.setModel(m_TestRequirementModel); m_TableColumnModelListener = new MyTableColumnModelListener(); m_TestRequirementTable.setSurrendersFocusOnKeystroke(true); m_TestRequirementTable.setColumnSelectionAllowed(true); m_TestRequirementTable.addMouseListener(new TableMouseListener(m_TestRequirementTable)); m_TestRequirementTable.getTableHeader().addMouseListener(new TableMouseListener(m_TestRequirementTable)); m_TestRequirementTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); m_TestRequirementTable.getActionMap().put("Save", new SaveAction()); m_TestRequirementTable.setDefaultEditor(String.class, new TestDataTableCellEditor()); m_TestRequirementTable.setDefaultEditor(Integer.class, new TestDataTableCellEditor()); m_TestRequirementTable.getTableHeader().getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), "Save"); m_TestRequirementTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), "Save"); m_TestRequirementTable.setRowHeight(ROW_HEIGHT); m_TestRequirementTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { // if (e.getKeyCode() == KeyEvent.VK_UP) { // check if previous line is empty } if (e.getKeyCode() == KeyEvent.VK_DOWN) { // if current row is the last one if (m_TestRequirementTable.getSelectedRow() == m_TestRequirementTable.getRowCount() - 1) { addNewRow(); } } if ((e.getKeyCode() == KeyEvent.VK_S) && (e.isControlDown())) { save(); } if ((e.getKeyCode() == KeyEvent.VK_C) && (e.isControlDown())) { copySelectionToClipboard(); } if ((e.getKeyCode() == KeyEvent.VK_V) && (e.isControlDown())) { if (m_TestRequirementTable.getSelectedColumn() != 0) { pasteSelectionFromClipboard(); } } } }); tableListener = new TableModelListener() { public void tableChanged(TableModelEvent e) { // build the test data if (e.getType() == TableModelEvent.UPDATE) { if (e.getFirstRow() >= 0) { setModified(true); } } } }; m_TestRequirementModel.addTableModelListener(tableListener); JScrollPane sp = new JScrollPane(m_TestRequirementTable); sp.addMouseListener(new TableMouseListener(null)); add(sp); }
From source file:SciTK.Plot.java
/** * Load the initial UI/*from w ww . ja va 2 s . c om*/ */ protected final void initUI() { setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); // create a ChartPanel, and make it default to 1/4 of screen size: chart_panel = new ChartPanel(chart); chart_panel.setPreferredSize(new Dimension(def_width, def_height)); //add the chart to the window: getContentPane().add(chart_panel); // create a menu bar: menubar = new JMenuBar(); // --------------------------------------------------------- // First dropdown menu: "File" // --------------------------------------------------------- file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); // Set up a save dialog option under the file menu: JMenuItem menu_file_save; ImageIcon menu_file_save_icon = null; try { menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png")); menu_file_save = new JMenuItem("Save", menu_file_save_icon); } catch (Exception e) { menu_file_save = new JMenuItem("Save"); } menu_file_save.setMnemonic(KeyEvent.VK_S); menu_file_save.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_save.setToolTipText("Save an image"); menu_file_save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveImage(); } }); file.add(menu_file_save); // Set up a save SVG dialog option under the file menu: JMenuItem menu_file_save_svg; try { menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon); } catch (Exception e) { menu_file_save_svg = new JMenuItem("Save VG"); } menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)"); menu_file_save_svg.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveVectorGraphics(); } }); file.add(menu_file_save_svg); // Set up a save data dialog option under the file menu: JMenuItem menu_file_save_data; try { menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon); } catch (Exception e) { menu_file_save_data = new JMenuItem("Save data"); } menu_file_save_data.setToolTipText("Save raw data to file"); menu_file_save_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveData(); } }); file.add(menu_file_save_data); // Set up a save data dialog option under the file menu: JMenuItem menu_file_print; try { ImageIcon menu_file_print_icon = new ImageIcon( getClass().getResource("/SciTK/resources/document-print-5.png")); menu_file_print = new JMenuItem("Print", menu_file_print_icon); } catch (Exception e) { menu_file_print = new JMenuItem("Print"); } menu_file_print.setToolTipText("Print image of chart"); menu_file_print.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { printPlot(); } }); file.add(menu_file_print); // menu item for exiting JMenuItem menu_file_exit; try { ImageIcon menu_file_exit_icon = new ImageIcon( getClass().getResource("/SciTK/resources/application-exit.png")); menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon); } catch (Exception e) { menu_file_exit = new JMenuItem("Exit"); } menu_file_exit.setMnemonic(KeyEvent.VK_X); menu_file_exit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_exit.setToolTipText("Exit application"); menu_file_exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dispose(); } }); file.add(menu_file_exit); // --------------------------------------------------------- // Second dropdown menu: "Edit" // --------------------------------------------------------- edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E); // copy to clipboard JMenuItem menu_edit_copy_image; ImageIcon menu_edit_copy_icon = null; try { menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png")); menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_image = new JMenuItem("Copy"); } menu_edit_copy_image.setMnemonic(KeyEvent.VK_C); menu_edit_copy_image.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_edit_copy_image.setToolTipText("Copy image to clipboard"); menu_edit_copy_image.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyImage(); } }); edit.add(menu_edit_copy_image); // copy data to clipboard JMenuItem menu_edit_copy_data; try { menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_data = new JMenuItem("Copy data"); } menu_edit_copy_data.setToolTipText("Copy data to clipboard"); menu_edit_copy_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyData(); } }); edit.add(menu_edit_copy_data); // set background color JMenuItem menu_edit_BackgroundColor; ImageIcon menu_edit_Color_icon = null; try { menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png")); menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_BackgroundColor = new JMenuItem("Background Color"); } menu_edit_BackgroundColor.setToolTipText("Select background color"); menu_edit_BackgroundColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint()); setBackgroundColor(bgColor); } }); edit.add(menu_edit_BackgroundColor); // set plot color JMenuItem menu_edit_PlotColor; try { menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_PlotColor = new JMenuItem("Window Color"); } menu_edit_PlotColor.setToolTipText("Select plot window color"); menu_edit_PlotColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color plotColor = plotColorChooser("Choose plot color", (Color) chart.getPlot().getBackgroundPaint()); setWindowBackground(plotColor); } }); edit.add(menu_edit_PlotColor); // set gridline color JMenuItem menu_edit_GridlineColor; try { menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_GridlineColor = new JMenuItem("Gridline Color"); } menu_edit_GridlineColor.setToolTipText("Select grid color"); menu_edit_GridlineColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color gridColor = plotColorChooser("Choose grid color", (Color) chart.getPlot().getBackgroundPaint()); setGridlineColor(gridColor); } }); edit.add(menu_edit_GridlineColor); // edit chart preferences JMenuItem menu_edit_preferences; try { ImageIcon menu_edit_preferences_icon = new ImageIcon( getClass().getResource("/SciTK/resources/preferences-desktop-3.png")); menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon); } catch (Exception e) { menu_edit_preferences = new JMenuItem("Preferences"); } menu_edit_preferences.setToolTipText("Edit chart preferences"); menu_edit_preferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { chart_panel.doEditChartProperties(); } }); edit.add(menu_edit_preferences); // --------------------------------------------------------- // Third dropdown menu: "Plot" // --------------------------------------------------------- plot = new JMenu("Plot"); plot.setMnemonic(KeyEvent.VK_P); // Options to set log axes JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis"); menu_plot_ylog.setToolTipText("Set y axis to logarithmic"); menu_plot_ylog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setRangeAxisLog(selected); } }); plot.add(menu_plot_ylog); JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis"); menu_plot_xlog.setToolTipText("Set x axis to logarithmic"); menu_plot_xlog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setDomainAxisLog(selected); } }); plot.add(menu_plot_xlog); // grid line display JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines"); menu_plot_grid.setToolTipText("Show plot grid lines?"); menu_plot_grid.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setGridlineVisible(selected); } }); // set appropirate checkbox state: menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible()); plot.add(menu_plot_grid); // control for displaying plot legend JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend"); menu_plot_legend.setToolTipText("Show plot legend?"); menu_plot_legend.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setLegend(selected); } }); // set appropirate checkbox state: menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle)); plot.add(menu_plot_legend); // --------------------------------------------------------- // General UI // --------------------------------------------------------- // Add menus to the menu bar: menubar.add(file); menubar.add(edit); menubar.add(plot); // Set menubar as this JFrame's menu setJMenuBar(menubar); // set default plot colors: chart.setBackgroundPaint(new Color(255, 255, 255, 0)); chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255)); setBackgroundAlpha(0.0f); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); pack(); setTitle(window_title); setLocationRelativeTo(null); setVisible(true); }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void setupTool() { LoggerJAXB.outputJaxpImplementationInfo(); Locale currentLocale = Locale.getDefault(); labels = new ResourceBundlesWrapper(I18N_BASENAMES, currentLocale); retrieveFromDb = new RetrieveFromDb(); apePanel = new APEPanel(labels, getContentPane(), this, retrieveFromDb); Utilities.setXsdList(fillXsdList()); CheckList checkList = new CheckList(); langList = checkList.getLangList();/*from w w w.java 2s. com*/ levelList = checkList.getLevelList(); dateNormalization = new DateNormalization(); super.setTitle(labels.getString("title")); Image topLeftIcon = Utilities.icon.getImage(); setIconImage(topLeftIcon); doChecks(); if (isFileMissing(Utilities.LOG_DIR)) { new File(Utilities.LOG_DIR).mkdir(); } File tempDir = new File(Utilities.TEMP_DIR); //In case it didn't deleteOnExit at the previous closing of the program, we clean up. if (tempDir.exists()) { LOG.warn("Probably a problem when deleting the temp files at closure, so we clean up"); eraseOldTempFiles(tempDir); try { FileUtils.deleteDirectory(tempDir); } catch (IOException e) { LOG.error("Could not delete the temp directory. Attempt to delete the directory once more: " + (tempDir.delete() ? "Successful." : "Unsuccessful.")); } } tempDir.mkdir(); tempDir.deleteOnExit(); // ListControlaccessTerms listControlaccessTerms = new ListControlaccessTerms("/Users/yoannmoranville/Documents/Work/APE/data/AD78/"); // listControlaccessTerms.countTerms(); // listControlaccessTerms.displayLogsResults(); // CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/Ready_APEnet/READY/Finland/HeNAF/FA_EAD/"); // CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/BORA/ALL/"); // countCLevels.setCopyInAppropriateDirs(true); // countCLevels.changeMainagencycodeForSweden(false); // countCLevels.countLevels(); // SeparateFinnishFiles separateFinnishFiles = new SeparateFinnishFiles(new File("/Users/yoannmoranville/Desktop/files_fi"), TEMP_DIR); makeDefaultXsdMenuItems(); makeDefaultXslMenuItems(); getContentPane().add(apePanel); xmlEadListModel = new ProfileListModel(fileInstances, this); xmlEadList = new JList(xmlEadListModel); xmlEadList.setCellRenderer(new IconListCellRenderer(fileInstances)); xmlEadList.setDragEnabled(true); xmlEadList.setTransferHandler(new ListTransferHandler()); xmlEadList.setDropTarget(new DropTarget(xmlEadList, new ListDropTargetListener(xmlEadList, from))); xmlEadListModel.setList(xmlEadList); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(optionMenu); menuBar.add(actionMenu); menuBar.add(windowMenu); menuBar.add(helpMenu); fileItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(fileItem); closeSelectedItem.setEnabled(false); // closeSelectedItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); closeSelectedItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(closeSelectedItem); saveSelectedItem.setEnabled(false); saveSelectedItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(saveSelectedItem); saveMessageReportItem.setEnabled(false); saveMessageReportItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(saveMessageReportItem); // sendFilesWebDAV.setEnabled(false); // fileMenu.add(sendFilesWebDAV); fileMenu.addSeparator(); fileMenu.add(quitItem); optionMenu.add(countryCodeItem); optionMenu.add(repositoryCodeItem); optionMenu.add(digitalObjectTypeItem); optionMenu.add(edmGeneralOptionsItem); optionMenu.add(listDateConversionRulesItem); optionMenu.addSeparator(); optionMenu.add(xsltItem); optionMenu.add(xsdItem); optionMenu.add(defaultXslSelectionSubmenu); optionMenu.add(defaultXsdSelectionSubmenu); optionMenu.addSeparator(); optionMenu.add(checksLoadingFilesItem); optionMenu.add(defaultSaveFolderItem); optionMenu.add(languageMenu); if (Utilities.isDev) { optionMenu.addSeparator(); optionMenu.add(databaseItem); } validateItem.setEnabled(false); validateItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); actionMenu.add(validateItem); convertItem.setEnabled(false); convertItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); actionMenu.add(convertItem); actionMenu.addSeparator(); // TODO: Uncomment when edit will be available. // eacCpfItem.add(this.editEacCpfFile); //add the different EAC-CPF options menu eacCpfItem.add(createEacCpf); actionMenu.add(eacCpfItem); createEag2012Item.add(createEag2012FromExistingEag2012); createEag2012Item.add(createEag2012FromScratch); actionMenu.add(createEag2012Item); summaryWindowItem.setEnabled(true); summaryWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(summaryWindowItem); validationWindowItem.setEnabled(true); validationWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(validationWindowItem); conversionWindowItem.setEnabled(true); conversionWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(conversionWindowItem); edmConversionWindowItem.setEnabled(true); edmConversionWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(edmConversionWindowItem); editionWindowItem.setEnabled(true); editionWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(editionWindowItem); helpMenu.add(internetApexItem); helpMenu.addSeparator(); JMenuItem versionItem = new JMenuItem("APE DPT v" + VERSION_NB); versionItem.setEnabled(false); helpMenu.add(versionItem); createLanguageMenu(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setMultiSelectionEnabled(true); getContentPane().add(menuBar, BorderLayout.NORTH); apePanel.setFilename(""); createHgListener = new CreateHGListener(retrieveFromDb, labels, getContentPane(), fileInstances, xmlEadList, this); createHGBtn.addActionListener(createHgListener); createHGBtn.setEnabled(false); analyzeControlaccessListener = new AnalyzeControlaccessListener(labels, getContentPane(), fileInstances); analyzeControlaccessBtn.addActionListener(analyzeControlaccessListener); analyzeControlaccessBtn.setEnabled(false); validateItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(), ConvertAndValidateActionListener.VALIDATE)); convertItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(), ConvertAndValidateActionListener.CONVERT)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(createWest(), BorderLayout.WEST); // convertAndValidateBtn.addActionListener(new ConvertAndValidateActionListener(this, getContentPane())); // validateSelectionBtn.addActionListener(new ValidateSelectionActionListener(this, getContentPane())); // convertEdmSelectionBtn.addActionListener(new ConvertEdmActionListener(labels, this, apePanel)); nameComponents(); wireUp(); setSize(Toolkit.getDefaultToolkit().getScreenSize()); setMinimumSize(Toolkit.getDefaultToolkit().getScreenSize()); setExtendedState(JFrame.MAXIMIZED_BOTH); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected void initComponent() { layout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]"); panel = new JPanel(layout); topPanel = new JPanel(new BorderLayout()); topPanel.setVisible(false);//from www. j a v a 2 s .co m panel.add(topPanel, "growx"); scrollPane = new JScrollPane(impl); impl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); impl.setFillsViewportHeight(true); panel.add(scrollPane, "grow"); impl.setShowGrid(true); impl.setGridColor(Color.lightGray); impl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { handleClickAction(); } } @Override public void mousePressed(MouseEvent e) { showPopup(e); } @Override public void mouseReleased(MouseEvent e) { showPopup(e); } protected void showPopup(MouseEvent e) { if (e.isPopupTrigger() && contextMenuEnabled) { // select row Point p = e.getPoint(); int viewRowIndex = impl.rowAtPoint(p); int rowNumber; if (viewRowIndex >= 0) { rowNumber = impl.convertRowIndexToModel(viewRowIndex); } else { rowNumber = -1; } ListSelectionModel model = impl.getSelectionModel(); if (!model.isSelectedIndex(rowNumber)) { model.setSelectionInterval(rowNumber, rowNumber); } // show popup menu JPopupMenu popupMenu = createPopupMenu(); if (popupMenu.getComponentCount() > 0) { popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } } }); ColumnControlButton columnControlButton = new ColumnControlButton(impl) { @Override protected ColumnVisibilityAction createColumnVisibilityAction(TableColumn column) { ColumnVisibilityAction columnVisibilityAction = super.createColumnVisibilityAction(column); columnVisibilityAction.addPropertyChangeListener(evt -> { if ("SwingSelectedKey".equals(evt.getPropertyName()) && evt.getNewValue() instanceof Boolean) { ColumnVisibilityAction action = (ColumnVisibilityAction) evt.getSource(); String columnName = action.getActionCommand(); boolean collapsed = !((boolean) evt.getNewValue()); Column col = getColumn(columnName); if (col != null) { col.setCollapsed(collapsed); } } }); return columnVisibilityAction; } }; impl.setColumnControl(columnControlButton); impl.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); impl.getActionMap().put("enter", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (enterPressAction != null) { enterPressAction.actionPerform(DesktopAbstractTable.this); } else { handleClickAction(); } } }); Messages messages = AppBeans.get(Messages.NAME); // localize default column control actions for (Object actionKey : impl.getActionMap().allKeys()) { if ("column.packAll".equals(actionKey)) { BoundAction action = (BoundAction) impl.getActionMap().get(actionKey); action.setName(messages.getMessage(DesktopTable.class, "DesktopTable.packAll")); } else if ("column.packSelected".equals(actionKey)) { BoundAction action = (BoundAction) impl.getActionMap().get(actionKey); action.setName(messages.getMessage(DesktopTable.class, "DesktopTable.packSelected")); } else if ("column.horizontalScroll".equals(actionKey)) { BoundAction action = (BoundAction) impl.getActionMap().get(actionKey); action.setName(messages.getMessage(DesktopTable.class, "DesktopTable.horizontalScroll")); } } // Ability to configure fonts in table // Add action to column control String configureFontsLabel = messages.getMessage(DesktopTable.class, "DesktopTable.configureFontsLabel"); impl.getActionMap().put(ColumnControlButton.COLUMN_CONTROL_MARKER + "fonts", new AbstractAction(configureFontsLabel) { @Override public void actionPerformed(ActionEvent e) { Component rootComponent = SwingUtilities.getRoot(impl); final FontDialog fontDialog = FontDialog.show(rootComponent, impl.getFont()); fontDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { Font result = fontDialog.getResult(); if (result != null) { impl.setFont(result); packRows(); } } }); fontDialog.open(); } }); // Ability to reset settings String resetSettingsLabel = messages.getMessage(DesktopTable.class, "DesktopTable.resetSettings"); impl.getActionMap().put(ColumnControlButton.COLUMN_CONTROL_MARKER + "resetSettings", new AbstractAction(resetSettingsLabel) { @Override public void actionPerformed(ActionEvent e) { resetPresentation(); } }); scrollPane.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (!columnsInitialized) { adjustColumnHeaders(); } columnsInitialized = true; } }); // init default row height SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (!fontInitialized) { applyFont(impl, impl.getFont()); } } }); }
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * //from w ww . ja v a 2 s. c om * @return */ public Action getOpenAction() { Action ret = actionMap.get(ACTION_OPEN); if (ret == null) { ret = new AbstractAction(ACTION_OPEN, getIcon("script_go.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { try { int option = jFileChooser.showOpenDialog(debuggerFrame); if (option != JFileChooser.CANCEL_OPTION) { File selectedFile = jFileChooser.getSelectedFile(); try { String scriptXml = FileUtils.readFileToString(selectedFile); setFromString(scriptXml); debuggerFrame.setScriptSource( new ScriptSource(selectedFile.getAbsolutePath(), SourceType.file)); } catch (Exception e) { LOG.error("Error reading file " + selectedFile.getName() + ": " + e); JOptionPane.showMessageDialog(debuggerFrame, e.getMessage(), "Error unmarshalling xml", JOptionPane.ERROR_MESSAGE); } } } catch (HeadlessException e) { showError("Error opening file: " + e); } } }; ret.putValue(Action.SHORT_DESCRIPTION, "Open Agent xml from filesystem."); ret.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke('O', menuActionMods)); ret.putValue(Action.MNEMONIC_KEY, new Integer('O')); actionMap.put(ACTION_OPEN, ret); } return ret; }
From source file:com.limegroup.gnutella.gui.GUIUtils.java
/** * Gets the keystroke for hiding a window according to the platform. *///from w w w . j a v a 2s. c om public static KeyStroke getHideKeystroke() { if (OSUtils.isMacOSX()) return KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); else return KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); }
From source file:DateTimeEditor.java
protected void setupKeymap() { Keymap keymap = m_textField.addKeymap("DateTimeKeymap", null); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), m_upAction); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), m_downAction); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), new BackwardAction(DefaultEditorKit.backwardAction)); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), new ForwardAction(DefaultEditorKit.forwardAction)); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), new BeginAction(DefaultEditorKit.beginAction)); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), new EndAction(DefaultEditorKit.endAction)); m_textField.setKeymap(keymap);//from w w w. j a v a2 s. com }
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
private Action getRefreshAction() { if (this.refreshAction == null) { String actionCommand = bundle.getString(REFRESH_NODE_KEY); String actionKey = bundle.getString(REFRESH_NODE_KEY + ".action"); this.refreshAction = new AbstractAction(actionCommand, Icons.REFRESH) { /**//from www . j a v a2 s.c o m * */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { model.refresh(nodes[0].getPath(), true); } }; this.refreshAction.putValue(Action.ACTION_COMMAND_KEY, actionKey); this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), actionKey); this.getActionMap().put(actionKey, this.refreshAction); } return this.refreshAction; }