本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
}
};
}
示例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]);
}
示例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);
}
示例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
}
}
}
示例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();
}
});
}
}
示例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);
}
示例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();
}
}
};
}
示例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();
}
}