當前位置: 首頁>>代碼示例>>Java>>正文


Java DataObject類代碼示例

本文整理匯總了Java中org.openide.loaders.DataObject的典型用法代碼示例。如果您正苦於以下問題:Java DataObject類的具體用法?Java DataObject怎麽用?Java DataObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataObject類屬於org.openide.loaders包,在下文中一共展示了DataObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openHistory

import org.openide.loaders.DataObject; //導入依賴的package包/類
public static void openHistory (File repositoryRoot, File[] files, String revision) {
    List<Node> nodes = new ArrayList<Node>(files.length);
    for (File file : files) {
        FileObject fo = FileUtil.toFileObject(file);
        if(fo == null) continue;
        DataObject dao;
        try {
            dao = DataObject.find(fo);
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
            continue;
        }
        nodes.add(dao.getNodeDelegate());
    }
    if(nodes.isEmpty()) return;
    
    String title = NbBundle.getMessage(
            LogAction.class, 
            "MSG_Log_TabTitle", // NOI18N
            Utils.getContextDisplayName(VCSContext.forNodes(nodes.toArray(new Node[nodes.size()]))));
    openHistory(repositoryRoot, files, title, revision);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:LogAction.java

示例2: getDocument

import org.openide.loaders.DataObject; //導入依賴的package包/類
@Override
protected BaseDocument getDocument(FileObject fo, String mimeType, Language language) {
    // for some reason GsfTestBase is not using DataObjects for BaseDocument construction
    // which means that for example Java formatter which does call EditorCookie to retrieve
    // document will get difference instance of BaseDocument for indentation
    try {
         DataObject dobj = DataObject.find(fo);
         assertNotNull(dobj);

         EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class);
         assertNotNull(ec);

         return (BaseDocument)ec.openDocument();
    }
    catch (Exception ex){
        fail(ex.toString());
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:HtmlIndenterTest.java

示例3: getEditorCookie

import org.openide.loaders.DataObject; //導入依賴的package包/類
/**
 * Tries to obtain an {@code EditorCookie} representing the given file.
 * @param  fileObj  file to get an {@code EditorCookie} from
 * @return  {@code EditorCookie} representing the file, or {@code null}
 * @throws  java.io.IOException
 *          if there was some I/O error while reading the file's content
 */
private static EditorCookie getEditorCookie(FileObject fileObj) throws IOException {
    DataObject dao;
    try {
        dao = DataObject.find(fileObj);
    } catch (DataObjectNotFoundException ex) {
        return null;
    }

    if (dao instanceof MultiDataObject) {
        MultiDataObject.Entry entry = findEntryForFile((MultiDataObject) dao, fileObj);
        if ((entry != null) && (entry instanceof CookieSet.Factory)) {
            CookieSet.Factory factory = (CookieSet.Factory) entry;
            return factory.createCookie(EditorCookie.class);   //can be null
        }
    }

    return dao.getCookie(EditorCookie.class);                  //can be null
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:DiffSidebar.java

示例4: copyNode

import org.openide.loaders.DataObject; //導入依賴的package包/類
protected Node copyNode (Node node) {
    boolean filter = false;
    try {
        DataObject d = (DataObject) node.getCookie (DataObject.class);
        if (d != null) {
            InstanceCookie.Of inst = (InstanceCookie.Of)d.getCookie(InstanceCookie.Of.class);
            if (inst != null && (inst.instanceOf(Node.class) || inst.instanceOf(Node.Handle.class))) {
                // This is just a node, not a real setting. E.g. ModuleNode, LoaderPoolNode. As such,
                // it itself should not display any origin information, it would make no sense. However
                // its children might have a legitimate DataObject cookie from the SFS.
                d = null;
            }
        }
        DataFolder folder = (DataFolder) node.getCookie (DataFolder.class);
        FileSystem fs = d == null || folder != null ? null : d.getPrimaryFile ().getFileSystem ();
        filter = fs == null ? false : fs.isDefault();
    } catch (FileStateInvalidException e) {
        // ignore
    }

    return filter ? new SettingFilterNode (node) : 
        node.isLeaf() ? node.cloneNode() : new TrivialFilterNode(node);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:SettingChildren.java

示例5: prepareMatchingObject

import org.openide.loaders.DataObject; //導入依賴的package包/類
private MatchingObject prepareMatchingObject(int numTextDetails)
        throws IOException {
    ResultModel rm = new org.netbeans.modules.search.ResultModel(
            new BasicSearchCriteria(), null, null);
    FileObject fo = FileUtil.createMemoryFileSystem().getRoot()
            .createData("test.tst");
    List<TextDetail> details = new LinkedList<TextDetail>();
    for (int i = 0; i < numTextDetails; i++) {
        TextDetail td = new TextDetail(DataObject.find(fo),
                SearchPattern.create("test", false, false, false));
        details.add(td);
    }
    rm.objectFound(fo, Charset.defaultCharset(), details);
    MatchingObject mo = rm.getMatchingObjects().get(0);
    return mo;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:MatchingObjectTest.java

示例6: setUp

import org.openide.loaders.DataObject; //導入依賴的package包/類
/** setUp method  */
public void setUp() {
    System.out.println("########  "+getName()+"  #######");
    
    OptionsOperator optionsOperator = OptionsOperator.invoke();
    optionsOperator.selectOption(Bundle.getString("org.netbeans.core.Bundle", "UI/Services/Editing")+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "PROP_Option_Menu"));
    PropertySheetOperator propertySheetTabOperator = new PropertySheetOperator(optionsOperator);
    new Property(propertySheetTabOperator, Bundle.getString("org.netbeans.modules.beans.Bundle", "PROP_Option_Prop_Style")).setValue(Bundle.getString("org.netbeans.modules.beans.Bundle", "MSG_Option_Gen_This"));

    FileObject testFile = Repository.getDefault().findResource("gui/data/" + NAME_TEST_FILE + ".java");
    FileObject destination = Repository.getDefault().findFileSystem(sampleDir.replace('\\', '/')).getRoot();
    optionsOperator.close();
    try {
        DataObject.find(testFile).copy(DataFolder.findFolder(destination));
    } catch (IOException e) {
        fail(e);
    }
    new PropertiesAction().perform();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:CreateNewNonIndexedProperty.java

示例7: setUp

import org.openide.loaders.DataObject; //導入依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    dir = FileUtil.toFileObject(getWorkDir());
    f1 = dir.createData("f1.data");
    f1form = dir.createData("f1.form");
    f2 = dir.createData("f2");
    subdir = dir.createFolder("sub");
    f3 = subdir.createData("f3.data");
    f3a = subdir.createData("f3a.data");
    subdir2 = dir.createFolder("subdir2");
    f4 = subdir2.createData("f3.nondata");
    subsubdir = subdir2.createFolder("sub");
    f5 = subdir2.createData("f1.data");
    f5a = subsubdir.createData("f3.data");
    fx = new XMLFileSystem().getRoot();
    d1 = DataObject.find(f1);
    d2 = DataObject.find(f2);
    d3 = DataObject.find(f3);
    dx = DataObject.find(fx);
    n1 = d1.getNodeDelegate();
    n2 = d2.getNodeDelegate();
    n3 = d3.getNodeDelegate();
    nx = dx.getNodeDelegate();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:ActionUtilsTest.java

示例8: closeAllDocuments

import org.openide.loaders.DataObject; //導入依賴的package包/類
/** Closes all opened documents and waits until this top component is closed. */
public void closeAllDocuments() {
    DataObject[] modifs = DataObject.getRegistry().getModified();
    if (modifs.length != 0) {
        // some object modified => need to call in new thread because modal question dialog appears
        new Thread(new Runnable() {

            @Override
            public void run() {
                pushMenuOnTab(closeAllDocumentsItem);
            }
         ;
        }, "thread to closeAllDocuments").start();
    } else {
        // no object modified
        new CloseAllDocumentsAction().perform(this);
        waitComponentShowing(false);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:TopComponentOperator.java

示例9: testPreCreateDecorator

import org.openide.loaders.DataObject; //導入依賴的package包/類
public void testPreCreateDecorator() throws Exception {
    MockLookup.setLayersAndInstances(new Deco() {
        @Override
        public boolean isBeforeCreation() {
            return true;
        }
        
        @Override
        public List<FileObject> decorate(CreateDescriptor desc, List<FileObject> createdFiles) throws IOException {
            assertSize("No files should have been created", createdFiles, 0);
            decorated = true;
            assertEquals(0, target.getChildren().length);
            return null;
        }
    });
    Map<String,String> parameters = Collections.singletonMap("type", "empty");
    DataObject n = obj.createFromTemplate(folder, "complex", parameters);
    assertTrue(decorated);
    assertNotNull(n);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:CreateFromTemplateDecoratorTest.java

示例10: getRootNodes

import org.openide.loaders.DataObject; //導入依賴的package包/類
private static List<Node> getRootNodes(Project prj,
                                       List<FileObject> roots, 
                                       FilteredNode.NodeFilter filter,
                                       boolean includeFiles) {
    List<Node> nodes = new ArrayList<Node>(roots.size());      
    for (FileObject rfo : roots) {
        try {
            if (includeFiles || (FileUtil.toFile(rfo)!=null)) {
                Project owner = org.netbeans.api.project.FileOwnerQuery.getOwner(rfo);
                Node origNode = DataObject.find(rfo).getNodeDelegate();
                FilteredNode node =  new FilteredNode(origNode,filter, getDisplayName(rfo, owner, prj!=owner));
                nodes.add(node);
            }
        } catch (org.openide.loaders.DataObjectNotFoundException ex) {}
    }
    return nodes;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:SelectorUtils.java

示例11: createKeys

import org.openide.loaders.DataObject; //導入依賴的package包/類
@Messages({"LBL_this_layer=<this layer>", "LBL_this_layer_in_context=<this layer in context>"})
@Override protected boolean createKeys(List<DataObject> keys) {
    handle.setAutosave(true);
    FileObject layer = handle.getLayerFile();
    if (layer == null) { // #180872, #212541
        return true;
    }
    Project p = FileOwnerQuery.getOwner(layer);
    if (p == null) { // #175861: inside JAR etc.
        return true;
    }
    FileSystem layerfs = handle.layer(false);
    try {
        if (layerfs != null) {
            keys.add(DataObject.find(badge(layerfs, handle.getLayerFile(), LBL_this_layer(), null).getRoot()));
        }
        LayerHandle h = LayerHandle.forProject(p);
        if (layer.equals(h.getLayerFile())) {
            h.setAutosave(true); // #135376
            keys.add(DataObject.find(badge(LayerUtils.getEffectiveSystemFilesystem(p), handle.getLayerFile(), LBL_this_layer_in_context(), handle.layer(false)).getRoot()));
        }
    } catch (IOException e) {
        Util.err.notify(ErrorManager.INFORMATIONAL, e);
    }
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:LayerNode.java

示例12: create

import org.openide.loaders.DataObject; //導入依賴的package包/類
public static List<Task> create(TextlintJsonResult[] results, FileObject fileObject) {
    List<Task> tasks = new ArrayList<>();
    final DataObject dataObject = getDataObject(fileObject);
    if (results != null && dataObject != null) {
        Line.Set lineSet = getLineSet(dataObject);
        if (lineSet != null) {
            for (TextlintJsonResult result : results) {
                result.getMessages().forEach((message) -> {
                    Line line = getCurrentLine(lineSet, message.getLine());
                    OpenAction defaultAction = line != null ? new OpenAction(line) : null;
                    Action[] popupActions = createPopupActions(dataObject, fileObject, message.getFix());
                    String description = String.format(MESSAGE_FORMAT,
                            message.getRuleId(),
                            message.getMessage(),
                            message.getLine(),
                            message.getIndex());
                    String groupName = message.getFix() != null ? TEXTLINT_FIXABLE_GROUP_NAME : TEXTLINT_GROUP_NAME;
                    tasks.add(Task.create(fileObject.toURL(), groupName, description, defaultAction, popupActions));
                });
            }
        }
    }
    return tasks;
}
 
開發者ID:junichi11,項目名稱:netbeans-textlint-plugin,代碼行數:25,代碼來源:TextlintPushTaskScanner.java

示例13: fileChanged

import org.openide.loaders.DataObject; //導入依賴的package包/類
@Override
public void fileChanged(final FileEvent fe) {
    if (fe.getTime() > lastSaveTime) {
        lastSaveTime = System.currentTimeMillis();

        // Refresh image viewer
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                try {
                    currentDataObject = DataObject.find(fe.getFile());
                    setNewContent(currentDataObject);
                } catch (DataObjectNotFoundException ex) {
                    Logger.getLogger(ImageNavigatorPanel.class.getName()).info(NbBundle.getMessage(ImageNavigatorPanel.class, "ERR_DataObject"));
                }
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:ImageNavigatorPanel.java

示例14: toCompletionItems

import org.openide.loaders.DataObject; //導入依賴的package包/類
private void toCompletionItems(String folderName, Collection<FileObject> files) {
    for (FileObject f : files) {
        DataObject d;
        try {
            d = DataObject.find(f);
        } catch (DataObjectNotFoundException ex) {
            // ???
            continue;
        }
        String value = folderName == null ? f.getNameExt() : folderName + "/" + f.getNameExt();
        if (f.isFolder()) {
            value = value + "/";
        }
        if (resourceRef) {
            value = "@" + value;
        }
        if (context.isAttribute()) {
            value = "\"" + value  + "\"";
        }
        CompletionItem item = new ResourcePathItem(d, context, value, null);
        results.add(item);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ResourcePathCompleter.java

示例15: testCreateFromTemplateUsingFreemarker

import org.openide.loaders.DataObject; //導入依賴的package包/類
public void testCreateFromTemplateUsingFreemarker() throws Exception {
    FileObject root = FileUtil.createMemoryFileSystem().getRoot();
    FileObject fo = FileUtil.createData(root, "simpleObject.txt");
    OutputStream os = fo.getOutputStream();
    String txt = "print('<html><h1>', title, '</h1></html>');";
    os.write(txt.getBytes());
    os.close();
    fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
    
    
    DataObject obj = DataObject.find(fo);
    
    DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
    
    Map<String,String> parameters = Collections.singletonMap("title", "Nazdar");
    DataObject n = obj.createFromTemplate(folder, "complex", parameters);
    
    assertEquals("Created in right place", folder, n.getFolder());
    assertEquals("Created with right name", "complex.txt", n.getName());
    
    String exp = "<html><h1> Nazdar </h1></html>\n";
    assertEquals(exp, readFile(n.getPrimaryFile()));
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:SCFTHandlerTest.java


注:本文中的org.openide.loaders.DataObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。