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


Java NbEditorUtilities.getDataObject方法代码示例

本文整理汇总了Java中org.netbeans.modules.editor.NbEditorUtilities.getDataObject方法的典型用法代码示例。如果您正苦于以下问题:Java NbEditorUtilities.getDataObject方法的具体用法?Java NbEditorUtilities.getDataObject怎么用?Java NbEditorUtilities.getDataObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.modules.editor.NbEditorUtilities的用法示例。


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

示例1: runTaskWithinContext

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
@Override
public void runTaskWithinContext(Lookup context, Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        DataObject dobj = NbEditorUtilities.getDataObject(component.getDocument());
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            ModelSource ms = Utilities.createModelSource(fo);
            SettingsModel model = SettingsModelFactory.getDefault().getModel(ms);
            if (model != null) {
                Lookup newContext = new ProxyLookup(context, Lookups.fixed(model));
                task.run(newContext);
                return;
            }
        }
    }
    task.run(context);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SettingsContextProvider.java

示例2: runTaskWithinContext

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
@Override
public void runTaskWithinContext(Lookup context, Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        DataObject dobj = NbEditorUtilities.getDataObject(component.getDocument());
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            ModelSource ms = Utilities.createModelSource(fo);
            if (ms.isEditable()) {
                POMModel model = POMModelFactory.getDefault().getModel(ms);
                if (model != null) {
                    Lookup newContext = new ProxyLookup(context, Lookups.fixed(model));
                    task.run(newContext);
                    return;
                }
            }
        }
    }
    task.run(context);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ContextProvider.java

示例3: actionPerformed

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt, JTextComponent target) {
    BaseDocument bdoc = Utilities.getDocument(target);
    if(bdoc == null) {
        return ; //no document?!?!
    }
    DataObject csso = NbEditorUtilities.getDataObject(bdoc);
    if(csso == null) {
        return ; //document not backuped by DataObject
    }
    
    String pi = createText(csso);
    StringSelection ss = new StringSelection(pi);
    ExClipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
    clipboard.setContents(ss, null);
    StatusDisplayer.getDefault().setStatusText( NbBundle.getMessage(CopyStyleAction.class, "MSG_Style_tag_in_clipboard"));  // NOI18N
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CopyStyleAction.java

示例4: analyseSource

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
private void analyseSource(JTextComponent comp) {
  DataObject dataObject = NbEditorUtilities.getDataObject(comp.getDocument());
  if (dataObject == null) {
    return;
  }
  FileObject fileObject = dataObject.getPrimaryFile();
  if (fileObject == null) {
    return;
  }
  String currentDocPath = defaultString(fileObject.getPath());
  FileType.logger.log(Level.INFO, "Path corrente: {0}\nPath anterior: {1}", new Object[]{currentDocPath, this.lastDocPath});
  if (!this.lastDocPath.equals(currentDocPath)) {
    showLineEnd(comp.getDocument());
  }
  this.lastDocPath = currentDocPath;
}
 
开发者ID:maumss,项目名称:file-type-plugin,代码行数:17,代码来源:FileType.java

示例5: actionPerformed

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ev) {
    if (!framework.canOperate()) {
        return;
    }

    JTextComponent component = context.getOpenedPanes()[0];
    org.openide.loaders.DataObject dataObject = NbEditorUtilities.getDataObject(context.getDocument());
    final String displayName = dataObject.getNodeDelegate().getDisplayName();
    
    Snippet snippet = new Snippet();
    snippet.setTitle(displayName);
    snippet.setCode(getCode(component));
    snippet.setLanguage(framework.getData().getLanguages().findByFileName(displayName));
    framework.showSnippetDialog(snippet);
}
 
开发者ID:massimozappino,项目名称:tagmycode-netbeans,代码行数:17,代码来源:CreateSnippetAction.java

示例6: getTargetFile

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
public static FileObject getTargetFile(JTextComponent targetComponent) {
    if (targetComponent == null) {
        return null;
    }
    DataObject d = NbEditorUtilities.getDataObject(targetComponent.getDocument());
    if (d == null) {
        return null;
    }
    EditorCookie ec = (EditorCookie) d.getLookup().lookup(EditorCookie.class);
    if (ec == null || ec.getOpenedPanes() == null) {
        return null;
    }
    return d.getPrimaryFile();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:SoapServiceClientEditorDrop.java

示例7: getTargetFile

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
public static FileObject getTargetFile(JTextComponent targetComponent) {
    if (targetComponent == null) {
        return null;
    }
    DataObject d = NbEditorUtilities.getDataObject(targetComponent.getDocument());
    if (d == null) {
        return null;
    }
    EditorCookie ec = (EditorCookie) d.getCookie(EditorCookie.class);
    if (ec == null || ec.getOpenedPanes() == null) {
        return null;
    }
    return d.getPrimaryFile();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CustomClientEditorDrop.java

示例8: getTargetFile

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
public static FileObject getTargetFile(Document doc) {
    if (doc == null) {
        return null;
    }
    DataObject d = NbEditorUtilities.getDataObject(doc);
    if (d == null) {
        return null;
    }
    EditorCookie ec = (EditorCookie) d.getCookie(EditorCookie.class);
    if (ec == null || ec.getOpenedPanes() == null) {
        return null;
    }
    return d.getPrimaryFile();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:RestClientEditorDrop.java

示例9: show

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
void show () {
    DataObject dataObject = NbEditorUtilities.getDataObject (document);
    LineCookie lineCookie = dataObject.getCookie (LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet ();
    Line line = lineSet.getCurrent (NbDocument.findLineNumber (document, item.getOffset ()));
    int column = NbDocument.findLineColumn (document, item.getOffset ());
    line.show (ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:LanguagesNavigatorModel.java

示例10: getJTextComponent

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
public JTextComponent getJTextComponent () {
    if (component == null) {
        DataObject dob = NbEditorUtilities.getDataObject (doc);
        EditorCookie ec = dob.getLookup ().lookup (EditorCookie.class);
        if (ec.getOpenedPanes ().length > 0)
            component = ec.getOpenedPanes () [0];
    }
    return component;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:Context.java

示例11: getProjectDir

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
private FileObject getProjectDir(Document doc) {
    DataObject dObject = NbEditorUtilities.getDataObject(doc);
    if (dObject != null) {
        return dObject.getPrimaryFile().getParent();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:HyperlinkProviderImpl.java

示例12: getProject

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
private Project getProject(Document doc) {
    DataObject dobj = NbEditorUtilities.getDataObject(doc);
    if (dobj != null) {
        return FileOwnerQuery.getOwner(dobj.getPrimaryFile());
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:HyperlinkProviderImpl.java

示例13: Bookmark

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
/**
 * Construct new instance of bookmark.
 *
 * <p>
 * The constructor is not public intentionally.
 * Please see <code>BookmarksApiPackageAccessor</code> for details.
 */
Bookmark (BookmarkList bookmarkList, BookmarkInfo info, int offset) {
    if (info == null) {
        throw new IllegalArgumentException("info cannot be null"); // NOI18N
    }
    this.bookmarkList = bookmarkList;
    this.info = info;
    Document document = bookmarkList.getDocument ();
    int lineIndex = BookmarkUtils.offset2LineIndex(document, offset);
    DataObject dataObject = NbEditorUtilities.getDataObject (document);
    for (Line _line : lineToAnnotation.keySet ()) {
        if (_line.getLineNumber () == lineIndex &&
            _line.getLookup().lookup (DataObject.class).equals (dataObject)
        ) {
            this.line = _line;
            Reference<Annotation> annoRef = lineToAnnotation.get (_line);
            Annotation a = annoRef.get();
            if (a != null) {
                info.setAnnotationRef(annoRef);
            }
        }
    }
    line = NbEditorUtilities.getLine (bookmarkList.getDocument (), offset, false);
    if (line != null) { // In tests it may be null
        if (info.getAnnotation() == null) {
            AAnnotation annotation = new AAnnotation ();
            info.setAnnotationRef(new WeakReference<Annotation>(annotation));
            annotation.attach (line);
        } 
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:Bookmark.java

示例14: getCurrentEditorCookie

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
/**
 * Get the {@link org.openide.cookies.EditorCookie} of currently edited file.
 * @return The current {@link org.openide.cookies.EditorCookie} or
 *         <code>null</code> when there is no currently edited file.
 */
private EditorCookie getCurrentEditorCookie() {
    JEditorPane editor = getCurrentEditor();
    if (editor != null) {
        Document document = editor.getDocument();
        DataObject dataObject = NbEditorUtilities.getDataObject(document);
        if (dataObject != null) {
            EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class);
            return ec;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EditorContextDispatcher.java

示例15: getMostRecentEditorCookie

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
private EditorCookie getMostRecentEditorCookie() {
    JEditorPane editor = getMostRecentEditor();
    if (editor != null) {
        Document document = editor.getDocument();
        DataObject dataObject = NbEditorUtilities.getDataObject(document);
        if (dataObject != null) {
            EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class);
            return ec;
        }
    }
    return null;

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:EditorContextDispatcher.java


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