当前位置: 首页>>代码示例>>Java>>正文


Java MultiViewHandler.getSelectedPerspective方法代码示例

本文整理汇总了Java中org.netbeans.core.api.multiview.MultiViewHandler.getSelectedPerspective方法的典型用法代码示例。如果您正苦于以下问题:Java MultiViewHandler.getSelectedPerspective方法的具体用法?Java MultiViewHandler.getSelectedPerspective怎么用?Java MultiViewHandler.getSelectedPerspective使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.core.api.multiview.MultiViewHandler的用法示例。


在下文中一共展示了MultiViewHandler.getSelectedPerspective方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
     }
 }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:GetLeftEditorAction.java

示例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();
     }
 }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:GetRightEditorAction.java

示例3: 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);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Install.java

示例4: updateGroupVisibility

import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private void updateGroupVisibility() {
    WindowManager wm = WindowManager.getDefault();
    final TopComponentGroup group = wm.findTopComponentGroup("ireport_jrctx"); // NOI18N
    if (group == null) {
        return; // group not found (should not happen)
    }
    //
    boolean isVisualViewSelected = false;
    Iterator it = wm.getModes().iterator();
    while (it.hasNext()) {
        Mode mode = (Mode) it.next();
        TopComponent selected = mode.getSelectedTopComponent();
        if (selected != null) {
        MultiViewHandler mvh = MultiViews.findMultiViewHandler(selected);
            if (mvh != null) {
                MultiViewPerspective mvp = mvh.getSelectedPerspective();
                if (mvp != null) {
                    String id = mvp.preferredID();
                    if (PREFERRED_ID.equals(id)) {
                        isVisualViewSelected = true;
                        break;
                    }
                }
            }
        }
    }
    //
    if (isVisualViewSelected && !Boolean.TRUE.equals(groupVisible)) {
        group.open();
    } else if (!isVisualViewSelected && !Boolean.FALSE.equals(groupVisible)) {
        group.close();
    }
    //
    groupVisible = isVisualViewSelected ? Boolean.TRUE : Boolean.FALSE;

}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:37,代码来源:JRTXVisualView.java

示例5: updateGroupVisibility

import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private void updateGroupVisibility() {
    WindowManager wm = WindowManager.getDefault();
    final TopComponentGroup group = wm.findTopComponentGroup("ireport_jrctx"); // NOI18N
    if (group == null) {
        return; // group not found (should not happen)
    }
    //
    boolean isVisualViewSelected = false;
    Iterator it = wm.getModes().iterator();
    while (it.hasNext()) {
        Mode mode = (Mode) it.next();
        TopComponent selected = mode.getSelectedTopComponent();
        if (selected != null) {
        MultiViewHandler mvh = MultiViews.findMultiViewHandler(selected);
            if (mvh != null) {
                MultiViewPerspective mvp = mvh.getSelectedPerspective();
                if (mvp != null) {
                    String id = mvp.preferredID();
                    if (JRCTXVisualView.PREFERRED_ID.equals(id)) {
                        isVisualViewSelected = true;
                        break;
                    }
                }
            }
        }
    }
    //
    if (isVisualViewSelected && !Boolean.TRUE.equals(groupVisible)) {
        group.open();
    } else if (!isVisualViewSelected && !Boolean.FALSE.equals(groupVisible)) {
        group.close();
    }
    //
    groupVisible = isVisualViewSelected ? Boolean.TRUE : Boolean.FALSE;

}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:37,代码来源:JRCTXVisualView.java

示例6: 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();
    
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:MultiViewCloneableTopComponentTest.java

示例7: 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());
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:MultiViewHandlerTest.java

示例8: testRequestActive

import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
public void testRequestActive() throws Exception {
        final MVElem elem1 = new MVElem();
        final MVElem elem2 = new MVElem();
        final 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);
        MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
        assertNotNull(hand);
        assertEquals(hand.getPerspectives().length, 3);
        
        MultiViewPerspective pers = hand.getSelectedPerspective();

        assertEquals(Accessor.DEFAULT.extractDescription(pers), 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());
        
        // test related hack, easy establishing a  connection from Desc->perspective
//        System.err.println("start caring..........................");
        hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
//        System.err.println("elem1=" + elem1.getLog());
//        System.err.println("elem2=" + elem2.getLog());
        assertEquals("componentOpened-componentShowing-componentActivated-", elem1.getLog());
        assertEquals("componentOpened-componentShowing-componentActivated-componentDeactivated-componentHidden-", elem2.getLog());
        assertEquals("",elem3.getLog());

        // do request active the same element, nothing should happen.
        // test related hack, easy establishing a  connection from Desc->perspective
        hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
        assertEquals("componentOpened-componentShowing-componentActivated-", elem1.getLog());
        assertEquals("componentOpened-componentShowing-componentActivated-componentDeactivated-componentHidden-", elem2.getLog());
        assertEquals("",elem3.getLog());
        
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:MultiViewHandlerTest.java

示例9: 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();
    
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:MultiViewTopComponentTest.java

示例10: updateGroupVisibility

import org.netbeans.core.api.multiview.MultiViewHandler; //导入方法依赖的package包/类
private void updateGroupVisibility() {
    WindowManager wm = WindowManager.getDefault();
    final TopComponentGroup group = wm.findTopComponentGroup("ireport"); // NOI18N
    if (group == null) {
        return; // group not found (should not happen)
    }
    //
    boolean isVisualViewSelected = false;
    Iterator it = wm.getModes().iterator();
    while (it.hasNext()) {
        Mode mode = (Mode) it.next();
        TopComponent selected = mode.getSelectedTopComponent();
        if (selected != null) {
        MultiViewHandler mvh = MultiViews.findMultiViewHandler(selected);
            if (mvh != null) {
                MultiViewPerspective mvp = mvh.getSelectedPerspective();
                if (mvp != null) {
                    String id = mvp.preferredID();
                    if (JrxmlVisualView.PREFERRED_ID.equals(id)) {
                        isVisualViewSelected = true;
                        break;
                    }
                }
            }
        }
    }
    //
    if (isVisualViewSelected && !Boolean.TRUE.equals(groupVisible)) {
        
        group.open();

        final TopComponent props = wm.findTopComponent("properties");
        if (props != null && props.isVisible())
        {
            try {
                props.getClass().getMethod("setNodes", new Class[]{(new Node[0]).getClass()}).invoke(props, new Object[]{getExplorerManager().getSelectedNodes()});
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

    } else if (!isVisualViewSelected && !Boolean.FALSE.equals(groupVisible)) {
        group.close();
    }
    //
    groupVisible = isVisualViewSelected ? Boolean.TRUE : Boolean.FALSE;
    
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:49,代码来源:JrxmlVisualView.java


注:本文中的org.netbeans.core.api.multiview.MultiViewHandler.getSelectedPerspective方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。