Source Code Cross Referenced for ViewStackTrimToolBar.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui workbench » org.eclipse.ui.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal;
011:
012:        import org.eclipse.jface.action.ContributionItem;
013:        import org.eclipse.jface.action.IContributionItem;
014:        import org.eclipse.jface.action.IMenuListener;
015:        import org.eclipse.jface.action.IMenuManager;
016:        import org.eclipse.jface.action.MenuManager;
017:        import org.eclipse.jface.action.ToolBarManager;
018:        import org.eclipse.swt.SWT;
019:        import org.eclipse.swt.events.SelectionAdapter;
020:        import org.eclipse.swt.events.SelectionEvent;
021:        import org.eclipse.swt.events.SelectionListener;
022:        import org.eclipse.swt.graphics.Image;
023:        import org.eclipse.swt.widgets.Menu;
024:        import org.eclipse.swt.widgets.MenuItem;
025:        import org.eclipse.swt.widgets.ToolBar;
026:        import org.eclipse.swt.widgets.ToolItem;
027:        import org.eclipse.ui.IViewReference;
028:        import org.eclipse.ui.internal.layout.TrimToolBarBase;
029:
030:        /**
031:         * @since 3.3
032:         *
033:         */
034:        public class ViewStackTrimToolBar extends TrimToolBarBase {
035:            private boolean restoreOnUnzoom = false;
036:
037:            // The orientation of the fast view pane when showing a view
038:            private int paneOrientation;
039:
040:            // The id of the part that was showing when we minimized
041:            private String selectedTabId;
042:
043:            public ViewStackTrimToolBar(String id, int curSide,
044:                    int paneOrientation, WorkbenchWindow wbw) {
045:                super (id, curSide, wbw);
046:
047:                this .paneOrientation = paneOrientation;
048:                dock(curSide);
049:            }
050:
051:            /**
052:             * Put the stack back into the presentation
053:             */
054:            protected void restoreToPresentation() {
055:                Perspective persp = wbw.getActiveWorkbenchPage()
056:                        .getActivePerspective();
057:                //FastViewManager fvMgr = persp.getFastViewManager();
058:
059:                LayoutPart part = persp.getPresentation().findPart(getId(),
060:                        null);
061:                if (part instanceof  ContainerPlaceholder) {
062:                    ViewStack stack = (ViewStack) ((ContainerPlaceholder) part)
063:                            .getRealContainer();
064:                    stack.setMinimized(false);
065:                }
066:                //fvMgr.restoreToPresentation(getId());
067:            }
068:
069:            public void initToolBarManager(final ToolBarManager mgr) {
070:                // Set up the ToolBar with a restore button
071:                IContributionItem restoreContrib = new ContributionItem() {
072:                    public void fill(ToolBar parent, int index) {
073:                        ToolItem restoreItem = new ToolItem(mgr.getControl(),
074:                                SWT.PUSH, index);
075:                        Image tbImage = WorkbenchImages
076:                                .getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART);
077:                        restoreItem.setImage(tbImage);
078:                        String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore;
079:                        restoreItem.setToolTipText(menuTip);
080:                        restoreItem
081:                                .addSelectionListener(new SelectionListener() {
082:                                    public void widgetDefaultSelected(
083:                                            SelectionEvent e) {
084:                                        restoreToPresentation();
085:                                    }
086:
087:                                    public void widgetSelected(SelectionEvent e) {
088:                                        restoreToPresentation();
089:                                    }
090:                                });
091:                    }
092:                };
093:                mgr.add(restoreContrib);
094:
095:                ShowFastViewContribution sfvc = new ShowFastViewContribution(
096:                        wbw, getId());
097:                mgr.add(sfvc);
098:
099:                // Add context menu items
100:                mgr.setContextMenuManager(new MenuManager());
101:                MenuManager menuMgr = mgr.getContextMenuManager();
102:
103:                final IContributionItem closeContrib = new ContributionItem() {
104:                    public void fill(Menu parent, int index) {
105:                        MenuItem closeItem = new MenuItem(parent, SWT.NONE,
106:                                index++);
107:                        closeItem
108:                                .setText(WorkbenchMessages.WorkbenchWindow_close);
109:                        closeItem.addSelectionListener(new SelectionAdapter() {
110:                            public void widgetSelected(SelectionEvent e) {
111:                                IViewReference selectedView = null;
112:                                if (contextToolItem != null) {
113:                                    selectedView = (IViewReference) contextToolItem
114:                                            .getData(ShowFastViewContribution.FAST_VIEW);
115:                                }
116:
117:                                if (selectedView != null) {
118:                                    WorkbenchPage page = wbw
119:                                            .getActiveWorkbenchPage();
120:                                    if (page != null) {
121:                                        page.hideView(selectedView);
122:                                    }
123:                                }
124:                            }
125:                        });
126:                    }
127:                };
128:
129:                // We have to manage the visiblity this way...?
130:                menuMgr.addMenuListener(new IMenuListener() {
131:                    public void menuAboutToShow(IMenuManager manager) {
132:                        IViewReference selectedView = null;
133:                        if (contextToolItem != null) {
134:                            selectedView = (IViewReference) contextToolItem
135:                                    .getData(ShowFastViewContribution.FAST_VIEW);
136:                        }
137:
138:                        // Only show the 'close' item if we've clicked on a view
139:                        Perspective persp = wbw.getActiveWorkbenchPage()
140:                                .getActivePerspective();
141:                        closeContrib.setVisible(selectedView != null
142:                                && persp.isCloseable(selectedView));
143:                        manager.update(true);
144:                    }
145:                });
146:
147:                menuMgr.add(closeContrib);
148:            }
149:
150:            /* (non-Javadoc)
151:             * @see org.eclipse.ui.internal.layout.TrimToolBarBase#hookControl(org.eclipse.swt.widgets.ToolBar)
152:             */
153:            public void hookControl(ToolBarManager mgr) {
154:                // Hook a drop Listener to the control
155:                // NOTE: the drop target is self-managing...it
156:                // both hooks the new target and removes it on dispose
157:                new FastViewDnDHandler(id, mgr, wbw);
158:            }
159:
160:            /**
161:             * Sets whether or not the stack gets restored on an unzoom
162:             * operation.
163:             * 
164:             * @param restoreOnUnzoom
165:             */
166:            public void setRestoreOnUnzoom(boolean restoreOnUnzoom) {
167:                this .restoreOnUnzoom = restoreOnUnzoom;
168:            }
169:
170:            public boolean restoreOnUnzoom() {
171:                return restoreOnUnzoom;
172:            }
173:
174:            /**
175:             * @param ref
176:             * @param selected
177:             */
178:            public void setIconSelection(IViewReference ref, boolean selected) {
179:                ToolItem item = ShowFastViewContribution.getItem(tbMgr
180:                        .getControl(), ref);
181:                if (item != null) {
182:                    item.setSelection(selected);
183:
184:                    if (selected) {
185:                        selectedTabId = ref.getId();
186:
187:                        // Create a 'compound' id if this is a multi-instance part
188:                        if (ref.getSecondaryId() != null)
189:                            selectedTabId = selectedTabId + ':'
190:                                    + ref.getSecondaryId();
191:                    }
192:                }
193:            }
194:
195:            /**
196:             * @return Returns the paneOrientation.
197:             */
198:            public int getPaneOrientation() {
199:                return paneOrientation;
200:            }
201:
202:            /**
203:             * Cache the tba that was on top when we were minimized
204:             * @param selectedTab The id of the PartPane for the tab 
205:             */
206:            public void setSelectedTabId(String id) {
207:                selectedTabId = id;
208:            }
209:
210:            /**
211:             * @return The id of the layout part representing the 'top' tab
212:             */
213:            public String getSelectedTabId() {
214:                return selectedTabId;
215:            }
216:
217:            /**
218:             * @param newOrientation The new orientation for the fact view display
219:             * @param wbw The currently active WorkbenchWindow
220:             */
221:            public void setOrientation(int newOrientation, WorkbenchWindow wbw) {
222:                if (newOrientation == paneOrientation)
223:                    return;
224:
225:                paneOrientation = newOrientation;
226:
227:                // If there's a fast view showing, toggle it to pick up the change
228:                if (wbw.getActivePage() instanceof  WorkbenchPage) {
229:                    WorkbenchPage wbp = (WorkbenchPage) wbw.getActivePage();
230:                    Perspective persp = wbp.getActivePerspective();
231:                    if (persp != null) {
232:                        IViewReference curRef = persp.getActiveFastView();
233:                        if (curRef != null) {
234:                            persp.setActiveFastView(null);
235:                            persp.setActiveFastView(curRef);
236:                        }
237:                    }
238:
239:                }
240:
241:            }
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.