当前位置: 首页>>代码示例>>Java>>正文


Java EditorRegistry类代码示例

本文整理汇总了Java中org.netbeans.api.editor.EditorRegistry的典型用法代码示例。如果您正苦于以下问题:Java EditorRegistry类的具体用法?Java EditorRegistry怎么用?Java EditorRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EditorRegistry类属于org.netbeans.api.editor包,在下文中一共展示了EditorRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: propertyChange

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
@Override public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName() == null || EditorRegistry.COMPONENT_REMOVED_PROPERTY.equals(evt.getPropertyName())) {
        resolveAllComponents();
    } else if (EditorRegistry.FOCUS_GAINED_PROPERTY.equals(evt.getPropertyName())) {
        JTextComponent c = EditorRegistry.focusedComponent();
        if (c == null) {
            //#222557: unclear how this could happen
            resolveAllComponents();
            return;
        }
        Object o = c.getDocument().getProperty(Document.StreamDescriptionProperty);
        @SuppressWarnings("element-type-mismatch")
        AnnotationHolder holder = file2Holder.get(o);

        if (holder != null) {
            holder.maybeAddComponent(c);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AnnotationHolder.java

示例2: propertyChange

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
public void propertyChange(PropertyChangeEvent e) {
    JTextComponent active = EditorRegistry.lastFocusedComponent();
    
    if (getComponent() != active) {
        removeHints();
        setComponent(active);

        if (getComponent() != null) {
            getComponent().removeFocusListener(this);
        }

        if (active != null) {
            active.addFocusListener(this);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:HintsUI.java

示例3: getNextDoc

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
private BaseDocument getNextDoc(BaseDocument doc) {
    if (doc == getStaticWordsDoc()) {
        return null;
    }
    BaseDocument nextDoc = null;
    Set<BaseDocument> list = new LinkedHashSet<BaseDocument>();
    for(JTextComponent jtc : EditorRegistry.componentList()) {
        list.add(Utilities.getDocument(jtc));
    }
    for(Iterator<? extends BaseDocument> i = list.iterator(); i.hasNext(); ) {
        if (doc == i.next()) {
            if (i.hasNext()) {
                nextDoc = i.next();
            }
            break;
        }
    }
    if (nextDoc == null) {
        nextDoc = getStaticWordsDoc();
    }
    return nextDoc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:WordMatch.java

示例4: getNextDocument

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
private Document getNextDocument() {
    // Initially documentIndex == -1
    if (documentIndex == documents.size() - 1) { // Check adding
        if (documentSet.isEmpty()) { // documents list not inited yet -> add 'doc'
            documentSet.put(doc, Boolean.TRUE);
        }
        for (JTextComponent tc : EditorRegistry.componentList()) {
            Document d = tc.getDocument();
            if (!documentSet.containsKey(d)) {
                documentSet.put(d, Boolean.TRUE);
                documents.add(new WeakReference<Document>(d));
            }
        }
    }
    Document retDoc = null;
    while (documentIndex < documents.size() - 1) {
        documentIndex++;
        retDoc = documents.get(documentIndex).get();
        if (retDoc != null) {
            break;
        }
    }
    return retDoc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:WordMatch.java

示例5: propertyChange

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
@Override
    public void propertyChange(PropertyChangeEvent evt) {
        String propName = evt.getPropertyName();
        if (EditorRegistry.FOCUS_LOST_PROPERTY.equals(propName)) {
            // For subsequent focus-gained it would be ideal to schedule a timer
            // that would possibly directly change to a new component.
//            for (PresenterUpdater updater : presenterUpdaters.getList()) {
//                updater.setActiveComponent(null);
//            }
        } else if (EditorRegistry.FOCUS_GAINED_PROPERTY.equals(propName)) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("EditorRegistryWatcher: EditorRegistry.FOCUS_GAINED\n");
            }
            updateActiveActionInPresenters((JTextComponent) evt.getNewValue());
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EditorRegistryWatcher.java

示例6: TrailingWhitespaceRemoveProcessor

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
public TrailingWhitespaceRemoveProcessor(Document doc, boolean removeFromModifiedLinesOnly, AtomicBoolean canceled) {
    this.doc = doc;
    this.removeFromModifiedLinesOnly = removeFromModifiedLinesOnly;
    this.canceled = canceled;
    this.docText = DocumentUtilities.getText(doc); // Persists for doc's lifetime
    lineRootElement = DocumentUtilities.getParagraphRootElement(doc);
    modRootElement = ModRootElement.get(doc);
    JTextComponent lastFocusedComponent = EditorRegistry.lastFocusedComponent();
    if (lastFocusedComponent != null && lastFocusedComponent.getDocument() == doc && !REMOVE_WHITESPACE_ON_CURRENT_LINE) {
        int caretOffset = lastFocusedComponent.getCaretPosition();
        caretLineIndex = lineRootElement.getElementIndex(caretOffset);
        // Assign the relativeCaretOffset since the subsequent modifications
        // done by physical whitespace removal would make the absolute offsets unusable.
        caretRelativeOffset = caretOffset - lineRootElement.getElement(caretLineIndex).getStartOffset();
    } else {
        caretLineIndex = -1;
        caretRelativeOffset = 0;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TrailingWhitespaceRemoveProcessor.java

示例7: notifyFocusLost

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
void notifyFocusLost(PropertyChangeEvent focusLostRegistryEvt) {
    Component origFocusedComponent = (Component) focusLostRegistryEvt.getOldValue();
    Component focusGainingComponent = (Component) focusLostRegistryEvt.getNewValue();
    // If the searchbar (or replacebar) had a focus and the focus is lost to a text component registered
    // in EditorRegistry then attempt to regain the focus later.
    if (origFocusedComponent == incSearchTextField ||
                origFocusedComponent == ReplaceBar.getInstance(SearchBar.this).getReplaceTextField() ||
                origFocusedComponent == getActualTextComponent()) // ER reports actual TC when focus in search field
    {
        if (focusGainingComponent == null) { // Must check on focusGained
            regainFocusState = 2;
        } else if (focusGainingComponent instanceof JTextComponent &&
            EditorRegistry.componentList().contains(focusGainingComponent))
        {
            regainFocusState = 1;
        } else {
            regainFocusState = 0;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SearchBar.java

示例8: getCurrentOffset

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
@Override
public int getCurrentOffset() {
    try {
        return performOnAWT(new Callable<Integer>() {

            @Override
            public Integer call() throws Exception {
                JTextComponent mostActiveEditor = EditorRegistry.lastFocusedComponent();

                if ((mostActiveEditor != null) && (mostActiveEditor.getCaret() != null)) {
                    return mostActiveEditor.getCaretPosition();
                }

                return -1;
            }
        });
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
    }
    return -1;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ProjectEditorSupportImpl.java

示例9: updateHints

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
/** Regenerate hints for the current file, if you change settings */
private void updateHints() {
    JTextComponent pane = EditorRegistry.lastFocusedComponent();
    if (pane != null) {
        Document doc = pane.getDocument();
        final Source source = Source.create(doc);
        // see issue #212967; non-file Source appears for some reason.
        if (source != null && source.getFileObject() != null) {
            RequestProcessor.getDefault().post(new Runnable() {
                public void run() {
                    try {
                        ParserManager.parse(Collections.singleton(source), new UserTask() {
                            public @Override void run(ResultIterator resultIterator) throws Exception {
                                GsfHintsManager.refreshHints(resultIterator);
                            }
                        });
                    } catch (ParseException ex) {
                        LOG.log(Level.WARNING, null, ex);
                    }
                }
            });
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:HintsPanelLogic.java

示例10: propertyChange

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
public void propertyChange (PropertyChangeEvent evt) {
            if (evt.getPropertyName () == null ||
                evt.getPropertyName ().equals (EditorRegistry.FOCUSED_DOCUMENT_PROPERTY) ||
                evt.getPropertyName ().equals (EditorRegistry.FOCUS_GAINED_PROPERTY)
            ) {
                JTextComponent editor = EditorRegistry.focusedComponent ();
                if (editor == currentEditor) return;
                currentEditor = editor;
                if (currentEditor != null) {
                    Document document = currentEditor.getDocument ();
                    FileObject fileObject = NbEditorUtilities.getFileObject(document);
                    if (fileObject == null) {
//                        System.out.println("no file object for " + document);
                        return;
                    }
                }
                setEditor (currentEditor);
            }
            else if (evt.getPropertyName().equals(EditorRegistry.LAST_FOCUSED_REMOVED_PROPERTY)) {
                currentEditor = null;
                setEditor(null);
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GsfFoldScheduler.java

示例11: propertyChange

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
public void propertyChange (PropertyChangeEvent evt) {
            if (evt.getPropertyName () == null ||
                evt.getPropertyName ().equals (EditorRegistry.FOCUSED_DOCUMENT_PROPERTY) ||
                evt.getPropertyName ().equals (EditorRegistry.FOCUS_GAINED_PROPERTY)
            ) {
                JTextComponent editor = EditorRegistry.focusedComponent ();
                if (editor == currentEditor) return;
                currentEditor = editor;
                if (currentEditor != null) {
                    Document document = currentEditor.getDocument ();
                    FileObject fileObject = NbEditorUtilities.getFileObject (document);
                    if (fileObject == null) {
//                        System.out.println("no file object for " + document);
                        return;
                    }
                }
                setEditor (currentEditor);
            }
            else if (evt.getPropertyName().equals(EditorRegistry.LAST_FOCUSED_REMOVED_PROPERTY)) {
                currentEditor = null;
                setEditor(null);
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BreadCrumbsScheduler.java

示例12: actionPerformed

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
    if (refreshButton == e.getSource()) {
        final JTextComponent lastFocusedComponent = EditorRegistry.lastFocusedComponent();
        if (lastFocusedComponent != null) {
            final JavaSource js = JavaSource.forDocument(Utilities.getDocument(lastFocusedComponent));
            if (js != null) {
                setContext(js, lastFocusedComponent);
            }
        }
    } else if (jdocButton == e.getSource()) {
        final TopComponent win = JavadocTopComponent.findInstance();
        if (win != null && !win.isShowing()) {
            win.open();
            win.requestVisible();
            jdocTask.schedule(NOW);
        }
    } else if (historyCombo == e.getSource()) {
        refresh();
    } else if (viewTypeCombo == e.getSource()) {
        refresh();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:HierarchyTopComponent.java

示例13: implement

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
    final FileObject file = handle.getFileObject();
    final JTextComponent comp = EditorRegistry.lastFocusedComponent();
    if (file != null && file == getFileObject(comp)) {
        final int[] pos = new int[]{-1};
        JavaSource.forFileObject(file).runUserActionTask(new Task<CompilationController>(){
            @Override
            public void run(CompilationController info) throws Exception {
                info.toPhase(JavaSource.Phase.PARSED);
                final TreePath tp = handle.resolve(info);
                if (tp != null && tp.getLeaf().getKind() == Tree.Kind.VARIABLE) {
                    pos[0] = (int) info.getTrees().getSourcePositions().getEndPosition(
                            tp.getCompilationUnit(),
                            ((VariableTree)tp.getLeaf()).getType()) + 1;
                }
            }
        }, true);
        invokeRefactoring (comp, pos[0]);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FieldEncapsulation.java

示例14: implement

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
    final FileObject file = handle.getFileObject();
    final JTextComponent component = EditorRegistry.lastFocusedComponent();
    if (file != null && file == getFileObject(component)) {
        final int[] position = new int[] {-1};
        JavaSource.forFileObject(file).runUserActionTask(new Task<CompilationController>() {
            @Override
            public void run(CompilationController controller) throws Exception {
                controller.toPhase(JavaSource.Phase.PARSED);
                final TreePath tp = handle.resolve(controller);
                if (tp != null && TreeUtilities.CLASS_TREE_KINDS.contains(tp.getLeaf().getKind())) {
                    position[0] = (int) controller.getTrees().getSourcePositions().getStartPosition(
                            tp.getCompilationUnit(),
                            (ClassTree)tp.getLeaf())+1;
                }
            }
        }, true);
        invokeRefactoring(component, position[0]);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ClassEncapsulation.java

示例15: invoke

import org.netbeans.api.editor.EditorRegistry; //导入依赖的package包/类
@Override
public void invoke() {
    final JTextComponent target = EditorRegistry.lastFocusedComponent();

    CssRuleCreateActionDialog cssRuleCreateActionDialog = new CssRuleCreateActionDialog();
    cssRuleCreateActionDialog.showDialog();
    final String styleRuleName = cssRuleCreateActionDialog.getStyleRuleName();
    if ((styleRuleName != null) && !styleRuleName.equals("")) {
	final BaseDocument doc = (BaseDocument) target.getDocument();
	doc.runAtomic(new Runnable() {

                   @Override
	    public void run() {
                       try {
		    doc.insertString(target.getCaretPosition(), "\n" + styleRuleName + " {\n\n}", null);
		} catch (BadLocationException exc) {
                           Exceptions.printStackTrace(exc);
		}
	    }
	});
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CssCodeGenerators.java


注:本文中的org.netbeans.api.editor.EditorRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。