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


Java MultiViewHandler类代码示例

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


MultiViewHandler类属于org.netbeans.core.api.multiview包,在下文中一共展示了MultiViewHandler类的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();
     }
 }
 
开发者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: testSourceViewMarker

import org.netbeans.core.api.multiview.MultiViewHandler; //导入依赖的package包/类
public void testSourceViewMarker() throws Exception {
    MVElem elem1 = new MVElem();
    MVElem elem2 = new MVElem();
    MVElem elem3 = new SourceMVElem();
    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;
    JEditorPane editor = pane.getEditorPane();
    assertNotNull(editor);
    
    MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
    assertFalse(desc3.equals(Accessor.DEFAULT.extractDescription(hand.getSelectedPerspective())));
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MultiViewCloneableTopComponentTest.java

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

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

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

示例7: testLookupInitializedForCloneable

import org.netbeans.core.api.multiview.MultiViewHandler; //导入依赖的package包/类
public void testLookupInitializedForCloneable() {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(10);

    CloneableTopComponent cmv = MultiViews.createCloneableMultiView("text/context", new LP(lookup));
    assertEquals("10 now", Integer.valueOf(10), cmv.getLookup().lookup(Integer.class));
    
    assertNotNull("MultiViewComponent created", cmv);
    TopComponent mvc = cmv.cloneTopComponent();
    
    assertNotNull("MultiViewComponent cloned", mvc);
    MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
    assertNotNull("Handler found", handler);
    
    assertEquals("10 now", Integer.valueOf(10), mvc.getLookup().lookup(Integer.class));
    ic.remove(10);
    ic.add(1);
    assertEquals("1 now", Integer.valueOf(1), mvc.getLookup().lookup(Integer.class));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MultiViewProcessorTest.java

示例8: 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

示例9: getContext

import org.netbeans.core.api.multiview.MultiViewHandler; //导入依赖的package包/类
private JavaSource getContext() {
    FileObject fo = Utilities.actionsGlobalContext().lookup(FileObject.class);
    if (fo == null) {
        final DataObject dobj = Utilities.actionsGlobalContext().lookup(DataObject.class);
        if (dobj != null) {
            fo = dobj.getPrimaryFile();
        }
    }
    if (fo == null) {
        return null;
    }
    TopComponent.Registry regs = WindowManager.getDefault().getRegistry();
    final TopComponent tc = regs.getActivated();
    final MultiViewHandler h = tc == null ?
            null :
            MultiViews.findMultiViewHandler(tc);
    if (h != null && FORM_VIEW_ID.equals(h.getSelectedPerspective().preferredID())) {
        //Form view does not support Members View
        return null;
    }
    return JavaSource.forFileObject(fo);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ShowMembersAction.java

示例10: openView

import org.netbeans.core.api.multiview.MultiViewHandler; //导入依赖的package包/类
/**
 * Opens the view identified by given <code>index</code>
 * and calls <code>#openDocument()</code>.
 * @param index the index of the view to be opened.
 */
void openView(final int index) {
    Utils.runInAwtDispatchThread(new Runnable() {
        public void run() {
            CloneableTopComponent mvtc = openCloneableTopComponent();
            MultiViewHandler handler = MultiViews.findMultiViewHandler(mvtc);
            handler.requestVisible(handler.getPerspectives()[index < 0 ? xmlMultiViewIndex : index]);
            mvtc.requestActive();
        }
    });
    try {
        openDocument();
    } catch (IOException ex) {
        ErrorManager.getDefault().notify(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:XmlMultiViewEditorSupport.java

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

示例12: propertyChange

import org.netbeans.core.api.multiview.MultiViewHandler; //导入依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if(Registry.PROP_ACTIVATED.equals(evt.getPropertyName())) {
        try {
            TopComponent tc =(TopComponent) evt.getNewValue();
            Lookup l = tc.getLookup();
            DataObject tcDataObject = l.lookup(DataObject.class);
            
            if (tcDataObject != null && dataObject.equals(tcDataObject)) {
                final MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
                if (handler == null || !activateHistoryTab(handler, tc)) {
                    // oops, whats this? 
                    // lets fallback on LHTC
                    tc.close();
                    openLocalHistoryTC(files);
                }
            }
        } finally {
            TopComponent.getRegistry().removePropertyChangeListener(this);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ShowHistoryAction.java

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

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

示例15: testcreateMultiViewHandler

import org.netbeans.core.api.multiview.MultiViewHandler; //导入依赖的package包/类
public void testcreateMultiViewHandler () throws Exception {
    MultiViewDescription desc1 = new MVDesc("desc1", null, 0, new MVElem());
    MultiViewDescription[] descs = new MultiViewDescription[] { desc1 };
    TopComponent tc = MultiViewFactory.createMultiView(descs, desc1);
    MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
    assertNotNull(hand);
    
    tc = new TopComponent();
    hand = MultiViews.findMultiViewHandler(tc);
    assertNull(hand);
    
    hand = MultiViews.findMultiViewHandler(null);
    assertNull(hand);

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:MultiViewsTest.java


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