本文整理汇总了Java中org.netbeans.api.editor.EditorRegistry.focusedComponent方法的典型用法代码示例。如果您正苦于以下问题:Java EditorRegistry.focusedComponent方法的具体用法?Java EditorRegistry.focusedComponent怎么用?Java EditorRegistry.focusedComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.editor.EditorRegistry
的用法示例。
在下文中一共展示了EditorRegistry.focusedComponent方法的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);
}
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: findActivePane
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
private JTextComponent findActivePane() {
DataObject d = peerDO;
LOG.fine(this + ": findActivePane DataObject=" + d);
if (d == null) {
return null;
}
EditorCookie ec = (EditorCookie)d.getCookie(EditorCookie.class);
if (ec == null) {
return null;
}
JTextComponent focused = EditorRegistry.focusedComponent();
LOG.fine(this + ": findActivePane focused=" + focused);
if (focused == null) {
return null;
}
JTextComponent[] comps = ec.getOpenedPanes();
if (comps == null) {
return null;
}
for (JTextComponent c : comps) {
if (c == focused) {
return c;
}
}
return null;
}
示例5: undo
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
@Override
public void undo() throws CannotUndoException {
JTextComponent focusedComponent = EditorRegistry.focusedComponent();
if (focusedComponent != null) {
if (focusedComponent.getDocument() == ces.getDocument()) {
//call global undo only for focused component
undoManager.undo(session, ces.getDocument());
}
}
//delegate.undo();
inner.undo();
}
示例6: redo
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
@Override
public void redo() throws CannotRedoException {
JTextComponent focusedComponent = EditorRegistry.focusedComponent();
if (focusedComponent != null) {
if (focusedComponent.getDocument() == ces.getDocument()) {
//call global undo only for focused component
undoManager.redo(session);
}
}
//delegate.redo();
inner.redo();
}
示例7: propertyChange
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
public synchronized void propertyChange(PropertyChangeEvent evt) {
JTextComponent jtc = EditorRegistry.focusedComponent();
if (jtc == null) return;
Document active = jtc.getDocument();
Object sourceProperty = active.getProperty(Document.StreamDescriptionProperty);
if (!(sourceProperty instanceof DataObject)) return;
FileObject activeFile = ((DataObject)sourceProperty).getPrimaryFile();
TimesCollectorPeer.getDefault().select(activeFile);
}
示例8: propertyChange
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
final JTextComponent component = EditorRegistry.focusedComponent();
FileObject fo = component != null ? NbEditorUtilities.getFileObject(component.getDocument()) : null;
if (target == null || target != fo) {
return;
}
EditorRegistry.removePropertyChangeListener(this);
RequestProcessor.getDefault().post(new Runnable() {
@Override
public void run() {
try {
JavaSource js = JavaSource.forDocument(component.getDocument());
js.runModificationTask(new Task<WorkingCopy>() {
@Override
public void run(WorkingCopy parameter) throws Exception {
parameter.toPhase(JavaSource.Phase.RESOLVED);
CompilationUnitTree cut = parameter.getCompilationUnit();
if (!cut.getTypeDecls().isEmpty()) {
TreePath path = TreePath.getPath(cut, cut.getTypeDecls().get(0));
if (isAbstract) {
GeneratorUtils.generateAllAbstractMethodImplementations(parameter, path);
}
if (hasNonDefaultConstructor) {
ConstructorGenerator.Factory factory = new ConstructorGenerator.Factory();
Iterator<? extends CodeGenerator> generators = factory.create(Lookups.fixed(component, parameter, path)).iterator();
if (generators.hasNext()) {
generators.next().invoke();
}
}
}
}
}).commit();
} catch (IOException ioe) {
}
}
});
}
示例9: performClickAction
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
public void performClickAction(Document doc, int offset, HyperlinkType type) {
switch (type) {
case GO_TO_DECLARATION:
GoToSupport.goTo(doc, offset, false);
break;
case ALT_HYPERLINK:
JTextComponent focused = EditorRegistry.focusedComponent();
if (focused != null && focused.getDocument() == doc) {
focused.setCaretPosition(offset);
GoToImplementation.goToImplementation(focused);
}
break;
}
}
示例10: run
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
@Override
public void run() {
JTextComponent jtc = EditorRegistry.focusedComponent();
if (jtc != null) {
Document doc = jtc.getDocument();
if (doc != null) {
BookmarkList.get (jtc.getDocument ()); // Initialize the bookmark list
}
}
}
示例11: editorRegistryChanged
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
private void editorRegistryChanged() {
final JTextComponent editor = EditorRegistry.lastFocusedComponent();
final JTextComponent lastEditor = lastEditorRef == null ? null : lastEditorRef.get();
if (lastEditor != editor && (editor == null || editor.getClientProperty("AsTextField") == null)) {
if (lastEditor != null) {
lastEditor.removeCaretListener(this);
lastEditor.removePropertyChangeListener(this);
k24.set(false);
}
lastEditorRef = new WeakReference<JTextComponent>(editor);
if (editor != null) {
editor.addCaretListener(this);
editor.addPropertyChangeListener(this);
}
final JTextComponent focused = EditorRegistry.focusedComponent();
if (focused != null) {
final Document doc = editor.getDocument();
final String mimeType = DocumentUtilities.getMimeType (doc);
if (doc != null && mimeType != null) {
final Source source = Source.create (doc);
if (source != null) {
((EventSupport)SourceEnvironment.forSource(source)).resetState(true, false, -1, -1, true);
}
}
}
}
}
示例12: updateComponent
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
private void updateComponent() {
JTextComponent comp = EditorRegistry.focusedComponent();
FileType.logger.log(Level.FINE, "========================= updateComponente =====================================");
if (comp != null) {
analyseSource(comp);
} else {
FileType.logger.log(Level.FINE, "Limpou label");
FileType.label.setText(" ");
this.lastDocPath = "";
}
FileType.logger.log(Level.FINE, "========================= updateComponente =====================================");
}
示例13: actionPerformed
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
final JTextComponent comp = EditorRegistry.focusedComponent();
if (comp == null) {
return ;
}
comp.getDocument().render(new Runnable() {
public void run() {
List<ErrorDescription> errors = null;
int errorOffset = -1;
int unusedOffset = -1;
int offsetToTest = comp.getCaretPosition() + 1;
if (offsetToTest < comp.getDocument().getLength()) {
errors = findNextError(comp, offsetToTest);
errorOffset = errors.isEmpty() ? -1 : errors.iterator().next().getRange().getBegin().getOffset();
unusedOffset = findNextUnused(comp, offsetToTest);
}
if (errorOffset == (-1) && unusedOffset == (-1)) {
errors = findNextError(comp, 0);
errorOffset = errors.isEmpty() ? -1 : errors.iterator().next().getRange().getBegin().getOffset();
unusedOffset = findNextUnused(comp, 0);
}
if (errorOffset == (-1) && unusedOffset == (-1)) {
Toolkit.getDefaultToolkit().beep();
} else {
if (errorOffset != (-1) && (errorOffset < unusedOffset || unusedOffset == (-1))) {
comp.getCaret().setDot(errorOffset);
Utilities.setStatusText(comp, buildText(errors), StatusDisplayer.IMPORTANCE_ERROR_HIGHLIGHT);
} else {
comp.getCaret().setDot(unusedOffset);
Utilities.setStatusText(comp,NbBundle.getMessage(NextErrorAction.class, "LBL_UnusedElement"),
StatusDisplayer.IMPORTANCE_ERROR_HIGHLIGHT);
}
}
}
});
}
示例14: getMostActiveComponent
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
public static JTextComponent getMostActiveComponent() {
registerListener();
return EditorRegistry.focusedComponent();
}
示例15: EditorRegistryWatcher
import org.netbeans.api.editor.EditorRegistry; //导入方法依赖的package包/类
private EditorRegistryWatcher() {
EditorRegistry.addPropertyChangeListener(this);
activeTextComponentRef = new WeakReference<JTextComponent>(EditorRegistry.focusedComponent());
}