Source Code Cross Referenced for WindowManager.java in  » IDE-Netbeans » openide » org » openide » windows » 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 Netbeans » openide » org.openide.windows 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.openide.windows;
043:
044:        import java.awt.EventQueue;
045:        import java.awt.Frame;
046:        import java.awt.Image;
047:        import java.awt.Window;
048:        import java.beans.PropertyChangeListener;
049:        import java.io.Serializable;
050:        import java.lang.ref.Reference;
051:        import java.lang.ref.WeakReference;
052:        import java.util.Set;
053:        import java.util.logging.Level;
054:        import java.util.logging.Logger;
055:        import javax.swing.SwingUtilities;
056:        import org.openide.nodes.Node;
057:        import org.openide.util.Lookup;
058:
059:        /**
060:         * Manages window system.
061:         * Allows the work with window system components, i.e. <code>Mode</code>s, <code>TopComponentGroup</code>s
062:         * and provides handling of operations provided over <code>TopComponent</code>s.
063:         * <p><p>
064:         * <b><font color="red"><em>Important note: Do not provide implementation of this abstract class unless you are window system provider!</em></font></b>
065:         *
066:         * @author Jaroslav Tulach
067:         */
068:        public abstract class WindowManager extends Object implements 
069:                Serializable {
070:            /** property change of workspaces.
071:             * @deprecated Do not use. Workspaces are not supported anymore. */
072:            @Deprecated
073:            public static final String PROP_WORKSPACES = "workspaces"; // NOI18N
074:
075:            /** property change of current workspace.
076:             * @deprecated Do not use. Workspaces are not supported anymore.
077:             */
078:            @Deprecated
079:            public static final String PROP_CURRENT_WORKSPACE = "currentWorkspace"; // NOI18N
080:
081:            /** Name of property for modes in the workspace.
082:             * @since 4.13 */
083:            public static final String PROP_MODES = "modes"; // NOI18N
084:
085:            /** Instance of dummy window manager. */
086:            private static WindowManager dummyInstance;
087:            static final long serialVersionUID = -4133918059009277602L;
088:
089:            /** The top component which is currently active */
090:            private Reference<TopComponent> activeComponent = new WeakReference<TopComponent>(
091:                    null);
092:
093:            /** the registry */
094:            private TopComponent.Registry registry;
095:
096:            /** Singleton instance accessor method for window manager. Provides entry
097:             * point for further work with window system API of the system.
098:             *
099:             * @return instance of window manager installed in the system
100:             * @since 2.10
101:             */
102:            public static final WindowManager getDefault() {
103:                WindowManager wmInstance = Lookup.getDefault().lookup(
104:                        WindowManager.class);
105:
106:                return (wmInstance != null) ? wmInstance : getDummyInstance();
107:            }
108:
109:            private static synchronized WindowManager getDummyInstance() {
110:                if (dummyInstance == null) {
111:                    dummyInstance = new DummyWindowManager();
112:                }
113:
114:                return dummyInstance;
115:            }
116:
117:            /** Finds mode of specified name.
118:             * @return <code>Mode</code> whith the specified name is or <code>null</code>
119:             *          if there does not exist such <code>Mode</code> inside window system.
120:             * @since 4.13 */
121:            public abstract Mode findMode(String name);
122:
123:            /** Finds mode which contains specified <code>TopComponent</code>.
124:             * @return <code>Mode</code> which contains specified <code>TopComponent</code> or <code>null</code>
125:             *          if the <code>TopComponent</code> is not added into any <code>Mode</code> inside window system.
126:             * @since 4.13 */
127:            public abstract Mode findMode(TopComponent tc);
128:
129:            /** Gets set of all <code>Mode</code>S added into window system.
130:             * @since 4.13 */
131:            public abstract Set<? extends Mode> getModes();
132:
133:            /**
134:             * Gets the NetBeans Main Window.
135:             * This should ONLY be used for:
136:             * <UL>
137:             *   <LI>using the Main Window as the parent for dialogs</LI>
138:             *   <LI>using the Main Window's position for preplacement of windows</LI>
139:             * </UL>
140:             * @return the Main Window
141:             */
142:            public abstract Frame getMainWindow();
143:
144:            /** Called after a Look&amp;Feel change to update the NetBeans UI.
145:             * Should call {@link javax.swing.JComponent#updateUI} on all opened windows.
146:             */
147:            public abstract void updateUI();
148:
149:            /** Create a component manager for the given top component.
150:             * @param c the component
151:             * @return the manager to handle opening, closing and selecting the component
152:             */
153:            protected abstract WindowManager.Component createTopComponentManager(
154:                    TopComponent c);
155:
156:            /** Access method for registry of all components in the system.
157:             * @return the registry
158:             */
159:            protected TopComponent.Registry componentRegistry() {
160:                return Lookup.getDefault().lookup(TopComponent.Registry.class);
161:            }
162:
163:            /** Getter for component registry.
164:             * @return the registry
165:             */
166:            public synchronized TopComponent.Registry getRegistry() {
167:                if (registry != null) {
168:                    return registry;
169:                }
170:
171:                registry = componentRegistry();
172:
173:                return registry;
174:            }
175:
176:            /** Creates new workspace.
177:             * @param name the name of the workspace
178:             * @return new workspace
179:             * @deprecated Do not use. Workspaces are not supported anymore. */
180:            @Deprecated
181:            public final Workspace createWorkspace(String name) {
182:                return createWorkspace(name, name);
183:            }
184:
185:            /** Creates new workspace with I18N support.
186:             * Note that it will not be displayed until {@link #setWorkspaces} is called
187:             * with an array containing the new workspace.
188:             * @param name the code name (used for internal purposes)
189:             * @param displayName the display name
190:             * @return the new workspace
191:             * @deprecated Do not use. Workspaces are not supported anymore. */
192:            @Deprecated
193:            public abstract Workspace createWorkspace(String name,
194:                    String displayName);
195:
196:            /** Finds workspace given its name.
197:             * @param name the (code) name of workspace to find
198:             * @return workspace or null if not found
199:             * @deprecated Do not use. Workspaces are not supported anymore. */
200:            @Deprecated
201:            public abstract Workspace findWorkspace(String name);
202:
203:            /**
204:             * Gets a list of all workspaces.
205:             * @return an array of all known workspaces
206:             * @deprecated Do not use. Workspaces are not supported anymore. */
207:            @Deprecated
208:            public abstract Workspace[] getWorkspaces();
209:
210:            /** Sets new array of workspaces.
211:             * In conjunction with {@link #getWorkspaces}, this may be used to reorder
212:             * workspaces, or add or remove workspaces.
213:             * @param workspaces An array consisting of new workspaces.
214:             * @deprecated Do not use. Workspaces are not supported anymore. */
215:            @Deprecated
216:            public abstract void setWorkspaces(Workspace[] workspaces);
217:
218:            /**
219:             * Gets the current workspace.
220:             * @return the currently active workspace
221:             * @see Workspace#activate
222:             * @deprecated Do not use. Workspaces are not supported anymore. */
223:            @Deprecated
224:            public abstract Workspace getCurrentWorkspace();
225:
226:            /** Finds <code>TopComponentGroup</code> of given name.
227:             * @return instance of TopComponetnGroup or null
228:             * @since 4.13 */
229:            public abstract TopComponentGroup findTopComponentGroup(String name);
230:
231:            //
232:            // You can add implementation to this class (+firePropertyChange), or implement it in subclass
233:            // Do as you want.
234:            //
235:
236:            /**
237:             * Attaches a listener for changes in workspaces.
238:             * @param l the new listener
239:             */
240:            public abstract void addPropertyChangeListener(
241:                    PropertyChangeListener l);
242:
243:            /**
244:             * Removes a listener for changes in workspaces.
245:             * @param l the listener to remove
246:             */
247:            public abstract void removePropertyChangeListener(
248:                    PropertyChangeListener l);
249:
250:            /** Finds top component manager for given top component.
251:             * @param tc top component to find manager for.
252:             * @return component manager for given top component.
253:             * @deprecated Do not use anymore.
254:             * See {@link WindowManager.Component} deprecation.
255:             */
256:            @Deprecated
257:            protected static final Component findComponentManager(
258:                    TopComponent tc) {
259:                return null;
260:            }
261:
262:            /** Activate a component. The top component containers should inform
263:             * the top component that it is active via a call to this method through
264:             * derived window manager implementation.
265:             * @param tc the top component to activate;
266:             * or <code>null</code> to deactivate all top components
267:             */
268:            protected void activateComponent(TopComponent tc) {
269:                // check
270:                if (getActiveComponent() == tc) {
271:                    return;
272:                }
273:
274:                TopComponent old = getActiveComponent();
275:                // deactivate old if possible
276:                if (old != null) {
277:                    try {
278:                        old.componentDeactivated();
279:                    } catch (Throwable th) {
280:                        logThrowable(
281:                                th,
282:                                "[Winsys] TopComponent "
283:                                        + old.getClass().getName() // NOI18N
284:                                        + " throws runtime exception from its componentDeactivated() method.\nPlease repair it!"); // NOI18N
285:                    }
286:                }
287:
288:                setActiveComponent(tc);
289:                TopComponent newTC = getActiveComponent();
290:
291:                if (newTC != null) {
292:                    try {
293:                        newTC.componentActivated();
294:                    } catch (Throwable th) {
295:                        logThrowable(
296:                                th,
297:                                "[Winsys] TopComponent "
298:                                        + newTC.getClass().getName() // NOI18N
299:                                        + " throws runtime exception from its componentActivated() method.\nPlease repair it!"); // NOI18N
300:                    }
301:                }
302:            }
303:
304:            /** Notifies component that it was opened (and wasn't opened on any
305:             * workspace before). Top component manager that implements Component
306:             * inner interface of this class should send open notifications via
307:             * calling this method
308:             * @param tc the top component to be notified
309:             */
310:            protected void componentOpenNotify(TopComponent tc) {
311:                try {
312:                    tc.componentOpened();
313:                } catch (Throwable th) {
314:                    logThrowable(
315:                            th,
316:                            "[Winsys] TopComponent "
317:                                    + tc.getClass().getName() // NOI18N
318:                                    + " throws exception/error from its componentOpened() method.\nPlease repair it!"); // NOI18N
319:                }
320:            }
321:
322:            /** Notifies component that it was closed (and is not opened on any
323:             * workspace anymore). Top component manager that implements Component
324:             * inner interface of this class should send close notifications via
325:             * calling this method
326:             * @param tc the top component to be notified
327:             */
328:            protected void componentCloseNotify(TopComponent tc) {
329:                try {
330:                    tc.componentClosed();
331:                } catch (Throwable th) {
332:                    logThrowable(
333:                            th,
334:                            "[Winsys] TopComponent "
335:                                    + tc.getClass().getName() // NOI18N
336:                                    + " throws exception/error from its componentClosed() method.\nPlease repair it!"); // NOI18N
337:                }
338:
339:                if (tc == getActiveComponent()) {
340:                    activateComponent(null);
341:                }
342:            }
343:
344:            /** Notifies <code>TopComponent</code> it is about to be shown.
345:             * @param tc <code>TopComponent</code> to be notified
346:             * @see TopComponent#componentShowing
347:             * @since 2.18 */
348:            protected void componentShowing(TopComponent tc) {
349:                try {
350:                    tc.componentShowing();
351:                } catch (Throwable th) {
352:                    logThrowable(
353:                            th,
354:                            "[Winsys] TopComponent "
355:                                    + tc.getClass().getName() // NOI18N
356:                                    + " throws runtime exception from its componentShowing() method.\nPlease repair it!"); // NOI18N
357:                }
358:            }
359:
360:            /** Notifies <code>TopComponent</code> it was hidden.
361:             * @param tc <code>TopComponent</code> to be notified
362:             * @see TopComponent#componentHidden
363:             * @since 2.18 */
364:            protected void componentHidden(TopComponent tc) {
365:                try {
366:                    tc.componentHidden();
367:                } catch (Throwable th) {
368:                    logThrowable(
369:                            th,
370:                            "[Winsys] TopComponent "
371:                                    + tc.getClass().getName() // NOI18N
372:                                    + " throws runtime exception from its componentHidden() method.\nPlease repair it!"); // NOI18N
373:                }
374:            }
375:
376:            /** #113391: catch all we can but ThreadDeath, as even java.lang.Error may come 
377:             * from TopComponent.componentOpened or componentClosed.
378:             */
379:            private static void logThrowable(Throwable th, String message) {
380:                if (th instanceof  ThreadDeath) {
381:                    // let us R.I.P. :-)
382:                    throw (ThreadDeath) th;
383:                }
384:                StackTraceElement[] stackTrace = th.getStackTrace();
385:                String cause = stackTrace.length > 0 ? " Probable cause is at "
386:                        + stackTrace[0].toString() : "";
387:                IllegalStateException ise = new IllegalStateException(message
388:                        + cause); // NOI18N
389:                ise.initCause(th);
390:                Logger.getLogger(WindowManager.class.getName()).log(
391:                        Level.WARNING, null, ise);
392:            }
393:
394:            /** Provides opening of specified <code>TopComponent</code>.
395:             * @param tc <code>TopComponent</code> to open
396:             * @since 4.13 */
397:            protected abstract void topComponentOpen(TopComponent tc);
398:
399:            /** Opens given TopComponent at given position in the mode. TopComponent is inserted at given
400:             * position, positions of already opened TopComponents in the same mode are
401:             * incremented.
402:             * 
403:             * <ul>
404:             *    <li>Does no operation if TopComponent is already opened.</li>
405:             *    <li>For position value less then 0, TopComponent is opened at position 0, the very first one.</li>
406:             *    <li>For position value greater then count of opened TopComponents in the mode,
407:             *          TopComponent is opened at last position</li>
408:             * </ul>
409:             * 
410:             * @param tc TopComponent which is opened.  
411:             * @param position Index of the requested position.
412:             * @since 6.15
413:             */
414:            protected void topComponentOpenAtTabPosition(TopComponent tc,
415:                    int position) {
416:                topComponentOpen(tc);
417:            }
418:
419:            /** Gives position index of given TopComponent in the mode. Result is
420:             * undefined for closed TopComponents.
421:             * 
422:             * @param tc TopComponent for which position is returned. 
423:             * @return Index of position.
424:             * @since 6.15
425:             */
426:            protected int topComponentGetTabPosition(TopComponent tc) {
427:                Mode mode = findMode(tc);
428:                if (mode == null || !topComponentIsOpened(tc)) {
429:                    return -1;
430:                }
431:
432:                TopComponent[] tcs = mode.getTopComponents();
433:                for (int i = 0; i < tcs.length; i++) {
434:                    if (tcs[i] == tc) {
435:                        return i;
436:                    }
437:                }
438:
439:                return -1;
440:            }
441:
442:            /** Provides closing of specified <code>TopComponent</code>.
443:             * @param tc <code>TopComponent</code> to close
444:             * @since 4.13 */
445:            protected abstract void topComponentClose(TopComponent tc);
446:
447:            /** Provides activation of specified <code>TopComponent</code>.
448:             * @param tc <code>TopComponent</code> to activate
449:             * @since 4.13 */
450:            protected abstract void topComponentRequestActive(TopComponent tc);
451:
452:            /** Provides selection of specfied <code>TopComponent</code>.
453:             * @param tc <code>TopComponent</code> to set visible (select)
454:             * @since 4.13 */
455:            protected abstract void topComponentRequestVisible(TopComponent tc);
456:
457:            /** Informs about change of display name of specified <code>TopComponent</code>.
458:             * @param tc <code>TopComponent</code> which display name has changed
459:             * @param displayName newly changed display name value
460:             * @since 4.13 */
461:            protected abstract void topComponentDisplayNameChanged(
462:                    TopComponent tc, String displayName);
463:
464:            /** Informs about change of html display name of specified <code>TopComponent</code>.
465:             * @param tc <code>TopComponent</code> which display name has changed
466:             * @param htmlDisplayName newly changed html display name value
467:             * @since 6.4 */
468:            protected abstract void topComponentHtmlDisplayNameChanged(
469:                    TopComponent tc, String htmlDisplayName);
470:
471:            /** Informs about change of tooltip of specified <code>TopComponent</code>.
472:             * @param tc <code>TopComponent</code> which tooltip has changed
473:             * @param toolTip newly changed tooltip value
474:             * @since 4.13 */
475:            protected abstract void topComponentToolTipChanged(TopComponent tc,
476:                    String toolTip);
477:
478:            /** Informs about chagne of icon of specified <code>TopComponent</code>.
479:             * @param tc <code>TopComponent</code> which icon has changed
480:             * @param icon newly chaned icon value
481:             * @since 4.13 */
482:            protected abstract void topComponentIconChanged(TopComponent tc,
483:                    Image icon);
484:
485:            /** Informs about change of activated nodes of specified <code>TopComponent</code>.
486:             * @param tc <code>TopComponent</code> which activated nodes has chagned
487:             * @param activatedNodes newly chaged activated nodes value
488:             * @since 4.13 */
489:            protected abstract void topComponentActivatedNodesChanged(
490:                    TopComponent tc, Node[] activatedNodes);
491:
492:            /** Indicates whether specified <code>TopComponent</code> is opened.
493:             * @param tc specified <code>TopComponent</code>
494:             * @since 4.13 */
495:            protected abstract boolean topComponentIsOpened(TopComponent tc);
496:
497:            /** Gets default list of actions which appear in popup menu of TopComponent.
498:             * The popup menu which is handled by window systsm implementation, typically at tab.
499:             * @param tc <code>TopComponent</code> for which the default actions to provide
500:             * @since 4.13 */
501:            protected abstract javax.swing.Action[] topComponentDefaultActions(
502:                    TopComponent tc);
503:
504:            /** Returns unique ID for specified <code>TopComponent</code>.
505:             * @param tc <code>TopComponent</code> the component for which is ID returned
506:             * @param preferredID first approximation used for ID
507:             * @return unique <code>TopComponent</code> ID
508:             * @since 4.13 */
509:            protected abstract String topComponentID(TopComponent tc,
510:                    String preferredID);
511:
512:            /**
513:             * Cause this TopComponent's tab to flash or otherwise draw the users' attention
514:             * to it.
515:             * Note to WindowManager providers: This method not abstract for backward compatibility reasons,
516:             * please override and provide implementation.
517:             * @param tc A TopComponent
518:             * @since 5.1 */
519:            protected void topComponentRequestAttention(TopComponent tc) {
520:            }
521:
522:            /**
523:             * Attempts to bring the parent <code>Window</code> of the given <code>TopComponent</code>
524:             * to front of other windows.
525:             * @see java.awt.Window#toFront()
526:             * @since 5.8
527:             */
528:            protected void topComponentToFront(TopComponent tc) {
529:                Window parentWindow = SwingUtilities.getWindowAncestor(tc);
530:
531:                // be defensive, although w probably will always be non-null here
532:                if (null != parentWindow) {
533:                    if (parentWindow instanceof  Frame) {
534:                        Frame parentFrame = (Frame) parentWindow;
535:                        int state = parentFrame.getExtendedState();
536:
537:                        if ((state & Frame.ICONIFIED) > 0) {
538:                            parentFrame.setExtendedState(state
539:                                    & ~Frame.ICONIFIED);
540:                        }
541:                    }
542:
543:                    parentWindow.toFront();
544:                }
545:            }
546:
547:            /**
548:             * Stop this TopComponent's tab from flashing if it is flashing.
549:             * Note to WindowManager providers: This method not abstract for backward compatibility reasons,
550:             * please override and provide implementation.
551:             *
552:             * @param tc A TopComponent
553:             * @since 5.1 */
554:            protected void topComponentCancelRequestAttention(TopComponent tc) {
555:            }
556:
557:            /** Returns unique ID for specified <code>TopComponent</code>.
558:             * @param tc <code>TopComponent</code> the component for which is ID returned
559:             * @return unique <code>TopComponent</code> ID
560:             * @since 4.13 */
561:            public String findTopComponentID(TopComponent tc) {
562:                return topComponentID(tc, tc.preferredID());
563:            }
564:
565:            /** Returns <code>TopComponent</code> for given unique ID.
566:             * @param tcID unique <code>TopComponent</code> ID
567:             * @return <code>TopComponent</code> instance corresponding to unique ID
568:             * @since 4.15 */
569:            public abstract TopComponent findTopComponent(String tcID);
570:
571:            /** Provides support for executing a piece of code when UI of the window
572:             * system is ready. 
573:             * The behaviour is similar to {@link EventQueue#invokeLater}
574:             * moreover it is guaranteed that only one Runnable runs at given time.
575:             * This method can be invoked from any thread.
576:             *
577:             * <p class="non-normative">
578:             * The typical usecase is to call this method during startup of NetBeans
579:             * based application. The default manager then waits till the main window
580:             * is opened and then executes all the registered methods one by one.
581:             * </p>
582:             * 
583:             * <b>Usage:</b>
584:             * <pre>
585:             *  // some initialization method
586:             *  public static void init () {
587:             *     WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
588:             *        public void run() {
589:             *           // code to be invoked when system UI is ready
590:             *        }
591:             *     );
592:             *  }
593:             * </pre>
594:             * 
595:             * Note to WindowManager providers: This method is not abstract for backward compatibility reasons,
596:             * please override and provide implementation.
597:             * 
598:             * @param run the runnable that executes piece of code when UI of the system is ready
599:             * @since 6.8
600:             */
601:            public void invokeWhenUIReady(Runnable run) {
602:                EventQueue.invokeLater(run);
603:            }
604:
605:            /**
606:             * <p>Check whether the given TopComponent will be/is docked into an 'editor' Mode.</p>
607:             * <p>Please note that some TopComponents may be docked into 'editor' modes as well as 
608:             * 'view' modes, see method isTopComponentAllowedToMoveAnywhere().</p>
609:             * 
610:             * @param tc TopComponent to check.
611:             * @return True if there is a Mode that the TopComponent will be/is docked to and
612:             * the Mode is of 'editor' kind (i.e. holds editor windows).
613:             * @since 6.13
614:             */
615:            public boolean isEditorTopComponent(TopComponent tc) {
616:                return false;
617:            }
618:
619:            /**
620:             * <p>Check whether the given TopComponent is opened and docked into an 'editor' Mode. 
621:             * It is safe to call this method outside the event dispatch thread.</p>
622:             * <p>Please note that some TopComponents may be docked into 'editor' modes as well as 
623:             * 'view' modes, see method isTopComponentAllowedToMoveAnywhere().</p>
624:             * 
625:             * @param tc TopComponent to check.
626:             * @return True if the TopComponent is opened and the Mode it is docked 
627:             * is of 'editor' kind (i.e. holds editor windows).
628:             * @since 6.16
629:             */
630:            public boolean isOpenedEditorTopComponent(TopComponent tc) {
631:                return false;
632:            }
633:
634:            /**
635:             * <p>Check whether the given Mode holds editor windows.</p>
636:             * <p>Please note that some TopComponents may be docked into 'editor' modes as well as 
637:             * 'view' modes, see method isTopComponentAllowedToMoveAnywhere().</p>
638:             * 
639:             * @param mode Mode to check.
640:             * @return True the Mode contains editor windows.
641:             * @since 6.13
642:             */
643:            public boolean isEditorMode(Mode mode) {
644:                return false;
645:            }
646:
647:            private TopComponent getActiveComponent() {
648:                return activeComponent.get();
649:            }
650:
651:            private void setActiveComponent(TopComponent activeComponent) {
652:                this .activeComponent = new WeakReference<TopComponent>(
653:                        activeComponent);
654:            }
655:
656:            /** A manager that handles operations on top components.
657:             * It is always attached to a {@link TopComponent}.
658:             * @deprecated Do not use anymore. This interface is replaced by bunch of protected methods
659:             * which name starts with topComponent prefix, i.e. {@link #topComponentOpen}, {@link #topComponentClose} etc. */
660:            @SuppressWarnings("deprecation")
661:            @Deprecated
662:            protected interface Component extends java.io.Serializable {
663:                /**
664:                 * Do not use.
665:                 * @deprecated Only public by accident.
666:                 */
667:                @Deprecated
668:                /* public static final */long serialVersionUID = 0L;
669:
670:                /** Open the component on current workspace */
671:                public void open();
672:
673:                /**
674:                 * Opens this component on a given workspace.
675:                 * @param workspace the workspace on which to open it
676:                 */
677:                public void open(Workspace workspace);
678:
679:                /**
680:                 * Closes this component on a given workspace.
681:                 * @param workspace the workspace on which to close it
682:                 */
683:                public void close(Workspace workspace);
684:
685:                /** Called when the component requests focus. Moves it to be visible.
686:                 */
687:                public void requestFocus();
688:
689:                /** Set this component visible but not selected or focused if possible.
690:                 * If focus is in other container (multitab) or other pane (split) in
691:                 * the same container it makes this component only visible eg. it selects
692:                 * tab with this component.
693:                 * If focus is in the same container (multitab) or in the same pane (split)
694:                 * it has the same effect as requestFocus().
695:                 */
696:                public void requestVisible();
697:
698:                /** Get the set of activated nodes.
699:                 * @return currently activated nodes for this component
700:                 */
701:                public Node[] getActivatedNodes();
702:
703:                /** Set the set of activated nodes for this component.
704:                 * @param nodes new set of activated nodes
705:                 */
706:                public void setActivatedNodes(Node[] nodes);
707:
708:                /** Called when the name of the top component changes.
709:                 */
710:                public void nameChanged();
711:
712:                /** Set the icon of the top component.
713:                 * @param icon the new icon
714:                 */
715:                public void setIcon(final Image icon);
716:
717:                /**
718:                 * Gets the icon associated with this component.
719:                 * @return the icon
720:                 */
721:                public Image getIcon();
722:
723:                /**
724:                 * Gets a list of workspaces where this component is currently open.
725:                 * @return the set of workspaces where the managed component is open
726:                 */
727:                public Set<Workspace> whereOpened();
728:            }
729:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.