public boolean editCellAt(final int row, final int column, final EventObject e) { if (cellEditor != null && !cellEditor.stopCellEditing()) { return false; } if (row < 0 || row >= getRowCount() || column < 0 || column >= getColumnCount()) { return false; } if (!isCellEditable(row, column)) { return false; } if (myEditorRemover == null) { final KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); myEditorRemover = new MyCellEditorRemover(); //noinspection HardCodedStringLiteral keyboardFocusManager.addPropertyChangeListener("focusOwner", myEditorRemover); //noinspection HardCodedStringLiteral keyboardFocusManager.addPropertyChangeListener("permanentFocusOwner", myEditorRemover); } final TableCellEditor editor = getCellEditor(row, column); if (editor != null && editor.isCellEditable(e)) { editorComp = prepareEditor(editor, row, column); // ((JComponent)editorComp).setBorder(null); if (editorComp == null) { removeEditor(); return false; } editorComp.setBounds(getCellRect(row, column, false)); add(editorComp); editorComp.validate(); IdeFocusManager.findInstanceByComponent(this).requestFocus(editorComp, false); setCellEditor(editor); setEditingRow(row); setEditingColumn(column); editor.addCellEditorListener(this); if (isTypeAhead) { JTableCellEditorHelper.typeAhead(this, e, row, column); } return true; } return false; }
public boolean editCellAt(int index, EventObject e) { if (editor != null && !editor.stopCellEditing()) return false; if (index < 0 || index >= getModel().getSize()) return false; if (!isCellEditable(index)) return false; if (editorRemover == null) { KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); editorRemover = new CellEditorRemover(fm); fm.addPropertyChangeListener("permanentFocusOwner", editorRemover); // NOI18N } if (editor != null && editor.isCellEditable(e)) { editorComp = prepareEditor(index); if (editorComp == null) { removeEditor(); return false; } editorComp.setBounds(getCellBounds(index, index)); add(editorComp); editorComp.validate(); editingIndex = index; editor.addCellEditorListener(this); return true; } return false; }
/* * Create using the specified focus policy */ public TabFocusHandler(JTabbedPane tabbedPane, int focusPolicy) { if (focusPolicy != RESET_FOCUS && focusPolicy != RETAIN_FOCUS) throw new IllegalArgumentException("Invalid focus policy"); this.tabbedPane = tabbedPane; this.focusPolicy = focusPolicy; // Add listeners to manage a tab change tabbedPane.addChangeListener(this); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener("permanentFocusOwner", this); }
/* * The method maps the list of the active windows to the window's AppContext, * then the method registers ActiveWindowListener, GuiDisposedListener listeners; * it executes the initilialization only once per AppContext. */ @SuppressWarnings("unchecked") private static void initActiveWindowsTracking(Window w) { AppContext appContext = AppContext.getAppContext(); synchronized (appContext) { List<WWindowPeer> l = (List<WWindowPeer>) appContext.get(ACTIVE_WINDOWS_KEY); if (l == null) { l = new LinkedList<WWindowPeer>(); appContext.put(ACTIVE_WINDOWS_KEY, l); appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener); KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); kfm.addPropertyChangeListener("activeWindow", activeWindowListener); } } }
/** * Constructs a new AlgebraicValueEditor. * * @param valueEditorHierarchyManager */ public AlgebraicValueEditor(ValueEditorHierarchyManager valueEditorHierarchyManager) { super(valueEditorHierarchyManager); setFocusCycleRoot(true); setLayout(new BorderLayout()); setResizable(true); add(contentScrollPane, BorderLayout.CENTER); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); contentScrollPane.getHorizontalScrollBar().setCursor(Cursor.getDefaultCursor()); contentScrollPane.getVerticalScrollBar().setCursor(Cursor.getDefaultCursor()); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener("permanentFocusOwner", focusChangeListener); }
/** Creates a new <code>CollapsiblePaneGroup</code>. */ public CollapsiblePaneGroup() { final KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); _listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { Component focusOwner = focusManager.getFocusOwner(); if (focusOwner != null) { for (CollapsiblePane pane : _panes) { if (SwingUtilities.isDescendingFrom(focusOwner, pane)) { pane.setEmphasized(true); break; } } } } }; focusManager.addPropertyChangeListener( "focusOwner", new WeakPropertyChangeListener(_listener, focusManager)); }
public FreeTextAnnotationComponent( Annotation annotation, DocumentViewController documentViewController, final AbstractPageViewComponent pageViewComponent, final DocumentViewModel documentViewModel) { super(annotation, documentViewController, pageViewComponent, documentViewModel); isRollover = false; isShowInvisibleBorder = false; freeTextAnnotation = (FreeTextAnnotation) annotation; // update the shapes array pruning any text glyphs as well as // extra any useful font information for the editing of this annotation. if (annotation.getShapes() != null) { ArrayList<DrawCmd> shapes = annotation.getShapes().getShapes(); DrawCmd cmd; for (int i = 0; i < shapes.size(); i++) { cmd = shapes.get(i); if (cmd instanceof TextSpriteDrawCmd) { // grab the font reference TextSprite tmp = ((TextSpriteDrawCmd) cmd).getTextSprite(); FontFile font = tmp.getFont(); freeTextAnnotation.setFontSize((int) font.getSize()); freeTextAnnotation.setFontColor(tmp.getStrokeColor()); // remove all text. shapes.remove(i); } } ((FreeTextAnnotation) annotation).clearShapes(); } // create the textArea to display the text. freeTextPane = new FreeTextArea( new FreeTextArea.ZoomProvider() { private DocumentViewModel model; { this.model = documentViewModel; } public float getZoom() { return this.model.getViewZoom(); } }); // line wrap false to force users to add line breaks. freeTextPane.setLineWrap(false); freeTextPane.setBackground(new Color(0, 0, 0, 0)); freeTextPane.setMargin(new Insets(0, 0, 0, 0)); // lock the field until the correct tool selects it. freeTextPane.setEditable(false); // clean up the contents make sure we have \n instead of \r String contents = freeTextAnnotation.getContents(); if (contents != null) { contents = contents.replace('\r', '\n'); freeTextPane.setText(contents); } // setup change listener so we now when to set the annotations AP stream freeTextPane .getDocument() .addDocumentListener( new DocumentListener() { public void insertUpdate(DocumentEvent e) { contentTextChange = true; } public void removeUpdate(DocumentEvent e) { contentTextChange = true; } public void changedUpdate(DocumentEvent e) { contentTextChange = true; } }); GridLayout grid = new GridLayout(1, 1, 0, 0); this.setLayout(grid); this.add(freeTextPane); // add a focus management listener. KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener(this); // set the default size hen building from external file if (annotation.getBbox() != null) { setBounds(annotation.getBbox().getBounds()); } resetAppearanceShapes(); revalidate(); }
/** Register us as KeyEventDispatcher and property "managingFocus" listeners. */ private void addTraversingOutListeners(KeyboardFocusManager kfm) { kfm.addKeyEventDispatcher(this); kfm.addPropertyChangeListener("managingFocus", this); }
/** * invoked by reflection * * @param dataManager * @param applicationInfoEx * @param actionManager * @param uiSettings */ public WindowManagerImpl( DataManager dataManager, ApplicationInfoEx applicationInfoEx, ActionManagerEx actionManager, UISettings uiSettings, MessageBus bus) { myApplicationInfoEx = applicationInfoEx; myDataManager = dataManager; myActionManager = actionManager; myUiSettings = uiSettings; if (myDataManager instanceof DataManagerImpl) { ((DataManagerImpl) myDataManager).setWindowManager(this); } final Application application = ApplicationManager.getApplication(); if (!application.isUnitTestMode()) { Disposer.register( application, new Disposable() { @Override public void dispose() { disposeRootFrame(); } }); } myCommandProcessor = new CommandProcessor(); myWindowWatcher = new WindowWatcher(); final KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); keyboardFocusManager.addPropertyChangeListener(FOCUSED_WINDOW_PROPERTY_NAME, myWindowWatcher); if (Patches.SUN_BUG_ID_4218084) { keyboardFocusManager.addPropertyChangeListener( FOCUSED_WINDOW_PROPERTY_NAME, new SUN_BUG_ID_4218084_Patch()); } myLayout = new DesktopLayout(); myProject2Frame = new HashMap<Project, IdeFrameImpl>(); myDialogsToDispose = new HashMap<Project, Set<JDialog>>(); myFrameExtendedState = Frame.NORMAL; // Calculate screen bounds. Rectangle screenBounds = new Rectangle(); if (!application.isHeadlessEnvironment()) { final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = env.getScreenDevices(); for (final GraphicsDevice device : devices) { screenBounds = screenBounds.union(device.getDefaultConfiguration().getBounds()); } } myScreenBounds = screenBounds; myActivationListener = new WindowAdapter() { public void windowActivated(WindowEvent e) { Window activeWindow = e.getWindow(); if (activeWindow instanceof IdeFrameImpl) { // must be proceedDialogDisposalQueue(((IdeFrameImpl) activeWindow).getProject()); } } }; bus.connect() .subscribe( AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() { @Override public void appClosing() { // save fullscreen window states if (isFullScreenSupportedInCurrentOS() && GeneralSettings.getInstance().isReopenLastProject()) { Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (openProjects.length > 0) { WindowManagerEx wm = WindowManagerEx.getInstanceEx(); for (Project project : openProjects) { IdeFrameImpl frame = wm.getFrame(project); if (frame != null) { frame.storeFullScreenStateIfNeeded(); } } } } } }); if (UIUtil.hasLeakingAppleListeners()) { UIUtil.addAwtListener( new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (event.getID() == ContainerEvent.COMPONENT_ADDED) { if (((ContainerEvent) event).getChild() instanceof JViewport) { UIUtil.removeLeakingAppleListeners(); } } } }, AWTEvent.CONTAINER_EVENT_MASK, application); } }