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


Java OpenCookie.open方法代码示例

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


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

示例1: openFile

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
public static boolean openFile(FileObject fo, int offset) {
    DataObject dataObject;
    boolean opened = false;
    try {
        dataObject = DataObject.find(fo);
        if (offset > 0) {
            opened = openFileAtOffset(dataObject, offset);
        }
    } catch (IOException e) {
        Exceptions.printStackTrace(e);
        return false;
    }
    if (opened) {
        return true;
    } else {
        OpenCookie oc = dataObject.getCookie(org.openide.cookies.OpenCookie.class);
        if (oc != null) {
            oc.open();
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SpringXMLConfigEditorUtils.java

示例2: finishGeneration

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
@NbBundle.Messages({
    "# {0} - file name",
    "MSG_CouldNotOpenTargetFile=Could not open generated file {0}.java in editor",
    "# {0} - the reported error message",
    "ERR_GenerationError=Error during class creation: {0}. See the log for the details.",
    "TITLE_GenerationError=Class creation failed"
})
private void finishGeneration(SnippetClassGenerator task) {
    if (task.getJavaFile() != null) {
        // open the file
        OpenCookie cake = task.getJavaFile().getLookup().lookup(OpenCookie.class);
        if (cake != null) {
            cake.open();
        } else {
            StatusDisplayer.getDefault().setStatusText(
                    Bundle.MSG_CouldNotOpenTargetFile(task.getJavaFile().getName()));
        }
    }
    
    if (task.getError() != null) {
        NotifyDescriptor nd = new NotifyDescriptor.Message(Bundle.ERR_GenerationError(
            task.getError().getLocalizedMessage()),NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:GenerateClassAction.java

示例3: findInSource

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
static boolean findInSource(CheckNode node) {
    Object o = node.getUserObject();
    if (o instanceof TreeElement) {
        if (o instanceof Openable) {
            ((Openable) o).open();
            return true;
        } else {
        o = ((TreeElement) o).getUserObject();
        if (o instanceof RefactoringElement) {
            APIAccessor.DEFAULT.getRefactoringElementImplementation((RefactoringElement) o).openInEditor();
            return true;
        } else if (o instanceof Openable) {
            ((Openable) o).open();
            return true;
        } else if (o instanceof FileObject) {
            try {
                OpenCookie oc = DataObject.find((FileObject) o).getCookie(OpenCookie.class);
                if (oc != null) {
                    oc.open();
                    return true;
                }
            } catch (DataObjectNotFoundException ex) {
                //ignore, unknown file, do nothing
            }
        }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CheckNodeListener.java

示例4: bEditActionPerformed

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
private void bEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bEditActionPerformed
        String mimeType = (String) lFiles.getSelectedValue ();
        if (mimeType == null) return;
        FileObject fileObject = Repository.getDefault ().getDefaultFileSystem ().findResource ("Editors/" + mimeType + "/language.nbs");
        try {
            DataObject dataObject = DataObject.find (fileObject);
            OpenCookie openCookie = dataObject.getCookie (OpenCookie.class);
            openCookie.open ();
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace (ex);
        }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:GLFFilesCustomEditor.java

示例5: testSelfProfileToStream

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
@Test
public void testSelfProfileToStream() throws Exception {
    Sampler sampler = Sampler.createManualSampler("testprofile");
    assertTrue("sampler instance", sampler != null);

    sampler.start();
    Thread.sleep(1000);
    assertSamplerThread("sampler-testprofile shall be there", true);

    FileObject fo = FileUtil.createMemoryFileSystem().getRoot().createData("slow.nps");
    OutputStream os = fo.getOutputStream();
    DataOutputStream dos = new DataOutputStream(os);
    sampler.stopAndWriteTo(dos);
    dos.close();

    if (fo.getSize() < 100) {
        fail("The file shall have real content: " + fo.getSize());
    }

    DataObject dataObject = DataObject.find(fo);
    assertEquals("Nps DataObject", NpsDataObject.class, dataObject.getClass());
    OpenCookie oc = dataObject.getLookup().lookup(OpenCookie.class);
    assertNotNull("Open cookie exists", oc);

    CharSequence log = Log.enable("", Level.WARNING);
    oc.open();

    if (log.length() > 0) {
        fail("There shall be no warnings:\n" + log);
    }

    assertSamplerThread("no sampler- thread shall be there", false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:SelfSamplerActionTest.java

示例6: actionPerformed

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    DataObject dobj = context.lookup(DataObject.class);
    OpenCookie oc = dobj.getCookie(OpenCookie.class);
    if (oc != null) {
        oc.open();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:FXMLEditAction.java

示例7: open

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
@Override
public boolean open(Lookup context) {
    DataObject dobj = context.lookup(DataObject.class);
    OpenCookie oc = dobj.getCookie(OpenCookie.class);
    if (oc != null) {
        oc.open();
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:FXMLOpenAction.java

示例8: getPreferredAction

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
@Override
public Action getPreferredAction() {
    return new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            OpenCookie oc = dataObj.getLookup().lookup(OpenCookie.class);
            if (oc != null) {
                oc.open();
            }
        }
    };

}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:15,代码来源:StoredTimelineNode.java

示例9: testOpenAsksAQuestionForBinaryFiles

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
public void testOpenAsksAQuestionForBinaryFiles() throws Exception {
    EditorCookie c = tryToOpen("\u0003\u0001\u0000");
    assertNull(c);

    DD.toReturn = DialogDescriptor.CANCEL_OPTION;
    OpenCookie open = obj.getCookie(OpenCookie.class);
    open.open();

    assertNotNull("There was a query", DD.options);
    assertEquals("Yes no options", 2, DD.options.length);
    assertEquals(DialogDescriptor.OK_OPTION, DD.options[0]);
    assertEquals(DialogDescriptor.CANCEL_OPTION, DD.options[1]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DefaultDataObjectHasOpenTest.java

示例10: testBinaryFilesQuestionContainsOpenActions

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
public void testBinaryFilesQuestionContainsOpenActions() throws Exception {
    EditorCookie c = tryToOpen("\u0003\u0001\u0000");
    assertNull(c);

    DD.toReturn = DialogDescriptor.CLOSED_OPTION;
    OpenCookie open = obj.getCookie(OpenCookie.class);
    open.open();

    assertNotNull("There was a query", DD.options);
    assertEquals("Two options", 2, DD.options.length);
    assertEquals(DialogDescriptor.OK_OPTION, DD.options[0]);
    assertEquals(DialogDescriptor.CANCEL_OPTION, DD.options[1]);
    DD.options = null;

    DD.toReturn = DialogDescriptor.OK_OPTION;
    open.open();

    assertNotNull("There was a query", DD.options);
    assertEquals("Still 2 options", 2, DD.options.length);
    assertEquals(DialogDescriptor.OK_OPTION, DD.options[0]);
    assertEquals(DialogDescriptor.CANCEL_OPTION, DD.options[1]);

    c = obj.getCookie(EditorCookie.class);
    assertNotNull("Editor cookie created", c);

    doRegularCheck(c);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:DefaultDataObjectHasOpenTest.java

示例11: openFile

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
/**
 * Opens a file in the editor area.
 *
 * @param file a File to open
 */
public static void openFile (File file) {
    FileObject fo = FileUtil.toFileObject(file);
    if (fo != null) {
        try {
            DataObject dao = DataObject.find(fo);
            OpenCookie oc = dao.getCookie(OpenCookie.class);
            if (oc != null) {
                oc.open();
            }
        } catch (DataObjectNotFoundException e) {
            // nonexistent DO, do nothing
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Utils.java

示例12: doOpen

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
private static void doOpen(final OpenCookie oc) {
    if (SwingUtilities.isEventDispatchThread()) {
        oc.open();
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                oc.open();
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:UiUtils.java

示例13: testIsThereANodeInTheLookup

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
public void testIsThereANodeInTheLookup() throws Exception {
    // make sure it has the cookie
    OpenCookie open = obj.getCookie(OpenCookie.class);
    open.open();
    open = null;

    FileObject fo = obj.getPrimaryFile();
    FileLock lock = fo.lock();
    final Object[] o = new Object[1];
    EventQueue.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            try {
                final EditorCookie c = obj.getCookie(EditorCookie.class);
                assertNotNull(c);
                c.open();

                JEditorPane[] arr = c.getOpenedPanes();

                assertNotNull("Something opened", arr);
                assertEquals("One opened", 1, arr.length);

                o[0] = SwingUtilities.getAncestorOfClass(TopComponent.class, arr[0]);
                assertNotNull("Top component found", o);
            } catch (Exception x) {
                throw new RuntimeException(x);
            }
        }
    });
    TopComponent tc = (TopComponent)o[0];

    DataObject query = tc.getLookup().lookup(DataObject.class);
    assertEquals("Object is in the lookup", obj, query);

    Node node = tc.getLookup().lookup(Node.class);
    assertEquals("Node is in the lookup", obj.getNodeDelegate(), node);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:DefaultDataObjectHasNodeInLookupTest.java

示例14: getPreferredAction

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
/**
 * When used doubleclicks on the node, open the timeline viewer for this timeline.
 * @return
 */
@Override
public Action getPreferredAction() {
    return new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            OpenCookie oc = dataObject.getLookup().lookup(OpenCookie.class);
            if (oc != null) {
                oc.open();
            }
        }
    };
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:18,代码来源:UTTimelineNode.java

示例15: open

import org.openide.cookies.OpenCookie; //导入方法依赖的package包/类
private static void open(@NonNull final DataObject dobj) {
    final Openable openable = dobj.getLookup().lookup(Openable.class);
    if (openable != null) {
        openable.open();
    }
    //Workaround of non functional org.openide.util.Lookup class hierarchy cache.
    final OpenCookie oc = dobj.getLookup().lookup(OpenCookie.class);
    if (oc != null) {
        oc.open();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FileDescription.java


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