本文整理汇总了Java中org.netbeans.core.api.multiview.MultiViewHandler.requestActive方法的典型用法代码示例。如果您正苦于以下问题:Java MultiViewHandler.requestActive方法的具体用法?Java MultiViewHandler.requestActive怎么用?Java MultiViewHandler.requestActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.core.api.multiview.MultiViewHandler
的用法示例。
在下文中一共展示了MultiViewHandler.requestActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testGetHelpCtx
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testGetHelpCtx() throws Exception {
final MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
final MVElem elem2 = new MVElem(new Action[] {new Act1("act2")} );
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
TopComponent tc = callFactory(descs, desc2);
tc.open();
HelpCtx help = tc.getHelpCtx();
MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
assertNotNull(help);
Object name = help.getHelpID();
assertEquals(desc2, Accessor.DEFAULT.extractDescription(hand.getSelectedPerspective()));
assertEquals("desc2", name);
hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
help = tc.getHelpCtx();
assertNotNull(help);
name = help.getHelpID();
assertEquals("desc1", name);
}
示例4: testGetLookup
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testGetLookup() throws Exception {
final MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
final MVElem elem2 = new MVElem(new Action[] {new Act1("act2")} );
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
TopComponent tc = callFactory(descs, desc2);
tc.open();
Object result = tc.getLookup().lookup(MVElem.class);
assertNotNull(result);
assertEquals(result, elem2);
MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
result = tc.getLookup().lookup(MVElem.class);
assertNotNull(result);
assertEquals(result, elem1);
}
示例5: testGetUndoRedo
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testGetUndoRedo() throws Exception {
final MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
UndoRedo redo = new UndoRedo.Empty();
elem1.setUndoRedo(redo);
final MVElem elem2 = new MVElem(new Action[] {new Act1("act2")} );
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
TopComponent tc = callFactory(descs, desc2);
tc.open();
UndoRedo result = tc.getUndoRedo();
MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
assertNotNull(result);
assertTrue(redo != result);
hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
result = tc.getUndoRedo();
assertFalse(redo.canRedo());
assertFalse(redo.canUndo());
}
示例6: propertyChange
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (TopComponent.Registry.PROP_TC_OPENED.equals(evt.getPropertyName())) {
final Object newValue = evt.getNewValue();
if (newValue instanceof TopComponent) {
final TopComponent opened = (TopComponent) newValue;
final FileObject moduleInfo = findModuleInfo(opened);
if (moduleInfo != null) {
final MultiViewHandler multiViewHandler = MultiViews.findMultiViewHandler(opened);
if (multiViewHandler != null) {
final MultiViewPerspective current = multiViewHandler.getSelectedPerspective();
multiViewHandler.addMultiViewDescription(
new GraphMultiViewDescription(Lookups.fixed(moduleInfo)),
-1);
multiViewHandler.requestActive(current);
}
}
}
}
}
示例7: openFormEditor
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
/** Main entry method. Called by OpenCookie implementation - opens the form.
*
* @param forceFormElement determines whether we should force switch to form element.
* @see OpenCookie#open
*/
public void openFormEditor(boolean forceFormElement) {
boolean alreadyOpened = opened.contains(this);
boolean switchToForm = forceFormElement || !alreadyOpened;
if (switchToForm) {
elementToOpen = FORM_ELEMENT_INDEX;
}
long ms = System.currentTimeMillis();
try {
showOpeningStatus("FMT_PreparingForm"); // NOI18N
multiviewTC = openCloneableTopComponent();
multiviewTC.requestActive();
registerNodeListener();
if (switchToForm) {
MultiViewHandler handler = MultiViews.findMultiViewHandler(multiviewTC);
handler.requestActive(handler.getPerspectives()[FORM_ELEMENT_INDEX]);
}
} finally {
hideOpeningStatus();
}
Logger.getLogger(FormEditor.class.getName()).log(Level.FINER, "Opening form time 1: {0}ms", (System.currentTimeMillis()-ms)); // NOI18N
}
示例8: openInAWT
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private void openInAWT() {
if (!formDataObject.isValid()) {
return;
}
if (Boolean.TRUE.equals(formDataObject.getPrimaryFile().getAttribute("nonEditableTemplate"))) { // NOI18N
String pattern = FormUtils.getBundleString("MSG_NonEditableTemplate"); // NOI18N
String message = MessageFormat.format(pattern, new Object[] {formDataObject.getNodeDelegate().getName()});
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message));
return;
}
elementToOpen = JAVA_ELEMENT_INDEX;
super.open();
// This method must be executed in AWT thread because
// otherwise multiview is opened in AWT using invokeLater
// and we don't have multiviewTC correctly set
MultiViewHandler handler = MultiViews.findMultiViewHandler(multiviewTC);
if (handler != null) {
handler.requestActive(handler.getPerspectives()[JAVA_ELEMENT_INDEX]);
// will continue in loadOpeningForm
}
}
示例9: testActions
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testActions() throws Exception {
final MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
final MVElem elem2 = new MVElem(new Action[] {new Act1("act2")} );
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
TopComponent tc = callFactory(descs, desc2);
tc.open();
tc.requestActive();
TopComponent result = TopComponent.getRegistry().getActivated();
Action[] acts = result.getActions();
assertNotNull(acts);
assertEquals("Four actions: " + Arrays.toString(acts), 4, acts.length);
assertEquals("Second is null", null, acts[1]);
assertTrue("Second from last one instance of tab switching", acts[2] instanceof EditorsAction);
assertTrue("Last one instance of spliting", acts[3] instanceof SplitAction);
Object name = acts[0].getValue(Action.NAME);
assertEquals("act2", name);
MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
// test related hack, easy establishing a connection from Desc->perspective
hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
acts = result.getActions();
assertNotNull(acts);
assertEquals(4, acts.length);
name = acts[0].getValue(Action.NAME);
assertEquals("act1", name);
}
示例10: testCreateMultiView2
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testCreateMultiView2 () throws Exception {
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, new NonClosableElem());
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, new NonClosableElem());
MultiViewDescription desc3 = new MVDesc("desc3", null, 0, new MVElem());
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
MyCloseHandler close = new MyCloseHandler();
TopComponent tc = MultiViewFactory.createMultiView(descs, desc1, close);
assertNotNull(tc);
tc.open();
// just one element as shown..
close.supposed = 1;
tc.close();
assertTrue(close.wasUsed);
tc.open();
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
handler.requestActive(handler.getPerspectives()[2]);
// 1 shall be checked - elem3 can be closed.
close.supposed = 1;
// do not allow closing..
close.canClose = false;
tc.close();
assertTrue(tc.isOpened());
handler.requestActive(handler.getPerspectives()[1]);
// 2 shall be checked.
close.supposed = 2;
// allow closing..
close.canClose = true;
tc.close();
assertTrue(!tc.isOpened());
}
示例11: 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));
}
示例12: 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));
}
示例13: testMVTCActivatedNodesOnElementChange
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testMVTCActivatedNodesOnElementChange() throws Exception {
Node[] nodes1 = new Node[] {new N("one"), new N("two")};
Node[] nodes2 = new Node[] {new N("three"), new N("four"), new N("five")};
Node[] nodes3 = new Node[] {new N("six")};
top.setActivatedNodes(nodes1);
top2.setActivatedNodes(nodes2);
top3.setActivatedNodes(nodes3);
assertEquals(TopComponent.getRegistry().getActivated(), mvtc);
// first element selected now..
Node[] ret = mvtc.getActivatedNodes();
assertNotNull(ret);
assertEquals(ret.length, 2);
MultiViewHandler handler = MultiViews.findMultiViewHandler(mvtc);
// test related hack, easy establishing a connection from Desc->perspective
handler.requestActive(Accessor.DEFAULT.createPerspective(desc2));
ret = mvtc.getActivatedNodes();
assertNotNull(ret);
assertEquals(ret.length, 3);
handler.requestActive(Accessor.DEFAULT.createPerspective(desc3));
ret = mvtc.getActivatedNodes();
assertNotNull(ret);
assertEquals(ret.length, 1);
handler.requestActive(Accessor.DEFAULT.createPerspective(desc1));
ret = mvtc.getActivatedNodes();
assertNotNull(ret);
assertEquals(ret.length, 2);
}
示例14: openAt
import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
/** Overriden from JavaEditor - opens editor at given position and ensures
* it is selected in the multiview.
*
* @param pos position
*/
public void openAt(PositionRef pos) {
elementToOpen = JAVA_ELEMENT_INDEX;
openCloneableTopComponent();
MultiViewHandler handler = MultiViews.findMultiViewHandler(multiviewTC);
handler.requestActive(handler.getPerspectives()[JAVA_ELEMENT_INDEX]);
openAt(pos, -1).getComponent().requestActive();
}
示例15: 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();
}
}