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


Java Mode.getTopComponents方法代码示例

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


在下文中一共展示了Mode.getTopComponents方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cloneWindow

import org.openide.windows.Mode; //导入方法依赖的package包/类
static void cloneWindow(TopComponent tc) {
    if(tc instanceof TopComponent.Cloneable) {
        TopComponent clone = ((TopComponent.Cloneable)tc).cloneComponent();
        int openIndex = -1;
        Mode m = findMode(tc);
        if( null != m ) {
            TopComponent[] tcs = m.getTopComponents();
            for( int i=0; i<tcs.length; i++ ) {
                if( tcs[i] == tc ) {
                    openIndex = i + 1;
                    break;
                }
            }
            if( openIndex >= tcs.length )
                openIndex = -1;
        }
        if( openIndex >= 0 ) {
            clone.openAtTabPosition(openIndex);
        } else {
            clone.open();
        }
        clone.requestActive();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ActionUtils.java

示例2: run

import org.openide.windows.Mode; //导入方法依赖的package包/类
@Override
public void run() {
    BIG: for (Mode m : WindowManager.getDefault().getModes()) {
        boolean found = false;
        for (TopComponent topComponent : m.getTopComponents()) {
            if (topComponent instanceof DesignViewComponent) {
                found = true;
                continue;
            }
            topComponent.close();
        }
        if (!found) {
            final DesignViewComponent mc = new DesignViewComponent();
            m.dockInto(mc);
            mc.open();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DesignView.java

示例3: readOpenedWindows

import org.openide.windows.Mode; //导入方法依赖的package包/类
public final List<TopComponent> readOpenedWindows() {
    List<TopComponent> result = new ArrayList<>();
    Mode editorMode = findEditorMode();
    try {
        if (editorMode != null) {
            TopComponent comps[] = editorMode.getTopComponents();

            if (comps != null) {
                for (TopComponent single : comps) {
                    if (single != null && single.isOpened()) {
                        result.add(single);
                    }
                }
            }
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "unable to read the list of open windows", e);
    }
    return result;
}
 
开发者ID:ranSprd,项目名称:netbeans-openedFiles,代码行数:21,代码来源:OpenFilesModel.java

示例4: actionPerformed

import org.openide.windows.Mode; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent unused) {
    JEditorPane[] panes = cookie.getOpenedPanes();
    if (panes == null || panes.length == 0) {
        return;
    }
    TopComponent self = getOuterTopComponent(panes[0]);

    Mode mode = WindowManager.getDefault().findMode(self);
    if (mode == null) {
        return;
    }
    boolean close = initialClose;
    for (TopComponent tc : mode.getTopComponents()) {
        if (tc == self) {
            close = !close;
            continue;
        }
        if (close && tc.isOpened()) {
            tc.close();
        }
    }
}
 
开发者ID:AlexanderYastrebov,项目名称:nb-editor-close-left-right,代码行数:24,代码来源:ActionBase.java

示例5: propertyChange

import org.openide.windows.Mode; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (TopComponent.Registry.PROP_OPENED.equals(evt.getPropertyName())) {
        for (Mode m : WindowManager.getDefault().getModes()) {
            for (TopComponent topComponent : m.getTopComponents()) {
                if (topComponent instanceof DesignViewComponent) {
                    continue;
                }
                topComponent.close();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DesignView.java

示例6: modeNameActionPerformed

import org.openide.windows.Mode; //导入方法依赖的package包/类
private void modeNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modeNameActionPerformed
    Mode mode = WindowManager.getDefault().findMode(this);
    if (mode instanceof ModeImpl) {
        ModeImpl mi = (ModeImpl)mode;
        mi.setModeName(modeName.getText());
    }

    for (TopComponent tc : mode.getTopComponents()) {
        if (tc instanceof DesignViewComponent) {
            DesignViewComponent dvc = (DesignViewComponent)tc;
            dvc.refresh();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:DesignViewComponent.java

示例7: testActivate

import org.openide.windows.Mode; //导入方法依赖的package包/类
/**
 * Test basic behavior when Mode is activated. TC is docked into Mode, opened, activated,
 * closed. During this activation state of Mode is tested.
 */
public void testActivate () throws Exception {
    Lookup.getDefault().lookup(ModuleInfo.class);
    
    PersistenceHandler.getDefault().load();
    
    //This must be unit test as we need minimum winsys config
    //if default minimum winsys config is changed this test must be changed too.
    WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    Mode activeMode = wmi.getActiveMode();
    assertNull("No mode is activated ie. active mode must be null",activeMode);
    
    //Mode cannot be activated when it is empty
    Mode editor = wmi.getDefaultEditorMode();
    wmi.setActiveMode((ModeImpl) editor);
    activeMode = wmi.getActiveMode();
    assertNull("Ignore mode activation when mode is empty",activeMode);
    
    //Editor mode must be empty
    TopComponent [] tcs = editor.getTopComponents();
    assertEquals("Mode editor must be empty",tcs.length,0);

    //Dock TC into mode
    TopComponent tc = new TopComponent();
    
    //As tc is not yet docked into any mode this must return null
    Mode m = wmi.findMode(tc);
    assertNull("No mode for TC",m);
    
    editor.dockInto(tc);
    //Editor mode must contain one TC
    tcs = editor.getTopComponents();
    assertEquals("Mode editor must contain one TC", 1, tcs.length);
    
    //Mode cannot be activated when it does not contain opened TC
    wmi.setActiveMode((ModeImpl) editor);
    activeMode = wmi.getActiveMode();
    assertNull("Mode cannot be activated when it does not contain opened TC",activeMode);
    
    m = wmi.findMode(tc);
    assertEquals("Mode editor must be found for TC", editor, m);
    
    //TC is closed
    assertFalse("TC is closed",tc.isOpened());
    
    tc.open();
    //TC is opened
    assertTrue("TC is opened",tc.isOpened());
    tc.requestActive();
    
    //Editor mode is now activated
    activeMode = wmi.getActiveMode();
    assertEquals("Editor mode is now activated",editor,activeMode);
    
    //Check active tc
    TopComponent activeTC = wmi.getRegistry().getActivated();
    assertEquals("TC is now active",tc,activeTC);
    
    tc.close();
    //TC is closed
    assertFalse("TC is closed",tc.isOpened());
    
    //No mode is now activated
    activeMode = wmi.getActiveMode();
    assertNull("No mode is activated ie. active mode must be null", activeMode);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:70,代码来源:ModeActivationTest.java

示例8: initEditorDocuments

import org.openide.windows.Mode; //导入方法依赖的package包/类
private void initEditorDocuments() {
    elementsList = new JList() {
        @Override
        public String getToolTipText(MouseEvent event) {
            int index = locationToIndex(event.getPoint());
            if (index != -1) {
                EditorListElement element = (EditorListElement) elementsList.getModel().getElementAt(index);
                return element.fileObject.getPath();
            }
            return null;
        }
    };
    
    List<EditorListElement> elements = new ArrayList<EditorListElement>();

    WindowManager wm = WindowManager.getDefault();
    Set<? extends Mode> modes = wm.getModes();
    for (Mode mode : modes) {
        if (wm.isEditorMode(mode)) {
            TopComponent[] tcs = mode.getTopComponents();
            for (TopComponent tc : tcs) {
                Lookup lukap = tc.getLookup();
                FileObject fo = lukap.lookup(FileObject.class);
                if (fo == null) {
                    DataObject dobj = lukap.lookup(DataObject.class);
                    if (dobj != null) {
                        fo = dobj.getPrimaryFile();
                    }
                }
                if (fo != null && fo != peer) {
                    if (tc.getHtmlDisplayName() != null) {
                        elements.add(new EditorListElement(fo, tc.getHtmlDisplayName(), true));
                    } else {
                        elements.add(new EditorListElement(fo, tc.getName(), false));
                    }   
                }
            }
        }
    }

    elementsList.setListData(elements.toArray(new EditorListElement[elements.size()]));
    elementsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    elementsList.addListSelectionListener(this);
    elementsList.setCellRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (isSelected && value instanceof EditorListElement && ((EditorListElement) value).isHtml()) {
                value = stripHtml(((EditorListElement) value).toString());
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }

        private String stripHtml (String htmlText) {
            if (null == htmlText) {
                return null;
            }
            String res = htmlText.replaceAll("<[^>]*>", ""); // NOI18N // NOI18N
            res = res.replaceAll("&nbsp;", " "); // NOI18N // NOI18N
            res = res.trim();
            return res;
        }
    });

    JScrollPane sp = new JScrollPane(elementsList);
    jPanel1.add(sp);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:67,代码来源:EditorBufferSelectorPanel.java


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