本文整理汇总了Java中org.openide.windows.TopComponent.setActivatedNodes方法的典型用法代码示例。如果您正苦于以下问题:Java TopComponent.setActivatedNodes方法的具体用法?Java TopComponent.setActivatedNodes怎么用?Java TopComponent.setActivatedNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.windows.TopComponent
的用法示例。
在下文中一共展示了TopComponent.setActivatedNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLookupPaletteTakePrecendsOverMimePalette
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
public void testLookupPaletteTakePrecendsOverMimePalette() throws IOException {
PaletteController pc = PaletteFactory.createPalette( lookupPaletteRootName, new DummyActions() );
TopComponent tc = createTopComponentWithPalette( pc );
tc.setActivatedNodes( new Node[] { DataObject.find( dummyDocumentFile ).getNodeDelegate() } );
PaletteSwitch paletteSwitch = PaletteSwitch.getDefault();
PaletteController foundPalette = paletteSwitch.getPaletteFromMimeType( MIME_TYPE_NAME );
assertNotNull( foundPalette );
assertEquals( mimePaletteRootName, foundPalette.getModel().getName() );
foundPalette = paletteSwitch.getPaletteFromTopComponent( tc, false, tc.isOpened() );
assertNotNull( foundPalette );
assertEquals( pc.getModel().getName(), foundPalette.getModel().getName() );
}
示例2: valueChanged
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
final TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, table);
if (tc == null) return; // table is no longer in component hierarchy
// this method may be called outside of AWT if a node fires change events from some other thread, see #79174
final Node [] nodeArray = getSelectedNodes();
if (SwingUtilities.isEventDispatchThread()) {
tc.setActivatedNodes(nodeArray);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
tc.setActivatedNodes(nodeArray);
}
});
}
}
示例3: propertyChange
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void propertyChange (PropertyChangeEvent evt) {
if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()) && !internalTraverse) {
Node[] selectedNodes = em.getSelectedNodes();
final TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, view);
if (tc != null) {
tc.setActivatedNodes(selectedNodes);
}
if (selectedNodes.length == 1) {
// single selection
T node = convertNode(selectedNodes[0]);
if (node != null) {
nodeSelected(node);
return;
}
}
nodeSelected(null);
}
}
示例4: testMimePalette
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
public void testMimePalette() throws IOException {
TopComponent tc = createTopComponentWithPalette( null );
tc.setActivatedNodes( new Node[] { DataObject.find( dummyDocumentFile ).getNodeDelegate() } );
tc.open();
PaletteSwitch paletteSwitch = PaletteSwitch.getDefault();
PaletteController foundPalette = paletteSwitch.getPaletteFromMimeType( MIME_TYPE_NAME );
assertNotNull( foundPalette );
assertEquals( mimePaletteRootName, foundPalette.getModel().getName() );
foundPalette = paletteSwitch.getPaletteFromTopComponent( tc, false, tc.isOpened() );
assertNotNull( foundPalette );
assertEquals( mimePaletteRootName, foundPalette.getModel().getName() );
}
示例5: propertyChange
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void propertyChange (PropertyChangeEvent evt) {
if (evt.getPropertyName() == ExplorerManager.PROP_SELECTED_NODES) {
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this);
if (tc != null) {
tc.setActivatedNodes(getExplorerManager().getSelectedNodes());
}
currRepository = null;
Revision oldRevision = currRevision;
currRevision = null;
if (getExplorerManager().getSelectedNodes().length == 1) {
Node selectedNode = getExplorerManager().getSelectedNodes()[0];
currRevision = selectedNode.getLookup().lookup(Revision.class);
currRepository = lookupRepository(selectedNode);
}
if ((currRevision != null || oldRevision != null) && !(currRevision != null && oldRevision != null
&& currRevision.equals(oldRevision))) {
firePropertyChange(PROP_REVISION_CHANGED, oldRevision, currRevision);
}
if (options.contains(Option.DISPLAY_REVISIONS) && currRevision != null) {
revisionsPanel1.updateHistory(currRepository, roots, currRevision);
}
} else if (options.contains(Option.DISPLAY_REVISIONS) && "focusOwner".equals(evt.getPropertyName())) {
Component compNew = (Component) evt.getNewValue();
if (compNew != null) {
if (SwingUtilities.getAncestorOfClass(tree.getClass(), compNew) != null) {
if (getExplorerManager().getSelectedNodes().length == 1) {
propertyChange(new PropertyChangeEvent(tree, ExplorerManager.PROP_SELECTED_NODES, getExplorerManager().getSelectedNodes(), getExplorerManager().getSelectedNodes()));
}
} else if (revisionsPanel1.lstRevisions == compNew) {
int selection = revisionsPanel1.lstRevisions.getSelectedIndex();
if (selection != -1) {
valueChanged(new ListSelectionEvent(revisionsPanel1.lstRevisions, selection, selection, false));
}
}
}
}
}
示例6: propertyChange
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this);
if (tc == null) return;
tc.setActivatedNodes((Node[]) evt.getNewValue());
} else if (RepositoryInfo.PROPERTY_BRANCHES.equals(evt.getPropertyName())) {
refreshBranchFilterModel();
}
}
示例7: propertyChange
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this);
if (tc == null) return;
tc.setActivatedNodes((Node[]) evt.getNewValue());
} else if (FileStatusCache.PROP_CACHE_READY.equals(evt.getPropertyName()) && Boolean.TRUE.equals(evt.getNewValue())) {
reScheduleRefresh(0);
}
}
示例8: valueChanged
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel selectionModel = table.getSelectionModel();
int min = selectionModel.getMinSelectionIndex();
int max = selectionModel.getMaxSelectionIndex();
if (min != -1 && min == max) {
// single selection
master.tableRowSelected(table.getSelectedRow());
} else {
List<DiffNode> selectedNodes = new ArrayList<DiffNode>();
if (min == -1) {
master.tableRowSelected(-1);
} else {
for (int i = min; i <= max; i++) {
if (selectionModel.isSelectedIndex(i)) {
int idx = sorter.modelIndex(i);
selectedNodes.add(nodes[idx]);
}
}
}
final TopComponent tc = (TopComponent) master.getClientProperty(TopComponent.class);
if (tc == null) return; // table is no longer in component hierarchy
Node [] nodesToActivate = selectedNodes.toArray(new Node[selectedNodes.size()]);
tc.setActivatedNodes(nodesToActivate);
}
}
示例9: propertyChange
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this);
if (tc == null) return;
tc.setActivatedNodes((Node[]) evt.getNewValue());
}
}
示例10: propertyChange
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void propertyChange (PropertyChangeEvent evt) {
String propertyName = evt.getPropertyName ();
TopComponent tc = (TopComponent) SwingUtilities.
getAncestorOfClass (TopComponent.class, this);
if (tc == null) {
return;
}
if (propertyName.equals (TopComponent.Registry.PROP_CURRENT_NODES)) {
ExplorerUtils.activateActions(getExplorerManager(), equalNodes());
} else
if (propertyName.equals (ExplorerManager.PROP_SELECTED_NODES)) {
tc.setActivatedNodes ((Node[]) evt.getNewValue ());
}
}
示例11: propertyChange
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName() == FileStatusCache.PROP_FILE_STATUS_CHANGED) {
FileStatusCache.ChangedEvent changedEvent = (FileStatusCache.ChangedEvent) evt.getNewValue();
Mercurial.LOG.log(Level.FINE, "Status.propertyChange(): {0} file: {1}", new Object [] { parentTopComponent.getContentTitle(), changedEvent.getFile()} ); // NOI18N
if (affectsView(evt)) {
reScheduleRefresh(1000);
}
return;
}
if (evt.getPropertyName() == Mercurial.PROP_CHANGESET_CHANGED) {
Object source = evt.getOldValue();
File root = HgUtils.getRootFile(context);
Mercurial.LOG.log(Level.FINE, "Mercurial.changesetChanged: source {0} repo {1} ", new Object [] {source, root}); // NOI18N
if (root != null && root.equals(source)) {
reScheduleRefresh(1000);
}
return;
}
if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this);
if (tc != null) {
tc.setActivatedNodes((Node[]) evt.getNewValue());
}
return;
}
}
示例12: valueChanged
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel selectionModel = table.getSelectionModel();
int min = selectionModel.getMinSelectionIndex();
int max = selectionModel.getMaxSelectionIndex();
if (min != -1 && min == max) {
// single selection
master.nodeSelected(getSelectedNode());
} else {
List<DiffNode> selectedNodes = new ArrayList<DiffNode>();
if (min == -1) {
master.nodeSelected(null);
} else {
for (int i = min; i <= max; i++) {
if (selectionModel.isSelectedIndex(i)) {
int idx = sorter.modelIndex(i);
selectedNodes.add(nodes[idx]);
}
}
}
final TopComponent tc = (TopComponent) master.getClientProperty(TopComponent.class);
if (tc == null) return; // table is no longer in component hierarchy
Node [] nodesToActivate = selectedNodes.toArray(new Node[selectedNodes.size()]);
tc.setActivatedNodes(nodesToActivate);
}
}
示例13: select
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
/**
* What should I do if I am selected(=left clicked)?
* In this case, change Properties widow to properties of associated DataNode
*/
public void select(Widget arg0, Point arg1, boolean arg2) {
TopComponent tc = TopComponent.getRegistry().getActivated();
getPoshScene().setFocusedWidget(this);
if (tc != null) {
tc.setActivatedNodes(new Node[]{getPropertiesNode()});
}
}
示例14: selectElementsAtOffset
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
/** Selects element at the given position. */
synchronized void selectElementsAtOffset(final int offset) {
if (syntaxSupport == null) {
Document doc = pane.getDocument();
if (doc instanceof BaseDocument) {
syntaxSupport = XMLSyntaxSupport.getSyntaxSupport((BaseDocument)doc);
}
if (syntaxSupport == null) {
return;
}
}
Container parent = pane.getParent();
while (parent != null && !(parent instanceof TopComponent)){
parent = parent.getParent();
}
if (parent == null) {
return;
}
TopComponent topComp = (TopComponent)parent;
Node activeNodes[] = topComp.getActivatedNodes();
if (activeNodes == null || activeNodes.length == 0) {
return; // No nodes active
}
if (originalUINode == null) {
originalUINode = activeNodes[0];
}
//it must be called from separate thread, it may the block UI thread
GrammarQuery grammarQuery = XMLCompletionQuery.getPerformer(pane.getDocument(), syntaxSupport);
if (grammarQuery == null) {
return;
}
SyntaxQueryHelper helper = null;
try {
helper = new SyntaxQueryHelper(syntaxSupport, offset);
} catch (BadLocationException e) {
topComp.setActivatedNodes(new Node[]{new DelegatingNode(originalUINode, null, null)});
return;
}
Node newUiNode = new DelegatingNode(originalUINode, grammarQuery, helper.getContext());
topComp.setActivatedNodes(new Node[]{newUiNode});
}
示例15: setDiffIndex
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
private void setDiffIndex(Setup selectedSetup, int location, boolean restartPrepareTask) {
currentSetup = selectedSetup;
currentSetupDiffLengthChanged = -1;
if (currentSetup != null) {
if (restartPrepareTask && dpt != null) {
dpt.cancel();
dpt.setSelectedSetup(currentSetup);
prepareTask.schedule(100);
}
DiffController view = currentSetup.getView();
TopComponent tc = (TopComponent) getClientProperty(TopComponent.class);
if (tc != null) {
Node node = currentSetup.getNode();
tc.setActivatedNodes(new Node[] {node == null ? Node.EMPTY : node});
}
diffView = null;
if (view != null) {
currentSetupDiffLengthChanged = view.getDifferenceCount();
if (showingFileComponent()) {
fileComponentSetSelectedIndexContext = true;
getActiveFileComponent().setSelectedNode(currentSetup.getNode());
fileComponentSetSelectedIndexContext = false;
}
getDiffViewModeSwitcher().setupMode(view);
diffView = view.getJComponent();
diffView.getActionMap().put("jumpNext", nextAction); // NOI18N
diffView.getActionMap().put("jumpPrev", prevAction); // NOI18N
displayDiffView();
if (location == -1) {
location = view.getDifferenceCount() - 1;
}
if (location >=0 && location < view.getDifferenceCount()) {
view.setLocation(DiffController.DiffPane.Modified, DiffController.LocationType.DifferenceIndex, location);
}
} else {
diffView = new NoContentPanel(NbBundle.getMessage(MultiDiffPanel.class, "MSG_DiffPanel_NoContent"));
displayDiffView();
}
} else {
diffView = new NoContentPanel(NbBundle.getMessage(MultiDiffPanel.class, "MSG_DiffPanel_NoFileSelected"));
displayDiffView();
}
delegatingUndoRedo.setDiffView(diffView);
refreshComponents();
}