public boolean isShowing() { return textComponent.isShowing(); }
protected void refresh(){ if (getComponent().isShowing() && needsRefresh){ modelChanged(); needsRefresh = false; } }
public void showPopupMenu(int x, int y) { // First call the build-popup-menu action to possibly rebuild the popup menu JTextComponent component = getComponent(); if (component != null) { BaseKit kit = Utilities.getKit(component); if (kit != null) { Action a = kit.getActionByName(ExtKit.buildPopupMenuAction); if (a != null) { a.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N } } JPopupMenu pm = getPopupMenu(); if (pm != null) { if (component.isShowing()) { // fix of #18808 pm.show(component, x, y); } } } }
public void showPopupMenu(int x, int y) { // First call the build-popup-menu action to possibly rebuild the popup // menu JTextComponent component = getComponent(); if (component != null) { BaseKit kit = Utilities.getKit(component); if (kit != null) { Action a = kit.getActionByName(ExtKit.buildPopupMenuAction); if (a != null) { a.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N } } JPopupMenu pm = getPopupMenu(); if (pm != null) { if (component.isShowing()) { // fix of #18808 pm.show(component, x, y); } } } }
public void start() { // Possibly clear editor from previous error message (#115073) String lastMessage = mostRecentMessage; if (lastMessage != null) { JTextComponent pane = EditorRegistry.lastFocusedComponent(); if (pane != null) { if (pane.isShowing()) { String text = Utilities.getStatusText(pane); if (lastMessage.equals(text)) { Utilities.clearStatusText(pane); } } } mostRecentMessage = null; } resetResults(); }
public void keyPressed(KeyEvent ev) { if (ev.isShiftDown() && (ev.getKeyCode() == KeyEvent.VK_F10)) { JTextComponent component = (JTextComponent) ev.getSource(); if (component.isShowing()) { try { Rectangle r = component.modelToView(component.getCaretPosition()); getPopup(component).show(component, r.x, r.y); } catch (BadLocationException ignored) { ; } } } } }
public void showSmartFix( final int offset, final int length, final String displayText ) { Runnable runnable = () -> { try { _offset = offset; _length = length; Rectangle rectangle = getLocationFromOffset( _offset ); if( rectangle != TEST_RECTANGLE && _editor.isShowing() ) { _managerPopup = new SmartFixPopup( displayText ); } _editor.getHighlighter().addHighlight( _offset, _offset + _length, new SmartFixHighlightPainter( SMARTFIX_HIGHLIGHT_COLOR ) ); } catch( BadLocationException e ) { resetSmartHelpState(); //The user must have cleared out the given smart fix. } }; SwingUtilities.invokeLater( runnable ); }
private void setSuggestionWindowLocation() { if (textComponent.isShowing()){ suggestionWindow.pack(); if (textComponent instanceof JTextField) { int width = Math.max(textComponent.getWidth(), suggestionWindow.getWidth()); int screenHeight = suggestionWindow.getGraphicsConfiguration().getDevice().getDisplayMode().getHeight(); suggestionWindow.setSize(width, (int) Math.min(suggestionWindow.getHeight(), screenHeight / 2)); int x = (int) textComponent.getLocationOnScreen().getX(); int y = (int) (textComponent.getLocationOnScreen().getY() + textComponent.getHeight()); suggestionWindow.setLocation(x, y); } else { try { final int caretPosition = Math.min(textComponent.getText().length(), textComponent.getCaretPosition()); final Rectangle rectangle = textComponent.modelToView(caretPosition); final Point p = new Point(rectangle.x, rectangle.y + rectangle.height); SwingUtilities.convertPointToScreen(p, textComponent); suggestionWindow.setLocation(p.x, p.y); } catch (BadLocationException e) { e.printStackTrace(); } } } }
public static boolean isEnabled() { if (EditorRegistry.lastFocusedComponent() == null || !EditorRegistry.lastFocusedComponent().isShowing()) { return false; } if ( OpenProjects.getDefault().getOpenProjects().length == 0 ){ return false; } final FileObject fileObject = NbEditorUtilities.getFileObject( EditorRegistry.lastFocusedComponent().getDocument()); return isEnabled( fileObject ); /*WebModule webModule = WebModule.getWebModule(fileObject); if ( webModule == null ){ return false; } Profile profile = webModule.getJ2eeProfile(); return Profile.JAVA_EE_6_WEB.equals( profile) || Profile.JAVA_EE_6_FULL.equals( profile );*/ }
/** * Attributes were changed in the are this view is responsible for. * * @param e * the change information from the associated document * @param a * the current allocation of the view * @param f * the factory to use to rebuild if the view has children */ public void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) { try { if (getComponent().isShowing()) { getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength()); } } catch (BadLocationException ex) { if (Boolean.getBoolean("netbeans.debug.exceptions")) { // NOI18N ex.printStackTrace(); } } }
@Override public void run() { try { _offset = offset; _length = length; Rectangle rectangle = getLocationFromOffset( _offset ); if( rectangle != TEST_RECTANGLE && _editor.isShowing() ) { _managerPopup = new SmartFixPopup( displayText ); } _editor.getHighlighter().addHighlight( _offset, _offset + _length, new SmartFixHighlightPainter( SMARTFIX_HIGHLIGHT_COLOR ) ); } catch( BadLocationException e ) { resetSmartHelpState(); //The user must have cleared out the given smart fix. } } };
/** Remove from document notification. */ public void removeUpdate(DocumentEvent evt) { try { BaseDocumentEvent bevt = (BaseDocumentEvent)evt; EditorUI editorUI = getEditorUI(); int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset()); // !!! patch for case when DocMarksOp.eolMark is at the end of document if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) { syntaxY += lineHeight; } if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y)); } } catch (BadLocationException ex) { Utilities.annotateLoggable(ex); } }
/** Insert to document notification. */ public void insertUpdate(DocumentEvent evt) { try { BaseDocumentEvent bevt = (BaseDocumentEvent)evt; EditorUI editorUI = getEditorUI(); int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset()); // !!! patch for case when DocMarksOp.eolMark is at the end of document if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) { syntaxY += lineHeight; } if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y)); } } catch (BadLocationException ex) { Utilities.annotateLoggable(ex); } }
/** Attributes were changed in the are this view is responsible for. * @param e the change information from the associated document * @param a the current allocation of the view * @param f the factory to use to rebuild if the view has children */ public void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) { try { if (getComponent().isShowing()) { getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength()); } } catch (BadLocationException ex) { Utilities.annotateLoggable(ex); } }
if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
if (pane.isShowing()) { mostRecentMessage = message; if (isError()) {
/** The change in document notification. * * @param evt The change notification from the currently associated document. */ public void changedUpdate(DocumentEvent evt) { if (evt instanceof BaseDocumentEvent) { BaseDocumentEvent bdevt = (BaseDocumentEvent)evt; BaseDocument doc = (BaseDocument)bdevt.getDocument(); String layerName = bdevt.getDrawLayerName(); if (layerName != null) { getEditorUI().addLayer(doc.findLayer(layerName), bdevt.getDrawLayerVisibility()); }else{ //temp try { JTextComponent comp = getComponent(); if (comp!=null && comp.isShowing()) { getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength()); } } catch (BadLocationException ex) { Utilities.annotateLoggable(ex); } } } }