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


Java OpenCookie类代码示例

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


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

示例1: extractAction

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
private Action extractAction( DataObject dob ) {
    OpenCookie oc = dob.getCookie( OpenCookie.class );
    if( null != oc )
        return new LinkAction( dob );

    InstanceCookie.Of instCookie = dob.getCookie(InstanceCookie.Of.class);
    if( null != instCookie && instCookie.instanceOf( Action.class ) ) {
        try {
            Action res = (Action) instCookie.instanceCreate();
            if( null != res ) {
                res.putValue(Action.NAME, dob.getNodeDelegate().getDisplayName() );
            }
            return res;
        } catch( Exception e ) {
            Logger.getLogger(SampleProjectAction.class.getName()).log( Level.INFO, null, e );
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Tutorials.java

示例2: getCookie

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
@Override
public <T extends Cookie> T getCookie(Class<T> type) {
    T retValue;
    
    if (OpenCookie.class.equals(type) || EditCookie.class.equals(type)) {
        if (openEdit == null)
            openEdit = new OpenEdit();
        retValue = type.cast(openEdit);
    } else if (!type.equals(Cookie.class) && type.isAssignableFrom(getFormEditorSupportClass())) {
        // Avoid calling synchronized getFormEditorSupport() when invoked from node lookup
        // initialization from cookies (asking for base Node.Cookie).
        retValue = (T) getFormEditorSupport();
    } else {
        retValue = super.getCookie(type);
    }
    return retValue;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:FormDataObject.java

示例3: 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

示例4: testReadOnlyLocalRepositoryFile

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
public void testReadOnlyLocalRepositoryFile() throws Exception {
    File repo = EmbedderFactory.getProjectEmbedder().getLocalRepositoryFile();
    File f = TestFileUtils.writeFile(new File(repo, "ant/ant/1.5.1/ant-1.5.1.jar.sha1"), "a50e3e050a6e78e0656edc183435b9773f53ce78");
    FileObject rw = FileUtil.toFileObject(f);
    FileObject ro = NodeUtils.readOnlyLocalRepositoryFile(rw);
    assertNotSame(rw, ro);
    assertFalse(ro.canWrite());
    assertNotNull(DataObject.find(ro).getLookup().lookup(OpenCookie.class));
    f = TestFileUtils.writeFile(new File(repo, "ant/ant/1.5.1/ant-1.5.1.pom.sha1"), "0ffdb41f140a621beeec4dc81b3d3ecaee085d28");
    rw = FileUtil.toFileObject(f);
    ro = NodeUtils.readOnlyLocalRepositoryFile(rw);
    assertNotSame(rw, ro);
    assertFalse(ro.canWrite());
    assertNotNull(DataObject.find(ro).getLookup().lookup(OpenCookie.class));
    assertSame(ro, NodeUtils.readOnlyLocalRepositoryFile(rw));
    FileObject skip = FileUtil.toFileObject(new File(repo, "ant/ant/1.5.1"));
    assertNotNull(skip);
    assertSame(skip, NodeUtils.readOnlyLocalRepositoryFile(skip));
    File stuff = TestFileUtils.writeFile(new File(getWorkDir(), "stuff"), "stuff");
    skip = FileUtil.toFileObject(stuff);
    assertNotNull(skip);
    assertSame(skip, NodeUtils.readOnlyLocalRepositoryFile(skip));
    Reference<?> r = new WeakReference<Object>(ro.getFileSystem());
    ro = null;
    assertGC("can collect FS", r);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:NodeUtilsTest.java

示例5: StructureItemNode

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
public StructureItemNode(final StructureItem item) {
    super(Children.create(new ChildFactory<StructureItem>() {
        @Override protected boolean createKeys(List<StructureItem> toPopulate) {
            toPopulate.addAll(item.getNestedItems());
            return true;
        }

        @Override
        protected Node createNodeForKey(StructureItem key) {
            return new StructureItemNode(key);
        }
        
    }, false), Lookups.fixed(new OpenCookie() {
        @Override public void open() {
            ElementHandle elementHandle = item.getElementHandle();
            FileObject file = elementHandle != null ? elementHandle.getFileObject() : null;
            if (file != null) {
                UiUtils.open(file, (int) item.getPosition());
            }
        }
    }));
    this.item = item;
    setDisplayName(item.getName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:BreadCrumbsTask.java

示例6: findCloneableEditorSupport

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
/**
    * Gets the CloneableEditorSupport for given FileObject
    *
    * @param fo A FileObject to get the CES for.
    * @return Instance of CloneableEditorSupport
    */
   public static CloneableEditorSupport findCloneableEditorSupport(FileObject fo) {
try {
    DataObject dob = DataObject.find(fo);
    Object obj = dob.getCookie(OpenCookie.class);
    if (obj instanceof CloneableEditorSupport) {
	return (CloneableEditorSupport)obj;
    }
    obj = dob.getCookie(org.openide.cookies.EditorCookie.class);
    if (obj instanceof CloneableEditorSupport) {
	return (CloneableEditorSupport)obj;
    }
} catch (DataObjectNotFoundException ex) {
    Exceptions.printStackTrace(ex);
}
       return null;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:GsfUtilities.java

示例7: 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);
            final OpenCookie oc = dao.getLookup().lookup(OpenCookie.class);
            if (oc != null) {
                Mutex.EVENT.readAccess(new Runnable() {

                    @Override
                    public void run () {
                        oc.open();
                    }
                });
            }
        } catch (DataObjectNotFoundException e) {
            // nonexistent DO, do nothing
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:Utils.java

示例8: findCloneableOpenSupport

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
/** Method that allows environment to find its 
 * cloneable open support.
* @return the support or null if the environment is not in valid 
* state and the CloneableOpenSupport cannot be found for associated
* data object
*/
public CloneableOpenSupport findCloneableOpenSupport() {
    OpenCookie oc = getDataObject().getCookie(OpenCookie.class);
    if (oc != null && oc instanceof CloneableOpenSupport) {
        return (CloneableOpenSupport) oc;
    }
    EditCookie edc = getDataObject().getCookie(EditCookie.class);
    if (edc != null && edc instanceof CloneableOpenSupport) {
        return (CloneableOpenSupport) edc;
    }
    EditorCookie ec = getDataObject().getCookie(EditorCookie.class);
    if (ec != null && ec instanceof CloneableOpenSupport) {
        return (CloneableOpenSupport) ec;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:OpenSupport.java

示例9: readResolve

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
public Object readResolve () {
    DataObject obj = entry.getDataObject ();
    OpenSupport os = null;
    OpenCookie oc = obj.getCookie(OpenCookie.class);
    if (oc != null && oc instanceof OpenSupport) {
        os = (OpenSupport) oc;
    } else {
        EditCookie edc = obj.getCookie(EditCookie.class);
        if (edc != null && edc instanceof OpenSupport) {
            os = (OpenSupport) edc;
        } else {
            EditorCookie ec = obj.getCookie(EditorCookie.class);
            if (ec != null && ec instanceof OpenSupport) {
                os = (OpenSupport) ec;
            }
        }
    }
    if (os == null) {
        // problem! no replace!?
        return this;
    }
    // use the editor support's CloneableTopComponent.Ref
    return os.allEditors ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:OpenSupport.java

示例10: instantiate

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
@Override
public Set<?> instantiate() throws IOException {
    // TODO: Use RequestProcessor for instantiation, this takes too much time.
    String className = Templates.getTargetName(wizard);
    FileObject pkg = Templates.getTargetFolder(wizard);
    DataFolder targetFolder = DataFolder.findFolder(pkg);
    FileObject templateFile = Templates.getTemplate(wizard);
    DataObject templateDataObject = DataObject.find(templateFile);
    DataObject createdDataObject = templateDataObject.createFromTemplate(targetFolder, className);

    OpenCookie open = (OpenCookie) createdDataObject.getCookie(OpenCookie.class);
    if (open != null) {
        open.open();
    }
    return Collections.singleton(createdDataObject);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:17,代码来源:NewPrimitiveWizardIterator.java

示例11: testComponentCanBeSerializedEvenItIsBig

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

    FileObject fo = obj.getPrimaryFile();
    FileLock lock = fo.lock();
    PrintStream os = new PrintStream(fo.getOutputStream(lock));
    for (int i = 0; i < 1024 * 1024 / 10; i++) {
        os.print("Ahoj " + i + "\n");
    }
    os.close();
    lock.releaseLock();
    assertTrue("Larger than 1Mb", 1024 * 1024 + 1000 < fo.getSize());

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

示例12: testWhatIsAddedToNodeLookupIsByDefaultVisibleInDataObjectLookup

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
public void testWhatIsAddedToNodeLookupIsByDefaultVisibleInDataObjectLookup() throws Exception {
    org.openide.filesystems.FileSystem lfs = TestUtilHid.createLocalFileSystem(getWorkDir (), new String[] {
        "F.java", "F.form"
    });
    
    FSWithStatus fs = new FSWithStatus ();
    fs.setRootDirectory(org.openide.filesystems.FileUtil.toFile(lfs.getRoot()));
    
    DataObject obj = DataObject.find (fs.findResource("F.java"));

    OpenCookie fromNode = obj.getNodeDelegate().getLookup().lookup(OpenCookie.class);
    assertNotNull("There is some cookie in node", fromNode);
    
    OpenCookie fromObject = obj.getLookup().lookup(OpenCookie.class);
    assertNotNull("There is a cookie in data object too", fromObject);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DataNodeTest.java

示例13: canOpenTask

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
private boolean canOpenTask() {
    if( null != Accessor.getDefaultAction( task ) )
        return true;

    URL url = Accessor.getURL( task );
    if( null != url )
        return true;

    FileObject fo = Accessor.getFile(task);
    if( null == fo )
        return false;

    DataObject dob = null;
    try {
        dob = DataObject.find( fo );
    } catch( DataObjectNotFoundException donfE ) {
        return false;
    }
    if( Accessor.getLine( task ) > 0 ) {
        return null != dob.getCookie( LineCookie.class );
    }

    return null != dob.getCookie( OpenCookie.class )
        || null != dob.getCookie( EditCookie.class )
        || null != dob.getCookie( ViewCookie.class );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:OpenTaskAction.java

示例14: JShellDataObject

import org.openide.cookies.OpenCookie; //导入依赖的package包/类
public JShellDataObject(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException {
    super(fo, loader);
    CookieSet cks = getCookieSet();
    cks.add(new Class[] {
            OpenCookie.class,
            EditorCookie.Observable.class,
            CloseCookie.class,
            LineCookie.class,
            SimpleES.class,
        }, new CookieSet.Factory() {
        private CloneableEditorSupport supp;
        public <T extends Node.Cookie> T createCookie(Class<T> klass) {
            if (supp != null) {
                return klass.cast(supp);
            }
            return klass.cast(
                    /*
                    supp = DataEditorSupport.create(JShellDataObject.this, 
                            getPrimaryEntry(), getCookieSet(), 
                            () -> createPane())
                    );*/
                    supp = new SimpleES(JShellDataObject.this, getPrimaryEntry())
            );
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JShellDataObject.java

示例15: 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


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