Source Code Cross Referenced for EditorStack.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) 2000, 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:         *     Cagatay Kavukcuoglu <cagatayk@acm.org> - Fix for bug 10025 - Resizing views
011:         *     should not use height ratios
012:         *******************************************************************************/package org.eclipse.ui.internal;
013:
014:        import org.eclipse.core.runtime.Assert;
015:        import org.eclipse.core.runtime.IStatus;
016:        import org.eclipse.core.runtime.Status;
017:        import org.eclipse.jface.action.IMenuManager;
018:        import org.eclipse.swt.widgets.Control;
019:        import org.eclipse.ui.IEditorReference;
020:        import org.eclipse.ui.IMemento;
021:        import org.eclipse.ui.PlatformUI;
022:        import org.eclipse.ui.internal.presentations.PresentablePart;
023:        import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
024:        import org.eclipse.ui.internal.presentations.SystemMenuPinEditor;
025:        import org.eclipse.ui.internal.presentations.SystemMenuSize;
026:        import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
027:        import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
028:        import org.eclipse.ui.internal.util.Util;
029:        import org.eclipse.ui.presentations.IPresentablePart;
030:        import org.eclipse.ui.presentations.IStackPresentationSite;
031:        import org.eclipse.ui.presentations.StackPresentation;
032:
033:        /**
034:         * Represents a tab folder of editors. This layout part container only accepts
035:         * EditorPane parts.
036:         * 
037:         * TODO: Make PartStack non-abstract and delete this class. The differences between
038:         * editors and views should be handled by the presentation or the editors/views themselves.
039:         */
040:        public class EditorStack extends PartStack {
041:
042:            private EditorSashContainer editorArea;
043:
044:            private WorkbenchPage page;
045:
046:            private SystemMenuSize sizeItem = new SystemMenuSize(null);
047:
048:            private SystemMenuPinEditor pinEditorItem = new SystemMenuPinEditor(
049:                    null);
050:
051:            public EditorStack(EditorSashContainer editorArea,
052:                    WorkbenchPage page) {
053:                super (PresentationFactoryUtil.ROLE_EDITOR);
054:                this .editorArea = editorArea;
055:                setID(this .toString());
056:                // Each folder has a unique ID so relative positioning is unambiguous.
057:                // save off a ref to the page
058:                //@issue is it okay to do this??
059:                //I think so since a ViewStack is
060:                //not used on more than one page.
061:                this .page = page;
062:            }
063:
064:            /* (non-Javadoc)
065:             * @see org.eclipse.ui.internal.PartStack#getPage()
066:             */
067:            protected WorkbenchPage getPage() {
068:                return page;
069:            }
070:
071:            public void addSystemActions(IMenuManager menuManager) {
072:                pinEditorItem = new SystemMenuPinEditor(
073:                        (EditorPane) getSelection());
074:                appendToGroupIfPossible(
075:                        menuManager,
076:                        "misc", new UpdatingActionContributionItem(pinEditorItem)); //$NON-NLS-1$
077:                sizeItem = new SystemMenuSize(getSelection());
078:                appendToGroupIfPossible(menuManager, "size", sizeItem); //$NON-NLS-1$
079:            }
080:
081:            public boolean isMoveable(IPresentablePart part) {
082:                return true;
083:            }
084:
085:            /* (non-Javadoc)
086:             * @see org.eclipse.ui.presentations.IStackPresentationSite#supportsState(int)
087:             */
088:            public boolean supportsState(int state) {
089:                if (page.isFixedLayout()) {
090:                    return false;
091:                }
092:
093:                return true;
094:            }
095:
096:            /**
097:             * Factory method for editor workbooks.
098:             */
099:            public static EditorStack newEditorWorkbook(
100:                    EditorSashContainer editorArea, WorkbenchPage page) {
101:                return new EditorStack(editorArea, page);
102:            }
103:
104:            protected void add(LayoutPart newChild, Object cookie) {
105:                super .add(newChild, cookie);
106:
107:                ((EditorPane) newChild).setWorkbook(this );
108:            }
109:
110:            /**
111:             * See IVisualContainer#add
112:             */
113:            public void add(LayoutPart child) {
114:                super .add(child);
115:
116:                if (child instanceof  EditorPane) {
117:                    ((EditorPane) child).setWorkbook(this );
118:                }
119:            }
120:
121:            protected void updateActions(PresentablePart current) {
122:                EditorPane pane = null;
123:                if (current != null && current.getPane() instanceof  EditorPane) {
124:                    pane = (EditorPane) current.getPane();
125:                }
126:
127:                sizeItem.setPane(pane);
128:                pinEditorItem.setPane(pane);
129:            }
130:
131:            public Control[] getTabList() {
132:                return getTabList(getSelection());
133:            }
134:
135:            public void removeAll() {
136:                LayoutPart[] children = getChildren();
137:
138:                for (int i = 0; i < children.length; i++) {
139:                    remove(children[i]);
140:                }
141:            }
142:
143:            public boolean isActiveWorkbook() {
144:                EditorSashContainer area = getEditorArea();
145:
146:                if (area != null) {
147:                    return area.isActiveWorkbook(this );
148:                } else {
149:                    return false;
150:                }
151:            }
152:
153:            public void becomeActiveWorkbook(boolean hasFocus) {
154:                EditorSashContainer area = getEditorArea();
155:
156:                if (area != null) {
157:                    area.setActiveWorkbook(this , hasFocus);
158:                }
159:            }
160:
161:            public EditorPane[] getEditors() {
162:                LayoutPart[] children = getChildren();
163:
164:                EditorPane[] panes = new EditorPane[children.length];
165:                for (int idx = 0; idx < children.length; idx++) {
166:                    panes[idx] = (EditorPane) children[idx];
167:                }
168:
169:                return panes;
170:            }
171:
172:            public EditorSashContainer getEditorArea() {
173:                return editorArea;
174:            }
175:
176:            /* (non-Javadoc)
177:             * @see org.eclipse.ui.internal.PartStack#canMoveFolder()
178:             */
179:            protected boolean canMoveFolder() {
180:                return true;
181:            }
182:
183:            /* (non-Javadoc)
184:             * @see org.eclipse.ui.internal.PartStack#derefPart(org.eclipse.ui.internal.LayoutPart)
185:             */
186:            protected void derefPart(LayoutPart toDeref) {
187:                EditorAreaHelper.derefPart(toDeref);
188:            }
189:
190:            /* (non-Javadoc)
191:             * @see org.eclipse.ui.internal.PartStack#allowsDrop(org.eclipse.ui.internal.PartPane)
192:             */
193:            protected boolean allowsDrop(PartPane part) {
194:                return part instanceof  EditorPane;
195:            }
196:
197:            public void setFocus() {
198:                super .setFocus();
199:                becomeActiveWorkbook(true);
200:            }
201:
202:            /* (non-Javadoc)
203:             * @see org.eclipse.ui.internal.PartStack#close(org.eclipse.ui.presentations.IPresentablePart[])
204:             */
205:            protected void close(IPresentablePart[] parts) {
206:
207:                if (parts.length == 1) {
208:                    close(parts[0]);
209:                    return;
210:                }
211:
212:                IEditorReference[] toClose = new IEditorReference[parts.length];
213:                for (int idx = 0; idx < parts.length; idx++) {
214:                    EditorPane part = (EditorPane) getPaneFor(parts[idx]);
215:                    toClose[idx] = part.getEditorReference();
216:                }
217:
218:                WorkbenchPage page = getPage();
219:
220:                if (page != null) {
221:                    page.closeEditors(toClose, true);
222:                }
223:            }
224:
225:            /* (non-Javadoc)
226:             * @see org.eclipse.ui.internal.LayoutPart#testInvariants()
227:             */
228:            public void testInvariants() {
229:                super .testInvariants();
230:
231:                int active = getActive();
232:
233:                if (active == StackPresentation.AS_ACTIVE_FOCUS) {
234:                    Assert.isTrue(isActiveWorkbook());
235:                } else if (active == StackPresentation.AS_ACTIVE_NOFOCUS) {
236:                    Assert.isTrue(isActiveWorkbook());
237:                } else if (active == StackPresentation.AS_INACTIVE) {
238:                    Assert.isTrue(!isActiveWorkbook());
239:                }
240:            }
241:
242:            /* (non-Javadoc)
243:             * @see org.eclipse.ui.internal.PartStack#restoreState(org.eclipse.ui.IMemento)
244:             */
245:            public IStatus restoreState(IMemento memento) {
246:                Integer expanded = memento
247:                        .getInteger(IWorkbenchConstants.TAG_EXPANDED);
248:                setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
249:                        : IStackPresentationSite.STATE_MINIMIZED);
250:
251:                Integer appearance = memento
252:                        .getInteger(IWorkbenchConstants.TAG_APPEARANCE);
253:                if (appearance != null) {
254:                    this .appearance = appearance.intValue();
255:                }
256:
257:                // Determine if the presentation has saved any info here
258:                savedPresentationState = null;
259:                IMemento[] presentationMementos = memento
260:                        .getChildren(IWorkbenchConstants.TAG_PRESENTATION);
261:
262:                for (int idx = 0; idx < presentationMementos.length; idx++) {
263:                    IMemento child = presentationMementos[idx];
264:
265:                    String id = child.getString(IWorkbenchConstants.TAG_ID);
266:
267:                    if (Util.equals(id, getFactory().getId())) {
268:                        savedPresentationState = child;
269:                        break;
270:                    }
271:                }
272:
273:                return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
274:            }
275:
276:            /* (non-Javadoc)
277:             * @see org.eclipse.ui.internal.PartStack#saveState(org.eclipse.ui.IMemento)
278:             */
279:            public IStatus saveState(IMemento memento) {
280:                memento
281:                        .putInteger(
282:                                IWorkbenchConstants.TAG_EXPANDED,
283:                                (getPresentationSite().getState() == IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_MINIMIZED
284:                                        : IStackPresentationSite.STATE_RESTORED);
285:
286:                memento.putInteger(IWorkbenchConstants.TAG_APPEARANCE,
287:                        appearance);
288:
289:                savePresentationState();
290:
291:                if (savedPresentationState != null) {
292:                    IMemento presentationState = memento
293:                            .createChild(IWorkbenchConstants.TAG_PRESENTATION);
294:                    presentationState.putMemento(savedPresentationState);
295:                }
296:
297:                return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
298:            }
299:
300:            /* (non-Javadoc)
301:             * @see org.eclipse.ui.internal.PartStack#setMinimized(boolean)
302:             */
303:            public void setMinimized(boolean minimized) {
304:                // 'Smart' minimize; move the editor area to the trim
305:                Perspective persp = getPage().getActivePerspective();
306:                if (Perspective.useNewMinMax(persp)) {
307:                    if (minimized) {
308:                        persp
309:                                .setEditorAreaState(IStackPresentationSite.STATE_MINIMIZED);
310:                    } else {
311:                        // First, if we're maximized then revert
312:                        if (persp.getPresentation().getMaximizedStack() != null) {
313:                            PartStack maxStack = persp.getPresentation()
314:                                    .getMaximizedStack();
315:                            if (maxStack instanceof  ViewStack) {
316:                                maxStack
317:                                        .setState(IStackPresentationSite.STATE_RESTORED);
318:                            } else if (maxStack instanceof  EditorStack) {
319:                                // We handle editor max through the perspective since it's
320:                                // shared between pages...
321:                                persp
322:                                        .setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
323:                            }
324:                        }
325:
326:                        int curState = persp.getEditorAreaState();
327:                        if (curState == IStackPresentationSite.STATE_MINIMIZED)
328:                            curState = IStackPresentationSite.STATE_RESTORED;
329:
330:                        persp.setEditorAreaState(curState);
331:                    }
332:
333:                    refreshPresentationState();
334:                    //return;
335:                }
336:
337:                super .setMinimized(minimized);
338:            }
339:
340:            /**
341:             * Changes the editor stack's state to the given one -without-
342:             * side-effects. This is used when switching perspectives because
343:             * the Editor Area is perspective based but is shared between all
344:             * perspectives...
345:             * 
346:             * @param newState The new state to set the editor stack to
347:             */
348:            public void setStateLocal(int newState) {
349:                if (newState == getState())
350:                    return;
351:
352:                //isMinimized = getState() == IStackPresentationSite.STATE_MINIMIZED;
353:                super 
354:                        .setMinimized(newState == IStackPresentationSite.STATE_MINIMIZED);
355:                presentationSite.setPresentationState(newState);
356:            }
357:
358:            /**
359:             * Cause the folder to hide or show its
360:             * Minimize and Maximize affordances.
361:             * 
362:             * @param show
363:             *            <code>true</code> - the min/max buttons are visible.
364:             * @since 3.3
365:             */
366:            public void showMinMax(boolean show) {
367:                StackPresentation pres = getPresentation();
368:                if (pres == null)
369:                    return;
370:
371:                if (pres instanceof  TabbedStackPresentation)
372:                    ((TabbedStackPresentation) pres).showMinMax(show);
373:            }
374:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.