本文整理汇总了Java中org.netbeans.spi.navigator.NavigatorPanel类的典型用法代码示例。如果您正苦于以下问题:Java NavigatorPanel类的具体用法?Java NavigatorPanel怎么用?Java NavigatorPanel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NavigatorPanel类属于org.netbeans.spi.navigator包,在下文中一共展示了NavigatorPanel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cacheLastSelPanel
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/** Remembers given panel for current context type */
private void cacheLastSelPanel(final NavigatorPanel panel) {
final Collection<? extends NavigatorLookupHint> hints = curHintsRes != null ? curHintsRes.allInstances() : null;
requestProcessor.post(new Runnable() {
@Override
public void run() {
LOG.fine("cacheLastSelPanel - looking for mime");
String mime = findMimeForContext(hints);
if (mime != null) {
String className = panel.getClass().getName();
NbPreferences.forModule(NavigatorController.class).put(mime, className);
LOG.fine("cacheLastSelPanel - cached " + className + "for mime " + mime);
}
}
});
}
示例2: getLastSelPanel
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/** Finds last selected panel for current context type */
private NavigatorPanel getLastSelPanel (List<NavigatorPanel> panels, String mime) {
if (mime == null) {
return null;
}
String className = NbPreferences.forModule(NavigatorController.class).get(mime, null);
if (className == null) {
return null;
}
LOG.fine("getLastSelPanel - found cached " + className + "for mime " + mime);
for (NavigatorPanel curPanel : panels) {
if (className.equals(curPanel.getClass().getName())) {
LOG.fine("getLastSelPanel - returning cached " + className + "for mime " + mime);
return curPanel;
}
}
return null;
}
示例3: testGetProviders
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
public void testGetProviders () throws Exception {
UnitTestUtils.prepareTest(new String [] { "/org/netbeans/modules/navigator/resources/testGetProvidersLayer.xml" });
ProviderRegistry providerReg = ProviderRegistry.getInstance();
System.out.println("Asking for non-existent type...");
assertEquals(0, providerReg.getProviders("image/non_existent_type").size());
System.out.println("Asking for non-existent class...");
assertEquals(0, providerReg.getProviders("text/plain").size());
System.out.println("Asking for valid type and provider...");
Collection<? extends NavigatorPanel> result = providerReg.getProviders(MARVELOUS_DATA_TYPE);
assertEquals(1, result.size());
NavigatorPanel np = result.iterator().next();
assertTrue(np instanceof MarvelousDataTypeProvider);
MarvelousDataTypeProvider provider = (MarvelousDataTypeProvider)np;
assertEquals(MARVELOUS_DATA_TYPE_NAME, provider.getDisplayName());
}
示例4: missingNavigatorAPIHack
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
static void missingNavigatorAPIHack(
@NonNull final ActionEvent ev,
@NonNull final JavaSource context,
@NullAllowed final JTextComponent target) {
final Action openNavigator = FileUtil.getConfigObject(
"Actions/Window/org-netbeans-modules-navigator-ShowNavigatorAction.instance",
Action.class);
if (openNavigator != null) {
openNavigator.actionPerformed(ev);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
NavigatorHandler.activateNavigator();
final Collection<? extends NavigatorPanel> panels = getPanels(context);
NavigatorPanel cmp = null;
for (NavigatorPanel panel : panels) {
if (panel.getComponent().getClass() == ClassMemberPanelUI.class) {
cmp = panel;
break;
}
}
if (cmp != null) {
NavigatorHandler.activatePanel(cmp);
((ClassMemberPanelUI)cmp.getComponent()).setContext(context, target);
}
}
});
}
}
示例5: getPanels
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
private static Collection<? extends NavigatorPanel> getPanels(@NonNull final JavaSource context) {
final Collection<? extends FileObject> files = context.getFileObjects();
assert files.size() == 1;
return Lookups.forPath(
String.format(
"Navigator/Panels/%s/", //NOI18N
files.iterator().next().getMIMEType())).lookupAll(NavigatorPanel.class);
}
示例6: navigatorTCClosed
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/** Stops listening to selected nodes and active component */
private void navigatorTCClosed() {
if (panelLookupNodesResult == null || closed) {
return;
}
LOG.fine("Entering navigatorTCClosed");
curNodesRes.removeLookupListener(this);
curHintsRes.removeLookupListener(this);
panelLookupNodesResult.removeLookupListener(panelLookupListener);
curNodesRes = null;
curHintsRes = null;
synchronized (CUR_NODES_LOCK) {
curNodes = Collections.emptyList();
}
weakNodesL = Collections.emptyList();
// #113764: mem leak fix - update lookup - force ClientsLookup to free its delegates
clientsLookup.lookup(Object.class);
panelLookupWithNodes.setNodes(null);
// #104145: panelDeactivated called if needed
NavigatorPanel selPanel = navigatorTC.getSelectedPanel();
if (selPanel != null) {
selPanel.panelDeactivated();
}
lastActivatedRef = null;
currentPanels = null;
navigatorTC.setPanels(null, null);
panelLookupNodesResult = null;
LOG.fine("navigatorTCClosed: activated nodes: " + navigatorTC.getTopComponent().getActivatedNodes());
if (navigatorTC.getTopComponent().getActivatedNodes() != null) {
LOG.fine("navigatorTCClosed: clearing act nodes...");
navigatorTC.getTopComponent().setActivatedNodes(new Node[0]);
}
closed = true;
}
示例7: obtainProviders
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/**
* Shortcut for test purposes
*
* @node Nodes collection context, may be empty.
*/
List<NavigatorPanel> obtainProviders(Collection<? extends Node> nodes) {
Lookup globalContext = Utilities.actionsGlobalContext();
NavigatorLookupPanelsPolicy panelsPolicy = globalContext.lookup(NavigatorLookupPanelsPolicy.class);
Collection<? extends NavigatorLookupHint> lkpHints = globalContext.lookupAll(NavigatorLookupHint.class);
return obtainProviders(nodes, panelsPolicy, lkpHints);
}
示例8: getSelectedPanelLookup
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/** Returns lookup of selected panel or null */
private Lookup getSelectedPanelLookup () {
NavigatorPanel selPanel = navigatorTC.getSelectedPanel();
if (selPanel != null) {
Lookup panelLkp = selPanel.getLookup();
if (panelLkp != null) {
return panelLkp;
}
}
return null;
}
示例9: panelMatch
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
public boolean panelMatch(NavigatorPanel panel) {
if (panel == null) {
return false;
}
if (this.getClass().equals(panel.getClass())) {
return super.equals(panel);
}
if (delegate != null) {
return delegate.equals(panel);
} else if (panel.getDisplayName().equals(attrs.get("displayName"))) {
return initialize().equals(panel);
} else {
return false;
}
}
示例10: register
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
private void register(Element e, NavigatorPanel.Registration r) throws LayerGenerationException {
String suffix = layer(e).instanceFile("dummy", null, null, r, null).getPath().substring("dummy".length()); // e.g. /my-Panel.instance
layer(e).file(ProviderRegistry.PANELS_FOLDER + r.mimeType() + suffix).
methodvalue("instanceCreate", LazyPanel.class.getName(), "create").
instanceAttribute("delegate", NavigatorPanel.class, r, null).
position(r.position()).
bundlevalue("displayName", r.displayName()).
write();
}
示例11: setPanels
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/** Sets content of navigator to given panels, selecting given one
* @param panels List of panels
* @param select Panel to be selected, shown
*/
@Override
public void setPanels (List<? extends NavigatorPanel> panels, NavigatorPanel select) {
this.panels = panels;
int panelsCount = panels == null ? -1 : panels.size();
selectedPanel = null;
toolbarComponent = null;
// clear regular content
panelSelector.removeActionListener(panelSelectionListener);
contentArea.removeAll();
panelSelector.removeAllItems();
// no panel, so make UI look empty
if (panelsCount <= 0) {
setToEmpty();
} else {
// #63777: hide panel selector when only one panel available
holderPanel.setVisible(panelsCount != 1 || (select instanceof NavigatorPanelWithToolbar && ((NavigatorPanelWithToolbar)select).getToolbarComponent() != null));
boolean selectFound = false;
for (NavigatorPanel curPanel : panels) {
panelSelector.addItem(curPanel.getDisplayName());
if (curPanel == select) {
selectFound = true;
}
}
panelSelector.addActionListener(panelSelectionListener);
if (selectFound) {
setSelectedPanel(select);
} else {
setSelectedPanel(panels.get(0));
}
// show if was hidden
resetFromEmpty();
}
}
示例12: getProviders
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/** Finds appropriate providers for given data content type
* (similar to mime type)
* and returns list of provider classes.
*
* @return Collection of providers, which implements NavigatorPanel interface.
* Never return null, only empty List if no provider exists for given content type.
*/
public Collection<? extends NavigatorPanel> getProviders (String contentType) {
if (contentTypes2Providers == null) {
contentTypes2Providers = new HashMap<String, Collection<? extends NavigatorPanel>>(15);
}
Collection<? extends NavigatorPanel> result = contentTypes2Providers.get(contentType);
if (result == null) {
// load and instantiate provider classes
result = loadProviders(contentType);
contentTypes2Providers.put(contentType, result);
}
return result;
}
示例13: loadProviders
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
/** Returns collection of NavigatorPanels or empty collection if no provider
* exist for given content type
*/
private Collection<? extends NavigatorPanel> loadProviders (String contentType) {
String path = PANELS_FOLDER + contentType;
Lookup.Result<NavigatorPanel> result = Lookups.forPath(path).lookup(NAV_PANEL_TEMPLATE);
return result.allInstances();
}
示例14: testBugfix104145_DeactivatedNotCalled
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
public void testBugfix104145_DeactivatedNotCalled () throws Exception {
System.out.println("Testing bugfix 104145...");
InstanceContent ic = getInstanceContent();
TestLookupHint ostravskiHint = new TestLookupHint("ostravski/gyzd");
ic.add(ostravskiHint);
NavigatorTC navTC = NavigatorTC.getInstance();
NavigatorTCHandle navTCH = new NavigatorTCHandle(navTC);
try {
navTCH.open();
waitForProviders(navTC);
NavigatorPanel selPanel = navTC.getSelectedPanel();
OstravskiGyzdProvider ostravak = (OstravskiGyzdProvider) selPanel;
ostravak.resetDeactCalls();
navTCH.close();
int deact = ostravak.getPanelDeactivatedCallsCount();
assertEquals("panelDeactivated expected to be called once but called " + deact + " times.",
1, deact);
} finally {
// clean in finally block so that test doesn't affect others
navTCH.close();
ic.remove(ostravskiHint);
}
}
示例15: testBugfix80155_NotEmptyOnProperties
import org.netbeans.spi.navigator.NavigatorPanel; //导入依赖的package包/类
public void testBugfix80155_NotEmptyOnProperties () throws Exception {
System.out.println("Testing bugfix 80155, keeping content on Properties window and similar...");
InstanceContent ic = getInstanceContent();
TestLookupHint ostravskiHint = new TestLookupHint("ostravski/gyzd");
ic.add(ostravskiHint);
NavigatorTC navTC = NavigatorTC.getInstance();
NavigatorTCHandle navTCH = new NavigatorTCHandle(navTC);
try {
navTCH.open();
waitForProviders(navTC);
NavigatorPanel selPanel = navTC.getSelectedPanel();
assertNotNull("Selected panel is null", selPanel);
ic.remove(ostravskiHint);
// wait for selected node change to be applied, because changes are
// reflected with little delay
waitForChange();
// after 80155 fix, previous navigator should keep its content even when
// new component was activated, but didn't contain any activated nodes or navigator lookup hint
selPanel = navTC.getSelectedPanel();
assertNotNull("Selected panel is null", selPanel);
assertTrue("Panel class not expected", selPanel instanceof OstravskiGyzdProvider);
} finally {
// cleanup
navTCH.close();
ic.remove(ostravskiHint);
}
}