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


Java EditorCookie.open方法代码示例

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


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

示例1: performAction

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
protected void performAction(Node[] activatedNodes) {
    for (Node node : activatedNodes) {
        WadlSaas saas = node.getLookup().lookup(WadlSaas.class);
        if (saas != null) {
            saas.toStateReady(true);
            if (saas.getLocalWadlFile() != null) {
                try {
                    DataObject wadlDataObject = DataObject.find(saas.getLocalWadlFile());
                    EditorCookie editorCookie = wadlDataObject.getLookup().lookup(EditorCookie.class);
                    editorCookie.open();
                } catch (Exception e) {
                    Exceptions.printStackTrace(e);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ViewWadlAction.java

示例2: testContextLookupFiresDuringMove

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@RandomlyFails
public void testContextLookupFiresDuringMove() throws Exception {              
    // Prepare the data object (to initialize the lookup)
    FileObject fo = fs.getRoot().createData("test3", "txt");
    DataObject data = DataObject.find(fo);
    EditorCookie ec = data.getCookie(EditorCookie.class);

    // open the editor and check the lookup before move
    ec.open();
    assertEquals("Lookup content consistent before move", data.getPrimaryFile(),ConsistencyCheckProvider.getInLkp());

    forceGC ();
    
    // now move the file
    ConsistencyCheckProvider.setCalled(0);
    FileObject fld = fs.getRoot().createFolder("folder1");
    DataFolder df = DataFolder.findFolder(fld);
    data.move(df);

    forceGC ();
    
    // check the result
    assertEquals("Lookup fires one change during move", 1, ConsistencyCheckProvider.changes);
    assertEquals("Lookup content consistent after move", data.getPrimaryFile(),ConsistencyCheckProvider.getInLkp());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:AnnotationProviderTest.java

示例3: openFile

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private JavaSource openFile(String name) throws DataObjectNotFoundException, IOException, InterruptedException, InvocationTargetException {
    String dataDir = getDataDir().getAbsoluteFile().getPath();
    File sample = new File(dataDir+"/projects/java_editor_test/src/markOccurrences",name);
    assertTrue("file "+sample.getAbsolutePath()+" does not exist",sample.exists());
    
    fileObject = FileUtil.toFileObject(sample);
    dataObject = DataObject.find(fileObject);
    JavaSource js = JavaSource.forFileObject(fileObject);                
    final EditorCookie ec = dataObject.getCookie(EditorCookie.class);
    ec.openDocument();
    ec.open();
            
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JEditorPane[] panes = ec.getOpenedPanes();
            editorPane = panes[0];
            
        }
    });
    return js;
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MarkOccurrencesTest.java

示例4: performContextAction

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
protected void performContextAction(Node[] nodes) {
    if (visible(nodes)) {
        JEditorPane pane = activatedEditorPane(nodes);
        AnnotationBarManager.hideAnnotationBar(pane);
    } else {
        EditorCookie ec = activatedEditorCookie(nodes);
        if (ec == null) return;

        final File file = activatedFile(nodes);

        JEditorPane[] panes = ec.getOpenedPanes();
        if (panes == null) {
            ec.open();
            panes = ec.getOpenedPanes();
        }

        if (panes == null) {
            return;
        }
        final JEditorPane currentPane = panes[0];
        showAnnotations(currentPane, file, null, true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:AnnotateAction.java

示例5: openEditor

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
public static void openEditor(EditorCookie ec, int lineIndex) {
    Line.Set lineSet = ec.getLineSet();
    if (lineSet != null) {
        try {
            Line line = lineSet.getCurrent(lineIndex);
            if (line != null) {
                line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
            }
        } catch (IndexOutOfBoundsException ex) {
            // attempt at least to open the editor
            ec.open();
            // expected, bookmark contains an invalid line
            StatusDisplayer.getDefault().setStatusText(
                    NbBundle.getMessage(BookmarkUtils.class, "MSG_InvalidLineNumnber", lineIndex));
        }
        JEditorPane[] panes = ec.getOpenedPanes();
        if (panes.length > 0) {
            panes[0].requestFocusInWindow();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BookmarkUtils.java

示例6: performContextAction

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
protected void performContextAction(Node[] nodes) {        
    if(!Subversion.getInstance().checkClientAvailable()) {            
        return;
    }        
    if (visible(nodes)) {
        JEditorPane pane = activatedEditorPane(nodes);
        AnnotationBarManager.hideAnnotationBar(pane);
    } else {
        EditorCookie ec = activatedEditorCookie(nodes);
        if (ec == null) return;
        
        final File file = activatedFile(nodes);

        JEditorPane[] panes = ec.getOpenedPanes();
        if (panes == null) {
            ec.open();
            panes = ec.getOpenedPanes();
        }
        if (panes == null) {
            return;
        }
        final JEditorPane currentPane = panes[0];
        showAnnotations(currentPane, file, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BlameAction.java

示例7: setupEditor

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private void setupEditor() throws IOException {
    // this doesn't work since the JTextPane doesn't like our Kits since they aren't StyleEditorKits.
    //            Document doc = createDocument();
    //            JTextPane pane = new JTextPane((StyledDocument)doc);
    //            EditorKit kit = CloneableEditorSupport.getEditorKit("text/css");
    //            pane.setEditorKit(kit);

    File tmpFile = new File(getWorkDir(), "bracketCompleterTest.css");
    tmpFile.createNewFile();
    FileObject fo = FileUtil.createData(tmpFile);
    DataObject dobj = DataObject.find(fo);
    EditorCookie ec = dobj.getCookie(EditorCookie.class);
    this.doc = ec.openDocument();
    ec.open();
    this.pane = ec.getOpenedPanes()[0];

    this.defaultKeyTypedAction = (BaseAction) pane.getActionMap().get(NbEditorKit.defaultKeyTypedAction);
    this.backspaceAction = (BaseAction) pane.getActionMap().get(NbEditorKit.deletePrevCharAction);
    this.deleteAction = (BaseAction) pane.getActionMap().get(NbEditorKit.deleteNextCharAction);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CssBracketCompleterTest.java

示例8: displayItem

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
protected void displayItem(PrimitiveData item) {
    String javaFilePath = item.classFQN.replace('.', '/') + ".java";
    for (FileObject curRoot : GlobalPathRegistry.getDefault().getSourceRoots()) {
        FileObject fileObject = curRoot.getFileObject(javaFilePath);
        if (fileObject != null) {
            // do something, e.g. openEditor(fileObject, lineNumber);
            DataObject dobj = null;
            try {
                dobj = DataObject.find(fileObject);
            } catch (DataObjectNotFoundException ex) {
                Exceptions.printStackTrace(ex);
            }
            if (dobj != null) {
                EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class);
                if (ec != null) {
                    ec.open();
                }
            }
        }
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:23,代码来源:Explorers.java

示例9: test211193

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
public void test211193() throws Exception {
    writeFilesAndWaitForScan(src,
            new File("t/A.java", "package t;\n"
            + "public class A {\n"
            + "    public static void foo() {\n"
            + "        int someArray[] = {};\n"
            + "    }\n"
            + "}"));
    FileObject testFile = src.getFileObject("t/A.java");
    DataObject testFileDO = DataObject.find(testFile);
    EditorCookie ec = testFileDO.getLookup().lookup(EditorCookie.class);
    ec.open();
    ec.getOpenedPanes()[0].setCaretPosition(71);
    ec.getOpenedPanes()[0].moveCaretPosition(80);
    final AtomicInteger called = new AtomicInteger();
    ContextAnalyzer.SHOW = new ContextAnalyzer.ShowUI() {
        @Override
        public void show(RefactoringUI ui, TopComponent activetc) {
            assertNotNull(ui);
            called.incrementAndGet();
        }
    };
    int expectedCount = 0;
    new RefactoringActionsProvider().doRename(Lookups.fixed(ec));
    assertEquals(++expectedCount, called.get());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JavaRefactoringActionsProviderTest.java

示例10: testContextLookupIsConsistentAfterMove

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@RandomlyFails
public void testContextLookupIsConsistentAfterMove() throws Exception {              
    ConsistencyCheckProvider.setCalled(0);
    // Prepare the data object (to initialize the lookup)
    FileObject fo = fs.getRoot().createData("test2", "txt");
    DataObject data = DataObject.find(fo);
    EditorCookie ec = data.getCookie(EditorCookie.class);

    // now move it (the lookup should update itself)
    FileObject fld = fs.getRoot().createFolder("folder1");
    DataFolder df = DataFolder.findFolder(fld);
    data.move(df);

    // now open the editor (invoke AnnotationProviders)
    // and check the lookup
    ec.open();
    assertEquals("Consistent lookup content", data.getPrimaryFile(),ConsistencyCheckProvider.getInLkp());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:AnnotationProviderTest.java

示例11: openFile

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private boolean openFile(FileObject file) {
    if (file == null) {
        return false;
    }
    DataObject dObj;
    try {
        dObj = DataObject.find(file);
    } catch (DataObjectNotFoundException ex) {
        return false;
    }
    EditorCookie editorCookie = dObj.getCookie(EditorCookie.class);
    if (editorCookie == null) {
        return false;
    }
    editorCookie.open();
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ResourceHyperlinkProcessor.java

示例12: open

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
/** Either opens the in text editor or asks user questions.
 */
public void open() {
    EditorCookie ic = getCookie(EditorCookie.class);
    if (ic != null) {
        ic.open();
    } else {
        // ask a query 
        List<Object> options = new ArrayList<Object>();
        options.add (NotifyDescriptor.OK_OPTION);
        options.add (NotifyDescriptor.CANCEL_OPTION);
        NotifyDescriptor nd = new NotifyDescriptor (
            NbBundle.getMessage (DefaultDataObject.class, "MSG_BinaryFileQuestion"),
            NbBundle.getMessage (DefaultDataObject.class, "MSG_BinaryFileWarning"),
            NotifyDescriptor.DEFAULT_OPTION,
            NotifyDescriptor.QUESTION_MESSAGE,
            options.toArray(), null
        );
        Object ret = DialogDisplayer.getDefault().notify (nd);
        if (ret != NotifyDescriptor.OK_OPTION) {
            return;
        }
        
        EditorCookie c = getCookie(EditorCookie.class, true);
        c.open ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:DefaultDataObject.java

示例13: openStandaloneTokenFile

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
protected EditorOperator openStandaloneTokenFile(String fileName) throws Exception {
    File tokensDir = new File(getDataDir(), "tokens");
    File file = new File(tokensDir, fileName);
    DataObject dataObj = DataObject.find(FileUtil.toFileObject(file));
    EditorCookie ed = dataObj.getCookie(EditorCookie.class);
    ed.open();
    operator = new EditorOperator(fileName);
    return operator;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:BasicOpenFileTest.java

示例14: beforeFilesChanged

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private void beforeFilesChanged () {
    if (controller != null) {
        SaveCookie[] saveCookies = getSaveCookies();
        if (saveCookies.length > 0 && SaveBeforeClosingDiffConfirmation.allSaved(saveCookies)) {
            EditorCookie[] editorCookies = getEditorCookies();
            for (EditorCookie cookie : editorCookies) {
                cookie.open();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:GitCommitPanel.java

示例15: testModifiedMove

import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
public void testModifiedMove() throws Exception {
    FileObject root = FileUtil.toFileObject(getWorkDir());
    FileObject data = FileUtil.createData(root, "someFolder/someFile.obj");
    
    DataObject obj = DataObject.find(data);
    assertEquals( MyDataObject.class, obj.getClass());
    assertEquals(MyLoader.class, obj.getLoader().getClass());
    
    EditorCookie ec = obj.getLookup().lookup(EditorCookie.class);
    assertNotNull("Editor cookie found", ec);
    ec.open();
    JEditorPane[] arr = openedPanes(ec);
    assertEquals("One pane is opened", 1, arr.length);
            
    StyledDocument doc = ec.openDocument();
    doc.insertString(0, "Ahoj", null);
    assertTrue("Modified", obj.isModified());
    Thread.sleep(100);
    
    FileObject newFolder = FileUtil.createFolder(root, "otherFolder");
    DataFolder df = DataFolder.findFolder(newFolder);
    
    obj.move(df);
    
    assertEquals(newFolder, obj.getPrimaryFile().getParent());
    
    assertEquals("Still one editor", 1, openedPanes(ec).length);
    DD.assertNoCalls();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:DataEditorSupportMoveTest.java


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