本文整理汇总了Java中org.netbeans.core.api.multiview.MultiViewHandler.getPerspectives方法的典型用法代码示例。如果您正苦于以下问题:Java MultiViewHandler.getPerspectives方法的具体用法?Java MultiViewHandler.getPerspectives怎么用?Java MultiViewHandler.getPerspectives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.core.api.multiview.MultiViewHandler
的用法示例。
在下文中一共展示了MultiViewHandler.getPerspectives方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
/** Perform the action. Sets/unsets maximzed mode. */
public void actionPerformed(java.awt.event.ActionEvent ev) {
WindowManager wm = WindowManager.getDefault();
MultiViewHandler handler = MultiViews.findMultiViewHandler(wm.getRegistry().getActivated());
if (handler != null) {
MultiViewPerspective pers = handler.getSelectedPerspective();
MultiViewPerspective[] all = handler.getPerspectives();
for (int i = 0; i < all.length; i++) {
if (pers.getDisplayName().equals(all[i].getDisplayName())) {
int newIndex = i != 0 ? i -1 : all.length - 1;
MultiViewDescription selectedDescr = Accessor.DEFAULT.extractDescription(pers);
if (selectedDescr instanceof ContextAwareDescription) {
if (((ContextAwareDescription) selectedDescr).isSplitDescription()) {
newIndex = i > 1 ? i - 2 : all.length - 1;
} else {
newIndex = i != 0 ? i - 2 : all.length - 2;
}
}
handler.requestActive(all[newIndex]);
break;
}
}
} else {
Utilities.disabledActionBeep();
}
}
示例2: actionPerformed
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
/** Perform the action. Sets/unsets maximzed mode. */
public void actionPerformed(java.awt.event.ActionEvent ev) {
WindowManager wm = WindowManager.getDefault();
MultiViewHandler handler = MultiViews.findMultiViewHandler(wm.getRegistry().getActivated());
if (handler != null) {
MultiViewPerspective pers = handler.getSelectedPerspective();
MultiViewPerspective[] all = handler.getPerspectives();
for (int i = 0; i < all.length; i++) {
if (pers.equals(all[i])) {
int newIndex = i != all.length - 1 ? i + 1 : 0;
MultiViewDescription selectedDescr = Accessor.DEFAULT.extractDescription(pers);
if (selectedDescr instanceof ContextAwareDescription) {
if (((ContextAwareDescription) selectedDescr).isSplitDescription()) {
newIndex = i != all.length - 1 ? i + 2 : 1;
} else {
newIndex = i != all.length - 2 ? i + 2 : 0;
}
}
handler.requestActive(all[newIndex]);
break;
}
}
} else {
Utilities.disabledActionBeep();
}
}
示例3: activateHistoryTab
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private boolean activateHistoryTab(final MultiViewHandler handler, final TopComponent tc) {
if (handler != null) {
MultiViewPerspective[] perspectives = handler.getPerspectives();
for (final MultiViewPerspective p : perspectives) {
if(p.preferredID().equals(HistoryTopComponent.PREFERRED_ID)) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
tc.open();
tc.requestActive();
handler.requestActive(p);
}
});
return true;
}
}
}
return false;
}
示例4: testMultiViewsCreate
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testMultiViewsCreate() {
TopComponent mvc = MultiViews.createMultiView("text/figaro", new LP(Lookup.EMPTY));
assertNotNull("MultiViewComponent created", mvc);
mvc.open();
mvc.requestActive();
MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
assertNotNull("Handler found", handler);
MultiViewPerspective[] arr = handler.getPerspectives();
assertEquals("Two perspetives found", 2, arr.length);
assertEquals("Figaro", arr[0].getDisplayName());
assertEquals("Figaro", arr[1].getDisplayName());
MultiViewDescription description = Accessor.DEFAULT.extractDescription(arr[0]);
assertTrue(description instanceof ContextAwareDescription);
assertFalse("First one is not for split", ((ContextAwareDescription)description).isSplitDescription());
description = Accessor.DEFAULT.extractDescription(arr[1]);
assertTrue(description instanceof ContextAwareDescription);
assertTrue("Second one is for split", ((ContextAwareDescription)description).isSplitDescription());
CloseH.retValue = true;
MVE.closeState = MultiViewFactory.createUnsafeCloseState("warn", new AbstractAction() {
@Override
public void actionPerformed( ActionEvent e ) {
MVE.closeState = null;
}
}, null);
assertTrue("Closed OK", mvc.close());
assertNotNull(CloseH.globalElements);
assertEquals("One handle", 1, CloseH.globalElements.length);
assertEquals("states are the same", MVE.closeState, CloseH.globalElements[0]);
}
示例5: doCheck
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private void doCheck(TopComponent mvc, InstanceContent ic) {
assertNotNull("MultiViewComponent cloned", mvc);
MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
assertNotNull("Handler found", handler);
MultiViewPerspective[] arr = handler.getPerspectives();
assertEquals("Two perspetives found", 2, arr.length);
assertEquals("Contextual", arr[0].getDisplayName());
assertEquals("Contextual", arr[1].getDisplayName());
MultiViewDescription description = Accessor.DEFAULT.extractDescription(arr[0]);
assertTrue(description instanceof ContextAwareDescription);
assertFalse("First one is not for split", ((ContextAwareDescription)description).isSplitDescription());
description = Accessor.DEFAULT.extractDescription(arr[1]);
assertTrue(description instanceof ContextAwareDescription);
assertTrue("Second one is for split", ((ContextAwareDescription)description).isSplitDescription());
assertPersistence("Always", TopComponent.PERSISTENCE_ALWAYS, mvc);
mvc.open();
mvc.requestActive();
mvc.requestVisible();
handler.requestActive(arr[0]);
assertNull("No integer now", mvc.getLookup().lookup(Integer.class));
ic.add(1);
assertEquals("1 now", Integer.valueOf(1), mvc.getLookup().lookup(Integer.class));
((MultiViewCloneableTopComponent)mvc).splitComponent(JSplitPane.HORIZONTAL_SPLIT, -1);
handler.requestActive(arr[0]);
ic.remove(1);
assertNull("No integer now", mvc.getLookup().lookup(Integer.class));
ic.add(2);
assertEquals("2 now", Integer.valueOf(2), mvc.getLookup().lookup(Integer.class));
}
示例6: testMultiViewsContextCreate
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testMultiViewsContextCreate() {
InstanceContent ic = new InstanceContent();
Lookup lookup = new AbstractLookup(ic);
TopComponent mvc = MultiViews.createMultiView("text/context", new LP(lookup));
assertNotNull("MultiViewComponent created", mvc);
MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
assertNotNull("Handler found", handler);
MultiViewPerspective[] arr = handler.getPerspectives();
assertEquals("Two perspetives found", 2, arr.length);
assertEquals("Contextual", arr[0].getDisplayName());
assertEquals("Contextual", arr[1].getDisplayName());
MultiViewDescription description = Accessor.DEFAULT.extractDescription(arr[0]);
assertTrue(description instanceof ContextAwareDescription);
assertFalse("First one is not for split", ((ContextAwareDescription)description).isSplitDescription());
description = Accessor.DEFAULT.extractDescription(arr[1]);
assertTrue(description instanceof ContextAwareDescription);
assertTrue("Second one is for split", ((ContextAwareDescription)description).isSplitDescription());
mvc.open();
mvc.requestActive();
mvc.requestVisible();
handler.requestActive(arr[0]);
assertNull("No integer now", mvc.getLookup().lookup(Integer.class));
ic.add(1);
assertEquals("1 now", Integer.valueOf(1), mvc.getLookup().lookup(Integer.class));
((MultiViewTopComponent)mvc).splitComponent(JSplitPane.HORIZONTAL_SPLIT, -1);
ic.remove(1);
handler.requestActive(arr[1]);
assertNull("No integer now", mvc.getLookup().lookup(Integer.class));
ic.add(2);
assertEquals("2 now", Integer.valueOf(2), mvc.getLookup().lookup(Integer.class));
}
示例7: 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());
}
}
示例8: 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());
}
示例9: 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;
}
}
}
}
示例10: edit
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
@Override
public void edit(Widget widget) {
Set<TopComponent> set = WindowManager.getDefault().getRegistry().getOpened();
Iterator<TopComponent> it = set.iterator();
TopComponent tableView = null;
while(it.hasNext()) {
TopComponent tmp = it.next();
if(tmp.getName().equals(topCompName)) {
tableView = tmp;
break;
}
}
if(tableView !=null) {
MultiViewHandler mvh = MultiViews.findMultiViewHandler(tableView);
MultiViewPerspective[] mp = mvh.getPerspectives();
for(MultiViewPerspective xxx : mp) {
if(table.getName().equals(xxx.preferredID())) {
mvh.requestActive(xxx);
return;
}
}
TableDataView panel = new TableDataView(table);
mvh.addMultiViewDescription(
new TableDataViewDescription(table.getName(), table.getName(), panel), 30);
panel.requestFocus();
}
}
示例11: testPersistence
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testPersistence() throws Exception {
MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
SerMVElem elem2 = new SerMVElem();
SerMVElem elem3 = new SerMVElem();
elem2.deserializeTest = "testtesttest - 2";
elem3.deserializeTest = "testtesttest - 3";
MultiViewDescription desc1 = new SerMVDesc("desc1", null, TopComponent.PERSISTENCE_NEVER, elem1);
MultiViewDescription desc2 = new SerMVDesc("desc2", null, TopComponent.PERSISTENCE_ONLY_OPENED, elem2);
MultiViewDescription desc3 = new SerMVDesc("desc3", null, TopComponent.PERSISTENCE_ALWAYS, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
SerCloseHandler close = new SerCloseHandler("serializedvalue");
TopComponent tc = callFactory(descs, desc2, close);
tc.open();
tc.requestActive();
// testing closehandler here..
tc.close();
NbMarshalledObject mars = new NbMarshalledObject(tc);
Object obj = mars.get();
assertNotNull(obj);
assertEquals(getTopComponentClass(), obj.getClass());
tc = (MultiViewCloneableTopComponent)obj;
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
MultiViewPerspective[] descsAfter = handler.getPerspectives();
assertNotNull(descsAfter);
assertEquals(2, descsAfter.length);
MultiViewPerspective selDesc = handler.getSelectedPerspective();
assertNotNull(selDesc);
assertEquals("desc2", selDesc.getDisplayName());
tc.open();
tc.requestActive();
MultiViewCloneableTopComponent mvtc = (MultiViewCloneableTopComponent)tc;
Collection cold = mvtc.getModel().getCreatedElements();
// expected number of elements is one, because the elem3 was not initialized at all..
assertEquals(1, cold.size());
// test if the deserialized instance is there..
SerMVElem elSelecto = (SerMVElem)mvtc.getModel().getActiveElement();
assertEquals("testtesttest - 2", elSelecto.deserializeTest);
assertEquals("componentOpened-componentShowing-componentActivated-", elSelecto.getLog());
//testing if closehandler was correctly deserialized..
tc.close();
}
示例12: 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());
}
示例13: testPersistence
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testPersistence() throws Exception {
MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
SerMVElem elem2 = new SerMVElem();
SerMVElem elem3 = new SerMVElem();
elem2.deserializeTest = "testtesttest - 2";
elem3.deserializeTest = "testtesttest - 3";
MultiViewDescription desc1 = new SerMVDesc("desc1", null, TopComponent.PERSISTENCE_NEVER, elem1);
MultiViewDescription desc2 = new SerMVDesc("desc2", null, TopComponent.PERSISTENCE_ONLY_OPENED, elem2);
MultiViewDescription desc3 = new SerMVDesc("desc3", null, TopComponent.PERSISTENCE_ALWAYS, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
SerCloseHandler close = new SerCloseHandler("serializedvalue");
TopComponent tc = callFactory(descs, desc2, close);
tc.open();
tc.requestActive();
// testing closehandler here..
tc.close();
NbMarshalledObject mars = new NbMarshalledObject(tc);
Object obj = mars.get();
assertNotNull(obj);
assertEquals(getTopComponentClass(), obj.getClass());
tc = (MultiViewTopComponent)obj;
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
MultiViewPerspective[] descsAfter = handler.getPerspectives();
assertNotNull(descsAfter);
assertEquals(2, descsAfter.length);
MultiViewPerspective selDesc = handler.getSelectedPerspective();
assertNotNull(selDesc);
assertEquals("desc2", selDesc.getDisplayName());
tc.open();
tc.requestActive();
MultiViewTopComponent mvtc = (MultiViewTopComponent)tc;
Collection cold = mvtc.getModel().getCreatedElements();
// expected number of elements is one, because the elem3 was not initialized at all..
assertEquals(1, cold.size());
// test if the deserialized instance is there..
SerMVElem elSelecto = (SerMVElem)mvtc.getModel().getActiveElement();
assertEquals("testtesttest - 2", elSelecto.deserializeTest);
assertEquals("componentOpened-componentShowing-componentActivated-", elSelecto.getLog());
//testing if closehandler was correctly deserialized..
tc.close();
}