public synchronized Node[] getCurrentNodes() { if (active != null) { return active.getActivatedNodes(); } else { return null; } }
public synchronized Node[] getCurrentNodes() { if (active != null) { return active.getActivatedNodes(); } else { return null; } }
synchronized void setActive(TopComponent tc) { active = tc; Node[] _nodes = tc == null ? new Node[0] : tc.getActivatedNodes(); if (_nodes != null) { nodes = _nodes; if (pcs != null) { pcs.firePropertyChange(PROP_ACTIVATED_NODES, null, null); } } if (pcs != null) { pcs.firePropertyChange(PROP_ACTIVATED, null, null); pcs.firePropertyChange(PROP_CURRENT_NODES, null, null); } }
synchronized void setActive(TopComponent tc) { active = tc; Node[] _nodes = tc == null ? new Node[0] : tc.getActivatedNodes(); if (_nodes != null) { nodes = _nodes; if (pcs != null) { pcs.firePropertyChange(PROP_ACTIVATED_NODES, null, null); } } if (pcs != null) { pcs.firePropertyChange(PROP_ACTIVATED, null, null); pcs.firePropertyChange(PROP_CURRENT_NODES, null, null); } }
/** Change in one of the lookups we delegate to */ public void resultChanged(LookupEvent ev) { updateLookups (tc.getActivatedNodes ()); }
/** Change in one of the lookups we delegate to */ public void resultChanged(LookupEvent ev) { updateLookups (tc.getActivatedNodes ()); }
/** * Returns files from all opened top components * @return set of opened files */ public static Set<VCSFileProxy> getOpenFiles() { TopComponent[] comps = TopComponent.getRegistry().getOpened().toArray(new TopComponent[0]); Set<VCSFileProxy> openFiles = new HashSet<VCSFileProxy>(comps.length); for (TopComponent tc : comps) { Node[] nodes = tc.getActivatedNodes(); if (nodes == null) { continue; } for (Node node : nodes) { VCSFileProxy file = node.getLookup().lookup(VCSFileProxy.class); if (file == null) { FileObject fo = node.getLookup().lookup(FileObject.class); if (fo != null && fo.isData()) { file = VCSFileProxy.createFileProxy(fo); } } if (file != null) { openFiles.add(file); } } } return openFiles; }
/** Creates the lookup. * @param tc component to work on */ public DefaultTopComponentLookup(TopComponent tc) { super (); this.tc = tc; this.listener = (LookupListener)WeakListeners.create(LookupListener.class, this, null); this.actionMap = Lookups.singleton (new DelegateActionMap (tc)); updateLookups (tc.getActivatedNodes ()); }
/** Creates the lookup. * @param tc component to work on */ public DefaultTopComponentLookup(TopComponent tc) { super (); this.tc = tc; this.listener = (LookupListener)WeakListeners.create(LookupListener.class, this, null); this.actionMap = Lookups.singleton (new DelegateActionMap (tc)); updateLookups (tc.getActivatedNodes ()); }
if (activated != null && activated.equals(projectsTab)) { logger.finer("propertyChange: processing activated nodes"); nodes = projectsTab.getActivatedNodes(); } else if (lastProject == null) { logger.finer("propertyChange: processing selected nodes");
Set<DesignContext> contextsFromTC = getDesignContextsForNodes(elementTC.getActivatedNodes());
private List<FacesModel> getVisibleModels() { List<FacesModel> visibleModels = new ArrayList<FacesModel>(); for(Mode mode : WindowManager.getDefault().getModes()) { TopComponent tc = mode.getSelectedTopComponent(); if(tc != null && tc.isOpened() && isMultiViewTopComponent(tc)){ TopComponent topComponent = getSelectedMultiView(tc); if(topComponent != null && isDesignerTopComponent(topComponent)) { // DataObject dObj = topComponent.getActivatedNodes()[0].getLookup().lookup(DataObject.class); // XXX #131996 Defend against possible NPE's. org.openide.nodes.Node[] activatedNodes = topComponent.getActivatedNodes(); if (activatedNodes == null || activatedNodes.length == 0) { info(new NullPointerException("TopComponent doesn't have any activated nodes, topComponent=" + topComponent + ", nodes=" + activatedNodes)); // NOI18N continue; } DataObject dObj = activatedNodes[0].getLookup().lookup(DataObject.class); if (dObj == null) { info(new NullPointerException("Activated node from top component" + " doesn't contain DataObject in its first activated node lookup, topComponent=" + topComponent + ", node=" + activatedNodes[0])); // NOI18N continue; } visibleModels.add((FacesModel)getModel(dObj.getPrimaryFile())); } } } return visibleModels; }
@Test public void shouldCallSetActivatedNodesOnSelectionChange() throws Exception { Injector.getDefault().inject(fixture, Lookups.fixed(topComponent, explorerManager)); final Node[] nodes = new Node[] { new AbstractNode(Children.LEAF) }; explorerManager.setRootContext(nodes[0]); assertThat(topComponent.getActivatedNodes(), is(nullValue())); explorerManager.setSelectedNodes(nodes); // Events are delivered in the EDT, so wait for the queue to be flushed EventQueue.invokeAndWait(new Runnable() { @Override public void run() { } }); assertThat(topComponent.getActivatedNodes(), is(nodes)); } }
@Override public void internalFrameActivated(InternalFrameEvent e) { //LOG.fine("internalFrameActivated: e = " + e); // Synchronise tab selection state, if not already done JInternalFrame internalFrame = e.getInternalFrame(); TabData selectedTab = frameToTabMap.get(internalFrame); int selectedTabIndex = tabbedContainer.getSelectionModel().getSelectedIndex(); List<TabData> tabs = tabbedContainer.getModel().getTabs(); for (int i = 0; i < tabs.size(); i++) { TabData tab = tabs.get(i); if (tab == selectedTab && selectedTabIndex != i) { tabbedContainer.getSelectionModel().setSelectedIndex(i); break; } } tabbedContainer.updateUI(); TopComponent topComponent = getTopComponent(internalFrame); // Publish lookup contents of selected frame to parent window lookup.setLookup(topComponent.getLookup()); // Publish activated nodes, if any setActivatedNodes(topComponent.getActivatedNodes()); // May not really be required if (WorkspaceTopComponent.this != WindowManager.getDefault().getRegistry().getActivated()) { WorkspaceTopComponent.this.requestActive(); } notifyActivated(topComponent); }