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


Java Mode类代码示例

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


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

示例1: findInstance

import org.openide.windows.Mode; //导入依赖的package包/类
public static synchronized AnalysisResultTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win instanceof AnalysisResultTopComponent) {
        return (AnalysisResultTopComponent) win;
    }
    if (win == null) {
        Logger.getLogger(AnalysisResultTopComponent.class.getName()).warning(
                "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
    } else {
        Logger.getLogger(AnalysisResultTopComponent.class.getName()).warning(
                "There seem to be multiple components with the '" + PREFERRED_ID +
                "' ID. That is a potential source of errors and unexpected behavior.");
    }
    
    AnalysisResultTopComponent result = new AnalysisResultTopComponent();
    Mode outputMode = WindowManager.getDefault().findMode("output");
    
    if (outputMode != null) {
        outputMode.dockInto(result);
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AnalysisResultTopComponent.java

示例2: supportsKind

import org.openide.windows.Mode; //导入依赖的package包/类
@Override
public boolean supportsKind(TopComponentDraggable transfer) {
    if( transfer.isModeTransfer() ) {
        ModeView mv = getModeView();
        Mode mode = WindowManagerImpl.getInstance().findMode( mv.getTopComponents().get( 0 ) );
        if( mode.getName().equals( transfer.getMode().getName() ) )
            return false;
    }
    if(transfer.isAllowedToMoveAnywhere()) {
        return true;
    }
    
    boolean isNonEditor = transfer.getKind() == Constants.MODE_KIND_VIEW || transfer.getKind() == Constants.MODE_KIND_SLIDING;
    boolean thisIsNonEditor = getKind() == Constants.MODE_KIND_VIEW || getKind() == Constants.MODE_KIND_SLIDING;

    return (isNonEditor == thisIsNonEditor);

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

示例3: processShortcut

import org.openide.windows.Mode; //导入依赖的package包/类
/**
 * Tries to process given <code>KeyEvent</code> and returns true is event
 * was successfully processed/consumed.
 */
public static boolean processShortcut(KeyEvent kev) {
    WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    // don't perform when focus is dialog
    if (!wmi.getMainWindow().isFocused() &&
        !WindowManagerImpl.isSeparateWindow(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow())) {
        return false;
    }

    if( Boolean.getBoolean("netbeans.winsys.ctrltab.editoronly") ) { //NOI18N
        Mode activeMode = wmi.getActiveMode();
        if( !wmi.isEditorMode(activeMode) )
            return false;
    }

    return doProcessShortcut( kev );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:KeyboardPopupSwitcher.java

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

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

示例6: attachTopComponent

import org.openide.windows.Mode; //导入依赖的package包/类
/** Uses Central.userDroppedTopComponents(ModeImpl mode, TopComponentDraggable draggable, String side)
 * to attach source TopComponent to target Mode according to sideConstant
 * value.
 * @param sourceTc source TopComponent
 * @param mode target mode
 * @param sideConstant side constant
 */
private static void attachTopComponent(TopComponent sourceTc, Mode mode, String sideConstant) {
    try {
        Class<?> centralClass = classForName("org.netbeans.core.windows.Central");
        Class<?> tcdClass = classForName("org.netbeans.core.windows.view.dnd.TopComponentDraggable");
        Class<?> modeImplClass = classForName("org.netbeans.core.windows.ModeImpl");
        Method attachMethod = centralClass.getMethod("userDroppedTopComponents", modeImplClass, tcdClass, String.class);
        Method getCentralMethod = WindowManager.getDefault().getClass().getDeclaredMethod("getCentral", (Class<?>[]) null);
        getCentralMethod.setAccessible(true);
        Object centralInstance = getCentralMethod.invoke(WindowManager.getDefault(), (Object[]) null);
        Constructor<?> tcdConstructor = tcdClass.getDeclaredConstructor(TopComponent.class);
        tcdConstructor.setAccessible(true);
        Object tcdInstance = tcdConstructor.newInstance(sourceTc);
        attachMethod.setAccessible(true);
        attachMethod.invoke(centralInstance, mode, tcdInstance, sideConstant);
    } catch (Exception e) {
        throw new JemmyException("Cannot attach TopComponent.", e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:AttachWindowAction.java

示例7: performAPI

import org.openide.windows.Mode; //导入依赖的package包/类
/** Performs Maximize Window by IDE API on given top component operator 
 * which is activated before the action.
 * @param tco top component operator which should be activated and maximized
 */
public void performAPI(final TopComponentOperator tco) {
    tco.makeComponentVisible();
    // run in dispatch thread
    tco.getQueueTool().invokeSmoothly(new Runnable() {

        @Override
        public void run() {
            WindowManager wm = WindowManager.getDefault();
            TopComponent tc = (TopComponent) tco.getSource();
            Mode mode = (Mode) wm.findMode(tc);
            if (mode == null) {
                throw new JemmyException("Mode not found for " + tc);
            }
            AttachWindowAction.callWindowManager("switchMaximizedMode", mode);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MaximizeWindowAction.java

示例8: view

import org.openide.windows.Mode; //导入依赖的package包/类
@Override
public void view(InputGraph graph, boolean clone) {
    
    if (!clone) {
        WindowManager manager = WindowManager.getDefault();
        for (Mode m : manager.getModes()) {
            for (TopComponent t : manager.getOpenedTopComponents(m)) {
                if (t instanceof EditorTopComponent) {
                    EditorTopComponent etc = (EditorTopComponent) t;
                    if (etc.getModel().getGroup().getGraphs().contains(graph)) {
                        etc.getModel().selectGraph(graph);
                        t.requestActive();
                        return;
                    }
                }
            }
        }
    }
    
    Diagram diagram = Diagram.createDiagram(graph, Settings.get().get(Settings.NODE_TEXT, Settings.NODE_TEXT_DEFAULT));
    EditorTopComponent tc = new EditorTopComponent(diagram);
    tc.open();
    tc.requestActive();
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:25,代码来源:GraphViewerImplementation.java

示例9: view

import org.openide.windows.Mode; //导入依赖的package包/类
@Override
public void view(InputGraph graph, boolean clone) {

    if (!clone) {
        WindowManager manager = WindowManager.getDefault();
        for (Mode m : manager.getModes()) {
            for (TopComponent t : manager.getOpenedTopComponents(m)) {
                if (t instanceof EditorTopComponent) {
                    EditorTopComponent etc = (EditorTopComponent) t;
                    if (etc.getModel().getGroup().getGraphs().contains(graph)) {
                        etc.getModel().selectGraph(graph);
                        t.requestActive();
                        return;
                    }
                }
            }
        }
    }

    Diagram diagram = Diagram.createDiagram(graph, Settings.get().get(Settings.NODE_TEXT, Settings.NODE_TEXT_DEFAULT));
    EditorTopComponent tc = new EditorTopComponent(diagram);
    tc.open();
    tc.requestActive();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:GraphViewerImplementation.java

示例10: availableModes

import org.openide.windows.Mode; //导入依赖的package包/类
/**
 * Allows the top component to specify a ui-list (with modes) which can be
 * docked by end user. Subclasses should override this method if they want
 * to alter docking policy of top component. So for example, by returning
 * empty list, top component refuses to be docked anywhere. Default
 * implementation allows docking anywhere by returning input list unchanged.
 *
 * @param modes
 * @return
 */
@Override
public List<Mode> availableModes(List<Mode> modes) {
    if (modes != null) {
        int size = modes.size();
        if (size > 0) {
            ArrayList<Mode> back = new ArrayList<Mode>(size);
            for (Mode single : modes) {
                String name = single.getName();
                if (name != null) {
                    // dock everywhere, except editor frame
                    if (!"editor".equals(name)) {
                        back.add(single);
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:ranSprd,项目名称:netbeans-openedFiles,代码行数:31,代码来源:OpenFilesListTopComponent.java

示例11: findEditorMode

import org.openide.windows.Mode; //导入依赖的package包/类
public final Mode findEditorMode() {
    try {
        // get a set of all available modes
        Set<? extends Mode> modes = WindowManager.getDefault().getModes();

        // make it robust
        if (modes != null) {
            for (Mode mode : modes) {
                if (mode != null) {
                    String dummy = mode.getName();
                    if (dummy != null) {
                        // we need only the <editor> mode
                        if ("editor".equals(dummy)) {
                            return mode;
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        // if any error occurs, throws null
    }
    return null;
}
 
开发者ID:ranSprd,项目名称:netbeans-openedFiles,代码行数:25,代码来源:OpenFilesModel.java

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

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

示例14: openInMode

import org.openide.windows.Mode; //导入依赖的package包/类
/**
 * Opens a top component in the given mode.
 *
 * @param topComponent The top component to open.
 * @param modeName     The mode's name.
 * @return {@code true} on success.
 */
public static boolean openInMode(TopComponent topComponent, String modeName) {
    Mode mode = WindowManager.getDefault().findMode(modeName);
    if (mode != null) {
        if (!Arrays.asList(mode.getTopComponents()).contains(topComponent)) {
            if (mode.dockInto(topComponent)) {
                topComponent.open();
                return true;
            }
        } else {
            topComponent.open();
            return true;
        }
    }
    return false;
}
 
开发者ID:GeertjanWielenga,项目名称:TiledNetBeansEditors,代码行数:23,代码来源:TileUtilities.java

示例15: open

import org.openide.windows.Mode; //导入依赖的package包/类
/** always open this top component in our special mode, if
* no mode for this component is specified yet */
public void open (Workspace workspace) {
    // do not open this component if this is dummy browser
    if (browserComponent.browserComponent == null)
        return;
    
    Workspace realWorkspace = (workspace == null)
                              ? WindowManager.getDefault().getCurrentWorkspace()
                              : workspace;
    // dock into our mode if not docked yet
    Mode mode = realWorkspace.findMode(MODE_NAME);
    if (mode == null) {
        mode = realWorkspace.createMode(
            MODE_NAME,
            NbBundle.getBundle(HtmlBrowser.class).getString("CTL_WebBrowser"),
            HtmlBrowser.class.getResource("/org/openide/resources/html/htmlView.gif")
        );
    }
    Mode tcMode = realWorkspace.findMode(this);
    if (tcMode == null)
        mode.dockInto(this);
    // behave like superclass
    super.open(workspace);
}
 
开发者ID:CharlesSkelton,项目名称:studio,代码行数:26,代码来源:HtmlBrowser.java


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