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


Java DataObject.getCookie方法代码示例

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


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

示例1: getPosition

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public PositionBounds getPosition() {
    try {
        DataObject dobj = DataObject.find(getParentFile());
        if (dobj != null) {
            EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getCookie(EditorCookie.Observable.class);
            if (obs != null && obs instanceof CloneableEditorSupport) {
                CloneableEditorSupport supp = (CloneableEditorSupport)obs;

                if (loc == null) {
                    loc = location();
                }
            PositionBounds bounds = new PositionBounds(
                    supp.createPositionRef(loc[0], Position.Bias.Forward),
                    supp.createPositionRef(Math.max(loc[0], loc[1]), Position.Bias.Forward)
                    );
            
            return bounds;
        }
        }
    } catch (DataObjectNotFoundException ex) {
        ex.printStackTrace();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:AbstractRefactoringElement.java

示例2: linePart

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public static PositionBounds linePart(FileObject file, int start, int end) {
    try {
        DataObject od = DataObject.find(file);
        
        if (od == null)
            return null;
        
        EditorCookie ec = od.getCookie(EditorCookie.class);
        
        if (!(ec instanceof CloneableEditorSupport)) {
            return null;
        }
        
        final CloneableEditorSupport ces = (CloneableEditorSupport) ec;
        
        checkOffsetsAndLog(start, end);
        
        return new PositionBounds(ces.createPositionRef(start, Position.Bias.Forward), ces.createPositionRef(end, Position.Bias.Backward));
    } catch (IOException e) {
        LOG.log(Level.INFO, null, e);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:HintsControllerImpl.java

示例3: getOpenedPanes

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Override
public JEditorPane[] getOpenedPanes(FileObject fo) {
    DataObject dobj;
    try {
        dobj = DataObject.find(fo);
    } catch (DataObjectNotFoundException ex) {
        return new JEditorPane[0];
    }

    EditorCookie editorCookie = dobj.getCookie(EditorCookie.class);

    if (editorCookie == null) {
        return new JEditorPane[0];
    }

    return editorCookie.getOpenedPanes();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DefaultDataLoadersBridge.java

示例4: getChildren

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private static Children getChildren(DataObject dobj, boolean noBeanInfo) {
    if (noBeanInfo) {
        return Children.LEAF;
    }
    InstanceCookie inst = (InstanceCookie)dobj.getCookie(InstanceCookie.class);
    if (inst == null) return Children.LEAF;
    try {
        Class clazz = inst.instanceClass();
        if (BeanContext.class.isAssignableFrom(clazz) ||
            BeanContextProxy.class.isAssignableFrom(clazz)) {
            return new InstanceChildren ();
        } else {
            return Children.LEAF;
        }
    } catch (Exception ex) {
        return Children.LEAF;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SerialDataNode.java

示例5: dumpFile

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**  @author David Kaspar */
public String dumpFile(DataObject dao) {
    SourceCookie sc = (SourceCookie) dao.getCookie(SourceCookie.class);
    SourceElement se = sc.getSource();
    ClassElement[] cea = se.getClasses();
    if (cea == null)
        return "";
    ClassElement[] newcea = new ClassElement[cea.length];
    for (int a = 0; a < cea.length; a ++)
        newcea[a] = (ClassElement) cea[a].clone();
    newcea = sortClasses(newcea);
    String str = "";
    for (int a = 0; a < newcea.length; a ++)
        str += newcea[a].toString();
    return str;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SAXGeneratorJTest.java

示例6: getMappingResourceOccurPlaces

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private static List<OccurrenceItem> getMappingResourceOccurPlaces(FileObject configFile, String resourceName, boolean searchingPathOnly) {
    List<OccurrenceItem> foundPlaces = new ArrayList<OccurrenceItem>();
    try {
        // Get the document for this file
        DataObject dataObject = DataObject.find(configFile);
        EditorCookie result = dataObject.getCookie(EditorCookie.class);
        if (result == null) {
            throw new IllegalStateException("File " + configFile + " does not have an EditorCookie.");
        }

        CloneableEditorSupport editor = (CloneableEditorSupport) result;
        BaseDocument document = (BaseDocument) editor.openDocument();
        XMLSyntaxSupport syntaxSupport = XMLSyntaxSupport.getSyntaxSupport(document);
        if (syntaxSupport == null) {
            return foundPlaces;
        }
        return syntaxSupport.runWithSequence(0, 
            (TokenSequence ts) -> {
                int start = document.getStartPosition().getOffset();
                return getMappingResourceOccurPlacesLocked(syntaxSupport, ts, start, editor, resourceName, searchingPathOnly);
        });
    } catch (IOException | BadLocationException ex) {
        ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ex);
    }
    return foundPlaces;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:HibernateRefactoringUtil.java

示例7: test135210

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**
 * SIOOBE when reformatting code with unclosed javadoc comment.
 * Regression test.
 *
 * http://www.netbeans.org/issues/show_bug.cgi?id=135210
 */
public void test135210() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile,
            "package hierbas.del.litoral;\n"
            + "\n"
            + "public class Test {\n"
            + "}\n");
    FileObject testSourceFO = FileUtil.toFileObject(testFile);
    DataObject testSourceDO = DataObject.find(testSourceFO);
    EditorCookie ec = (EditorCookie)testSourceDO.getCookie(EditorCookie.class);
    final Document doc = ec.openDocument();
    doc.putProperty(Language.class, JavaTokenId.language());
    String content =
            "package hierbas.del.litoral;\n"
            + "public class Test{\n"
            + "/**\n"
            + "*\n"
            + "*\n"
            + "}\n";

    String golden =
            "package hierbas.del.litoral;\n"
            + "\n"
            + "public class Test {\n"
            + "\n"
            + "    /**\n"
            + "     *\n"
            + "     *\n"
            + "     * }\n";
    reformat(doc, content, golden);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:FormatingTest.java

示例8: isDocumentActive

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**
 * Verify whether the given document is still being actively used
 * by the corresponding editor support.
 */
public static boolean isDocumentActive(Document doc) {
    DataObject dob = getDataObject(doc);
    if (dob != null) {
        EditorCookie editorCookie = (EditorCookie)dob.getCookie(EditorCookie.class);
        if (editorCookie != null) {
            Document ecDoc = editorCookie.getDocument(); // returns null if closed
            if (ecDoc == doc) { // actively used by ec
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NbEditorUtilities.java

示例9: getInstance

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public static synchronized AnnotationHolder getInstance(FileObject file) {
    if (file == null)
        return null;

    try {
        DataObject od = DataObject.find(file);
        AnnotationHolder result = file2Holder.get(od);

        if (result == null) {
            EditorCookie editorCookie = od.getCookie(EditorCookie.class);

            if (editorCookie == null) {
                LOG.log(Level.WARNING,
                        "No EditorCookie.Observable for file: {0}", FileUtil.getFileDisplayName(file)); //NOI18N
            } else {
                Document doc = editorCookie.getDocument();

                if (doc instanceof BaseDocument) {
                    file2Holder.put(od, result = new AnnotationHolder(file, od, (BaseDocument) doc));
                }
            }
        }

        return result;
    } catch (IOException e) {
        LOG.log(Level.FINE, null, e);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:AnnotationHolder.java

示例10: cancel

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Cancels current internationalizing session and re-layout top component to original layout. */
public void cancel() {
    if (replaceCount>0) {
        //Need to save resource
        DataObject resource = support.getResourceHolder().getResource();
        if (resource != null) {
            SaveCookie save = resource.getCookie(SaveCookie.class);
            if (save!=null) {
                try {
                    save.save();
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }
    replaceCount = 0;
    // No memory leaks.
    support = null;

    if(LOG.isLoggable(Level.FINEST)) {
        LOG.logp(Level.FINEST, getClass().getName(), "cancel()",
                 "Sets the I18nSupport to  null"); // NOI18N
    }
    
    closeDialog();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:I18nManager.java

示例11: getTargetFile

import org.openide.loaders.DataObject; //导入方法依赖的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

示例12: isModified

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Override
public EditorCookie isModified(FileObject file) {
    DataObject.Registry regs = DataObject.getRegistry();
    Set<DataObject> modified = (Set<DataObject>) regs.getModifiedSet();
    for (DataObject dobj : modified) {
        if (file.equals(dobj.getPrimaryFile())) {
            EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class);
            return ec;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:DefaultDataLoadersBridge.java

示例13: openAndFocusElement

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private void openAndFocusElement(final TreeNodeAdapter selected, final boolean selectLineOnly) {
    BaseDocument bdoc = (BaseDocument)selected.getDocumentElement().getDocument();
    DataObject dobj = NbEditorUtilities.getDataObject(bdoc);
    if(dobj == null) return ;
    
    final EditorCookie.Observable ec = (EditorCookie.Observable)dobj.getCookie(EditorCookie.Observable.class);
    if(ec == null) return ;
    
    try {
        final Document doc = ec.openDocument(); //wait to editor to open
    }catch(IOException ioe) {
        ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe);
    }
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JEditorPane[] panes = ec.getOpenedPanes();
            if (panes != null && panes.length > 0) {
                // editor already opened, so just select
                selectElementInPane(panes[0], selected, !selectLineOnly);
            } else if(!selectLineOnly) {
                // editor not opened yet
                ec.open();
                panes = ec.getOpenedPanes();
                if (panes != null && panes.length > 0) {
                    selectElementInPane(panes[0], selected, true);
                }
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:NavigatorContent.java

示例14: performAction

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** 
 * Actually performs the action. Implements superclass abstract method.
 * @param activatedNodes Currently activated nodes.
 */
protected void performAction(final Node[] activatedNodes) {
    if (activatedNodes.length != 1) {
        return;
    }

    final Node node = activatedNodes[0];
    DataObject dataObject = node.getCookie(DataObject.class);
    if (dataObject == null) {
        return;
    }

    if (FileOwnerQuery.getOwner(dataObject.getPrimaryFile()) == null) {
        return;
    }

    EditorCookie editorCookie = node.getCookie(EditorCookie.class);
    if (editorCookie == null) {
        editorCookie = dataObject.getCookie(EditorCookie.class);
        if (editorCookie == null) {
            return;
        }
    }

    editorCookie.open(); 
    I18nManager.getDefault().internationalize(dataObject);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:I18nAction.java

示例15: openSnapshot

import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void openSnapshot(FileObject snapshotFo) {
    try {
        DataObject snapshotDo = DataObject.find(snapshotFo);
        OpenCookie open = snapshotDo.getCookie(OpenCookie.class);
        if (open != null) {
            open.open();
        }
    } catch (DataObjectNotFoundException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ResultsManager.java


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