Java 类org.eclipse.ui.presentations.IStackPresentationSite 实例源码

项目:skin4eclipse    文件:VSViewStackPresentation.java   
public VSViewStackPresentation(Composite parent, final IStackPresentationSite site,
        boolean showResizeCommands) {
    super(parent, site, showResizeCommands);

    if(isDetached()){
        // add listener to allow not to close detached views when ESC is pressed.
        Shell shell = parent.getShell();
        shell.addListener(SWT.Traverse, new Listener(){
            public void handleEvent(Event event) {
                if (event.type == SWT.Traverse && event.detail == SWT.TRAVERSE_ESCAPE
                        && event.keyCode == SWT.ESC && event.stateMask == SWT.NONE) {
                    if(!getPrefs().getBoolean(ThemeConstants.ESC_CLOSES_DETACHED_VIEWS)){
                        // Prevent the ESC from closing the detached views
                        // if the user has chosen that option.
                        event.doit = false;
                    }
                }
            }
        });
    }
}
项目:skin4eclipse    文件:PartListControl.java   
protected void gotoSelectedElement() {
    Object selectedElement = getSelectedElement();
    if (selectedElement == null) {
        if (!isPinned) {
            dispose();
        }
        return;
    }
    IStackPresentationSite stackPresentationSite = tabArea.getPresentation()
    .getSite();
    TabArea tabsArea = tabArea;
    IPresentablePart oldSelectedPart = tabsArea.getSelectedPart();
    IPresentablePart newSelectedPart = (IPresentablePart) selectedElement;
    //close the shell
    if (!isPinned) {
        dispose();
    }
    if (newSelectedPart == oldSelectedPart) {
        // part stack does not fire an event if the part is already selected,
        // but we should notify taberea if the *tab* for this part is not visible
        // and should be now shown
        tabsArea.selectPart(newSelectedPart);
    } else {
        stackPresentationSite.selectPart(newSelectedPart);
    }
}
项目:skin4eclipse    文件:MinimizeButton.java   
protected void paintControl(PaintEvent e, int gap, Rectangle clientArea) {
    GC gc = e.gc;
    Color color;
    if (active) {
        color = colorTextFocus;
    } else {
        color = colorTextNoFocus;
    }
    // both foreground and background the same
    gc.setBackground(color);
    if (site.getState() != IStackPresentationSite.STATE_MINIMIZED) {
        // Draw minimize icon
        int width = clientArea.width / 4;
        int height = clientArea.height / 4;
        gc.fillRectangle(clientArea.x + width + 1 + gap, clientArea.y
                + clientArea.height - height - 2 + gap, width * 2, 2);

    } else {
        // Draw restore icon
        gc.setForeground(color);
        UIUtils.drawRestoreIcon(e, gap, clientArea);
    }
}
项目:skin4eclipse    文件:MaximizeButton.java   
protected void paintControl(PaintEvent e, int gap, Rectangle clientArea) {
    GC gc = e.gc;
    Color color;
    if (active) {
        color = colorTextFocus;
    } else {
        color = colorTextNoFocus;
    }
    // both foreground and background the same
    gc.setBackground(color);
    gc.setForeground(color);

    if (site.getState() != IStackPresentationSite.STATE_MAXIMIZED) {
        // Draw maximize icon
        int width = clientArea.width / 4;
        int height = clientArea.height / 4;
        int xCoord = clientArea.x + width + 1 + gap;
        int yCoord = clientArea.y + height + 1 + gap;
        gc.fillRectangle(xCoord, yCoord, width * 2, 2);
        gc.drawRectangle(xCoord, yCoord, width * 2, height * 2);
    } else {
        // Draw restore icon
        UIUtils.drawRestoreIcon(e, gap, clientArea);
    }
}
项目:skin4eclipse    文件:VSImprovedPresentationFactory.java   
public StackPresentation createEditorPresentation(Composite parent,
        IStackPresentationSite site) {
    VSEditorStackPresentation presentation = new VSEditorStackPresentation(parent, site, true);
    synchronized(VSImprovedPresentationFactory.class){
        editorPresentations.add(presentation);
    }
    return presentation;
}
项目:skin4eclipse    文件:VSStackPresentation.java   
public void setState(int state) {
    // if closing, the action was not created
    if (minimizeAction == null) {
        return;
    }
    minimizeAction.setEnabled(state != IStackPresentationSite.STATE_MINIMIZED);
    maximizeAction.setEnabled(state != IStackPresentationSite.STATE_MAXIMIZED);
    restoreAction.setEnabled(state != IStackPresentationSite.STATE_RESTORED);
    title.setState(state);
}
项目:translationstudio8    文件:StandardEditorSystemMenu.java   
/**
 * Create the standard view menu
 * 
 * @param site the site to associate the view with
 */
public StandardEditorSystemMenu(IStackPresentationSite site) {
    restore = new SystemMenuRestore(site);
    move = new SystemMenuMove(site, getMoveMenuText(), false);
    minimize = new SystemMenuMinimize(site);
    maximize = new SystemMenuMaximize(site);
    close = new SystemMenuClose(site);
    closeOthers = new SystemMenuCloseOthers(site);
    closeAll = new SystemMenuCloseAll(site);

    { // Initialize system menu
        menuManager.add(new GroupMarker("misc")); //$NON-NLS-1$
        menuManager.add(new GroupMarker("restore")); //$NON-NLS-1$
        menuManager.add(new UpdatingActionContributionItem(restore));

        menuManager.add(move);
        menuManager.add(new GroupMarker("size")); //$NON-NLS-1$
        menuManager.add(new GroupMarker("state")); //$NON-NLS-1$
        menuManager.add(new UpdatingActionContributionItem(minimize));

        menuManager.add(new UpdatingActionContributionItem(maximize));
        menuManager.add(new Separator("close")); //$NON-NLS-1$
        menuManager.add(close);
        menuManager.add(closeOthers);
        menuManager.add(closeAll);

        site.addSystemActions(menuManager);
    } // End of system menu initialization

}
项目:tmxeditor8    文件:StandardEditorSystemMenu.java   
/**
 * Create the standard view menu
 * 
 * @param site the site to associate the view with
 */
public StandardEditorSystemMenu(IStackPresentationSite site) {
    restore = new SystemMenuRestore(site);
    move = new SystemMenuMove(site, getMoveMenuText(), false);
    minimize = new SystemMenuMinimize(site);
    maximize = new SystemMenuMaximize(site);
    close = new SystemMenuClose(site);
    closeOthers = new SystemMenuCloseOthers(site);
    closeAll = new SystemMenuCloseAll(site);

    { // Initialize system menu
        menuManager.add(new GroupMarker("misc")); //$NON-NLS-1$
        menuManager.add(new GroupMarker("restore")); //$NON-NLS-1$
        menuManager.add(new UpdatingActionContributionItem(restore));

        menuManager.add(move);
        menuManager.add(new GroupMarker("size")); //$NON-NLS-1$
        menuManager.add(new GroupMarker("state")); //$NON-NLS-1$
        menuManager.add(new UpdatingActionContributionItem(minimize));

        menuManager.add(new UpdatingActionContributionItem(maximize));
        menuManager.add(new Separator("close")); //$NON-NLS-1$
        menuManager.add(close);
        menuManager.add(closeOthers);
        menuManager.add(closeAll);

        site.addSystemActions(menuManager);
    } // End of system menu initialization

}
项目:skin4eclipse    文件:VSEditorStackPresentation.java   
public VSEditorStackPresentation(Composite parent,
        final IStackPresentationSite site, boolean showResizeCommands) {
    super(parent, site, showResizeCommands);
}
项目:skin4eclipse    文件:VSEditorStackPresentation.java   
protected void addActionsToSystemMenu(final IStackPresentationSite site) {
    mainSystemMenu = new StandardEditorMenu(this, true);
    reducedSystemMenu = new StandardEditorMenu(this, false);
}
项目:skin4eclipse    文件:VSImprovedPresentationFactory.java   
public StackPresentation createViewPresentation(Composite parent,
        IStackPresentationSite site) {
    return new VSViewStackPresentation(parent, site, true);
}
项目:skin4eclipse    文件:VSImprovedPresentationFactory.java   
public StackPresentation createStandaloneViewPresentation(Composite parent,
        IStackPresentationSite site, boolean showTitle) {
    return new VSViewStackPresentation(parent, site, true);
}
项目:skin4eclipse    文件:VSStackPresentation.java   
protected boolean isMinimized() {
    return getSite().getState() == IStackPresentationSite.STATE_MINIMIZED;
}
项目:skin4eclipse    文件:VSStackPresentation.java   
public IStackPresentationSite getSite() {
    return super.getSite();
}
项目:skin4eclipse    文件:VSViewStackPresentation.java   
protected void addActionsToSystemMenu(final IStackPresentationSite site) {
    mainSystemMenu = new StandardViewMenu(this, true);
    reducedSystemMenu = new StandardViewMenu(this, false);
}
项目:skin4eclipse    文件:PartTitle.java   
private boolean isMinimized(){
    return state == IStackPresentationSite.STATE_MINIMIZED;
}
项目:skin4eclipse    文件:ShowPartListAction.java   
public ShowPartListAction(IStackPresentationSite site){
    super();
    setId("showList");
    this.site = site;
}
项目:skin4eclipse    文件:MinimizePartAction.java   
public MinimizePartAction(IStackPresentationSite site) {
    super(site);
    setText("Mi&nimize");
}
项目:skin4eclipse    文件:MinimizePartAction.java   
public void run() {
    site.setState(IStackPresentationSite.STATE_MINIMIZED);
}
项目:skin4eclipse    文件:RestorePartAction.java   
public RestorePartAction(IStackPresentationSite site) {
    super(site);
    setText("&Restore");
}
项目:skin4eclipse    文件:RestorePartAction.java   
public void run() {
    site.setState(IStackPresentationSite.STATE_RESTORED);
}
项目:skin4eclipse    文件:AbstractPresentationAction.java   
protected AbstractPresentationAction(IStackPresentationSite site) {
    this.site = site;
}
项目:skin4eclipse    文件:MaximizePartAction.java   
public MaximizePartAction(IStackPresentationSite site) {
    super(site);
    setText("Ma&ximize");
}
项目:skin4eclipse    文件:MaximizePartAction.java   
public void run() {
    site.setState(IStackPresentationSite.STATE_MAXIMIZED);
}
项目:skin4eclipse    文件:ShowClosedPartListAction.java   
public ShowClosedPartListAction(IStackPresentationSite site){
    super();
    setId("showClosedList");
    this.site = site;
    update();
}
项目:skin4eclipse    文件:MinimizeButton.java   
public MinimizeButton(Composite parent, int style, boolean isTitle,
        IStackPresentationSite site) {
    super(parent, style, isTitle);
    this.site = site;
}
项目:skin4eclipse    文件:MaximizeButton.java   
public MaximizeButton(Composite parent, int style, boolean isTitle,
        IStackPresentationSite site) {
    super(parent, style, isTitle);
    this.site = site;
}
项目:skin4eclipse    文件:StandardViewMenu.java   
public StandardViewMenu(VSStackPresentation presentation, boolean addSystemActions) {
    menuManager = new MenuManager();
    IStackPresentationSite site = presentation.getSite();
    restore = new SystemMenuRestore(site);
    restore.setId("restore");
    UIUtils.initAction(restore);

    move = new SystemMenuMove(site, WorkbenchMessages.ViewPane_moveView, false);

    minimize = new SystemMenuMinimize(site);
    minimize.setId("minimize");
    UIUtils.initAction(minimize);

    maximize = new SystemMenuMaximize(site);
    maximize.setId("maximize");
    UIUtils.initAction(maximize);

    close = new SystemMenuClose(presentation);
    UIUtils.initAction(close);

    SystemMenuToggleTabs toggleTabs = new SystemMenuToggleTabs(presentation, isViewMenu());
    UIUtils.initAction(toggleTabs);

    SystemMenuToggleToolbar toggleToolbar = null;
    if(isViewMenu()){
        toggleToolbar = new SystemMenuToggleToolbar(presentation);
        UIUtils.initAction(toggleToolbar);

        showView = new SystemMenuShowView(presentation);
    }

    { // Initialize system menu
        menuManager.add(new Separator("misc"));
        menuManager.add(new Separator("restore"));
        menuManager.add(new UpdatingActionContributionItem(restore));

        menuManager.add(move);
        menuManager.add(new GroupMarker("size"));
        menuManager.add(new GroupMarker("state"));
        menuManager.add(new UpdatingActionContributionItem(minimize));

        menuManager.add(new UpdatingActionContributionItem(maximize));
        menuManager.add(new Separator("toggle"));
        menuManager.add(toggleTabs);
        if(isViewMenu()){
            menuManager.add(toggleToolbar);
        }
        if(isViewMenu()){
            menuManager.add(showView);
        }
        menuManager.add(new Separator("list"));
        menuManager.add(new Separator("close"));
        menuManager.appendToGroup("close", close);
        if(addSystemActions) {
            site.addSystemActions(menuManager);
        }
    } // End of system menu initialization

    if(isViewMenu()){
        sortEditorList = new SystemMenuSortTabs(presentation);
        UIUtils.initAction(sortEditorList);
        menuManager.appendToGroup("list", sortEditorList);
    }
}
项目:skin4eclipse    文件:StandardEditorMenu.java   
public StandardEditorMenu(VSStackPresentation presentation, boolean addSystemActions) {
    super(presentation, addSystemActions);
    IStackPresentationSite site = presentation.getSite();

    closeOthers = new SystemMenuCloseOthers(presentation);
    UIUtils.initAction(closeOthers);

    closeOthersL = new SystemMenuCloseLeftRight(presentation, true);
    UIUtils.initAction(closeOthersL);

    closeOthersR = new SystemMenuCloseLeftRight(presentation, false);
    UIUtils.initAction(closeOthersR);

    closeAll = new SystemMenuCloseAll(presentation);
    UIUtils.initAction(closeAll);

    if(addSystemActions) {
        openAgain = ActionFactory.NEW_EDITOR.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
        openAgain.setId("openAgain");
        UIUtils.initAction(openAgain);
    }

    openUnnamedEditor = new OpenUnnamedEditorAction();

    pathToClipboard = new CopyPathToClipboardAction();
    UIUtils.initAction(pathToClipboard);

    allPathToClipboard = new CopyAllPathsToClipboardAction();
    UIUtils.initAction(allPathToClipboard);

    showClosedEditorList = new ShowClosedPartListAction(site);
    UIUtils.initAction(showClosedEditorList);
    menuManager.appendToGroup("list", showClosedEditorList);

    sortEditorList = new SystemMenuSortTabs(presentation);
    UIUtils.initAction(sortEditorList);
    menuManager.appendToGroup("list", sortEditorList);

    ShowPartListAction showEditorList = new ShowPartListAction(site);
    UIUtils.initAction(showEditorList);
    menuManager.insertBefore("showClosedList", showEditorList);

    SystemMenuSave saveList = new SystemMenuSave(presentation);
    menuManager.insertBefore("showList", saveList);

    menuManager.appendToGroup("close", closeOthersL);
    menuManager.appendToGroup("close", closeOthersR);
    menuManager.appendToGroup("close", closeOthers);
    menuManager.appendToGroup("close", closeAll);
    menuManager.add(new Separator());
    menuManager.add(pathToClipboard);
    menuManager.add(allPathToClipboard);
    menuManager.add(new Separator());
    if(addSystemActions){
        menuManager.add(openAgain);
    }
    menuManager.add(openUnnamedEditor);
}
项目:skin4eclipse    文件:TestBug128455.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    Point size = window.getShell().getSize();
    /*
     * wide enough to be able to resize views, hight enough to paint tabs + toolbars
     */
    size.x = 1050;
    size.y = 220;
    window.getShell().setSize(size);
    IWorkbenchPage activePage = window.getActivePage();

    activePage.closeAllPerspectives(false, false);
    activePage.setPerspective(PlatformUI.getWorkbench().getPerspectiveRegistry()
            .findPerspectiveWithId("EclipseSkins-test.perspective1"));
    display.update();

    for (String id : MyPerspectiveFactory.ALL) {
        IViewPart part = activePage.showView(id);
        activePage.activate(part);
        display.update();
        if (id.equals(CONSOLE_ID)) {
            console = part;
            /*
             * get console IPresentablePart
             */
            Method method2 = StackPresentation.class.getDeclaredMethod("getSite",
                    (Class[]) null);
            method2.setAccessible(true);
            StackPresentation pres = ((ViewStack) ((ViewSite) console.getSite())
                    .getPane().getStack()).getTestPresentation();
            IStackPresentationSite tlSite = (IStackPresentationSite) method2.invoke(
                    pres, (Object[]) null);
            consolePresPart = tlSite.getSelectedPart();
        }
    }

    Platform.getJobManager().cancel(null);
    Platform.getJobManager().suspend();
    display.update();
}
项目:translationstudio8    文件:UnOpenAgainEditorPresentationFactory.java   
public StackPresentation createEditorPresentation(Composite parent,
        IStackPresentationSite site) {
    DefaultTabFolder folder = new DefaultTabFolder(parent,
            editorTabPosition | SWT.BORDER, site
                    .supportsState(IStackPresentationSite.STATE_MINIMIZED),
            site.supportsState(IStackPresentationSite.STATE_MAXIMIZED));

    /*
     * Set the minimum characters to display, if the preference is something
     * other than the default. This is mainly intended for RCP applications
     * or for expert users (i.e., via the plug-in customization file).
     * 
     * Bug 32789.
     */
    final IPreferenceStore store = PlatformUI.getPreferenceStore();
    if (store
            .contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) {
        final int minimumCharacters = store
                .getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS);
        if (minimumCharacters >= 0) {
            folder.setMinimumCharacters(minimumCharacters);
        }
    }

    PresentablePartFolder partFolder = new PresentablePartFolder(folder);

    TabbedStackPresentation result = new TabbedStackPresentation(site,
            partFolder, new StandardEditorSystemMenu(site));

    DefaultThemeListener themeListener = new DefaultThemeListener(folder,
            result.getTheme());
    result.getTheme().addListener(themeListener);

    new DefaultMultiTabListener(result.getApiPreferences(),
            IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder);

    new DefaultSimpleTabListener(result.getApiPreferences(),
            IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
            folder);

    return result;
}
项目:tmxeditor8    文件:UnOpenAgainEditorPresentationFactory.java   
public StackPresentation createEditorPresentation(Composite parent,
        IStackPresentationSite site) {
    DefaultTabFolder folder = new DefaultTabFolder(parent,
            editorTabPosition | SWT.BORDER, site
                    .supportsState(IStackPresentationSite.STATE_MINIMIZED),
            site.supportsState(IStackPresentationSite.STATE_MAXIMIZED));

    /*
     * Set the minimum characters to display, if the preference is something
     * other than the default. This is mainly intended for RCP applications
     * or for expert users (i.e., via the plug-in customization file).
     * 
     * Bug 32789.
     */
    final IPreferenceStore store = PlatformUI.getPreferenceStore();
    if (store
            .contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) {
        final int minimumCharacters = store
                .getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS);
        if (minimumCharacters >= 0) {
            folder.setMinimumCharacters(minimumCharacters);
        }
    }

    PresentablePartFolder partFolder = new PresentablePartFolder(folder);

    TabbedStackPresentation result = new TabbedStackPresentation(site,
            partFolder, new StandardEditorSystemMenu(site));

    DefaultThemeListener themeListener = new DefaultThemeListener(folder,
            result.getTheme());
    result.getTheme().addListener(themeListener);

    new DefaultMultiTabListener(result.getApiPreferences(),
            IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder);

    new DefaultSimpleTabListener(result.getApiPreferences(),
            IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
            folder);

    return result;
}
项目:skin4eclipse    文件:VSStackPresentation.java   
protected abstract void addActionsToSystemMenu(final IStackPresentationSite site);