org.openide.cookies.EditorCookie Java Examples

The following examples show how to use org.openide.cookies.EditorCookie. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GoldenFileTestBase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    File dataDir = getDataDir();
    fname = getName().replace("test", "");
    File f = new File(dataDir, getClass().getName().
            replaceAll("\\.", "/") + "/" + fname + ".fxml");
    
    File w = new File(getWorkDir(), f.getName());
    InputStream is = new FileInputStream(f);
    OutputStream os = new FileOutputStream(w);
    FileUtil.copy(is, os);
    os.close();
    is.close();
    FileObject fo = FileUtil.toFileObject(w);
    sourceDO = DataObject.find(fo);
    document = ((EditorCookie)sourceDO.getCookie(EditorCookie.class)).openDocument();
    hierarchy = TokenHierarchy.get(document);
}
 
Example #2
Source File: OpenSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 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;
}
 
Example #3
Source File: DiffResultsViewForLine.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Document getSourceDocument(StreamSource ss) {
    Document sdoc = null;
    FileObject fo = ss.getLookup().lookup(FileObject.class);
    if (fo != null) {
        try {
            DataObject dao = DataObject.find(fo);
            if (dao.getPrimaryFile() == fo) {
                EditorCookie ec = dao.getCookie(EditorCookie.class);
                if (ec != null) {
                    sdoc = ec.openDocument();
                }
            }
        } catch (Exception e) {
            // fallback to other means of obtaining the source
        }
    } else {
        sdoc = ss.getLookup().lookup(Document.class);
    }
    return sdoc;
}
 
Example #4
Source File: ResourceHyperlinkProcessor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static boolean openFile(FileObject file) {
    if (file == null) {
        return false;
    }
    DataObject dObj;
    try {
        dObj = DataObject.find(file);
    } catch (DataObjectNotFoundException ex) {
        return false;
    }
    EditorCookie editorCookie = dObj.getCookie(EditorCookie.class);
    if (editorCookie == null) {
        return false;
    }
    editorCookie.open();
    return true;
}
 
Example #5
Source File: HintTestTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonJavaChangesOpenedInEditor214197() throws Exception {
    HintTest ht = HintTest.create()
                          .input("package test;\n" +
                                 "public class Test { }\n")
                          .input("test/test.txt", "1\n#foobar\n\n2", false);
    FileObject resource = ht.getSourceRoot().getFileObject("test/test.txt");
    DataObject od = DataObject.find(resource);
    EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
    Document doc = ec.openDocument();
    doc.remove(0, doc.getLength());
    doc.insertString(0, "5\n6\n", null);
    ht.run(NonJavaChanges.class)
      .findWarning("1:13-1:17:verifier:Test")
      .applyFix(false)
      .assertVerbatimOutput("test/test.txt", "6\n7\n");
    Assert.assertEquals("1\n#foobar\n\n2", resource.asText("UTF-8"));
    Assert.assertEquals("6\n7\n", doc.getText(0, doc.getLength()));
}
 
Example #6
Source File: ResourceStringLoader.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    FileObject closedFile = null;
    
    if (!EditorCookie.Observable.PROP_DOCUMENT.equals(evt.getPropertyName())) {
        return;
    }
    synchronized (this) {
        Document old = (Document)evt.getOldValue();
        if (old != null && docWL != null) {
            old.removeDocumentListener(docWL);
            docWL = null;
        }
        Document nue = (Document)evt.getNewValue();
        if (nue != null) {
            nue.addDocumentListener(docWL = WeakListeners.document(this, nue));
        } else {
            closedFile = extractFileObject(old);
        }
    }
    if (closedFile != null) {
        invalidate(closedFile);
    }
}
 
Example #7
Source File: JShellEnvironment.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void postCloseCleanup() {
    try {
        // try to close the dataobject
        DataObject d = DataObject.find(getConsoleFile());
        EditorCookie cake = d.getLookup().lookup(EditorCookie.class);
        cake.close();
        // discard the dataobject
        synchronized (this) {
            if (document == null) {
                return;
            }
            document = null;
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    if (controlsIO) {
        inputOutput.closeInputOutput();
    }
    ShellRegistry.get().closed(this);
}
 
Example #8
Source File: NavigatorContent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JTextComponent findActivePane() {
    DataObject d = peerDO;
    LOG.fine(this + ": findActivePane DataObject=" + d);
    if (d == null) {
        return null;
    }
    EditorCookie ec = (EditorCookie)d.getCookie(EditorCookie.class);
    if (ec == null) {
        return null;
    }
    JTextComponent focused = EditorRegistry.focusedComponent();
    LOG.fine(this + ": findActivePane focused=" + focused);
    if (focused == null) {
        return null;
    }
    JTextComponent[] comps = ec.getOpenedPanes();
    if (comps == null) {
        return null;
    }
    for (JTextComponent c : comps) {
        if (c == focused) {
            return c;
        }
    }
    return null;
}
 
Example #9
Source File: TplIndenterTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example #10
Source File: MultiDiffPanelController.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public MultiDiffPanelController (File file, Revision rev1, Revision rev2, int requestedRightLine) {
    this(null, rev1, rev2, true);
    diffViewPanel = new PlaceholderPanel();
    diffViewPanel.setComponent(getInfoPanelLoading());
    this.requestedRightLine = requestedRightLine;
    this.popupAllowed = false;
    replaceVerticalSplitPane(diffViewPanel);
    initToolbarButtons();
    initNextPrevActions();
    for (JComponent c : new JComponent[] { panel.tgbHeadVsIndex, panel.tgbHeadVsWorking, panel.tgbIndexVsWorking }) {
        c.setVisible(false);
    }
    // mimics refreshSetups()
    Setup s = new Setup(file, rev1, rev2, null);
    GitLocalFileNode fNode = new GitLocalFileNode(Git.getInstance().getRepositoryRoot(file), file);
    EditorCookie cookie = DiffUtils.getEditorCookie(s);
    s.setNode(new DiffLocalNode(fNode, s, cookie, Mode.HEAD_VS_WORKING_TREE));
    Map<File, Setup> localSetups = Collections.singletonMap(file, s);
    setSetups(localSetups, getCookiesFromSetups(localSetups));
    setDiffIndex(s, 0, false);
    dpt = new DiffPrepareTask(setups.values().toArray(new Setup[setups.size()]));
    prepareTask = RP.create(dpt);
    prepareTask.schedule(0);
}
 
Example #11
Source File: ContextJspServletGenTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected BaseDocument getDocument(FileObject fo, String mimeType, Language language) {
    try {
        DataObject dobj = DataObject.find(fo);
        assertNotNull(dobj);

        EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class);
        assertNotNull(ec);

        return (BaseDocument) ec.openDocument();
    }
    catch (Exception ex) {
        fail(ex.toString());
        return null;
    }
}
 
Example #12
Source File: HintsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
    final HintMetadata selectedHint = getSelectedHint();
    final String selectedHintId = selectedHint.id;
    DataObject dob = getDataObject(selectedHint);
    EditorCookie ec = dob.getCookie(EditorCookie.class);
    try {
        ec.saveDocument();
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    RulesManager.getInstance().reload();
    cpBased.reset();
    errorTreeModel = constructTM(Utilities.getBatchSupportedHints(cpBased).keySet(), false);
    setModel(errorTreeModel);
    if (logic != null) {
        logic.errorTreeModel = errorTreeModel;
    }
    select(getHintByName(selectedHintId));
    customHintCodeBeforeEditing = null;
    cancelEditActionPerformed(evt);
    hasNewHints = true;
}
 
Example #13
Source File: AbstractRefactoringElement.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #14
Source File: UtilsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void doTestDefaultIndent(String code, String insertCode, String expectedResult) throws Exception {
    clearWorkDir();
    FileObject wd = FileUtil.toFileObject(getWorkDir());
    FileObject sourceFile1 = wd.createData("Test1.txt");
    EditorCookie ec = sourceFile1.getLookup().lookup(EditorCookie.class);
    Document doc = ec.openDocument();
    int insertPos = code.indexOf("|");
    code = code.replace("|", "");
    doc.insertString(0, code, null);
    javax.swing.text.Position caret = doc.createPosition(insertPos);
    doc.insertString(insertPos, insertCode, null);
    List<TextEdit> edits = Utils.computeDefaultOnTypeIndent(doc, insertPos, Utils.createPosition(doc, insertPos), insertCode);
    Utils.applyEditsNoLock(doc, edits);
    int expectedPos = expectedResult.indexOf("|");
    expectedResult = expectedResult.replace("|", "");
    assertEquals(expectedResult, doc.getText(0, doc.getLength()));
    assertEquals(expectedPos, caret.getOffset());
    LifecycleManager.getDefault().saveAll();
}
 
Example #15
Source File: GsfDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public GsfDataObject(FileObject pf, MultiFileLoader loader, Language language) throws DataObjectExistsException {
    super(pf, loader);

    // If the user creates a file with a filename where we can't figure out the language
    // (e.g. the PHP New File wizard doesn't enforce a file extension, so if you create
    // a file named "pie.class" (issue 124044) the data loader doesn't know which language
    // to associate this with since it isn't a GSF file extension or mimetype). However
    // during template creation we know the language anyway so we can use it. On subsequent
    // IDE restarts the file won't be recognized so the user will have to rename or
    // add a new file extension to file type mapping.
    if (language == null) {
        language = templateLanguage;
    }
    this.language = language;
    getCookieSet().add(new Class[]{
            GenericEditorSupport.class, // NOI18N
            SaveAsCapable.class, Openable.class, EditorCookie.Observable.class, 
            PrintCookie.class, CloseCookie.class, Editable.class, LineCookie.class,
            DataEditorSupport.class, CloneableEditorSupport.class,
            CloneableOpenSupport.class
        }, new EditorSupportFactory());
}
 
Example #16
Source File: PHPFormatterTemplateTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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 other 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 = (EditorCookie) dobj.getLookup().lookup(EditorCookie.class);
        assertNotNull(ec);

        return (BaseDocument) ec.openDocument();
    } catch (Exception ex) {
        fail(ex.toString());
        return null;
    }
}
 
Example #17
Source File: SourceFileObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected final Long isDirty() {
    final FileObject file = getHandle().resolveFileObject(false);
    if (file == null) {
        return null;
    }
    final DataObject.Registry regs = DataObject.getRegistry();
    final Set<DataObject> modified = regs.getModifiedSet();
    for (DataObject dobj : modified) {
        if (file.equals(dobj.getPrimaryFile())) {
            final EditorCookie ec = dobj.getCookie(EditorCookie.class);
            if (ec != null) {
                final Document doc = ec.getDocument();
                if (doc != null) {
                    return DocumentUtilities.getDocumentTimestamp(doc);
                }
            }
        }
    }
    return null;
}
 
Example #18
Source File: ConfigFileSpringBeanSourceTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testPropertyParseWithoutPNamespace() throws Exception {
    String contents = TestUtils.createXMLConfigText(
            "<bean id='foo' name='bar baz' " +
            "parent='father' factory-bean='factory' factory-method='createMe' " +
            "class='org.example.Foo' p:p2='v2' p:p3-ref='v3'>" +
            "<property name='p1' value='v1'/>" + 
            "</bean>", false);
    TestUtils.copyStringToFile(contents, configFile);
    DataObject dataObject = DataObject.find(FileUtil.toFileObject(configFile));
    BaseDocument doc = (BaseDocument)dataObject.getCookie(EditorCookie.class).openDocument();
    ConfigFileSpringBeanSource source = new ConfigFileSpringBeanSource();
    source.parse(doc);
    List<SpringBean> beans = source.getBeans();
    assertEquals(1, beans.size());
    SpringBean bean = beans.get(0);
    assertSame(bean, source.findBean("foo"));
    Set<SpringBeanProperty> properties = bean.getProperties();
    assertEquals(1, properties.size());
}
 
Example #19
Source File: VcsAnnotateAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    if (visible()) {
        JEditorPane pane = activatedEditorPane();
        AnnotationBarManager.hideAnnotationBar(pane);
    } else {
        EditorCookie ec = activatedEditorCookie();
        if (ec == null) return;
        
        JEditorPane[] panes = ec.getOpenedPanes();
        if (panes == null) {
            ec.open();
        }
        panes = ec.getOpenedPanes();
        if (panes == null) {
            return;
        }
        final JEditorPane currentPane = panes[0];
        
        AnnotationBar ab = AnnotationBarManager.showAnnotationBar(currentPane);
        ab.setAnnotationMessage(NbBundle.getMessage(VcsAnnotateAction.class, "CTL_AnnotationSubstitute")); // NOI18N;
        
        computeAnnotationsAsync(ab);
    }
}
 
Example #20
Source File: RelationshipMappingWhereUsed.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
 public PositionBounds getPosition() {
    try {
        DataObject dobj = DataObject.find(getParentFile());
        if (dobj != null) {
            EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getLookup().lookup(EditorCookie.Observable.class);
            if (obs != null && obs instanceof CloneableEditorSupport) {
                CloneableEditorSupport supp = (CloneableEditorSupport)obs;

            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) {
        LOG.log(Level.INFO, "Can't resolve", ex);//NOI18N
    }
    return null;
}
 
Example #21
Source File: RelationshipMappingRename.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
 public PositionBounds getPosition() {
    try {
        DataObject dobj = DataObject.find(getParentFile());
        if (dobj != null) {
            EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getLookup().lookup(EditorCookie.Observable.class);
            if (obs != null && obs instanceof CloneableEditorSupport) {
                CloneableEditorSupport supp = (CloneableEditorSupport)obs;

            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) {
        LOG.log(Level.INFO, "Can't resolve", ex);//NOI18N
    }
    return null;
}
 
Example #22
Source File: MockEnvironmentFactory.java    From jeddict with Apache License 2.0 5 votes vote down vote up
@Override
public Document readDocument(FileObject f, boolean forceOpen) throws IOException {
    DataObject d = DataObject.find(f);
    EditorCookie cake = d.getCookie(EditorCookie.class);
    if (!forceOpen) {
        return cake.getDocument();
    } else {
        return cake.openDocument();
    }
}
 
Example #23
Source File: RefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Lookup getLookup(Node[] n) {
    InstanceContent ic = new InstanceContent();
    for (Node node:n)
        ic.add(node);
    if (n.length>0) {
        EditorCookie tc = getTextComponent(n[0]);
        if (tc != null) {
            ic.add(tc);
        }
    }
    return new AbstractLookup(ic);
}
 
Example #24
Source File: Utils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static EditorKit findKit_(EditorCookie editor) {
    JEditorPane[] panes = editor.getOpenedPanes();
    EditorKit kit;
    if (panes != null) {
        kit = panes[0].getEditorKit ();
    } else {
        kit = JEditorPane.createEditorKitForContentType ("text/xml"); // NOI18N
        if (kit == null) {
            // #39301: fallback; can happen if xml/text-edit is disabled
            kit = new DefaultEditorKit ();
        }
    }
    assert kit != null;
    return kit;
}
 
Example #25
Source File: GitUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void openInRevision (final File fileToOpen, final File originalFile, final int lineNumber, final String revision, boolean showAnnotations, ProgressMonitor pm) throws IOException {
    final FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(fileToOpen));
    EditorCookie ec = null;
    org.openide.cookies.OpenCookie oc = null;
    try {
        DataObject dobj = DataObject.find(fo);
        ec = dobj.getCookie(EditorCookie.class);
        oc = dobj.getCookie(org.openide.cookies.OpenCookie.class);
    } catch (DataObjectNotFoundException ex) {
        Logger.getLogger(GitUtils.class.getName()).log(Level.FINE, null, ex);
    }
    if (ec == null && oc != null) {
        oc.open();
    } else {
        CloneableEditorSupport ces = org.netbeans.modules.versioning.util.Utils.openFile(fo, revision.substring(0, 7));
        if (showAnnotations && ces != null && !pm.isCanceled()) {
            final org.openide.text.CloneableEditorSupport support = ces;
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    javax.swing.JEditorPane[] panes = support.getOpenedPanes();
                    if (panes != null) {
                        if (lineNumber >= 0 && lineNumber < support.getLineSet().getLines().size()) {
                            support.getLineSet().getCurrent(lineNumber).show(Line.ShowOpenType.NONE, Line.ShowVisibilityType.FRONT);
                        }
                        SystemAction.get(AnnotateAction.class).showAnnotations(panes[0], originalFile, revision);
                    }
                }
            });
        }
    }
}
 
Example #26
Source File: JSPELPlugin.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Document getDocumentForFile(FileObject fo) {
    try {
        EditorCookie ec = DataObject.find(fo).getLookup().lookup(EditorCookie.class);
        return (ec == null) ? null : ec.getDocument();
    } catch (DataObjectNotFoundException ex) {
        LOGGER.log(Level.INFO, null, ex);
    }
    return null;
}
 
Example #27
Source File: SoapClientEditorDrop.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static FileObject getTargetFile(JTextComponent targetComponent) {
    if (targetComponent == null) {
        return null;
    }
    DataObject d = NbEditorUtilities.getDataObject(targetComponent.getDocument());
    if (d == null) {
        return null;
    }
    EditorCookie ec = d.getCookie(EditorCookie.class);
    if (ec == null || ec.getOpenedPanes() == null) {
        return null;
    }
    return d.getPrimaryFile();
}
 
Example #28
Source File: CreateElementTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void performTestAnalysisTest(String className, int offset, Set<String> golden) throws Exception {
      prepareTest(className);

      DataObject od = DataObject.find(info.getFileObject());
      EditorCookie ec = (EditorCookie) od.getLookup().lookup(EditorCookie.class);

      Document doc = ec.openDocument();

      List<Fix> fixes = CreateElement.analyze(info, offset);
      Set<String> real = new HashSet<String>();

      for (Fix f : fixes) {
          if (f instanceof CreateFieldFix) {
              real.add(((CreateFieldFix) f).toDebugString(info));
              continue;
          }
          if (f instanceof AddParameterOrLocalFix) {
              real.add(((AddParameterOrLocalFix) f).toDebugString(info));
              continue;
          }
   if (f instanceof CreateMethodFix) {
              real.add(((CreateMethodFix) f).toDebugString(info));
              continue;
   }
   if (f instanceof CreateClassFix) {
real.add(((CreateClassFix) f).toDebugString(info));
continue;
   }

          if (f instanceof CreateEnumConstant) {
              real.add(((CreateEnumConstant) f).toDebugString(info));
              continue;
          }

          fail("Fix of incorrect type: " + f.getClass());
      }

      assertEquals(golden, real);
  }
 
Example #29
Source File: FileTreeView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setModel (T[] nodes, EditorCookie[] editorCookies, Object modelData) {
    this.editorCookies = editorCookies;
    this.nodes = nodes;
    em.setRootContext((Node) modelData);
    for (T n : nodes) {
        view.expandNode(toTreeNode(n));
    }
}
 
Example #30
Source File: DiffSidebarManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private FileObject fileForDataobject(Document doc, MultiDataObject dobj) {
    for (MultiDataObject.Entry entry : dobj.secondaryEntries()) {
        if (entry instanceof CookieSet.Factory) {
            CookieSet.Factory factory = (CookieSet.Factory) entry;
            EditorCookie ec = factory.createCookie(EditorCookie.class);
            Document entryDocument = ec.getDocument();
            if (entryDocument == doc) {
                return entry.getFile();
            }
        }
    }
    return dobj.getPrimaryFile();
}