本文整理汇总了Java中org.netbeans.core.api.multiview.MultiViewHandler.requestVisible方法的典型用法代码示例。如果您正苦于以下问题:Java MultiViewHandler.requestVisible方法的具体用法?Java MultiViewHandler.requestVisible怎么用?Java MultiViewHandler.requestVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.core.api.multiview.MultiViewHandler
的用法示例。
在下文中一共展示了MultiViewHandler.requestVisible方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testActionMapChanges
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testActionMapChanges() throws Exception {
MVElemTopComponent elem1 = new MVElemTopComponent();
MVElemTopComponent elem2 = new MVElemTopComponent();
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs, desc1);
// WARNING: as anything else the first element's action map is set only after the tc is opened..
Lookup.Result result = tc.getLookup().lookup(new Lookup.Template(ActionMap.class));
LookListener list = new LookListener();
list.resetCount();
result.addLookupListener(list);
result.allItems();
tc.open();
assertEquals(1, list.getCount());
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
// test related hack, easy establishing a connection from Desc->perspective
Accessor.DEFAULT.createPerspective(desc2);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc2));
assertEquals(2, list.getCount());
Accessor.DEFAULT.createPerspective(desc3);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
assertEquals(3, list.getCount());
}
示例2: testActionMapChangesForElementsWithComponentShowingInit
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testActionMapChangesForElementsWithComponentShowingInit() throws Exception {
Action act1 = new TestAction("MultiViewAction1");
Action act2 = new TestAction("MultiViewAction2");
MVElemTopComponent elem1 = new ComponentShowingElement("testAction", act1);
MVElemTopComponent elem2 = new ComponentShowingElement("testAction", act2);
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs, desc1);
Lookup.Result result = tc.getLookup().lookup(new Lookup.Template(ActionMap.class));
LookListener2 list = new LookListener2();
result.addLookupListener(list);
result.allInstances().size();
list.setCorrectValues("testAction", act1);
// WARNING: as anything else the first element's action map is set only after the tc is opened..
tc.open();
assertEquals(1, list.getCount());
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
// test related hack, easy establishing a connection from Desc->perspective
Accessor.DEFAULT.createPerspective(desc2);
list.setCorrectValues("testAction", act2);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc2));
assertEquals(2, list.getCount());
Accessor.DEFAULT.createPerspective(desc3);
list.setCorrectValues("testAction", null);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
assertEquals(3, list.getCount());
}
示例3: doToolbarCheck
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private void doToolbarCheck(int select) throws Exception {
CloneableTopComponent tc = MultiViews.createCloneableMultiView("text/toolbar", this);
tc.open();
assertVisible("MultiView visible", tc);
assertEquals("One toolbar exists: " + MVE.allToolbars, 1, MVE.allToolbars.size());
MultiViewHandler handle = MultiViews.findMultiViewHandler(tc);
final MultiViewPerspective[] perspectives = handle.getPerspectives();
assertEquals("Four perspectives", 4, perspectives.length);
handle.requestVisible(perspectives[2]);
assertEquals("two toolbars exist", 2, MVE.allToolbars.size());
for (int i = 0; i < 2; i++) {
handle.requestVisible(perspectives[i == 0 ? i : i + 1]);
assertVisible("Toolbar is showing(" + i +")", MVE.allToolbars.get(i));
}
handle.requestVisible(perspectives[select]);
W waiter = new W();
editorSettingsPreferences.addPreferenceChangeListener(waiter);
editorSettingsPreferences.putBoolean("toolbarVisible", false);
waiter.waitThree();
for (int i = 0; i < 2; i++) {
handle.requestVisible(perspectives[i == 0 ? i : i + 1]);
assertFalse("No Toolbar is showing anymore", MVE.allToolbars.get(i).isShowing());
}
}
示例4: testUpdateTitle
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testUpdateTitle() throws Exception {
MVElem elem1 = new MVElem();
MVElem elem2 = new MVElem();
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs, desc2);
tc.open();
assertEquals(null, tc.getDisplayName());
elem2.observer.updateTitle("test1");
assertEquals("test1", tc.getDisplayName());
// switch to desc3 to initilize the element..
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
// test related hack, easy establishing a connection from Desc->perspective
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
elem3.observer.updateTitle("test2");
assertEquals("test2", tc.getDisplayName());
}
示例5: testLookupProvidersAreConsistent
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testLookupProvidersAreConsistent() throws Exception {
InstanceContent ic = new InstanceContent();
Lookup context = new AbstractLookup(ic);
CloneableEditorSupport ces = createSupport(context);
ic.add(ces);
ic.add(10);
final CloneableTopComponent tc = MultiViews.createCloneableMultiView("text/plaintest", new LP(context));
final CloneableEditorSupport.Pane p = (CloneableEditorSupport.Pane) tc;
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
tc.open();
tc.requestActive();
p.updateName();
}
});
assertNull("No icon yet", tc.getIcon());
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
final MultiViewPerspective[] one = handler.getPerspectives();
assertEquals("Two elements only" + Arrays.asList(one), 2, handler.getPerspectives().length);
assertEquals("First one is source", "source", one[0].preferredID());
assertEquals("Second one is also source", "source", one[1].preferredID());
handler.requestVisible(one[0]);
List<Lookup.Provider> arr = new ArrayList<Provider>();
findProviders(tc, arr);
assertEquals("Two providers: " + arr, 2, arr.size());
assertSame("Both return same lookup", arr.get(0).getLookup(), arr.get(1).getLookup());
}
示例6: showArtifactViewer
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private static void showArtifactViewer(NBVersionInfo info, Artifact artifact, List<ArtifactRepository> repos, String panelHint) {
ArtifactViewerFactory fact = Lookup.getDefault().lookup(ArtifactViewerFactory.class);
if (fact == null) {
Logger.getLogger(ArtifactViewer.class.getName()).info("No implementation of ArtifactViewerFactory available.");
return;
}
Lookup l;
if (info != null) {
l = fact.createLookup(info);
} else {
l = fact.createLookup(artifact, repos);
}
TopComponent tc = fact.createTopComponent(l);
tc.open();
tc.requestActive();
if (panelHint != null) {
MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
if (hand == null) {
return;
}
for (MultiViewPerspective pers : hand.getPerspectives()) {
if (panelHint.equals(pers.preferredID())) {
hand.requestVisible(pers);
return;
}
}
}
}
示例7: testUpdateNameTellsAll
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testUpdateNameTellsAll() throws Exception {
class P extends CloneableEditor {
int cnt;
boolean used;
@Override
public void updateName() {
cnt++;
}
}
final P edit1 = new P();
final P edit2 = new P();
final P edit3 = new P();
MVElem elem1 = new MVElem() {
@Override
public JComponent getVisualRepresentation() {
edit1.used = true;
return edit1;
}
};
MVElem elem2 = new MVElem() {
@Override
public JComponent getVisualRepresentation() {
edit2.used = true;
return edit2;
}
};
MVElem elem3 = new SourceMVElem() {
@Override
public JComponent getVisualRepresentation() {
edit3.used = true;
return edit3;
}
};
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new SourceMVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
CloneableTopComponent tc = MultiViewFactory.createCloneableMultiView(descs, desc1);
tc.open();
tc.requestActive();
CloneableEditorSupport.Pane pane = (CloneableEditorSupport.Pane)tc;
assertTrue("First one is used", edit1.used);
assertFalse("Second one is not used", edit2.used);
assertFalse("Third one is not used", edit3.used);
edit1.cnt = 0;
edit2.cnt = 0;
edit3.cnt = 0;
pane.updateName();
assertTrue("First one is used (obviously)", edit1.used);
assertFalse("Second one is still not used", edit2.used);
assertTrue("Third one is now used", edit3.used);
assertEquals("Update name called on first as it is used", 1, edit1.cnt);
assertEquals("Update name called on third as it marked", 1, edit3.cnt);
assertEquals("No call to 2nd one", 0, edit2.cnt);
MultiViewHandler h = MultiViews.findMultiViewHandler(tc);
h.requestActive(h.getPerspectives()[1]);
h.requestVisible(h.getPerspectives()[1]);
edit1.cnt = 0;
edit2.cnt = 0;
edit3.cnt = 0;
pane.updateName();
assertTrue("1st is used", edit1.used);
assertTrue("2nd is used", edit2.used);
assertTrue("3rd is now used", edit3.used);
assertEquals("All updateName called: 1st", 1, edit1.cnt);
assertEquals("All updateName called: 2nd", 1, edit2.cnt);
assertEquals("All updateName called: 3rd", 1, edit3.cnt);
}
示例8: testRequestVisible
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testRequestVisible() throws Exception {
MVElem elem1 = new MVElem();
MVElem elem2 = new MVElem();
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs, desc1);
MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
assertNotNull(hand);
assertEquals(hand.getPerspectives().length, 3);
MultiViewPerspective pers = hand.getSelectedPerspective();
assertEquals(Accessor.DEFAULT.extractDescription(pers), desc1);
// NOT OPENED YET.
assertEquals("",elem1.getLog());
assertEquals("",elem2.getLog());
tc.open();
assertEquals("componentOpened-componentShowing-", elem1.getLog());
assertEquals("",elem2.getLog());
// test related hack, easy establishing a connection from Desc->perspective
hand.requestVisible(Accessor.DEFAULT.createPerspective(desc2));
assertEquals(Accessor.DEFAULT.extractDescription(hand.getSelectedPerspective()), desc2);
assertEquals("componentOpened-componentShowing-componentHidden-", elem1.getLog());
assertEquals("componentOpened-componentShowing-", elem2.getLog());
assertEquals("", elem3.getLog());
// test related hack, easy establishing a connection from Desc->perspective
hand.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
assertEquals("componentOpened-componentShowing-componentHidden-", elem1.getLog());
assertEquals("componentOpened-componentShowing-componentHidden-", elem2.getLog());
assertEquals("componentOpened-componentShowing-", elem3.getLog());
// test related hack, easy establishing a connection from Desc->perspective
hand.requestVisible(Accessor.DEFAULT.createPerspective(desc1));
assertEquals("componentOpened-componentShowing-componentHidden-", elem3.getLog());
assertEquals("componentOpened-componentShowing-componentHidden-componentShowing-", elem1.getLog());
}
示例9: testIconIsAlwaysTakenFromSourceView
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testIconIsAlwaysTakenFromSourceView() throws Exception {
InstanceContent ic = new InstanceContent();
Lookup lkp = new AbstractLookup(ic);
ic.add(MultiViewEditorElementTest.createSupport(lkp));
final CloneableTopComponent tc = MultiViews.createCloneableMultiView("text/plaintest", new LP(lkp));
final CloneableEditorSupport.Pane p = (CloneableEditorSupport.Pane) tc;
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
p.updateName();
}
});
assertNull("No icon yet", tc.getIcon());
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
final MultiViewPerspective[] two = handler.getPerspectives();
assertEquals("Two elements only" + Arrays.asList(two), 2, handler.getPerspectives().length);
assertEquals("First one is source", "source", two[0].preferredID());
MultiViewDescription description = Accessor.DEFAULT.extractDescription(two[0]);
assertTrue(description instanceof ContextAwareDescription);
assertFalse("First one is not for split", ((ContextAwareDescription)description).isSplitDescription());
assertEquals("Second one is source", "source", two[1].preferredID());
description = Accessor.DEFAULT.extractDescription(two[1]);
assertTrue(description instanceof ContextAwareDescription);
assertTrue("Second one is for split", ((ContextAwareDescription)description).isSplitDescription());
handler.requestVisible(two[0]);
class P implements PropertyChangeListener {
int cnt;
@Override
public void propertyChange(PropertyChangeEvent evt) {
cnt++;
}
}
P listener = new P();
tc.addPropertyChangeListener("icon", listener);
BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_BYTE_GRAY);
ic.add(img);
assertEquals("One change in listener", 1, listener.cnt);
assertEquals("Image changed", img, tc.getIcon());
ic.remove(img);
assertEquals("Second change in listener", 2, listener.cnt);
assertNull("No icon again", tc.getIcon());
((MultiViewCloneableTopComponent)tc).splitComponent(JSplitPane.HORIZONTAL_SPLIT, -1);
handler.requestVisible(two[1]);
ic.add(img);
assertEquals("Third change in listener", 3, listener.cnt);
assertEquals("Image changed", img, tc.getIcon());
ic.remove(img);
assertEquals("Forth change in listener", 4, listener.cnt);
assertNull("No icon again", tc.getIcon());
}
示例10: testRequestVisible
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testRequestVisible() throws Exception {
MVElem elem1 = new MVElem();
MVElem elem2 = new MVElem();
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs, desc1);
// NOT OPENED YET.
assertEquals("",elem1.getLog());
assertEquals("",elem2.getLog());
tc.open();
assertEquals("componentOpened-componentShowing-", elem1.getLog());
assertEquals("",elem2.getLog());
// initilize the elements..
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
// test related hack, easy establishing a connection from Desc->perspective
Accessor.DEFAULT.createPerspective(desc2);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc2));
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc1));
elem1.resetLog();
elem2.resetLog();
elem3.resetLog();
elem2.doRequestVisible();
assertEquals("componentHidden-", elem1.getLog());
assertEquals("componentShowing-", elem2.getLog());
assertEquals("", elem3.getLog());
elem3.doRequestVisible();
assertEquals("componentHidden-", elem1.getLog());
assertEquals("componentShowing-componentHidden-", elem2.getLog());
assertEquals("componentShowing-", elem3.getLog());
elem1.doRequestVisible();
assertEquals("componentShowing-componentHidden-", elem3.getLog());
assertEquals("componentHidden-componentShowing-", elem1.getLog());
}
示例11: testRequestActive
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testRequestActive() throws Exception {
MVElem elem1 = new MVElem();
MVElem elem2 = new MVElem();
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs, desc2);
// NOT OPENED YET.
assertEquals("",elem1.getLog());
assertEquals("",elem2.getLog());
tc.open();
tc.requestActive();
assertEquals("",elem1.getLog());
assertEquals("componentOpened-componentShowing-componentActivated-", elem2.getLog());
assertEquals("",elem3.getLog());
// initilize the elements..
// test related hack, easy establishing a connection from Desc->perspective
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc1));
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
handler.requestActive(Accessor.DEFAULT.createPerspective(desc2));
elem1.resetLog();
elem2.resetLog();
elem3.resetLog();
// System.err.println("start Caring.........................");
elem1.doRequestActive();
// System.err.println("elem1=" + elem1.getLog());
// System.err.println("elem2=" + elem2.getLog());
assertEquals("componentShowing-componentActivated-", elem1.getLog());
assertEquals("componentDeactivated-componentHidden-", elem2.getLog());
assertEquals("",elem3.getLog());
// do request active the same component, nothing should happen.
elem1.doRequestActive();
assertEquals("componentShowing-componentActivated-", elem1.getLog());
assertEquals("componentDeactivated-componentHidden-", elem2.getLog());
assertEquals("",elem3.getLog());
}
示例12: testUndoRedo
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testUndoRedo() throws Exception {
UndoRedoImpl redo1 = new UndoRedoImpl();
redo1.undo = false;
UndoRedoImpl redo2 = new UndoRedoImpl();
redo2.redo = false;
ChangeListenerImpl changeList = new ChangeListenerImpl();
MVElem elem1 = new MVElem();
elem1.setUndoRedo(redo1);
MVElem elem2 = new MVElem();
elem2.setUndoRedo(redo2);
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs, desc2);
UndoRedo result = tc.getUndoRedo();
assertNotNull(result);
assertFalse(result.canRedo());
assertTrue(result.canUndo());
result.addChangeListener(changeList);
assertEquals(1, redo2.listeners.size());
tc.open();
tc.requestActive();
assertEquals(0, changeList.count);
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc1));
assertTrue(result.canRedo());
assertFalse(result.canUndo());
assertEquals(1, redo1.listeners.size());
assertEquals(0, redo2.listeners.size());
assertEquals(1, changeList.count);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
assertFalse(result.canRedo());
assertFalse(result.canUndo());
assertEquals(0, redo2.listeners.size());
assertEquals(0, redo1.listeners.size());
assertEquals(2, changeList.count);
}