List of usage examples for java.awt.event KeyEvent VK_BACK_SPACE
int VK_BACK_SPACE
To view the source code for java.awt.event KeyEvent VK_BACK_SPACE.
Click Source Link
From source file:org.squidy.designer.zoom.impl.SourceCodeShape.java
private JEditorPane createCodePane(URL sourceCodeURL) { codePane = new JEditorPane() { @Override/*from w w w . ja va 2 s .c o m*/ protected void processComponentKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE && e.isControlDown()) { System.out.println("Code completion"); int caretPosition = codePane.getCaretPosition(); String code = codePane.getText(); switch (code.charAt(caretPosition - 1)) { case '.': int pseudoCaret = caretPosition - 1; StringBuilder word = new StringBuilder(); for (char c = code.charAt(--pseudoCaret); !isEndOfWord(c); c = code.charAt(--pseudoCaret)) { word.append(c); } word = word.reverse(); System.out.println("WORD: " + word); // Class<?> type = // ReflectionUtil.loadClass(word.toString()); // // System.out.println("TYPE: " + type); JPopupMenu menu = new JPopupMenu("sdaf"); Point p = codePane.getCaret().getMagicCaretPosition(); System.out.println("CARET POS: " + p); // Point p = codePane.get // menu.setPreferredSize(new Dimension(200, 200)); menu.setLocation(30, 30); menu.add("test"); codePane.add(menu); // System.out.println(p); // codePane.get menu.show(codePane, p.x, p.y); break; } } super.processComponentKeyEvent(e); } /** * @param c * @return */ private boolean isEndOfWord(char c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t'; } }; EditorKit editorKit = new StyledEditorKit() { /** * */ private static final long serialVersionUID = 7024886168909204806L; public Document createDefaultDocument() { return new SyntaxDocument(); } }; codePane.setEditorKitForContentType("text/java", editorKit); codePane.setContentType("text/java"); try { FileInputStream fis = new FileInputStream(sourceCodeURL.getPath()); codePane.read(fis, null); originSourceCode = codePane.getText(); computeHeightOfCodePane(); codePane.setAutoscrolls(true); } catch (Exception e) { codePane.setText("File not found!"); } codePane.requestFocus(); codePane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); codePane.addKeyListener(new KeyAdapter() { /* * (non-Javadoc) * * @see * java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent) */ @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: case KeyEvent.VK_SPACE: computeHeightOfCodePane(); break; } markDirty(); } }); // final JPopupMenu menu = new JPopupMenu(); // // JMenuItem i = new JMenuItem("Option 1"); // JMenuItem i2 = new JMenuItem("Option 2"); // menu.add(i); // menu.add(i2); // edit.add(menu); // getComponent().addKeyListener(new KeyAdapter() { // // public void keyTyped(KeyEvent e) { // if(e.getModifiers() == 2 && e.getKeyChar() == ' ') { // Point popupLoc = edit.getCaret().getMagicCaretPosition(); // System.out.println(popupLoc); // menu.setLocation(new // Point((int)popupLoc.getX(),(int)popupLoc.getY())); // menu.setVisible(true); // } // // } // }); return codePane; }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.RefineFEGeometryWidget.java
@Override public void keyPressed(final KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { m_modePolygon = !m_modePolygon;//from w w w . j ava 2 s . c o m reinit(); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) reinit(); else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) m_geometryBuilder.removeLastPoint(); else if (e.getKeyCode() == KeyEvent.VK_ENTER) convertRefinementToModel(); else super.keyPressed(e); }
From source file:org.kepler.gui.KeplerGraphFrame.java
/** * Override BasicGraphFrame._initBasicGraphFrame() *//*from w ww . j a v a 2 s. c o m*/ @Override protected void _initBasicGraphFrame() { /** * @todo - FIXME - Need to move this further up the hierarchy, so other * types of frames use it too. Don't put it in a launcher class * like KeplerApplication, because it then gets overridden later, * elsewhere in PTII */ StaticGUIResources.setLookAndFeel(); _initBasicGraphFrameInitialization(); _dropTarget = BasicGraphFrameExtension.getDropTarget(_jgraph); // add a CanvasDropTargetListener so that other classes can get CanvasDropTargetListener listener = CanvasDropTargetListener.getInstance(); _dropTarget.registerAdditionalListener(listener); ActionListener deletionListener = new DeletionListener(); _rightComponent.registerKeyboardAction(deletionListener, "Delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); _rightComponent.registerKeyboardAction(deletionListener, "BackSpace", KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); _initBasicGraphFrameRightComponent(); _jgraph.setRequestFocusEnabled(true); // Background color is parameterizable by preferences. Configuration configuration = getConfiguration(); if (configuration != null) { try { // Set the PtolemyPreference to the desired background. // See // http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2321#c14 PtolemyPreferences preferences = PtolemyPreferences .getPtolemyPreferencesWithinConfiguration(configuration); if (_isDebugging) { _log.debug("bg: " + BACKGROUND_COLOR); } if (preferences != null) { float[] components = new float[4]; // Make sure we get only 4 elements in case the color space // is bigger than 4 components = BACKGROUND_COLOR.getComponents(components); preferences.backgroundColor.setExpression("{" + components[0] + "," + components[1] + "," + components[2] + "," + components[3] + "}"); _rightComponent.setBackground(preferences.backgroundColor.asColor()); if (_isDebugging) { _log.debug("desired background: " + BACKGROUND_COLOR + " actual background: " + preferences.backgroundColor.asColor()); } } } catch (IllegalActionException e1) { // Ignore the exception and use the default color. } } _initBasicGraphFrameRightComponentMouseListeners(); try { // The SizeAttribute property is used to specify the size // of the JGraph component. Unfortunately, with Swing's // mysterious and undocumented handling of component sizes, // there appears to be no way to control the size of the // JGraph from the size of the Frame, which is specified // by the WindowPropertiesAttribute. SizeAttribute size = (SizeAttribute) getModel().getAttribute("_vergilSize", SizeAttribute.class); if (size != null) { size.setSize(_jgraph); } else { // Set the default size. // Note that the location is of the frame, while the size // is of the scrollpane. _jgraph.setPreferredSize(new Dimension(600, 400)); } _initBasicGraphFrameSetZoomAndPan(); } catch (Exception ex) { // Ignore problems here. Errors simply result in a default // size and location. } // Create the panner. _graphPanner = new JCanvasPanner(_jgraph); _horizontalScrollBar = new JScrollBar(Adjustable.HORIZONTAL); _verticalScrollBar = new JScrollBar(Adjustable.VERTICAL); // see if we want scrollbars on the canvas or not // the answer defaults to 'no' CanvasNavigationModifierFactory CNMfactory = (CanvasNavigationModifierFactory) getConfiguration() .getAttribute("canvasNavigationModifier"); if (CNMfactory != null) { // get the scrollbar flag from the factory if // it exists in the config ScrollBarModifier modifier = CNMfactory.createScrollBarModifier(); _scrollBarFlag = modifier.getScrollBarModifier(); } _canvasPanel = new JPanel(); _canvasPanel.setBorder(null); _canvasPanel.setLayout(new BorderLayout()); if (_scrollBarFlag) { _canvasPanel.add(_horizontalScrollBar, BorderLayout.SOUTH); _canvasPanel.add(_verticalScrollBar, BorderLayout.EAST); _horizontalScrollBar.setModel(_jgraph.getGraphPane().getCanvas().getHorizontalRangeModel()); _verticalScrollBar.setModel(_jgraph.getGraphPane().getCanvas().getVerticalRangeModel()); _horizontalScrollBarListener = new ScrollBarListener(_horizontalScrollBar); _verticalScrollBarListener = new ScrollBarListener(_verticalScrollBar); _horizontalScrollBar.addAdjustmentListener(_horizontalScrollBarListener); _verticalScrollBar.addAdjustmentListener(_verticalScrollBarListener); } // NOTE: add _rightComponent instead of _jgraph since _rightComponent // may be sub-divided into tabbed panes. // see http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3708 _canvasPanel.add(_rightComponent, BorderLayout.CENTER); TabManager tabman = TabManager.getInstance(); tabman.initializeTabs(this); ViewManager viewman = ViewManager.getInstance(); viewman.initializeViews(this); try { viewman.addCanvasToLocation(_canvasPanel, this); } catch (Exception e) { throw new RuntimeException("Could not add canvas panel: " + e.getMessage()); } // _jgraph.setMinimumSize(new Dimension(0, 0)); getContentPane().add(viewman.getViewArea(this), BorderLayout.CENTER); // The toolbar panel is the container that contains the main toolbar and // any additional toolbars JPanel toolbarPanel = new JPanel(); toolbarPanel.setLayout(new BoxLayout(toolbarPanel, BoxLayout.Y_AXIS)); // They // stack _toolbar = new JToolBar(); // The main Kepler toolbar toolbarPanel.add(_toolbar); getContentPane().add(toolbarPanel, BorderLayout.NORTH); // Place the // toolbar panel _initBasicGraphFrameToolBarZoomButtons(); _initBasicGraphFrameActions(); // Add a weak reference to this to keep track of all // the graph frames that have been created. _openGraphFrames.add(this); System.gc(); }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java
/** * This method initializes jComboBoxClonedFrom * /*from w w w . j a va 2s. c om*/ * @return javax.swing.JComboBox */ private JComboBox<String> getJComboBoxClonedFrom() { if (jComboBoxClonedFrom == null) { jComboBoxClonedFrom = new JComboBox<String>(); jComboBoxClonedFrom.setRenderer(new ComboToopTip()); jComboBoxClonedFrom.setEditable(true); jComboBoxClonedFrom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("jComboBoxClonedFrom.actionPerformed()"); eventHandler.handleEvent(EventHandler.COMBO_CLONED_FROM); } }); refresh(jComboBoxClonedFrom); final JTextField editor; editor = (JTextField) jComboBoxClonedFrom.getEditor().getEditorComponent(); editor.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) return; if (ch == KeyEvent.VK_ENTER) { jComboBoxClonedFrom.hidePopup(); return; } String str = editor.getText(); if (jComboBoxClonedFrom.getComponentCount() > 0) { jComboBoxClonedFrom.removeAllItems(); } jComboBoxClonedFrom.addItem(str); try { String tmpProjectName = null; if (str.length() > 0) { for (int i = 0; i < names.size(); i++) { tmpProjectName = names.get(i); if (tmpProjectName.toLowerCase().startsWith(str.toLowerCase())) jComboBoxClonedFrom.addItem(tmpProjectName); } } else { for (int i = 0; i < names.size(); i++) { jComboBoxClonedFrom.addItem(names.get(i)); } } } catch (Exception e1) { log.warn(e1.getMessage()); } jComboBoxClonedFrom.hidePopup(); if (str.length() > 0) jComboBoxClonedFrom.showPopup(); } }); editor.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (editor.getText().length() > 0) jComboBoxClonedFrom.showPopup(); } public void focusLost(FocusEvent e) { jComboBoxClonedFrom.hidePopup(); } }); } return jComboBoxClonedFrom; }
From source file:vistas.ModPersonal.java
private void txt_apellidoMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_apellidoMKeyTyped char car = evt.getKeyChar(); if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE) && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Ingrese solo letras"); evt.consume();//from ww w . ja va 2 s . co m } }
From source file:org.docx4all.swing.text.WordMLEditorKit.java
private void initKeyBindings(JEditorPane editor) { ActionMap myActionMap = new ActionMap(); InputMap myInputMap = new InputMap(); KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK); myActionMap.put(insertSoftBreakAction, new InsertSoftBreakAction(insertSoftBreakAction)); myInputMap.put(ks, insertSoftBreakAction); ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); myActionMap.put(enterKeyTypedAction, new EnterKeyTypedAction(enterKeyTypedAction)); myInputMap.put(ks, enterKeyTypedAction); ks = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); myActionMap.put(deleteNextCharAction, new DeleteNextCharAction(deleteNextCharAction)); myInputMap.put(ks, deleteNextCharAction); ks = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0); myActionMap.put(deletePrevCharAction, new DeletePrevCharAction(deletePrevCharAction)); myInputMap.put(ks, deletePrevCharAction); myActionMap.setParent(editor.getActionMap()); myInputMap.setParent(editor.getInputMap()); editor.setActionMap(myActionMap);/*from w w w . j ava2 s. com*/ editor.setInputMap(JComponent.WHEN_FOCUSED, myInputMap); }
From source file:vistas.ModPersonal.java
private void txt_horaMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_horaMKeyTyped char car = evt.getKeyChar(); if (txt_horaM.getText().length() >= 8) { JOptionPane.showMessageDialog(this, "Permitido hasta 8 digitos"); evt.consume();/*from w w w . ja v a 2s. c o m*/ } if ((car < '0' || car > '9') && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Solo numeros"); evt.consume(); } }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void keyPressed(KeyEvent e) { if (e.getSource() != table) { return;//from w ww . j a v a 2s . co m } if (e.getKeyCode() == KeyEvent.VK_ENTER) { // What's the current selection ? final List<File> selection = getSelection(); if (selection.size() == 1) { final File selectedFile = selection.iterator().next(); if (selectedFile.isDirectory()) { // Change to the selected directory setDirectory(selectedFile); } } } else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { // Return to the parent directory (if any) final File parentDir = getParentDirectory(); if ((parentDir != null) && parentDir.exists()) { setDirectory(parentDir); } } else { // Propagate event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); } }
From source file:vistas.ModPersonal.java
private void txt_NameMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_NameMKeyTyped char car = evt.getKeyChar(); if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE) && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Ingrese solo letras"); evt.consume();//from w w w.jav a 2s.c o m } }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private void initGui(final String initialPath) { this.setLayout(new BorderLayout()); JLabel pathLabel = new JLabel(Messages.getMessage("browser.location")); pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); pathField = new JTextField(80); pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f)); pathField.setToolTipText(Messages.getMessage("nav.pathTooltip")); GuiUtils.addBlinkOnFocusGain(pathField); pathLabel.setLabelFor(pathField);/*from www . j a va2 s .c om*/ pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0)); InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED); inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH"); inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) { @Override protected void performLongOperation(CheckBeforeActionResult actionResult) { try { FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim()); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); actionApproveDelegate.actionPerformed( // TODO: Does actionResult provide an ID for 2nd param here, // or should use a Random number? new ActionEvent(actionResult, (int) new java.util.Date().getTime(), "SELECTED_FILE")); return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(pathField.getText().trim()); } @Override protected boolean canGoUrl() { return true; } @Override protected boolean canExecuteDefaultAction() { return false; } }); actionFocusOnTable = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { tableFiles.requestFocusInWindow(); if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) { tableFiles.getSelectionModel().setSelectionInterval(0, 0); } } }; pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this); goUpButton = new JButton(goUpAction); BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this); JButton refreshButton = new JButton(refreshAction); JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName")); upperPanel.setRollover(true); upperPanel.add(pathLabel); upperPanel.add(pathField, "growx"); upperPanel.add(goUpButton); upperPanel.add(refreshButton); AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction( this); JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction); addCurrentLocationToFavoriteButton.setText(""); upperPanel.add(addCurrentLocationToFavoriteButton); previewComponent = new PreviewComponent(); vfsTableModel = new VfsTableModel(); tableFiles = new JTable(vfsTableModel); tableFiles.setFillsViewportHeight(true); tableFiles.getColumnModel().getColumn(0).setMinWidth(140); tableFiles.getColumnModel().getColumn(1).setMaxWidth(80); tableFiles.getColumnModel().getColumn(2).setMaxWidth(80); tableFiles.getColumnModel().getColumn(3).setMaxWidth(180); tableFiles.getColumnModel().getColumn(3).setMinWidth(120); sorter = new TableRowSorter<VfsTableModel>(vfsTableModel); final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator(); sorter.addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { RowSorterEvent.Type type = e.getType(); if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) { List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys(); for (RowSorter.SortKey sortKey : sortKeys) { if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) { fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder()); } } } } }); sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator); tableFiles.setRowSorter(sorter); tableFiles.setShowGrid(false); tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { try { selectionChanged(); } catch (FileSystemException e1) { LOGGER.error("Error during update state", e); } } }); tableFiles.setColumnSelectionAllowed(false); vfsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateStatusText(); } }); tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer()); tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer()); tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer()); tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer()); tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent)); JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]")); favoritesUserListModel = new MutableListModel<Favorite>(); List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations(); List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration); List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks(); for (Favorite favorite : favUser) { favoritesUserListModel.add(favorite); } favoritesUserListModel.addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { saveFavorites(); } @Override public void intervalRemoved(ListDataEvent e) { saveFavorites(); } @Override public void contentsChanged(ListDataEvent e) { saveFavorites(); } protected void saveFavorites() { FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList()); } }); favoritesUserList = new JList(favoritesUserListModel); favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList)); new MutableListDragListener(favoritesUserList); favoritesUserList.setCellRenderer(new FavoriteListCellRenderer()); favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter()); addOpenActionToList(favoritesUserList); addEditActionToList(favoritesUserList, favoritesUserListModel); favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction( Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) { @Override public void actionPerformed(ActionEvent e) { Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex()); if (!Favorite.Type.USER.equals(favorite.getType())) { return; } int response = JOptionPane.showConfirmDialog(VfsBrowser.this, Messages.getMessage("favorites.areYouSureToDeleteConnections"), Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { favoritesUserListModel.remove(favoritesUserList.getSelectedIndex()); } } }); InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED); favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE); ActionMap actionMap = tableFiles.getActionMap(); actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this)); actionMap.put(ACTION_GO_UP, goUpAction); actionMap.put(ACTION_APPROVE, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (actionApproveButton.isEnabled()) { actionApproveDelegate.actionPerformed(e); } } }); InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE); inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP); addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE); JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations)); favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer()); addOpenActionToList(favoriteSystemList); addPopupMenu(favoriteSystemList, ACTION_OPEN); favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter()); JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser)); addOpenActionToList(favoriteJVfsList); favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer()); addPopupMenu(favoriteJVfsList, ACTION_OPEN); favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter()); JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"), COMPUTER_ICON); favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList); favoritesSystemLocationsLabel .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0)); favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16"); favoritesPanel.add(favoriteSystemList, "growx"); JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"), Icons.getInstance().getStar()); favoritesFavoritesLabel.setLabelFor(favoritesUserList); favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0)); favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16"); favoritesPanel.add(favoritesUserList, "growx"); if (favoriteJVfsList.getModel().getSize() > 0) { JLabel favoritesJVfsFileChooser = getTitleListLabel( Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null); favoritesJVfsFileChooser.setDisplayedMnemonic( Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0)); favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList); favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16"); favoritesPanel.add(favoriteJVfsList, "growx"); } tableFiles.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null); } } }); tableFiles.addKeyListener(new QuickSearchKeyAdapter()); cardLayout = new CardLayout(); tablePanel = new JPanel(cardLayout); loadingProgressBar = new JProgressBar(); loadingProgressBar.setStringPainted(true); loadingProgressBar.setString(Messages.getMessage("browser.loading")); loadingProgressBar.setIndeterminate(true); loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline()); skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks")); skipCheckingLinksButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (taskContext != null) { taskContext.setStop(skipCheckingLinksButton.isSelected()); } } }); showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden); showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip")); showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0)); Font tmpFont = showHidCheckBox.getFont(); showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f)); showHidCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUiFilters(); } }); final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText"); filterField = new JTextField("", 16); filterField.setForeground(filterField.getDisabledTextColor()); filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip")); PromptSupport.setPrompt(defaultFilterText, filterField); filterField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { documentChanged(); } void documentChanged() { if (filterField.getText().length() == 0) { updateUiFilters(); } } @Override public void removeUpdate(DocumentEvent e) { documentChanged(); } @Override public void changedUpdate(DocumentEvent e) { documentChanged(); } }); filterField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { updateUiFilters(); } }); AbstractAction actionClearRegexFilter = new AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) { @Override public void actionPerformed(ActionEvent e) { filterField.setText(""); } }; filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_CLEAR_REGEX_FILTER); JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter")); nameFilterLabel.setLabelFor(filterField); nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0)); sorter.setRowFilter(createFilter()); statusLabel = new JLabel(); actionApproveButton = new JButton(); actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD)); actionCancelButton = new JButton(); ActionMap browserActionMap = this.getActionMap(); browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { filterField.requestFocus(); filterField.selectAll(); GuiUtils.blinkComponent(filterField); } }); browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField)); browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox)); browserActionMap.put(ACTION_REFRESH, refreshAction); browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction); browserActionMap.put(ACTION_GO_UP, goUpAction); browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles)); InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER); browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN); browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES); browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP); browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE); //DO layout // create the layer for the panel using our custom layerUI tableScrollPane = new JScrollPane(tableFiles); JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout()); tableScrollPaneWithFilter.add(tableScrollPane); JToolBar filtersToolbar = new JToolBar("Filters"); filtersToolbar.setFloatable(false); filtersToolbar.setBorderPainted(true); tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH); filtersToolbar.add(nameFilterLabel); filtersToolbar.add(filterField); filtersToolbar.add(showHidCheckBox); JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, tableScrollPaneWithFilter, previewComponent); tableWithPreviewPane.setOneTouchExpandable(true); JPanel loadingPanel = new JPanel(new MigLayout()); loadingPanel.add(loadingIconLabel, "right"); loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap"); loadingPanel.add(skipCheckingLinksButton, "span, right"); tablePanel.add(loadingPanel, LOADING); tablePanel.add(tableWithPreviewPane, TABLE); JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel), tablePanel); jSplitPane.setOneTouchExpandable(true); jSplitPane.setDividerLocation(180); JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", "")); southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); southPanel.add(statusLabel); southPanel.add(actionApproveButton); southPanel.add(actionCancelButton); this.add(upperPanel, BorderLayout.NORTH); this.add(jSplitPane, BorderLayout.CENTER); this.add(southPanel, BorderLayout.SOUTH); try { selectionChanged(); } catch (FileSystemException e) { LOGGER.error("Can't initialize default selection mode", e); } // Why this not done in EDT? // Is it assume that constructor is invoked from an EDT? try { if (initialPath == null) { goToUrl(VFSUtils.getUserHome()); } else { try { FileObject resolveFile = VFSUtils.resolveFileObject(initialPath); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); targetFileSelected = true; return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(initialPath); } } catch (FileSystemException e1) { LOGGER.error("Can't initialize default location", e1); } showTable(); }