Source Code Cross Referenced for GraphicManager.java in  » Project-Management » OpenProj » com » projity » pm » graphic » frames » 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 » Project Management » OpenProj » com.projity.pm.graphic.frames 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:        The contents of this file are subject to the Common Public Attribution License
0003:        Version 1.0 (the "License"); you may not use this file except in compliance with
0004:        the License. You may obtain a copy of the License at
0005:        http://www.projity.com/license . The License is based on the Mozilla Public
0006:        License Version 1.1 but Sections 14 and 15 have been added to cover use of
0007:        software over a computer network and provide for limited attribution for the
0008:        Original Developer. In addition, Exhibit A has been modified to be consistent
0009:        with Exhibit B.
0010:
0011:        Software distributed under the License is distributed on an "AS IS" basis,
0012:        WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
0013:        specific language governing rights and limitations under the License. The
0014:        Original Code is OpenProj. The Original Developer is the Initial Developer and
0015:        is Projity, Inc. All portions of the code written by Projity are Copyright (c)
0016:        2006, 2007. All Rights Reserved. Contributors Projity, Inc.
0017:
0018:        Alternatively, the contents of this file may be used under the terms of the
0019:        Projity End-User License Agreeement (the Projity License), in which case the
0020:        provisions of the Projity License are applicable instead of those above. If you
0021:        wish to allow use of your version of this file only under the terms of the
0022:        Projity License and not to allow others to use your version of this file under
0023:        the CPAL, indicate your decision by deleting the provisions above and replace
0024:        them with the notice and other provisions required by the Projity  License. If
0025:        you do not delete the provisions above, a recipient may use your version of this
0026:        file under either the CPAL or the Projity License.
0027:
0028:        [NOTE: The text of this license may differ slightly from the text of the notices
0029:        in Exhibits A and B of the license at http://www.projity.com/license. You should
0030:        use the latest text at http://www.projity.com/license for your modifications.
0031:        You may not remove this license text from the source files.]
0032:
0033:        Attribution Information: Attribution Copyright Notice: Copyright � 2006, 2007
0034:        Projity, Inc. Attribution Phrase (not exceeding 10 words): Powered by OpenProj,
0035:        an open source solution from Projity. Attribution URL: http://www.projity.com
0036:        Graphic Image as provided in the Covered Code as file:  openproj_logo.png with
0037:        alternatives listed on http://www.projity.com/logo
0038:
0039:        Display of Attribution Information is required in Larger Works which are defined
0040:        in the CPAL as a work which combines Covered Code or portions thereof with code
0041:        not governed by the terms of the CPAL. However, in addition to the other notice
0042:        obligations, all copies of the Covered Code in Executable and Source Code form
0043:        distributed must, as a form of attribution of the original author, include on
0044:        each user interface screen the "OpenProj" logo visible to all users.  The
0045:        OpenProj logo should be located horizontally aligned with the menu bar and left
0046:        justified on the top left of the screen adjacent to the File menu.  The logo
0047:        must be at least 100 x 25 pixels.  When users click on the "OpenProj" logo it
0048:        must direct them back to http://www.projity.com.
0049:         */
0050:        package com.projity.pm.graphic.frames;
0051:
0052:        import java.applet.Applet;
0053:        import java.awt.BorderLayout;
0054:        import java.awt.Color;
0055:        import java.awt.Component;
0056:        import java.awt.Container;
0057:        import java.awt.Cursor;
0058:        import java.awt.Dimension;
0059:        import java.awt.Frame;
0060:        import java.awt.HeadlessException;
0061:        import java.awt.event.ActionEvent;
0062:        import java.awt.event.FocusEvent;
0063:        import java.awt.event.FocusListener;
0064:        import java.awt.event.WindowEvent;
0065:        import java.awt.event.WindowStateListener;
0066:        import java.beans.XMLDecoder;
0067:        import java.beans.XMLEncoder;
0068:        import java.io.BufferedInputStream;
0069:        import java.io.BufferedOutputStream;
0070:        import java.io.ByteArrayInputStream;
0071:        import java.io.ByteArrayOutputStream;
0072:        import java.io.IOException;
0073:        import java.io.ObjectInputStream;
0074:        import java.io.ObjectOutputStream;
0075:        import java.lang.reflect.InvocationTargetException;
0076:        import java.util.ArrayList;
0077:        import java.util.HashMap;
0078:        import java.util.HashSet;
0079:        import java.util.Iterator;
0080:        import java.util.LinkedList;
0081:        import java.util.List;
0082:        import java.util.Set;
0083:
0084:        import javax.swing.Action;
0085:        import javax.swing.BorderFactory;
0086:        import javax.swing.Box;
0087:        import javax.swing.BoxLayout;
0088:        import javax.swing.JApplet;
0089:        import javax.swing.JButton;
0090:        import javax.swing.JComponent;
0091:        import javax.swing.JDialog;
0092:        import javax.swing.JFrame;
0093:        import javax.swing.JMenu;
0094:        import javax.swing.JMenuBar;
0095:        import javax.swing.JMenuItem;
0096:        import javax.swing.JOptionPane;
0097:        import javax.swing.JPanel;
0098:        import javax.swing.JRadioButtonMenuItem;
0099:        import javax.swing.JTabbedPane;
0100:        import javax.swing.JToolBar;
0101:        import javax.swing.LookAndFeel;
0102:        import javax.swing.RootPaneContainer;
0103:        import javax.swing.UIManager;
0104:        import javax.swing.undo.AbstractUndoableEdit;
0105:        import javax.swing.undo.CannotRedoException;
0106:        import javax.swing.undo.CannotUndoException;
0107:
0108:        import org.apache.batik.util.gui.resource.ActionMap;
0109:        import org.apache.batik.util.gui.resource.MissingListenerException;
0110:        import org.apache.commons.collections.Closure;
0111:
0112:        import com.projity.configuration.FieldDictionary;
0113:        import com.projity.dialog.AboutDialog;
0114:        import com.projity.dialog.AbstractDialog;
0115:        import com.projity.dialog.BaselineDialog;
0116:        import com.projity.dialog.HelpDialog;
0117:        import com.projity.dialog.OpenProjectDialog;
0118:        import com.projity.dialog.ProjectDialog;
0119:        import com.projity.dialog.ProjectInformationDialog;
0120:        import com.projity.dialog.RenameProjectDialog;
0121:        import com.projity.dialog.ResourceInformationDialog;
0122:        import com.projity.dialog.ResourceMappingDialog;
0123:        import com.projity.dialog.TaskInformationDialog;
0124:        import com.projity.dialog.TipOfTheDay;
0125:        import com.projity.dialog.WelcomeDialog;
0126:        import com.projity.dialog.assignment.AssignmentDialog;
0127:        import com.projity.dialog.options.CalendarDialogBox;
0128:        import com.projity.document.Document;
0129:        import com.projity.document.ObjectEvent;
0130:        import com.projity.exchange.ResourceMappingForm;
0131:        import com.projity.field.Field;
0132:        import com.projity.graphic.configuration.SpreadSheetFieldArray;
0133:        import com.projity.grouping.core.Node;
0134:        import com.projity.grouping.core.NodeFactory;
0135:        import com.projity.grouping.core.VoidNodeImpl;
0136:        import com.projity.grouping.core.model.NodeModel;
0137:        import com.projity.grouping.core.transform.CommonTransformFactory;
0138:        import com.projity.grouping.core.transform.ViewTransformer;
0139:        import com.projity.grouping.core.transform.filtering.NodeFilter;
0140:        import com.projity.grouping.core.transform.filtering.ResourceInTeamFilter;
0141:        import com.projity.job.Job;
0142:        import com.projity.job.JobQueue;
0143:        import com.projity.job.JobRunnable;
0144:        import com.projity.job.Mutex;
0145:        import com.projity.menu.MenuActionConstants;
0146:        import com.projity.menu.MenuActionsMap;
0147:        import com.projity.menu.MenuManager;
0148:        import com.projity.options.GeneralOption;
0149:        import com.projity.pm.assignment.Assignment;
0150:        import com.projity.pm.graphic.IconManager;
0151:        import com.projity.pm.graphic.TabbedNavigation;
0152:        import com.projity.pm.graphic.frames.workspace.DefaultFrameManager;
0153:        import com.projity.pm.graphic.frames.workspace.FrameHolder;
0154:        import com.projity.pm.graphic.frames.workspace.FrameManager;
0155:        import com.projity.pm.graphic.frames.workspace.NamedFrame;
0156:        import com.projity.pm.graphic.frames.workspace.NamedFrameEvent;
0157:        import com.projity.pm.graphic.frames.workspace.NamedFrameListener;
0158:        import com.projity.pm.graphic.laf.LafManager;
0159:        import com.projity.pm.graphic.spreadsheet.SpreadSheet;
0160:        import com.projity.pm.graphic.spreadsheet.SpreadSheetModel;
0161:        import com.projity.pm.graphic.spreadsheet.common.CommonSpreadSheet;
0162:        import com.projity.pm.graphic.spreadsheet.selection.event.SelectionNodeEvent;
0163:        import com.projity.pm.graphic.spreadsheet.selection.event.SelectionNodeListener;
0164:        import com.projity.pm.graphic.views.BaseView;
0165:        import com.projity.pm.resource.Resource;
0166:        import com.projity.pm.resource.ResourcePool;
0167:        import com.projity.pm.task.Project;
0168:        import com.projity.pm.task.ProjectFactory;
0169:        import com.projity.pm.task.SubProj;
0170:        import com.projity.pm.task.Task;
0171:        import com.projity.pm.time.HasStartAndEnd;
0172:        import com.projity.preference.GlobalPreferences;
0173:        import com.projity.print.GraphPageable;
0174:        import com.projity.print.PrintDocumentFactory;
0175:        import com.projity.server.data.ProjectData;
0176:        import com.projity.session.CreateOptions;
0177:        import com.projity.session.LoadOptions;
0178:        import com.projity.session.LocalSession;
0179:        import com.projity.session.SaveOptions;
0180:        import com.projity.session.Session;
0181:        import com.projity.session.SessionFactory;
0182:        import com.projity.strings.Messages;
0183:        import com.projity.toolbar.FilterToolBarManager;
0184:        import com.projity.toolbar.TransformComboBox;
0185:        import com.projity.toolbar.TransformComboBoxModel;
0186:        import com.projity.undo.UndoController;
0187:        import com.projity.util.Alert;
0188:        import com.projity.util.BrowserControl;
0189:        import com.projity.util.ClassUtils;
0190:        import com.projity.util.Environment;
0191:        import com.projity.workspace.SavableToWorkspace;
0192:        import com.projity.workspace.WorkspaceSetting;
0193:
0194:        /**
0195:         *
0196:         */
0197:        public class GraphicManager implements  FrameHolder, NamedFrameListener,
0198:                WindowStateListener, SelectionNodeListener,
0199:                ObjectEvent.Listener, ActionMap, MenuActionConstants,
0200:                SavableToWorkspace {
0201:            private static final boolean BINARY_WORKSPACE = true;
0202:            private static GraphicManager lastGraphicManager = null; // used when displaying a popup but the frame isn't known
0203:            private DocumentFrame currentFrame = null;
0204:            private List frameList = new ArrayList();
0205:            private HashMap<Project, NamedFrame> frameMap = new HashMap<Project, NamedFrame>();
0206:            //    private JFileChooser fileChooser = null;
0207:
0208:            private NamedFrame viewBarFrame;
0209:            private FrameManager frameManager;
0210:
0211:            private MenuManager menuManager;
0212:            MenuActionsMap actionsMap = null;
0213:            //private String[] projectUrl;
0214:            private static String server = null;
0215:
0216:            private AssignmentDialog assignResourcesDialog = null;
0217:            private ProjectInformationDialog projectInformationDialog = null;
0218:            private TaskInformationDialog taskInformationDialog = null;
0219:            private ResourceInformationDialog resourceInformationDialog = null;
0220:            private AboutDialog aboutDialog = null;
0221:            private HelpDialog helpDialog = null;
0222:            private BaselineDialog baselineDialog = null;
0223:            private ResourceMappingDialog resourceMappingDialog = null;
0224:            ProjectFactory projectFactory = null;
0225:            protected Container container;
0226:            protected Frame frame;
0227:            TabbedNavigation topTabs = null;
0228:
0229:            private static Object lastWorkspace = null; // static required - used for copying current workspace to new instance
0230:            static LinkedList graphicManagers = new LinkedList();
0231:            private static LafManager lafManager;
0232:            private StartupFactory startupFactory = null;
0233:            protected JobQueue jobQueue = null;
0234:
0235:            protected GlobalPreferences preferences = null;
0236:            private FilterToolBarManager filterToolBarManager;
0237:            private JMenu projectListMenu = null;
0238:
0239:            /** determines the parent graphic manager for a component
0240:             *
0241:             * @param component
0242:             * @return
0243:             */
0244:            public static GraphicManager getInstance(Component component) {
0245:                Component c = component;
0246:                for (c = component; c != null; c = c.getParent()) {
0247:                    if (c instanceof  FrameHolder)
0248:                        return ((FrameHolder) c).getGraphicManager();
0249:                    else if (c.getName() != null
0250:                            && c.getName().endsWith("BootstrapApplet")
0251:                            && c.getClass().getName().endsWith(
0252:                                    "BootstrapApplet")) {
0253:                        System.out.println("applet: " + c.getClass().getName());
0254:                        try {
0255:                            FrameHolder holder = (FrameHolder) Class
0256:                                    .forName(
0257:                                            "com.projity.bootstrap.BootstrapApplet.class")
0258:                                    .getMethod("getObject", null).invoke(c,
0259:                                            null);
0260:                            return holder.getGraphicManager();
0261:                        } catch (Exception e) {
0262:                            return null;
0263:                        }
0264:                    }
0265:                }
0266:                return lastGraphicManager; // if none found, use last used one
0267:            }
0268:
0269:            public static GraphicManager getInstance() {
0270:                //System.out.println("Graphic manager getInstance = " + lastGraphicManager.hashCode());
0271:                return lastGraphicManager;
0272:            }
0273:
0274:            public static Frame getFrameInstance() {
0275:                return lastGraphicManager.getFrame();
0276:            }
0277:
0278:            public static DocumentFrame getDocumentFrameInstance() {
0279:                return lastGraphicManager == null ? null : lastGraphicManager
0280:                        .getCurrentFrame();
0281:            }
0282:
0283:            void setMeAsLastGraphicManager() { // makes this the current graphic manager for job queue and dialogs
0284:                lastGraphicManager = this ;
0285:                if (jobQueue != null)
0286:                    SessionFactory.getInstance().setJobQueue(getJobQueue());
0287:
0288:            }
0289:
0290:            public static LinkedList getGraphicManagers() {
0291:                return graphicManagers;
0292:            }
0293:
0294:            /**
0295:             * @param projectUrl TODO
0296:             * @param server TODO
0297:             * @throws java.awt.HeadlessException
0298:             */
0299:            public GraphicManager(/*String[] projectUrl,*/String server,
0300:                    Container container) throws HeadlessException {
0301:                graphicManagers.add(this );
0302:                lastGraphicManager = this ;
0303:                container.addFocusListener(new FocusListener() {
0304:
0305:                    public void focusGained(FocusEvent e) {
0306:                        //				System.out.println("GainFocus " + GraphicManager.this.hashCode());
0307:                        setMeAsLastGraphicManager();
0308:                    }
0309:
0310:                    public void focusLost(FocusEvent e) {
0311:                        //				System.out.println("LostFocus " + GraphicManager.this.hashCode());
0312:                    }
0313:                });
0314:
0315:                projectFactory = ProjectFactory.getInstance();
0316:                projectFactory.getPortfolio().addObjectListener(this );
0317:
0318:                //this.projectUrl = projectUrl;
0319:                GraphicManager.server = server;
0320:                this .container = container;
0321:                if (container instanceof  Frame)
0322:                    frame = (Frame) container;
0323:                else if (container instanceof  JApplet)
0324:                    frame = JOptionPane.getFrameForComponent(container);
0325:                if (container instanceof  FrameHolder)
0326:                    ((FrameHolder) container).setGraphicManager(this );
0327:                //		else if (container instanceof BootstrapApplet){
0328:                else {
0329:                    try {
0330:                        FrameHolder holder = (FrameHolder) Class.forName(
0331:                                "com.projity.bootstrap.BootstrapApplet")
0332:                                .getMethod("getObject", null).invoke(container,
0333:                                        null);
0334:                        holder.setGraphicManager(this );
0335:                    } catch (Exception e) {
0336:                    }
0337:                }
0338:            }
0339:
0340:            public GraphicManager(Container container) {
0341:                this (/*null,*/server, container);
0342:            }
0343:
0344:            protected void finalize() throws Throwable {
0345:                //		System.out.println("~~~~~~~~~~~~~~~~ GraphicManager.finalize()");
0346:                super .finalize();
0347:            }
0348:
0349:            public void cleanUp() {
0350:
0351:                //		On quitting, a sleep interrupted exception (below) is thrown by Substance. Without changing the source
0352:                //		java.lang.InterruptedException: sleep interrupted
0353:                //		at java.lang.Thread.sleep(Native Method)
0354:                //		at org.jvnet.substance.utils.FadeTracker$FadeTrackerThread.run(FadeTracker.java:210)
0355:                //		I have submitted a bug report: https://substance.dev.java.net/issues/show_bug.cgi?id=155 with a proposed fix
0356:
0357:                projectFactory.getPortfolio().removeObjectListener(this );
0358:                ((DefaultFrameManager) frameManager).cleanUp();
0359:                graphicManagers.remove(this );
0360:                if (graphicManagers.isEmpty())
0361:                    getLafManager().clean();
0362:
0363:                if (jobQueue != null)
0364:                    jobQueue.cancel();
0365:                jobQueue = null;
0366:            }
0367:
0368:            public LafManager getLafManager() {
0369:                if (lafManager == null) {
0370:                    try {
0371:                        String lafName = Messages.getMetaString("LafManager");
0372:                        lafManager = (LafManager) Class.forName(lafName)
0373:                                .getConstructor(
0374:                                        new Class[] { GraphicManager.class })
0375:                                .newInstance(new Object[] { this  });
0376:                    } catch (IllegalArgumentException e) {
0377:                        // TODO Auto-generated catch block
0378:                        e.printStackTrace();
0379:                    } catch (SecurityException e) {
0380:                        // TODO Auto-generated catch block
0381:                        e.printStackTrace();
0382:                    } catch (InstantiationException e) {
0383:                        // TODO Auto-generated catch block
0384:                        e.printStackTrace();
0385:                    } catch (IllegalAccessException e) {
0386:                        // TODO Auto-generated catch block
0387:                        e.printStackTrace();
0388:                    } catch (InvocationTargetException e) {
0389:                        // TODO Auto-generated catch block
0390:                        e.printStackTrace();
0391:                    } catch (NoSuchMethodException e) {
0392:                        // TODO Auto-generated catch block
0393:                        e.printStackTrace();
0394:                    } catch (ClassNotFoundException e) {
0395:                        // TODO Auto-generated catch block
0396:                        e.printStackTrace();
0397:                    }
0398:                    //lafManager=new LafManager(this);
0399:                }
0400:                return lafManager;
0401:            }
0402:
0403:            private String fileName = "../projity_exchange/testdata/New Product.mpp"; //$NON-NLS-1$
0404:            private ViewAction resourceAction;
0405:
0406:            //    private JFileChooser getFileChooser() {
0407:            //    	if (fileChooser == null)
0408:            //    		fileChooser = new JFileChooser();
0409:            //    	return fileChooser;
0410:            //    }
0411:
0412:            private static String getTabIdForProject(Project project) {
0413:                if (project == null)
0414:                    return null;
0415:                return "" + project.getUniqueId(); //see later //$NON-NLS-1$
0416:            }
0417:
0418:            void setTabNameAndTitle(DocumentFrame frame, Project project) {
0419:                frame.setTabNameAndTitle(project);
0420:            }
0421:
0422:            public void switchToProject(long projectId) {
0423:                Project project = ProjectFactory.getInstance().findFromId(
0424:                        projectId);
0425:                if (project == null)
0426:                    return;
0427:                DocumentFrame f = (DocumentFrame) frameMap.get(project);
0428:                if (f == null)
0429:                    return;
0430:                setCurrentFrame(f);
0431:
0432:            }
0433:
0434:            protected void setCurrentFrame(DocumentFrame frame) {
0435:                if (frame instanceof  DocumentFrame) {
0436:                    if (currentFrame != null && projectListMenu != null) {
0437:                        currentFrame.getMenuItem().setSelected(false);
0438:                    }
0439:
0440:                    if (currentFrame != null)
0441:                        currentFrame.refreshViewButtons(false); // disable buttons for old view
0442:
0443:                    currentFrame = (DocumentFrame) frame;
0444:                    if (projectListMenu != null) {
0445:                        currentFrame.getMenuItem().setSelected(true);
0446:                    }
0447:                    if (topTabs != null) {
0448:                        topTabs.setCurrentFrame(currentFrame);
0449:                    }
0450:                    DocumentSelectedEvent.fire(this , currentFrame);
0451:                    if (projectInformationDialog != null)
0452:                        projectInformationDialog
0453:                                .documentSelected(new DocumentSelectedEvent(
0454:                                        this , currentFrame));
0455:                    if (taskInformationDialog != null)
0456:                        taskInformationDialog
0457:                                .documentSelected(new DocumentSelectedEvent(
0458:                                        this , currentFrame));
0459:                    if (resourceInformationDialog != null)
0460:                        resourceInformationDialog
0461:                                .documentSelected(new DocumentSelectedEvent(
0462:                                        this , currentFrame));
0463:
0464:                    setTitle(false);
0465:                    if (currentFrame != null)
0466:                        currentFrame.refreshViewButtons(true);
0467:
0468:                    getFrameManager().activateFrame(currentFrame); // need to force activation in case being activated by closing another
0469:                    setEnabledDocumentMenuActions(currentFrame != null);
0470:                    setButtonState(null, currentFrame.getProject());
0471:                }
0472:            }
0473:
0474:            void setTitle(boolean isSaving) {
0475:                DocumentFrame dframe = getCurrentFrame();
0476:                String title = Messages
0477:                        .getContextString("Text.ApplicationTitle"); //$NON-NLS-1$
0478:                if (dframe != null && dframe.getProject() != null) {
0479:                    if (Environment.getStandAlone())
0480:                        title = dframe.getProject().getTitle();
0481:                    else
0482:                        title += " - " + dframe.getProject().getName(); //$NON-NLS-1$
0483:                    if (!isSaving && dframe.getProject().needsSaving())
0484:                        title += " *"; // modified; //$NON-NLS-1$
0485:                }
0486:                Frame f = getFrame();
0487:                if (frame != null)
0488:                    frame.setTitle(title);
0489:
0490:            }
0491:
0492:            /**
0493:             * Adds a new document frame and shows it
0494:             * @param project
0495:             * @return
0496:             */
0497:
0498:            public DocumentFrame addProjectFrame(final Project project) {
0499:                String tabId = getTabIdForProject(project);
0500:                final DocumentFrame frame = new DocumentFrame(this , project,
0501:                        tabId);
0502:                getFrameManager().addFrame(frame);
0503:                //		DocumentFrame newDocumentFrame = (DocumentFrame)getFrameManager().getFrame(tabId);
0504:
0505:                setTabNameAndTitle(frame, project);
0506:                frame.setShowTitleBar(false);
0507:                getFrameManager().showFrame(frame); // show the frame
0508:                frame.addNamedFrameListener(this ); // main frame listens to changes in selection
0509:
0510:                project.addProjectListener(frame);
0511:
0512:                if (projectListMenu != null) {
0513:                    JRadioButtonMenuItem mi = new JRadioButtonMenuItem(
0514:                            new SelectDocumentAction(frame));
0515:                    mi.setSelected(true);
0516:                    frame.setMenuItem(mi);
0517:                    projectListMenu.add(mi);
0518:                }
0519:                setCurrentFrame(frame);
0520:
0521:                frameList.add(frame);
0522:                frameMap.put(project, frame);
0523:                return frame;
0524:            }
0525:
0526:            private void closeProjectFrame(Project project) {
0527:                String tabId = getTabIdForProject(project);
0528:                DocumentFrame frame = (DocumentFrame) frameMap.get(project);
0529:                if (frame != null) { //TODO why is it sometimes null? Well, in the case of opening a subproject it can be
0530:
0531:                    if (currentFrame == frame) {
0532:                        frame.setVisible(false);
0533:                        JMenuItem mi = frame.getMenuItem();
0534:                        if (mi != null && projectListMenu != null)
0535:                            projectListMenu.remove(mi);
0536:
0537:                        if (frameList.size() <= 1) {
0538:                            frame.refreshViewButtons(false); // disable old buttons
0539:                            currentFrame = null;//TODO open a new one instead
0540:                            setTitle(false);
0541:                            setEnabledDocumentMenuActions(false);
0542:                        } else {
0543:                            DocumentFrame current;
0544:                            int index = 0;
0545:                            for (Iterator i = frameList.iterator(); i.hasNext(); index++) {
0546:                                current = (DocumentFrame) i.next();
0547:                                if (tabId.equals(getTabIdForProject(current
0548:                                        .getProject())))
0549:                                    break;
0550:                            }
0551:                            setCurrentFrame((DocumentFrame) frameList
0552:                                    .get((index == 0) ? 1 : index - 1));//TODO use previous instead
0553:                        }
0554:                    }
0555:                    project.removeProjectListener(frame); // hk uncommented this for applet. don't know why it was commented
0556:                    frame.removeNamedFrameListener(this ); // main frame listens to changes in selection
0557:
0558:                    getFrameManager().removeFrame(frame);
0559:                    frame.onClose();
0560:                    frameList.remove(frame);
0561:                    frameMap.remove(project);
0562:                }
0563:
0564:            }
0565:
0566:            public String doRenameProjectDialog(String name, Set projectNames,
0567:                    boolean saveAs) {
0568:                finishAnyOperations();
0569:                RenameProjectDialog renameProjectDialog = RenameProjectDialog
0570:                        .getInstance(getFrame(), null);
0571:                renameProjectDialog.getForm().setName(name);
0572:                renameProjectDialog.getForm().setProjectNames(projectNames);
0573:                renameProjectDialog.getForm().setSaveAs(saveAs);
0574:                if (renameProjectDialog.doModal())
0575:                    return renameProjectDialog.getForm().getName();
0576:                return null;
0577:            }
0578:
0579:            public void doWelcomeDialog() {
0580:                WelcomeDialog instance = WelcomeDialog.getInstance(getFrame(),
0581:                        getMenuManager());
0582:                if (instance.doModal()) {
0583:                    waitInitialization();
0584:                    if (instance.getForm().isCreateProject())
0585:                        doNewProjectDialog();
0586:                    else if (instance.getForm().isOpenProject()) {
0587:                        if (Environment.getStandAlone())
0588:                            openLocalProject();
0589:                        else
0590:                            doOpenProjectDialog();
0591:                    } else if (instance.getForm().isManageResources()) {
0592:                        loadMasterProject();
0593:                    }
0594:                }
0595:            }
0596:
0597:            private boolean doNewProjectDialog() {
0598:                finishAnyOperations();
0599:                ProjectDialog projectDialog = ProjectDialog.getInstance(
0600:                        getFrame(), null);
0601:                projectDialog.getForm().setManager(
0602:                        Environment.getUser().getName());
0603:                if (!projectDialog.doModal())
0604:                    return false; // if cancelled
0605:
0606:                showWaitCursor(true);
0607:                ResourcePool resourcePool = projectDialog.getForm()
0608:                        .getResourcePool();
0609:                boolean local = projectDialog.getForm().isLocal();
0610:                if (resourcePool != null)
0611:                    resourcePool.setLocal(local);
0612:                CreateOptions opt = new CreateOptions();
0613:                opt.setResourcePool(projectDialog.getForm().getResourcePool());
0614:                opt.setLocal(local);
0615:                opt.setName(projectDialog.getForm().getName());
0616:                opt.setAddResources(!local);
0617:                Project project = projectFactory.createProject(opt);
0618:                try {
0619:                    //createProject above might make a new resource pool, so make sur it is used when copying properties
0620:                    //projectDialog.getForm().setResourcePool(project.getResourcePool());
0621:
0622:                    project.setManager(projectDialog.getForm().getManager());
0623:                    project.setName(projectDialog.getForm().getName());
0624:                    project.setNotes(projectDialog.getForm().getNotes());
0625:                    project.setForward(projectDialog.getForm().isForward());
0626:                    project.setGroup(projectDialog.getForm().getGroup());
0627:                    project.setDivision(projectDialog.getForm().getDivision());
0628:                    project.setProjectType(projectDialog.getForm()
0629:                            .getProjectType());
0630:                    project.setProjectStatus(projectDialog.getForm()
0631:                            .getProjectStatus());
0632:                    project.setExpenseType(projectDialog.getForm()
0633:                            .getExpenseType());
0634:
0635:                    if (!projectDialog.getForm().isLocal()) {
0636:                        project.setAccessControlPolicy(projectDialog.getForm()
0637:                                .getAccessControlType());
0638:                        project.resetRoles(projectDialog.getForm()
0639:                                .getAccessControlType() == 0);
0640:                    }
0641:
0642:                    if (projectDialog.getForm().isLocal())
0643:                        project.setLocal(true);
0644:                    else
0645:                        project.setTemporaryLocal(true);
0646:                    if (projectDialog.getForm().isForward())
0647:                        project.setStartDate(projectDialog.getForm()
0648:                                .getStartDate());
0649:                    else
0650:                        project.setFinishDate(projectDialog.getForm()
0651:                                .getStartDate());
0652:                    // copy any extra fields to the project
0653:                    project.getExtraFields()
0654:                            .putAll(
0655:                                    projectDialog.getForm().getExtra()
0656:                                            .getExtraFields());
0657:
0658:                    //			PropertyUtils.copyProperties(project, projectDialog.getForm());
0659:                } catch (Exception propertyException) {
0660:                    propertyException.printStackTrace();
0661:                }
0662:                showWaitCursor(false);
0663:
0664:                return true;
0665:            }
0666:
0667:            boolean doingOpenDialog = false;
0668:
0669:            private void doOpenProjectDialog() {
0670:                if (doingOpenDialog)
0671:                    return;
0672:                doingOpenDialog = true;
0673:                finishAnyOperations();
0674:
0675:                final ArrayList descriptors = new ArrayList();
0676:
0677:                Session session = SessionFactory.getInstance()
0678:                        .getSession(false);
0679:                Job job = (Job) SessionFactory.callNoEx(session,
0680:                        "getLoadProjectDescriptorsJob", new Class[] {
0681:                                boolean.class, java.util.List.class,
0682:                                boolean.class }, new Object[] { true,
0683:                                descriptors, !Environment.isAdministrator() });
0684:                job.addSwingRunnable(new JobRunnable("Local: loadDocument") { //$NON-NLS-1$
0685:                            public Object run() throws Exception {
0686:                                final Closure setter = new Closure() {
0687:                                    public void execute(Object obj) {
0688:
0689:                                    }
0690:                                };
0691:                                final Closure getter = new Closure() {
0692:                                    public void execute(Object obj) {
0693:                                        final Object[] r = (Object[]) obj;
0694:                                        if (r != null) {
0695:                                            ProjectData data = (ProjectData) r[0];
0696:                                            boolean openAs = (Boolean) r[1];
0697:                                            loadDocument(data.getUniqueId(),
0698:                                                    false, openAs);
0699:                                        }
0700:
0701:                                    }
0702:                                };
0703:                                try {
0704:                                    OpenProjectDialog
0705:                                            .getInstance(
0706:                                                    getFrame(),
0707:                                                    descriptors,
0708:                                                    Messages
0709:                                                            .getString("Text.openProject"), true, true, null).execute(setter, getter); //$NON-NLS-1$
0710:                                } finally {
0711:                                    doingOpenDialog = false;
0712:                                }
0713:
0714:                                return null;
0715:                            }
0716:                        });
0717:                session.schedule(job);
0718:            }
0719:
0720:            private void doInsertProjectDialog() {
0721:                if (doingOpenDialog)
0722:                    return;
0723:                doingOpenDialog = true;
0724:
0725:                finishAnyOperations();
0726:
0727:                final Project project;
0728:                project = getCurrentFrame().getProject();
0729:
0730:                //		List nodes=getCurrentFrame().getSelectedNodes();
0731:                //		if (nodes==null||nodes.size()==0) return;
0732:                //		Node node=(Node)nodes.get(0);
0733:                //		if (!node.isInSubproject()) project= getCurrentFrame().getProject();
0734:                //		else{
0735:                //			while (!(node==null) && !(node.getImpl().getClass().getName().equals("com.projity.pm.task.Subproject"))){
0736:                //				node=(Node)node.getParent();
0737:                //			}
0738:                //			if (node==null) return; //shouldn't happen
0739:                //			try {
0740:                //				project=(Project)node.getImpl().getClass().getMethod("getSubproject", null).invoke(node.getImpl(), null);
0741:                //			} catch (Exception e) {
0742:                //				return;
0743:                //			}
0744:                //		}
0745:
0746:                final ArrayList descriptors = new ArrayList();
0747:
0748:                Session session = SessionFactory.getInstance()
0749:                        .getSession(false);
0750:                Job job = (Job) SessionFactory.callNoEx(session,
0751:                        "getLoadProjectDescriptorsJob", new Class[] {
0752:                                boolean.class, java.util.List.class,
0753:                                boolean.class }, new Object[] { true,
0754:                                descriptors, true });
0755:                job.addSwingRunnable(new JobRunnable("Local: add") { //$NON-NLS-1$
0756:                            public Object run() throws Exception {
0757:                                Closure setter = new Closure() {
0758:                                    public void execute(Object obj) {
0759:
0760:                                    }
0761:                                };
0762:                                Closure getter = new Closure() {
0763:                                    public void execute(Object obj) {
0764:                                        final Object[] r = (Object[]) obj;
0765:                                        if (r != null) {
0766:                                            final ProjectData data = (ProjectData) r[0];
0767:                                            if (data.isMaster())
0768:                                                return;
0769:                                            insertSubproject(project, data
0770:                                                    .getUniqueId(), true);
0771:                                            //	    	        		Project openedAlready = ProjectFactory.getInstance().findFromId(data.getUniqueId());
0772:                                            //
0773:                                            //							if (!project.canInsertProject(data.getUniqueId())) {
0774:                                            //								Alert.error("The selected project is already a subproject in this consolidated project.");
0775:                                            //								return;
0776:                                            //							}
0777:                                            //							if (openedAlready != null && openedAlready.isOpenedAsSubproject()) {
0778:                                            //								Alert.error("The selected project is already opened as a subproject in another consolidated project.");
0779:                                            //								return;
0780:                                            //							}
0781:                                            //							Subproject subprojectTask = new Subproject(project,data.getUniqueId());
0782:                                            //							Node subprojectNode = getCurrentFrame().addNodeForImpl(subprojectTask,NodeModel.EVENT);
0783:                                            //							ProjectFactory.getInstance().openSubproject(project, subprojectNode, true);
0784:                                        }
0785:                                    }
0786:                                };
0787:
0788:                                try {
0789:                                    OpenProjectDialog dlg = OpenProjectDialog
0790:                                            .getInstance(
0791:                                                    getFrame(),
0792:                                                    descriptors,
0793:                                                    Messages
0794:                                                            .getString("Text.insertProject"), false, false, project); //$NON-NLS-1$
0795:                                    dlg.execute(setter, getter);
0796:                                } catch (Exception e) {
0797:                                    Alert
0798:                                            .error(
0799:                                                    Messages
0800:                                                            .getString("Message.serverUnreachable"), getContainer()); //$NON-NLS-1$
0801:                                    //TODO need more precise exception
0802:                                    e.printStackTrace();
0803:                                } finally {
0804:                                    doingOpenDialog = false;
0805:                                }
0806:                                return null;
0807:                            }
0808:                        });
0809:                session.schedule(job);
0810:            }
0811:
0812:            public void insertSubproject(final Project project,
0813:                    final long subprojectUniqueId, final boolean undo) {
0814:                Project openedAlready = ProjectFactory.getInstance()
0815:                        .findFromId(subprojectUniqueId);
0816:
0817:                if (!project.getSubprojectHandler().canInsertProject(
0818:                        subprojectUniqueId)) {
0819:                    Alert
0820:                            .error(Messages
0821:                                    .getString("GraphicManager.SelectedProjectAlreadySubproject")); //$NON-NLS-1$
0822:                    return;
0823:                }
0824:                if (openedAlready != null
0825:                        && openedAlready.isOpenedAsSubproject()) {
0826:                    Alert
0827:                            .error(Messages
0828:                                    .getString("GraphicManager.SelectedProjectAlreadyOpenedAsSubproject")); //$NON-NLS-1$
0829:                    return;
0830:                }
0831:                SubProj subprojectTask = project.getSubprojectHandler()
0832:                        .createSubProj(subprojectUniqueId);
0833:                Node subprojectNode = getCurrentFrame().addNodeForImpl(
0834:                        subprojectTask, NodeModel.EVENT);
0835:                ProjectFactory.getInstance().openSubproject(project,
0836:                        subprojectNode, true);
0837:
0838:                //Undo
0839:                if (undo) {
0840:                    UndoController undoContoller = project.getUndoController();
0841:                    if (undoContoller.getEditSupport() != null) {
0842:                        undoContoller.clear();
0843:                        //undoContoller.getEditSupport().postEdit(new CreateSubprojectEdit(project,subprojectNode,subprojectUniqueId));
0844:                    }
0845:                }
0846:
0847:            }
0848:
0849:            protected class CreateSubprojectEdit extends AbstractUndoableEdit {
0850:                protected Project project;
0851:                protected final Node subprojectNode;
0852:                protected long subprojectUniqueId;
0853:
0854:                public CreateSubprojectEdit(Project project,
0855:                        final Node subprojectNode, long subprojectUniqueId) {
0856:                    super ();
0857:                    this .project = project;
0858:                    this .subprojectNode = subprojectNode;
0859:                    this .subprojectUniqueId = subprojectUniqueId;
0860:                }
0861:
0862:                public void redo() throws CannotRedoException {
0863:                    super .redo();
0864:                    insertSubproject(project, subprojectUniqueId, false);
0865:                }
0866:
0867:                public void undo() throws CannotUndoException {
0868:                    super .undo();
0869:                    project.getTaskOutline().remove(subprojectNode,
0870:                            NodeModel.EVENT);
0871:
0872:                    //			UndoController undoContoller=project.getUndoController();
0873:                    //			if (undoContoller.getEditSupport()!=null){
0874:                    //				undoContoller.clear();
0875:                    //			}
0876:                }
0877:            }
0878:
0879:            private void doProjectInformationDialog() {
0880:                if (!getCurrentFrame().isActive())
0881:                    return;
0882:
0883:                finishAnyOperations();
0884:
0885:                if (projectInformationDialog == null) {
0886:                    projectInformationDialog = ProjectInformationDialog
0887:                            .getInstance(getFrame(), getCurrentFrame()
0888:                                    .getProject());
0889:                    projectInformationDialog.pack();
0890:                    projectInformationDialog.setModal(false);
0891:                } else {
0892:                    projectInformationDialog.setObject(getCurrentFrame()
0893:                            .getProject());
0894:                }
0895:                projectInformationDialog
0896:                        .setLocationRelativeTo(getCurrentFrame());//to center on screen
0897:                projectInformationDialog.setVisible(true);
0898:
0899:            }
0900:
0901:            public void doInformationDialog(boolean notes) {
0902:
0903:                if (!isDocumentActive())
0904:                    return;
0905:
0906:                finishAnyOperations();
0907:                List nodes = getCurrentFrame().getSelectedNodes();
0908:                if (nodes == null)
0909:                    return;
0910:                if (nodes.size() > 1) {
0911:                    Alert
0912:                            .warn(
0913:                                    Messages
0914:                                            .getString("Message.onlySelectOneElement"), getContainer()); //$NON-NLS-1$
0915:                    return;
0916:                }
0917:                final Node node = (Node) nodes.get(0);
0918:                Object impl = node.getImpl();
0919:                if (impl instanceof  Task
0920:                        || (impl instanceof  Assignment && taskType)) {
0921:                    Task task = (Task) ((impl instanceof  Assignment) ? (((Assignment) impl)
0922:                            .getTask())
0923:                            : impl);
0924:                    if (taskInformationDialog == null) {
0925:                        taskInformationDialog = TaskInformationDialog
0926:                                .getInstance(getFrame(), task, notes);
0927:                        taskInformationDialog.pack();
0928:                        taskInformationDialog.setModal(false);
0929:                    } else {
0930:                        taskInformationDialog.setObject(task);
0931:                        taskInformationDialog.updateAll();
0932:                    }
0933:                    taskInformationDialog
0934:                            .setLocationRelativeTo(getCurrentFrame());//to center on screen
0935:                    if (notes)
0936:                        taskInformationDialog.showNotes();
0937:                    else if (impl instanceof  Assignment)
0938:                        taskInformationDialog.showResources();
0939:
0940:                    taskInformationDialog.setVisible(true);
0941:                } else if (impl instanceof  Resource
0942:                        || (impl instanceof  Assignment && resourceType)) {
0943:                    Resource resource = (Resource) ((impl instanceof  Assignment) ? (((Assignment) impl)
0944:                            .getResource())
0945:                            : impl);
0946:                    ;
0947:                    if (resourceInformationDialog == null) {
0948:                        resourceInformationDialog = ResourceInformationDialog
0949:                                .getInstance(getFrame(), resource);
0950:                        resourceInformationDialog.pack();
0951:                        resourceInformationDialog.setModal(false);
0952:                    } else {
0953:                        resourceInformationDialog.setObject(resource);
0954:                        resourceInformationDialog.updateAll();
0955:                    }
0956:                    resourceInformationDialog
0957:                            .setLocationRelativeTo(getCurrentFrame());//to center on screen
0958:                    if (notes)
0959:                        resourceInformationDialog.showNotes();
0960:                    resourceInformationDialog.setVisible(true);
0961:
0962:                } else if (impl instanceof  Project) {
0963:                    doProjectInformationDialog();
0964:                }
0965:
0966:            }
0967:
0968:            public Action getAction(String key) throws MissingListenerException {
0969:                if (actionsMap == null)
0970:                    addHandlers();
0971:
0972:                Action action = actionsMap.getConcreteAction(key);
0973:                if (action == null)
0974:                    throw new MissingListenerException(
0975:                            "no listener for mainFrame", getClass().getName(), key); //$NON-NLS-1$
0976:
0977:                return action;
0978:            }
0979:
0980:            public String getStringFromAction(Action action)
0981:                    throws MissingListenerException {
0982:                return actionsMap.getStringFromAction(action);
0983:            }
0984:
0985:            public void addHandlers() {
0986:                actionsMap = new MenuActionsMap(this , menuManager);
0987:                actionsMap.addHandler(ACTION_NEW_PROJECT,
0988:                        new NewProjectAction());
0989:                actionsMap.addHandler(ACTION_OPEN_PROJECT,
0990:                        new OpenProjectAction());
0991:                actionsMap.addHandler(ACTION_INSERT_PROJECT,
0992:                        new InsertProjectAction());
0993:                actionsMap.addHandler(ACTION_EXIT, new ExitAction());
0994:                actionsMap.addHandler(ACTION_IMPORT_MSPROJECT,
0995:                        new ImportMSProjectAction());
0996:                actionsMap.addHandler(ACTION_EXPORT_MSPROJECT,
0997:                        new ExportMSProjectAction());
0998:                actionsMap.addHandler(ACTION_ABOUT_PROJITY, new AboutAction());
0999:                actionsMap.addHandler(ACTION_OPENPROJ, new OpenProjAction());
1000:                actionsMap.addHandler(ACTION_PROJITY_DOCUMENTATION,
1001:                        new HelpAction());
1002:                actionsMap.addHandler(ACTION_TIP_OF_THE_DAY,
1003:                        new TipOfTheDayAction());
1004:                actionsMap.addHandler(ACTION_PROJECT_INFORMATION,
1005:                        new ProjectInformationAction());
1006:                actionsMap.addHandler(ACTION_TEAM_FILTER,
1007:                        new TeamFilterAction());
1008:                actionsMap.addHandler(ACTION_DOCUMENTS, new DocumentsAction());
1009:                actionsMap.addHandler(ACTION_INFORMATION,
1010:                        new InformationAction());
1011:                actionsMap.addHandler(ACTION_NOTES, new NotesAction());
1012:                actionsMap.addHandler(ACTION_ASSIGN_RESOURCES,
1013:                        new AssignResourcesAction());
1014:
1015:                actionsMap.addHandler(ACTION_INSERT_TASK,
1016:                        new InsertTaskAction());
1017:                actionsMap.addHandler(ACTION_INSERT_RESOURCE,
1018:                        new InsertTaskAction()); // will do resource
1019:                actionsMap.addHandler(ACTION_SAVE_PROJECT,
1020:                        new SaveProjectAction());
1021:                actionsMap.addHandler(ACTION_SAVE_PROJECT_AS,
1022:                        new SaveProjectAsAction());
1023:                actionsMap.addHandler(ACTION_PRINT, new PrintAction());
1024:                actionsMap.addHandler(ACTION_PRINT_PREVIEW,
1025:                        new PrintPreviewAction());
1026:                actionsMap.addHandler(ACTION_CLOSE_PROJECT,
1027:                        new CloseProjectAction());
1028:                actionsMap.addHandler(ACTION_UNDO, new UndoAction());
1029:                actionsMap.addHandler(ACTION_REDO, new RedoAction());
1030:                //		actionsMap.addHandler(ACTION_ENTERPRISE_RESOURCES, new EnterpriseResourcesAction());
1031:                actionsMap.addHandler(ACTION_CHANGE_WORKING_TIME,
1032:                        new ChangeWorkingTimeAction());
1033:                actionsMap.addHandler(ACTION_LEVEL_RESOURCES,
1034:                        new LevelResourcesAction());
1035:                actionsMap.addHandler(ACTION_DELEGATE_TASKS,
1036:                        new DelegateTasksAction());
1037:                actionsMap.addHandler(ACTION_UPDATE_TASKS,
1038:                        new UpdateTasksAction());
1039:                actionsMap.addHandler(ACTION_UPDATE_PROJECT,
1040:                        new UpdateProjectAction());
1041:                actionsMap.addHandler(ACTION_BAR, new BarAction());
1042:                actionsMap.addHandler(ACTION_INSERT_RECURRING,
1043:                        new RecurringTaskAction());
1044:                actionsMap.addHandler(ACTION_SORT, new SortAction());
1045:                actionsMap.addHandler(ACTION_GROUP, new GroupAction());
1046:                actionsMap.addHandler(ACTION_SCHEDULE_OPTIONS,
1047:                        new ScheduleOptionsAction());
1048:                actionsMap.addHandler(ACTION_CALENDAR_OPTIONS,
1049:                        new CalendarOptionsAction());
1050:                actionsMap.addHandler(ACTION_GENERAL_OPTIONS,
1051:                        new GeneralOptionsAction());
1052:                actionsMap.addHandler(ACTION_EDIT_OPTIONS,
1053:                        new EditOptionsAction());
1054:                actionsMap.addHandler(ACTION_SAVE_BASELINE,
1055:                        new SaveBaselineAction());
1056:                actionsMap.addHandler(ACTION_CLEAR_BASELINE,
1057:                        new ClearBaselineAction());
1058:                actionsMap.addHandler(ACTION_LINK, new LinkAction());
1059:                actionsMap.addHandler(ACTION_UNLINK, new UnlinkAction());
1060:                actionsMap.addHandler(ACTION_ZOOM_IN, new ZoomInAction());
1061:                actionsMap.addHandler(ACTION_ZOOM_OUT, new ZoomOutAction());
1062:                actionsMap.addHandler(ACTION_SCROLL_TO_TASK,
1063:                        new ScrollToTaskAction());
1064:                actionsMap.addHandler(ACTION_INDENT, new IndentAction());
1065:                actionsMap.addHandler(ACTION_OUTDENT, new OutdentAction());
1066:                actionsMap.addHandler(ACTION_CUT, new CutAction());
1067:                actionsMap.addHandler(ACTION_COPY, new CopyAction());
1068:                actionsMap.addHandler(ACTION_PASTE, new PasteAction());
1069:                actionsMap.addHandler(ACTION_DELETE, new DeleteAction());
1070:
1071:                actionsMap.addHandler(ACTION_GANTT,
1072:                        new ViewAction(ACTION_GANTT));
1073:                actionsMap.addHandler(ACTION_TRACKING_GANTT, new ViewAction(
1074:                        ACTION_TRACKING_GANTT));
1075:                actionsMap.addHandler(ACTION_TASK_USAGE_DETAIL, new ViewAction(
1076:                        ACTION_TASK_USAGE_DETAIL));
1077:                actionsMap.addHandler(ACTION_RESOURCE_USAGE_DETAIL,
1078:                        new ViewAction(ACTION_RESOURCE_USAGE_DETAIL));
1079:                actionsMap.addHandler(ACTION_NETWORK, new ViewAction(
1080:                        ACTION_NETWORK));
1081:                actionsMap.addHandler(ACTION_WBS, new ViewAction(ACTION_WBS));
1082:                actionsMap.addHandler(ACTION_RBS, new ViewAction(ACTION_RBS));
1083:                actionsMap.addHandler(ACTION_REPORT, new ViewAction(
1084:                        ACTION_REPORT));
1085:                actionsMap.addHandler(ACTION_PROJECTS, new ViewAction(
1086:                        ACTION_PROJECTS));
1087:                actionsMap.addHandler(ACTION_RESOURCES,
1088:                        resourceAction = new ViewAction(ACTION_RESOURCES));
1089:                actionsMap.addHandler(ACTION_HISTOGRAM, new ViewAction(
1090:                        ACTION_HISTOGRAM));
1091:                actionsMap.addHandler(ACTION_CHARTS, new ViewAction(
1092:                        ACTION_CHARTS));
1093:                actionsMap.addHandler(ACTION_TASK_USAGE, new ViewAction(
1094:                        ACTION_TASK_USAGE));
1095:                actionsMap.addHandler(ACTION_RESOURCE_USAGE, new ViewAction(
1096:                        ACTION_RESOURCE_USAGE));
1097:                actionsMap.addHandler(ACTION_NO_SUB_WINDOW, new ViewAction(
1098:                        ACTION_NO_SUB_WINDOW));
1099:
1100:                actionsMap.addHandler(ACTION_CHOOSE_FILTER,
1101:                        new TransformAction());
1102:                actionsMap
1103:                        .addHandler(ACTION_CHOOSE_SORT, new TransformAction());
1104:                actionsMap.addHandler(ACTION_CHOOSE_GROUP,
1105:                        new TransformAction());
1106:
1107:                actionsMap.addHandler(ACTION_PALETTE, new PaletteAction());
1108:                actionsMap.addHandler(ACTION_LOOK_AND_FEEL,
1109:                        new LookAndFeelAction());
1110:                actionsMap.addHandler(ACTION_FULL_SCREEN,
1111:                        new FullScreenAction());
1112:                actionsMap.addHandler(ACTION_REFRESH, new RefreshAction());
1113:
1114:            }
1115:
1116:            public class NewProjectAction extends
1117:                    MenuActionsMap.GlobalMenuAction {
1118:                private static final long serialVersionUID = 1L;
1119:
1120:                public void actionPerformed(ActionEvent arg0) {
1121:                    setMeAsLastGraphicManager();
1122:                    doNewProjectDialog();
1123:                }
1124:            }
1125:
1126:            public class OpenProjectAction extends
1127:                    MenuActionsMap.GlobalMenuAction {
1128:                private static final long serialVersionUID = 1L;
1129:
1130:                public void actionPerformed(ActionEvent arg0) {
1131:                    setMeAsLastGraphicManager();
1132:                    if (Environment.getStandAlone())
1133:                        openLocalProject();
1134:                    else
1135:                        doOpenProjectDialog();
1136:                }
1137:            }
1138:
1139:            public class InsertProjectAction extends
1140:                    MenuActionsMap.DocumentMenuAction {
1141:                private static final long serialVersionUID = 1L;
1142:
1143:                public void actionPerformed(ActionEvent arg0) {
1144:                    setMeAsLastGraphicManager();
1145:                    doInsertProjectDialog();
1146:                }
1147:            }
1148:
1149:            public class ExitAction extends MenuActionsMap.GlobalMenuAction {
1150:                private static final long serialVersionUID = 1L;
1151:
1152:                public void actionPerformed(ActionEvent arg0) {
1153:                    setMeAsLastGraphicManager();
1154:                    closeApplication();
1155:                }
1156:            }
1157:
1158:            public class ImportMSProjectAction extends
1159:                    MenuActionsMap.GlobalMenuAction {
1160:                private static final long serialVersionUID = 1L;
1161:
1162:                public void actionPerformed(ActionEvent arg0) {
1163:                    setMeAsLastGraphicManager();
1164:                    openLocalProject();
1165:                }
1166:            }
1167:
1168:            public class ExportMSProjectAction extends
1169:                    MenuActionsMap.DocumentMenuAction {
1170:                private static final long serialVersionUID = 1L;
1171:
1172:                public void actionPerformed(ActionEvent arg0) {
1173:                    setMeAsLastGraphicManager();
1174:                    saveLocalProject(true);
1175:                }
1176:            }
1177:
1178:            public class AboutAction extends MenuActionsMap.GlobalMenuAction {
1179:                private static final long serialVersionUID = 1L;
1180:
1181:                public void actionPerformed(ActionEvent arg0) {
1182:                    setMeAsLastGraphicManager();
1183:                    showAboutDialog();
1184:                }
1185:            }
1186:
1187:            public class OpenProjAction extends MenuActionsMap.GlobalMenuAction {
1188:                private static final long serialVersionUID = 1L;
1189:
1190:                public void actionPerformed(ActionEvent arg0) {
1191:                    setMeAsLastGraphicManager();
1192:                    BrowserControl.displayURL("http://www.projity.com/");
1193:                }
1194:            }
1195:
1196:            public class HelpAction extends MenuActionsMap.GlobalMenuAction {
1197:                private static final long serialVersionUID = 1L;
1198:
1199:                public void actionPerformed(ActionEvent arg0) {
1200:                    setMeAsLastGraphicManager();
1201:                    showHelpDialog();
1202:                }
1203:            }
1204:
1205:            public class TipOfTheDayAction extends
1206:                    MenuActionsMap.GlobalMenuAction {
1207:                private static final long serialVersionUID = 1L;
1208:
1209:                public void actionPerformed(ActionEvent arg0) {
1210:                    setMeAsLastGraphicManager();
1211:                    TipOfTheDay.showDialog(getFrame(), true);
1212:                }
1213:            }
1214:
1215:            public class ProjectInformationAction extends
1216:                    MenuActionsMap.DocumentMenuAction {
1217:                private static final long serialVersionUID = 1L;
1218:
1219:                public void actionPerformed(ActionEvent arg0) {
1220:                    setMeAsLastGraphicManager();
1221:                    doProjectInformationDialog();
1222:                }
1223:            }
1224:
1225:            public class TeamFilterAction extends
1226:                    MenuActionsMap.DocumentMenuAction {
1227:                private static final long serialVersionUID = 1L;
1228:
1229:                public void actionPerformed(ActionEvent arg0) {
1230:                    GlobalPreferences preferences = getPreferences();
1231:                    ;
1232:                    //Field field = Configuration.getFieldFromId("Field.showProjectResourcesOnly");
1233:                    boolean teamOnly = !preferences
1234:                            .isShowProjectResourcesOnly();
1235:                    //field.setValue(preferences,this,teamOnly);
1236:                    preferences.setShowProjectResourcesOnly(teamOnly);
1237:                    ArrayList buttons = getMenuManager().getToolBarFactory()
1238:                            .getButtonsFromId("TeamFilter"); //$NON-NLS-1$
1239:                    if (buttons != null && buttons.size() == 1) {
1240:                        JButton b = (JButton) buttons.get(0);
1241:                        if (Environment.isNewLook())
1242:                            b
1243:                                    .setIcon(IconManager
1244:                                            .getIcon(teamOnly ? "menu24.showTeamResources" : "menu24.showAllResources")); //$NON-NLS-1$ //$NON-NLS-2$
1245:                        else
1246:                            b
1247:                                    .setIcon(IconManager
1248:                                            .getIcon(teamOnly ? "menu.showTeamResourcesSmall" : "menu.showAllResourcesSmall")); //$NON-NLS-1$ //$NON-NLS-2$
1249:                    }
1250:                    menuManager.setActionSelected(ACTION_TEAM_FILTER, teamOnly);
1251:
1252:                }
1253:            }
1254:
1255:            public class DocumentsAction extends
1256:                    MenuActionsMap.DocumentMenuAction {
1257:                private static final long serialVersionUID = 1L;
1258:
1259:                public void actionPerformed(ActionEvent arg0) {
1260:                    setMeAsLastGraphicManager();
1261:                    if (!isDocumentActive())
1262:                        return;
1263:                    invokeFieldAction(ACTION_DOCUMENTS, getCurrentFrame()
1264:                            .getProject());
1265:                }
1266:            }
1267:
1268:            private boolean isEnabledFieldAction(String action, Object obj) {
1269:                Field f = FieldDictionary.getInstance().getActionField(
1270:                        ACTION_DOCUMENTS);
1271:                return (obj != null && f != null && f.getValue(obj, null) != null);
1272:
1273:            }
1274:
1275:            private void invokeFieldAction(String action, Object obj) {
1276:                Field f = FieldDictionary.getInstance().getActionField(
1277:                        ACTION_DOCUMENTS);
1278:                if (f != null)
1279:                    f.invokeAction(obj);
1280:
1281:            }
1282:
1283:            public class ScheduleOptionsAction extends
1284:                    MenuActionsMap.GlobalMenuAction {
1285:                private static final long serialVersionUID = 1L;
1286:
1287:                public void actionPerformed(ActionEvent arg0) {
1288:                    setMeAsLastGraphicManager();
1289:                    doScheduleOptionsDialog();
1290:                }
1291:            }
1292:
1293:            public class CalendarOptionsAction extends
1294:                    MenuActionsMap.GlobalMenuAction {
1295:                private static final long serialVersionUID = 1L;
1296:
1297:                public void actionPerformed(ActionEvent arg0) {
1298:                    setMeAsLastGraphicManager();
1299:                    doCalendarOptionsDialog();
1300:                }
1301:            }
1302:
1303:            public class GeneralOptionsAction extends
1304:                    MenuActionsMap.GlobalMenuAction {
1305:                private static final long serialVersionUID = 1L;
1306:
1307:                public void actionPerformed(ActionEvent arg0) {
1308:                    setMeAsLastGraphicManager();
1309:                    doGeneralOptionsDialog();
1310:                }
1311:            }
1312:
1313:            public class EditOptionsAction extends
1314:                    MenuActionsMap.GlobalMenuAction {
1315:                private static final long serialVersionUID = 1L;
1316:
1317:                public void actionPerformed(ActionEvent arg0) {
1318:                    setMeAsLastGraphicManager();
1319:                    doEditOptionsDialog();
1320:                }
1321:            }
1322:
1323:            public class InformationAction extends
1324:                    MenuActionsMap.DocumentMenuAction {
1325:                private static final long serialVersionUID = 1L;
1326:
1327:                public void actionPerformed(ActionEvent arg0) {
1328:                    setMeAsLastGraphicManager();
1329:                    doInformationDialog(false);
1330:                }
1331:            }
1332:
1333:            public class NotesAction extends MenuActionsMap.DocumentMenuAction {
1334:                private static final long serialVersionUID = 1L;
1335:
1336:                public void actionPerformed(ActionEvent arg0) {
1337:                    setMeAsLastGraphicManager();
1338:                    doInformationDialog(true);
1339:                }
1340:            }
1341:
1342:            public class AssignResourcesAction extends
1343:                    MenuActionsMap.DocumentMenuAction {
1344:                private static final long serialVersionUID = 1L;
1345:
1346:                public void actionPerformed(ActionEvent arg0) {
1347:                    setMeAsLastGraphicManager();
1348:                    showAssignmentDialog(getCurrentFrame());
1349:                }
1350:            }
1351:
1352:            public class SelectDocumentAction extends
1353:                    MenuActionsMap.GlobalMenuAction {
1354:                private static final long serialVersionUID = 1L;
1355:                DocumentFrame frame;
1356:
1357:                public SelectDocumentAction(DocumentFrame frame) {
1358:                    this .frame = frame;
1359:                }
1360:
1361:                public void actionPerformed(ActionEvent arg0) {
1362:                    setMeAsLastGraphicManager();
1363:                    GraphicManager.this .setCurrentFrame(frame);
1364:                }
1365:
1366:                @Override
1367:                public Object getValue(String key) {
1368:                    if (key == Action.NAME)
1369:                        return frame.getProject().getName();
1370:                    return super .getValue(key);
1371:                }
1372:            }
1373:
1374:            // Document actions
1375:            public class InsertTaskAction extends
1376:                    MenuActionsMap.DocumentMenuAction {
1377:                private static final long serialVersionUID = 1L;
1378:
1379:                public void actionPerformed(ActionEvent arg0) {
1380:                    setMeAsLastGraphicManager();
1381:                    if (isDocumentActive())
1382:                        getCurrentFrame().addNodeForImpl(null);
1383:                }
1384:            }
1385:
1386:            public class SaveProjectAction extends
1387:                    MenuActionsMap.DocumentMenuAction {
1388:                private static final long serialVersionUID = 1L;
1389:
1390:                public void actionPerformed(ActionEvent arg0) {
1391:                    setMeAsLastGraphicManager();
1392:                    if (Environment.getStandAlone())
1393:                        saveLocalProject(false);
1394:                    else {
1395:                        if (isDocumentActive()) {
1396:                            final DocumentFrame frame = getCurrentFrame();
1397:                            final Project project = frame.getProject();
1398:                            SaveOptions opt = new SaveOptions();
1399:                            opt.setPostSaving(new Closure() {
1400:                                public void execute(Object arg0) {
1401:                                    refreshSaveStatus(true);
1402:                                }
1403:                            });
1404:                            opt.setPreSaving(getSavingClosure());
1405:                            projectFactory.saveProject(project, opt);
1406:                        }
1407:                    }
1408:
1409:                }
1410:
1411:                protected boolean allowed(boolean enable) {
1412:                    if (enable == false)
1413:                        return true;
1414:                    NamedFrame frame = getCurrentFrame();
1415:                    if (frame == null)
1416:                        return false;
1417:                    Project project = getCurrentFrame().getProject();
1418:                    if (project == null)
1419:                        return false;
1420:                    return /*!project.isLocal()&&*/project.needsSaving();
1421:                }
1422:            }
1423:
1424:            public class SaveProjectAsAction extends
1425:                    MenuActionsMap.DocumentMenuAction {
1426:                private static final long serialVersionUID = 1L;
1427:
1428:                public void actionPerformed(ActionEvent arg0) {
1429:                    setMeAsLastGraphicManager();
1430:                    if (Environment.getStandAlone())
1431:                        saveLocalProject(true);
1432:                    else {
1433:                        if (isDocumentActive()) {
1434:                            final DocumentFrame frame = getCurrentFrame();
1435:                            final Project project = frame.getProject();
1436:                            SaveOptions opt = new SaveOptions();
1437:                            opt.setPostSaving(new Closure() {
1438:                                public void execute(Object arg0) {
1439:                                    frame.setId(project.getUniqueId() + ""); //$NON-NLS-1$
1440:                                    refreshSaveStatus(true);
1441:                                }
1442:                            });
1443:                            opt.setSaveAs(true);
1444:                            opt.setPreSaving(getSavingClosure());
1445:                            projectFactory.saveProject(project, opt);
1446:                        }
1447:                    }
1448:                }
1449:
1450:                protected boolean allowed(boolean enable) {
1451:                    if (enable == false)
1452:                        return true;
1453:                    NamedFrame frame = getCurrentFrame();
1454:                    if (frame == null)
1455:                        return false;
1456:                    Project project = getCurrentFrame().getProject();
1457:                    if (project == null)
1458:                        return false;
1459:
1460:                    return true;//!project.isLocal()&&!project.isMaster();
1461:                }
1462:            }
1463:
1464:            public class PrintAction extends MenuActionsMap.DocumentMenuAction {
1465:                private static final long serialVersionUID = 1L;
1466:
1467:                public void actionPerformed(ActionEvent arg0) {
1468:                    setMeAsLastGraphicManager();
1469:                    if (isDocumentActive())
1470:                        print();
1471:                }
1472:            }
1473:
1474:            public class PrintPreviewAction extends
1475:                    MenuActionsMap.DocumentMenuAction {
1476:                private static final long serialVersionUID = 1L;
1477:
1478:                public void actionPerformed(ActionEvent arg0) {
1479:                    setMeAsLastGraphicManager();
1480:                    if (isDocumentActive())
1481:                        printPreview();
1482:                }
1483:            }
1484:
1485:            public class CloseProjectAction extends
1486:                    MenuActionsMap.DocumentMenuAction {
1487:                private static final long serialVersionUID = 1L;
1488:
1489:                public void actionPerformed(ActionEvent arg0) {
1490:                    setMeAsLastGraphicManager();
1491:                    if (isDocumentActive())
1492:                        closeProject(getCurrentFrame().getProject());
1493:                }
1494:            }
1495:
1496:            public class UndoAction extends MenuActionsMap.DocumentMenuAction {
1497:                private static final long serialVersionUID = 1L;
1498:
1499:                public void actionPerformed(ActionEvent arg0) {
1500:                    setMeAsLastGraphicManager();
1501:                    if (isDocumentActive())
1502:                        getCurrentFrame().doUndoRedo(true);
1503:                }
1504:            }
1505:
1506:            public class RedoAction extends MenuActionsMap.DocumentMenuAction {
1507:                private static final long serialVersionUID = 1L;
1508:
1509:                public void actionPerformed(ActionEvent arg0) {
1510:                    setMeAsLastGraphicManager();
1511:                    if (isDocumentActive())
1512:                        getCurrentFrame().doUndoRedo(false);
1513:                }
1514:            }
1515:
1516:            //	public class EnterpriseResourcesAction extends MenuActionsMap.DocumentMenuAction {
1517:            //		public void actionPerformed(ActionEvent arg0) {
1518:            //			if (isDocumentActive())
1519:            //				getCurrentFrame().doEnterpriseResourcesDialog();
1520:            //		}
1521:            //	}
1522:
1523:            public class ChangeWorkingTimeAction extends
1524:                    MenuActionsMap.DocumentMenuAction {
1525:                private static final long serialVersionUID = 1L;
1526:
1527:                public void actionPerformed(ActionEvent arg0) {
1528:                    setMeAsLastGraphicManager();
1529:                    JDialog dlg = AbstractDialog.containedInDialog(arg0
1530:                            .getSource());
1531:                    boolean restrict = dlg != null;
1532:                    if (isDocumentActive())
1533:                        getCurrentFrame().doChangeWorkingTimeDialog(restrict);
1534:                }
1535:            }
1536:
1537:            public class LevelResourcesAction extends
1538:                    MenuActionsMap.DocumentMenuAction {
1539:                private static final long serialVersionUID = 1L;
1540:
1541:                public void actionPerformed(ActionEvent arg0) {
1542:                    setMeAsLastGraphicManager();
1543:                    if (isDocumentActive())
1544:                        getCurrentFrame().doLevelResourcesDialog();
1545:                }
1546:            }
1547:
1548:            public class DelegateTasksAction extends
1549:                    MenuActionsMap.DocumentMenuAction {
1550:                private static final long serialVersionUID = 1L;
1551:
1552:                public void actionPerformed(ActionEvent arg0) {
1553:                    setMeAsLastGraphicManager();
1554:                    if (isDocumentActive())
1555:                        getCurrentFrame().doDelegateTasksDialog();
1556:                }
1557:            }
1558:
1559:            public class UpdateTasksAction extends
1560:                    MenuActionsMap.DocumentMenuAction {
1561:                private static final long serialVersionUID = 1L;
1562:
1563:                public void actionPerformed(ActionEvent arg0) {
1564:                    setMeAsLastGraphicManager();
1565:                    if (isDocumentActive())
1566:                        getCurrentFrame().doUpdateTasksDialog();
1567:                }
1568:            }
1569:
1570:            public class UpdateProjectAction extends
1571:                    MenuActionsMap.DocumentMenuAction {
1572:                private static final long serialVersionUID = 1L;
1573:
1574:                public void actionPerformed(ActionEvent arg0) {
1575:                    setMeAsLastGraphicManager();
1576:                    if (isDocumentActive())
1577:                        getCurrentFrame().doUpdateProjectDialog();
1578:                }
1579:            }
1580:
1581:            public class DefineCodeAction extends
1582:                    MenuActionsMap.DocumentMenuAction {
1583:                private static final long serialVersionUID = 1L;
1584:
1585:                public void actionPerformed(ActionEvent arg0) {
1586:                    setMeAsLastGraphicManager();
1587:                    if (isDocumentActive())
1588:                        getCurrentFrame().doDefineCodeDialog();
1589:                }
1590:            }
1591:
1592:            public class BarAction extends MenuActionsMap.DocumentMenuAction {
1593:                private static final long serialVersionUID = 1L;
1594:
1595:                public void actionPerformed(ActionEvent arg0) {
1596:                    setMeAsLastGraphicManager();
1597:                    if (isDocumentActive())
1598:                        getCurrentFrame().doBarDialog();
1599:                }
1600:            }
1601:
1602:            public class RecurringTaskAction extends
1603:                    MenuActionsMap.DocumentMenuAction {
1604:                private static final long serialVersionUID = 1L;
1605:
1606:                public void actionPerformed(ActionEvent arg0) {
1607:                    setMeAsLastGraphicManager();
1608:                    if (isDocumentActive())
1609:                        getCurrentFrame().doRecurringTaskDialog();
1610:                }
1611:            }
1612:
1613:            public class SortAction extends MenuActionsMap.DocumentMenuAction {
1614:                private static final long serialVersionUID = 1L;
1615:
1616:                public void actionPerformed(ActionEvent arg0) {
1617:                    setMeAsLastGraphicManager();
1618:                    if (isDocumentActive())
1619:                        getCurrentFrame().doSortDialog();
1620:                }
1621:            }
1622:
1623:            public class GroupAction extends MenuActionsMap.DocumentMenuAction {
1624:                private static final long serialVersionUID = 1L;
1625:
1626:                public void actionPerformed(ActionEvent arg0) {
1627:                    setMeAsLastGraphicManager();
1628:                    if (isDocumentActive())
1629:                        getCurrentFrame().doGroupDialog();
1630:                }
1631:            }
1632:
1633:            public class SaveBaselineAction extends
1634:                    MenuActionsMap.DocumentMenuAction {
1635:                private static final long serialVersionUID = 1L;
1636:
1637:                public void actionPerformed(ActionEvent arg0) {
1638:                    setMeAsLastGraphicManager();
1639:                    if (isDocumentActive())
1640:                        getCurrentFrame().doBaselineDialog(true);
1641:                }
1642:            }
1643:
1644:            public class ClearBaselineAction extends
1645:                    MenuActionsMap.DocumentMenuAction {
1646:                private static final long serialVersionUID = 1L;
1647:
1648:                public void actionPerformed(ActionEvent arg0) {
1649:                    setMeAsLastGraphicManager();
1650:                    if (isDocumentActive())
1651:                        getCurrentFrame().doBaselineDialog(false);
1652:                }
1653:            }
1654:
1655:            public class LinkAction extends MenuActionsMap.DocumentMenuAction {
1656:                private static final long serialVersionUID = 1L;
1657:
1658:                public void actionPerformed(ActionEvent arg0) {
1659:                    setMeAsLastGraphicManager();
1660:                    if (isDocumentActive())
1661:                        getCurrentFrame().doLinkTasks();
1662:                }
1663:            }
1664:
1665:            public class UnlinkAction extends MenuActionsMap.DocumentMenuAction {
1666:                private static final long serialVersionUID = 1L;
1667:
1668:                public void actionPerformed(ActionEvent arg0) {
1669:                    setMeAsLastGraphicManager();
1670:                    if (isDocumentActive())
1671:                        getCurrentFrame().doUnlinkTasks();
1672:                }
1673:            }
1674:
1675:            public class ZoomInAction extends MenuActionsMap.DocumentMenuAction {
1676:                private static final long serialVersionUID = 1L;
1677:
1678:                public void actionPerformed(ActionEvent arg0) {
1679:                    setMeAsLastGraphicManager();
1680:                    if (isDocumentActive())
1681:                        getCurrentFrame().doZoomIn();
1682:                    setZoomButtons();
1683:
1684:                }
1685:            }
1686:
1687:            public class ZoomOutAction extends
1688:                    MenuActionsMap.DocumentMenuAction {
1689:                private static final long serialVersionUID = 1L;
1690:
1691:                public void actionPerformed(ActionEvent arg0) {
1692:                    setMeAsLastGraphicManager();
1693:                    if (isDocumentActive())
1694:                        getCurrentFrame().doZoomOut();
1695:                    setZoomButtons();
1696:                }
1697:            }
1698:
1699:            public class ScrollToTaskAction extends
1700:                    MenuActionsMap.DocumentMenuAction {
1701:                private static final long serialVersionUID = 1L;
1702:
1703:                public void actionPerformed(ActionEvent arg0) {
1704:                    setMeAsLastGraphicManager();
1705:                    if (isDocumentActive())
1706:                        getCurrentFrame().doScrollToTask();
1707:                }
1708:            }
1709:
1710:            public class IndentAction extends MenuActionsMap.DocumentMenuAction {
1711:                private static final long serialVersionUID = 1L;
1712:
1713:                public void actionPerformed(ActionEvent arg0) {
1714:                    setMeAsLastGraphicManager();
1715:                    if (isDocumentActive())
1716:                        getCurrentFrame().doIndent();
1717:                }
1718:            }
1719:
1720:            public class OutdentAction extends
1721:                    MenuActionsMap.DocumentMenuAction {
1722:                private static final long serialVersionUID = 1L;
1723:
1724:                public void actionPerformed(ActionEvent arg0) {
1725:                    setMeAsLastGraphicManager();
1726:                    if (isDocumentActive())
1727:                        getCurrentFrame().doOutdent();
1728:                }
1729:            }
1730:
1731:            public class CutAction extends MenuActionsMap.DocumentMenuAction {
1732:                private static final long serialVersionUID = 1L;
1733:
1734:                public void actionPerformed(ActionEvent arg0) {
1735:                    setMeAsLastGraphicManager();
1736:                    if (isDocumentActive())
1737:                        getCurrentFrame().doCut();
1738:                }
1739:            }
1740:
1741:            public class CopyAction extends MenuActionsMap.DocumentMenuAction {
1742:                private static final long serialVersionUID = 1L;
1743:
1744:                public void actionPerformed(ActionEvent arg0) {
1745:                    setMeAsLastGraphicManager();
1746:                    if (isDocumentActive())
1747:                        getCurrentFrame().doCopy();
1748:                }
1749:            }
1750:
1751:            public class PasteAction extends MenuActionsMap.DocumentMenuAction {
1752:                private static final long serialVersionUID = 1L;
1753:
1754:                public void actionPerformed(ActionEvent arg0) {
1755:                    setMeAsLastGraphicManager();
1756:                    if (isDocumentActive())
1757:                        getCurrentFrame().doPaste();
1758:                }
1759:            }
1760:
1761:            public class DeleteAction extends MenuActionsMap.DocumentMenuAction {
1762:                private static final long serialVersionUID = 1L;
1763:
1764:                public void actionPerformed(ActionEvent arg0) {
1765:                    setMeAsLastGraphicManager();
1766:                    if (isDocumentActive())
1767:                        getCurrentFrame().doDelete();
1768:                }
1769:            }
1770:
1771:            public class ViewAction extends MenuActionsMap.DocumentMenuAction {
1772:                private static final long serialVersionUID = 1L;
1773:                private String viewName;
1774:
1775:                public ViewAction(String viewName) {
1776:                    this .viewName = viewName;
1777:                }
1778:
1779:                public void actionPerformed(ActionEvent e) {
1780:                    setMeAsLastGraphicManager();
1781:                    if (getCurrentFrame() == null)
1782:                        return;
1783:                    setColorTheme(viewName);
1784:                    getCurrentFrame().activateView(viewName);
1785:                    setButtonState(null, currentFrame.getProject()); // disable buttons because no selection when first activated
1786:
1787:                }
1788:
1789:                public final String getViewName() {
1790:                    return viewName;
1791:                }
1792:
1793:            }
1794:
1795:            public class TransformAction extends
1796:                    MenuActionsMap.DocumentMenuAction {
1797:                private static final long serialVersionUID = 1L;
1798:
1799:                public void actionPerformed(ActionEvent e) {
1800:                    setMeAsLastGraphicManager();
1801:                    if (!isDocumentActive())
1802:                        return;
1803:                    CommonSpreadSheet spreadSheet = getCurrentFrame()
1804:                            .getTopSpreadSheet();
1805:                    if (spreadSheet != null) {
1806:                        if (spreadSheet.isEditing())
1807:                            spreadSheet.getCellEditor().stopCellEditing();//.cancelCellEditing();
1808:                        spreadSheet.clearSelection();
1809:                    }
1810:                    TransformComboBox combo = (TransformComboBox) e.getSource();
1811:                    CommonTransformFactory factory = (CommonTransformFactory) combo
1812:                            .getSelectedItem();
1813:                    boolean none = (combo.getSelectedIndex() <= 0);
1814:                    combo.setBackground(none ? UIManager
1815:                            .getColor("ComboBox.background") : Color.YELLOW); //$NON-NLS-1$
1816:                    ((TransformComboBoxModel) combo.getModel())
1817:                            .changeTransform(factory);
1818:                }
1819:            }
1820:
1821:            protected void closeApplication() {
1822:                //		if (Environment.getStandAlone()) {
1823:                //			Frame frame=getFrame();
1824:                //			if (frame!=null)
1825:                //				frame.dispose();
1826:                //			System.exit(0);
1827:                //			return;
1828:                //		}
1829:
1830:                (new Thread() {
1831:                    public void run() {
1832:                        JobRunnable exitRunnable = new JobRunnable(
1833:                                "Local: closeProjects") {
1834:                            public Object run() throws Exception {
1835:                                Frame frame = getFrame();
1836:                                if (frame != null)
1837:                                    frame.dispose();
1838:                                System.exit(0);
1839:                                return null; //return not used anyway
1840:                            }
1841:                        };
1842:
1843:                        Job job = projectFactory.getPortfolio()
1844:                                .getRemoveAllProjectsJob(exitRunnable);
1845:                        SessionFactory.getInstance().getLocalSession()
1846:                                .schedule(job);
1847:
1848:                    }
1849:                }).start();
1850:            }
1851:
1852:            public void initLayout() {
1853:                getFrameManager().getWorkspace().setLayout(new BorderLayout());
1854:            }
1855:
1856:            public void initProject() {
1857:                //projects loaded in doStartupAction
1858:                //        if (projectUrl == null && !GeneralOption.getInstance().isStartWithBlankProject()) {
1859:                //			//System.out.println("not opening anything");
1860:                //		} else if (projectUrl == null   || projectUrl.length==0 || projectUrl[0].startsWith("http")) { //same as in Main //$NON-NLS-1$
1861:                //			System.out.println("loading local project:" +projectUrl); //$NON-NLS-1$
1862:                //			boolean ok = loadLocalDocument(projectUrl[0],true); //if null then it will create a new project. WebStart will send a file name
1863:                //			if (!ok)
1864:                //				return;
1865:                //		}
1866:                ////		else {
1867:                ////			loadDownloadedDocument(); //not used anymore
1868:                ////		}
1869:                if (currentFrame != null)
1870:                    currentFrame.activateView(ACTION_GANTT);
1871:
1872:            }
1873:
1874:            void setEnabledDocumentMenuActions(boolean enable) {
1875:                actionsMap.setEnabledDocumentMenuActions(enable);
1876:                if (getCurrentFrame() != null)
1877:                    getCurrentFrame().getFilterToolBarManager().setEnabled(
1878:                            enable);
1879:            }
1880:
1881:            protected Document loadMasterProject() {
1882:                return loadDocument(Session.MASTER, false, false);
1883:            }
1884:
1885:            //	protected void loadDownloadedDocument(){
1886:            //		//showWaitCursor(true);
1887:            //
1888:            //		projectFactory.openDownloadedProject();
1889:            //		//showWaitCursor(false);
1890:            //	}
1891:            protected Document loadDocument(long id, boolean sync,
1892:                    boolean openAs) {
1893:                return loadDocument(id, sync, openAs, null);
1894:            }
1895:
1896:            protected Document loadDocument(long id, boolean sync,
1897:                    boolean openAs, Closure endSwingClosure) {
1898:                //showWaitCursor(true);
1899:                if (id == -1L)
1900:                    return null;
1901:                ProjectFactory factory = projectFactory;
1902:                factory.setServer(server);
1903:                LoadOptions opt = new LoadOptions();
1904:                opt.setId(id);
1905:                opt.setSync(sync);
1906:                opt.setOpenAs(openAs);
1907:                opt.setEndSwingClosure(endSwingClosure);
1908:
1909:                Document result = factory.openProject(opt);
1910:                //showWaitCursor(false);
1911:                return result;
1912:            }
1913:
1914:            protected boolean loadLocalDocument(String fileName, boolean merge) { //uses server to merge
1915:                //showWaitCursor(true);
1916:                Project project;
1917:                if (fileName == null) {
1918:                    //System.out.println("creating empty project");
1919:                    project = projectFactory.createProject();
1920:
1921:                } else {
1922:                    LoadOptions opt = new LoadOptions();
1923:                    opt.setFileName(fileName);
1924:                    opt.setLocal(true);
1925:                    opt.setSync(false);
1926:
1927:                    if (merge)
1928:                        opt.setResourceMapping(new ResourceMappingForm() {
1929:                            public boolean execute() {
1930:                                if (getImportedResources().size() == 0) // don't show dialog if no resources were imported
1931:                                    return true;
1932:                                if (resourceMappingDialog == null) {
1933:                                    resourceMappingDialog = ResourceMappingDialog
1934:                                            .getInstance(this );
1935:                                    resourceMappingDialog.pack();
1936:                                    resourceMappingDialog.setModal(true);
1937:                                } else
1938:                                    resourceMappingDialog.setForm(this );
1939:                                resourceMappingDialog.bind(true);
1940:                                resourceMappingDialog
1941:                                        .setLocationRelativeTo(getCurrentFrame());//to center on screen
1942:                                resourceMappingDialog.setVisible(true);
1943:                                return resourceMappingDialog.getDialogResult() == JOptionPane.OK_OPTION;
1944:                            }
1945:                        });
1946:
1947:                    if (fileName.endsWith(".pod")) { //$NON-NLS-1$
1948:                        opt
1949:                                .setImporter(Environment.getStandAlone() ? LocalSession.LOCAL_PROJECT_IMPORTER
1950:                                        : LocalSession.SERVER_LOCAL_PROJECT_IMPORTER);
1951:                    } else
1952:                        opt
1953:                                .setImporter(LocalSession.MICROSOFT_PROJECT_IMPORTER);
1954:                    project = projectFactory.openProject(opt);
1955:
1956:                }
1957:                //showWaitCursor(false);
1958:                return project != null;
1959:            }
1960:
1961:            protected void saveLocalDocument(String fileName,
1962:                    final boolean saveAs) {
1963:                //showWaitCursor(true);
1964:                SaveOptions opt = new SaveOptions();
1965:                opt.setLocal(true);
1966:                final Project project = getCurrentFrame().getProject();
1967:                if (project.getFileName() != fileName) {
1968:                    final DocumentFrame frame = getCurrentFrame();
1969:                    if (saveAs)
1970:                        opt.setSaveAs(true);
1971:                    opt.setPostSaving(new Closure() {
1972:                        public void execute(Object arg0) {
1973:                            if (saveAs)
1974:                                frame.setId(project.getUniqueId() + ""); //$NON-NLS-1$
1975:                            refreshSaveStatus(true);
1976:                        }
1977:                    });
1978:                }
1979:                if (fileName.endsWith(".pod")) { //$NON-NLS-1$
1980:                    opt.setFileName(fileName);
1981:                    opt.setImporter(LocalSession.LOCAL_PROJECT_IMPORTER);
1982:                } else {
1983:                    opt
1984:                            .setFileName(fileName/*+((fileName.endsWith(".xml"))?"":".xml")*/);
1985:                    opt.setImporter(LocalSession.MICROSOFT_PROJECT_IMPORTER);
1986:                }
1987:                opt.setPreSaving(getSavingClosure());
1988:                projectFactory.saveProject(getCurrentFrame().getProject(), opt);
1989:                //showWaitCursor(false);
1990:            }
1991:
1992:            private Closure getSavingClosure() {
1993:                return null;
1994:                //		return new Closure() {
1995:                //
1996:                //			public void execute(Object arg0) {
1997:                //				Project proj = (Project)arg0;
1998:                //				SpreadSheetFieldArray fieldArray = (SpreadSheetFieldArray) getCurrentFrame().getGanttView().getSpreadSheet().getFieldArray();
1999:                //				proj.getDocumentWorkspace().setSetting("fieldArray", fieldArray);
2000:                //			}
2001:                //
2002:                //		};
2003:                //
2004:            }
2005:
2006:            private Closure getLoadClosure() {
2007:                return null;
2008:                //		return new Closure() {
2009:                //
2010:                //			public void execute(Object arg0) {
2011:                //				Project proj = (Project)arg0;
2012:                //				SpreadSheetFieldArray fieldArray = (SpreadSheetFieldArray) proj.getDocumentWorkspace().getSetting("fieldArray");
2013:                //				if (fieldArray != null)
2014:                //					getCurrentFrame().getGanttView().getSpreadSheet().setFieldArray(fieldArray);
2015:                //			}
2016:                //
2017:                //		};
2018:
2019:            }
2020:
2021:            protected void saveLocalDocument(Project project, String fileName) {
2022:                //showWaitCursor(true);
2023:                SaveOptions opt = new SaveOptions();
2024:                opt.setFileName(fileName);
2025:                opt.setLocal(true);
2026:                opt.setPreSaving(getSavingClosure());
2027:
2028:                projectFactory.saveProject(project, opt);
2029:                //showWaitCursor(false);
2030:            }
2031:
2032:            protected void closeProject(Project project) {
2033:                projectFactory.removeProject(project, true, true);
2034:            }
2035:
2036:            public void openLocalProject() {
2037:                String fileName = SessionFactory.getInstance()
2038:                        .getLocalSession().chooseFileName(false, null);
2039:                if (fileName != null)
2040:                    loadLocalDocument(fileName, !Environment.getStandAlone());
2041:            }
2042:
2043:            public void saveLocalProject(boolean saveAs) {
2044:                String fileName = null;
2045:                Project project = getCurrentFrame().getProject();
2046:                if (!saveAs) {
2047:                    fileName = project.getFileName();
2048:                }
2049:                if (fileName == null)
2050:                    fileName = SessionFactory.getInstance().getLocalSession()
2051:                            .chooseFileName(true, project.getGuessedFileName());
2052:                if (fileName != null)
2053:                    saveLocalDocument(fileName, saveAs);
2054:            }
2055:
2056:            public void showAboutDialog() {
2057:                if (aboutDialog == null) {
2058:                    aboutDialog = AboutDialog.getInstance(getFrame());
2059:                    aboutDialog.pack();
2060:                    aboutDialog.setModal(true);
2061:                }
2062:                aboutDialog.setLocationRelativeTo(getFrame());//to center on screen
2063:                aboutDialog.setVisible(true);
2064:            }
2065:
2066:            public void showHelpDialog(/*DocumentFrame documentFrame*/) {
2067:                if (helpDialog == null) {
2068:                    helpDialog = HelpDialog.getInstance(getFrame());
2069:                    helpDialog.pack();
2070:                    helpDialog.setModal(true);
2071:                }
2072:                helpDialog.setLocationRelativeTo(getFrame());//to center on screen
2073:                helpDialog.setVisible(true);
2074:            }
2075:
2076:            /**
2077:             * Show or focus the assignment dialog.  If showing, initilize to project
2078:             * @param project
2079:             */
2080:            public void showAssignmentDialog(DocumentFrame documentFrame) {
2081:                if (currentFrame == null || !getCurrentFrame().isActive())
2082:                    return;
2083:
2084:                if (assignResourcesDialog == null) {
2085:                    assignResourcesDialog = new AssignmentDialog(documentFrame);
2086:                    assignResourcesDialog.pack();
2087:                    assignResourcesDialog.setModal(false);
2088:                }
2089:                assignResourcesDialog.setLocationRelativeTo(documentFrame);//to center on screen
2090:                assignResourcesDialog.setVisible(true);
2091:            }
2092:
2093:            void doScheduleOptionsDialog() {
2094:                finishAnyOperations();
2095:                //		ScheduleDialogBox.getInstance(getFrame(), null).doModal();
2096:            }
2097:
2098:            void doCalculationOptionsDialog() {
2099:                finishAnyOperations();
2100:                //		CalculationDialogBox.getInstance(getFrame(), null).doModal();
2101:            }
2102:
2103:            void doCalendarOptionsDialog() {
2104:                finishAnyOperations();
2105:                CalendarDialogBox.getInstance(getFrame(), null).doModal();
2106:            }
2107:
2108:            void doGeneralOptionsDialog() {
2109:                finishAnyOperations();
2110:                //		GeneralDialogBox.getInstance(getFrame(), null).doModal();
2111:            }
2112:
2113:            void doEditOptionsDialog() {
2114:                finishAnyOperations();
2115:                //		EditDialogBox.getInstance(getFrame(), null).doModal();
2116:            }
2117:
2118:            void print() {
2119:                GraphPageable document = PrintDocumentFactory.getInstance()
2120:                        .createDocument(getCurrentFrame());
2121:                if (document != null)
2122:                    document.print();
2123:            }
2124:
2125:            void printPreview() {
2126:                GraphPageable document = PrintDocumentFactory.getInstance()
2127:                        .createDocument(getCurrentFrame());
2128:                if (document != null)
2129:                    document.preview();
2130:            }
2131:
2132:            public DocumentFrame getCurrentFrame() {
2133:                return currentFrame;
2134:            }
2135:
2136:            public Frame getFrame() {
2137:                return frame;
2138:            }
2139:
2140:            public Container getContainer() {
2141:                return container;
2142:            }
2143:
2144:            public JobQueue getJobQueue() {
2145:                if (jobQueue == null) {
2146:                    jobQueue = new JobQueue("GraphicManager", false); //$NON-NLS-1$
2147:                }
2148:                return jobQueue;
2149:            }
2150:
2151:            public boolean isDocumentActive() {
2152:                return currentFrame != null && currentFrame.isActive();
2153:            }
2154:
2155:            public void namedFrameActivated(NamedFrameEvent evt) {
2156:                //		System.out.println("Frame activated");
2157:                NamedFrame frame = evt.getNamedFrame();
2158:                if (frame instanceof  DocumentFrame) {
2159:                    DocumentFrame df = (DocumentFrame) frame;
2160:                    setCurrentFrame(df);
2161:
2162:                }
2163:            }
2164:
2165:            public void namedFrameShown(NamedFrameEvent arg0) {
2166:            }
2167:
2168:            public void namedFrameTabShown(NamedFrameEvent evt) {
2169:                NamedFrame frame = evt.getNamedFrame();
2170:                if (frame instanceof  DocumentFrame) {
2171:                    DocumentFrame df = (DocumentFrame) frame;
2172:                    setCurrentFrame(df);
2173:
2174:                }
2175:            }
2176:
2177:            public void windowActivated(WindowEvent arg0) {
2178:            }
2179:
2180:            public void windowClosed(WindowEvent evt) {
2181:                if (evt.getWindow() == assignResourcesDialog)
2182:                    assignResourcesDialog = null;
2183:            }
2184:
2185:            public void windowClosing(WindowEvent arg0) {
2186:            }
2187:
2188:            public void windowDeactivated(WindowEvent arg0) {
2189:            }
2190:
2191:            public void windowDeiconified(WindowEvent arg0) {
2192:            }
2193:
2194:            public void windowIconified(WindowEvent arg0) {
2195:            }
2196:
2197:            public void windowStateChanged(WindowEvent arg0) {
2198:            }
2199:
2200:            protected boolean resourceType = false;
2201:            protected boolean taskType = false;
2202:
2203:            public void setTaskInformation(boolean taskType,
2204:                    boolean resourceType) {
2205:                this .taskType = taskType;
2206:                this .resourceType = resourceType;
2207:                //		JButton button = null;
2208:                //		String infoText = "Task Information";
2209:                //		String notesText = "Task Notes";
2210:                //		String insertText = getMenuManager().getString(ACTION_INSERT_TASK + ButtonFactory.TOOLTIP_SUFFIX);
2211:                //		if (resourceType&&!taskType){
2212:                //			infoText = "Resource Information";
2213:                //			notesText = "Resource Notes";
2214:                //			insertText = "Insert Resource";
2215:                //		}
2216:                //		getMenuManager().setText(ACTION_INFORMATION,infoText);
2217:                //		getMenuManager().setText(ACTION_NOTES,notesText);
2218:                //		getMenuManager().setText(ACTION_INSERT_TASK,insertText);
2219:            }
2220:
2221:            public void setConnected(boolean connected) {
2222:                getMenuManager().setActionEnabled(ACTION_IMPORT_MSPROJECT,
2223:                        connected);
2224:                getMenuManager().setActionEnabled(ACTION_OPEN_PROJECT,
2225:                        connected);
2226:                getMenuManager()
2227:                        .setActionEnabled(ACTION_NEW_PROJECT, connected);
2228:                if (connected)
2229:                    refreshSaveStatus(true);
2230:
2231:            }
2232:
2233:            Set getActionSet() {
2234:                Set actions = null;
2235:                DocumentFrame df = getCurrentFrame();
2236:                if (df != null) {
2237:                    SpreadSheet sp = df.getActiveSpreadSheet();
2238:                    actions = new HashSet();
2239:                    if (sp != null) {
2240:                        String[] a = sp.getActionList();
2241:                        if (a != null) {
2242:                            for (int i = 0; i < a.length; i++)
2243:                                actions.add(a[i]);
2244:                        }
2245:                    }
2246:                }
2247:                return actions;
2248:            }
2249:
2250:            void setButtonState(Object currentImpl, Project project) {
2251:                Set actions = getActionSet();
2252:                boolean infoEnabled = currentImpl != null
2253:                        && (currentImpl instanceof  Assignment
2254:                                || currentImpl instanceof  Task || currentImpl instanceof  Resource);
2255:                boolean notVoid = currentImpl != null
2256:                        && !(currentImpl instanceof  VoidNodeImpl);
2257:
2258:                getMenuManager().setActionEnabled(ACTION_INFORMATION,
2259:                        infoEnabled);
2260:                getMenuManager().setActionEnabled(ACTION_NOTES, infoEnabled);
2261:                getMenuManager().setActionEnabled(
2262:                        ACTION_INSERT_TASK,
2263:                        (taskType || resourceType)
2264:                                && (actions == null || actions
2265:                                        .contains(ACTION_INSERT_TASK)));
2266:                getMenuManager().setActionEnabled(
2267:                        ACTION_INSERT_RESOURCE,
2268:                        (taskType || resourceType)
2269:                                && (actions == null || actions
2270:                                        .contains(ACTION_INSERT_TASK)));
2271:                getMenuManager().setActionEnabled(
2272:                        ACTION_CUT,
2273:                        notVoid
2274:                                && (actions == null || actions
2275:                                        .contains(ACTION_CUT)));
2276:                getMenuManager().setActionEnabled(
2277:                        ACTION_COPY,
2278:                        notVoid
2279:                                && (actions == null || actions
2280:                                        .contains(ACTION_COPY)));
2281:                getMenuManager().setActionEnabled(ACTION_PASTE,
2282:                        actions == null || actions.contains(ACTION_PASTE));
2283:                getMenuManager().setActionEnabled(ACTION_DELETE,
2284:                        actions == null || actions.contains(ACTION_DELETE));
2285:                //TODO set state of paste button
2286:                boolean isTask = currentImpl != null
2287:                        && currentImpl instanceof  Task;
2288:                boolean isResource = currentImpl != null
2289:                        && currentImpl instanceof  Resource;
2290:                boolean isHasStartAndEnd = currentImpl != null
2291:                        && currentImpl instanceof  HasStartAndEnd;
2292:                boolean writable = (currentImpl != null && !ClassUtils
2293:                        .isObjectReadOnly(currentImpl));
2294:                getMenuManager().setActionEnabled(
2295:                        ACTION_INDENT,
2296:                        (isTask || isResource)
2297:                                && (actions == null || actions
2298:                                        .contains(ACTION_INDENT)));
2299:                getMenuManager().setActionEnabled(
2300:                        ACTION_OUTDENT,
2301:                        (isTask || isResource)
2302:                                && (actions == null || actions
2303:                                        .contains(ACTION_OUTDENT)));
2304:                getMenuManager().setActionEnabled(ACTION_LINK, isTask);
2305:                getMenuManager().setActionEnabled(ACTION_UNLINK, isTask);
2306:                getMenuManager().setActionEnabled(ACTION_ASSIGN_RESOURCES,
2307:                        isTask && writable);
2308:                getMenuManager().setActionEnabled(ACTION_DELEGATE_TASKS,
2309:                        isTask && writable);
2310:                getMenuManager().setActionEnabled(ACTION_UPDATE_TASKS, isTask);
2311:
2312:                boolean insertProject = getCurrentFrame()
2313:                        .isCurrentRowInMainProject();
2314:
2315:                //			taskType && (!notVoid || currentImpl == null || ((Task)currentImpl).getOwningProject() == null || ((Task)currentImpl).getOwningProject() == project);
2316:                getMenuManager().setActionEnabled(ACTION_INSERT_PROJECT,
2317:                        insertProject);
2318:
2319:                BaseView view = null;
2320:                DocumentFrame frame = getCurrentFrame();
2321:                if (frame != null) {
2322:                    view = (BaseView) frame.getMainView().getTopComponent();
2323:                }
2324:                getMenuManager().setActionEnabled(ACTION_SCROLL_TO_TASK,
2325:                        isHasStartAndEnd && view.canScrollToTask());
2326:
2327:                if (currentFrame != null) {
2328:                    currentFrame.refreshUndoButtons();
2329:                    //refreshSaveStatus(false);
2330:                }
2331:                boolean printable = currentFrame != null
2332:                        && currentFrame.isPrintable();
2333:                getMenuManager().setActionEnabled(ACTION_PRINT, printable);
2334:                getMenuManager().setActionEnabled(ACTION_PRINT_PREVIEW,
2335:                        printable);
2336:
2337:                setZoomButtons();
2338:
2339:                Field f = FieldDictionary.getInstance().getActionField(
2340:                        ACTION_DOCUMENTS);
2341:                getMenuManager().setActionVisible(ACTION_DOCUMENTS,
2342:                        currentFrame != null && f != null);
2343:                getMenuManager().setActionEnabled(
2344:                        ACTION_DOCUMENTS,
2345:                        currentFrame != null
2346:                                && isEnabledFieldAction(ACTION_DOCUMENTS,
2347:                                        currentFrame.getProject()));
2348:
2349:            }
2350:
2351:            public void setZoomButtons() {
2352:                getMenuManager().setActionEnabled(ACTION_ZOOM_IN,
2353:                        currentFrame != null && currentFrame.canZoomIn());
2354:                getMenuManager().setActionEnabled(ACTION_ZOOM_OUT,
2355:                        currentFrame != null && currentFrame.canZoomOut());
2356:
2357:            }
2358:
2359:            /**
2360:             * React to selection changed events and forward them on to any bottom window
2361:             */
2362:            protected Node lastNode = null;
2363:
2364:            public void selectionChanged(SelectionNodeEvent e) {
2365:                if (assignResourcesDialog != null)
2366:                    assignResourcesDialog.selectionChanged(e);
2367:
2368:                Node currentNode = e.getCurrentNode();
2369:                Object currentImpl = currentNode.getImpl();
2370:                setButtonState(currentImpl, currentFrame.getProject());
2371:                // if on resource view, hide task info and vice versa.  Otherwise just show it
2372:                if (lastNode != null
2373:                        && taskInformationDialog != null
2374:                        && (lastNode.getImpl() instanceof  Task || lastNode
2375:                                .getImpl() instanceof  Assignment)
2376:                        && currentNode.getImpl() instanceof  Resource) {
2377:                    taskInformationDialog.setVisible(false);
2378:                    doInformationDialog(false);
2379:                } else if (lastNode != null
2380:                        && resourceInformationDialog != null
2381:                        && lastNode.getImpl() instanceof  Resource
2382:                        && (currentNode.getImpl() instanceof  Task || currentNode
2383:                                .getImpl() instanceof  Assignment)) {
2384:                    resourceInformationDialog.setVisible(false);
2385:                    doInformationDialog(false);
2386:                } else {
2387:                    if (taskInformationDialog != null)
2388:                        taskInformationDialog.selectionChanged(e);
2389:                    if (resourceInformationDialog != null)
2390:                        resourceInformationDialog.selectionChanged(e);
2391:                }
2392:                lastNode = currentNode;
2393:            }
2394:
2395:            void refreshSaveStatus(boolean isSaving) {
2396:                getMenuManager().setActionEnabled(
2397:                        ACTION_SAVE_PROJECT,
2398:                        currentFrame != null && !isSaving
2399:                                && currentFrame.getProject().needsSaving());
2400:                setTitle(isSaving);
2401:
2402:                FrameManager dm = getFrameManager();
2403:                if (dm != null)
2404:                    dm.update(); //update project combo
2405:            }
2406:
2407:            /* (non-Javadoc)
2408:             * @see com.projity.document.ObjectEvent.Listener#objectChanged(com.projity.document.ObjectEvent)
2409:             */
2410:            public void objectChanged(ObjectEvent objectEvent) {
2411:
2412:                if (objectEvent.getObject() instanceof  Project) {
2413:                    Project project = (Project) objectEvent.getObject();
2414:                    if (objectEvent.isCreate()) {
2415:                        if (project.isOpenedAsSubproject())
2416:                            closeProjectFrame(project); // because it's now in a project
2417:                        else {
2418:                            DocumentFrame f = addProjectFrame(project);
2419:                        }
2420:
2421:                    } else if (objectEvent.isDelete()) {
2422:                        closeProjectFrame(project);
2423:                    }
2424:                    if (projectInformationDialog != null)
2425:                        projectInformationDialog.objectChanged(objectEvent);
2426:                    if (taskInformationDialog != null)
2427:                        taskInformationDialog.objectChanged(objectEvent);
2428:                    if (resourceInformationDialog != null)
2429:                        resourceInformationDialog.objectChanged(objectEvent);
2430:
2431:                }
2432:            }
2433:
2434:            /**
2435:             * @return Returns the menuManager.
2436:             */
2437:            public MenuManager getMenuManager() {
2438:                if (menuManager == null) {
2439:                    menuManager = MenuManager.getInstance(this );
2440:                    addHandlers();
2441:                }
2442:
2443:                return menuManager;
2444:            }
2445:
2446:            public void finishAnyOperations() {
2447:                if (getCurrentFrame() != null)
2448:                    getCurrentFrame().finishAnyOperations();
2449:            }
2450:
2451:            public void showWaitCursor(boolean show) {
2452:                Frame frame = getFrame();
2453:                if (frame == null)
2454:                    return;
2455:                if (show)
2456:                    frame.setCursor(Cursor
2457:                            .getPredefinedCursor(Cursor.WAIT_CURSOR));
2458:                else
2459:                    frame.setCursor(Cursor.getDefaultCursor());
2460:            }
2461:
2462:            public final ProjectFactory getProjectFactory() {
2463:                return projectFactory;
2464:            }
2465:
2466:            public String getTopViewId() {
2467:                if (getCurrentFrame() == null)
2468:                    return ACTION_GANTT;
2469:                else
2470:                    return getCurrentFrame().getTopViewId();
2471:            }
2472:
2473:            public boolean isApplet() {
2474:                return container instanceof  Applet;
2475:            }
2476:
2477:            protected void setToolBarAndMenus(final Container contentPane) {
2478:                JToolBar toolBar;
2479:                if (Environment.isNewLook()) {
2480:                    toolBar = getMenuManager().getToolBar(
2481:                            MenuManager.BIG_TOOL_BAR);
2482:                    if (!Environment.isNewLaf())
2483:                        toolBar.setOpaque(false);
2484:                    if (!isApplet())
2485:                        getMenuManager().setActionVisible(ACTION_FULL_SCREEN,
2486:                                false);
2487:                    toolBar.addSeparator(new Dimension(20, 20));
2488:                    toolBar.add(new Box.Filler(new Dimension(0, 0),
2489:                            new Dimension(0, 0), new Dimension(
2490:                                    Integer.MAX_VALUE, Integer.MAX_VALUE)));
2491:                    toolBar.add(((DefaultFrameManager) getFrameManager())
2492:                            .getProjectComboPanel());
2493:                    toolBar.add(Box.createRigidArea(new Dimension(20, 20)));
2494:                    if (Environment.isNewLaf())
2495:                        toolBar.setBackground(Color.WHITE);
2496:                    toolBar.setFloatable(false);
2497:                    toolBar.setCursor(Cursor
2498:                            .getPredefinedCursor(Cursor.HAND_CURSOR));
2499:                    Box top;
2500:                    JComponent bottom;
2501:
2502:                    top = new Box(BoxLayout.Y_AXIS);
2503:                    toolBar.setAlignmentX(0.0f); // so it is left justified
2504:                    top.add(toolBar);
2505:
2506:                    JToolBar viewToolBar = getMenuManager().getToolBar(
2507:                            MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION);
2508:                    topTabs = new TabbedNavigation();
2509:                    JComponent tabs = topTabs.createContentPanel(
2510:                            getMenuManager(), viewToolBar, 0, JTabbedPane.TOP,
2511:                            true);
2512:                    tabs.setAlignmentX(0.0f); // so it is left justified
2513:
2514:                    top.add(tabs);
2515:                    bottom = new TabbedNavigation().createContentPanel(
2516:                            getMenuManager(), viewToolBar, 1,
2517:                            JTabbedPane.BOTTOM, false);
2518:                    contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE);
2519:                    contentPane.add(bottom, BorderLayout.AFTER_LAST_LINE);
2520:                    if (Environment.isNewLaf())
2521:                        contentPane.setBackground(Color.WHITE);
2522:                } else {
2523:
2524:                    toolBar = getMenuManager().getToolBar(
2525:                            MenuManager.STANDARD_TOOL_BAR);
2526:                    filterToolBarManager = FilterToolBarManager
2527:                            .create(getMenuManager());
2528:                    filterToolBarManager.addButtons(toolBar);
2529:                    contentPane.add(toolBar, BorderLayout.BEFORE_FIRST_LINE);
2530:                    JToolBar viewToolBar = getMenuManager().getToolBar(
2531:                            MenuManager.VIEW_TOOL_BAR);
2532:                    viewToolBar.setOrientation(JToolBar.VERTICAL);
2533:                    viewToolBar.setRollover(true);
2534:                    contentPane.add(viewToolBar, BorderLayout.WEST);
2535:
2536:                    JMenuBar menu = getMenuManager()
2537:                            .getMenu(
2538:                                    Environment.getStandAlone() ? MenuManager.STANDARD_MENU
2539:                                            : MenuManager.SERVER_STANDARD_MENU);
2540:                    ((JComponent) menu).setBorder(BorderFactory
2541:                            .createEmptyBorder());
2542:
2543:                    JMenuItem logo = (JMenuItem) menu.getComponent(0);
2544:                    logo.setBorder(BorderFactory.createEmptyBorder());
2545:                    logo.setMaximumSize(new Dimension(124, 52));
2546:
2547:                    ((JFrame) container).setJMenuBar(menu);
2548:                    projectListMenu = (JMenu) menu.getComponent(6);
2549:                }
2550:
2551:            }
2552:
2553:            private LookAndFeel getPlaf() {
2554:                return getLafManager().getPlaf();
2555:            }
2556:
2557:            public void invalidate() {
2558:                container.invalidate();
2559:                ((RootPaneContainer) container).getContentPane().invalidate();
2560:                ((RootPaneContainer) container).getContentPane().repaint();
2561:            }
2562:
2563:            public void initLookAndFeel() {
2564:                getLafManager().initLookAndFeel();
2565:            }
2566:
2567:            private HashMap colorThemes = null;
2568:
2569:            public HashMap getColorThemes() {
2570:                if (colorThemes == null) {
2571:                    colorThemes = new HashMap();
2572:                    colorThemes.put(ACTION_GANTT, "Bloody Moon"); //$NON-NLS-1$
2573:                    colorThemes.put(ACTION_TRACKING_GANTT, "Mahogany"); //$NON-NLS-1$
2574:                    colorThemes.put(ACTION_NETWORK, "Emerald Grass"); //$NON-NLS-1$
2575:                    colorThemes.put(ACTION_RESOURCES, "Blue Yonder"); //$NON-NLS-1$
2576:                    colorThemes.put(ACTION_PROJECTS, "Emerald Grass"); //$NON-NLS-1$
2577:                    colorThemes.put(ACTION_WBS, "Sepia"); //$NON-NLS-1$
2578:                    colorThemes.put(ACTION_RBS, "Steel Blue"); //$NON-NLS-1$
2579:                    colorThemes.put(ACTION_REPORT, "Aqua"); //$NON-NLS-1$
2580:                    colorThemes.put(ACTION_TASK_USAGE_DETAIL, "Brown Velvet"); //$NON-NLS-1$
2581:                    colorThemes.put(ACTION_RESOURCE_USAGE_DETAIL,
2582:                            "Earth Fresco"); //$NON-NLS-1$
2583:                }
2584:                return colorThemes;
2585:            }
2586:
2587:            public void setPaletteText(String themeName) {
2588:                getMenuManager().setText(ACTION_PALETTE, themeName);
2589:            }
2590:
2591:            void setColorTheme(String viewName) {
2592:                getLafManager().setColorTheme(viewName);
2593:            }
2594:
2595:            public class PaletteAction extends MenuActionsMap.GlobalMenuAction {
2596:                private static final long serialVersionUID = 1L;
2597:
2598:                public void actionPerformed(ActionEvent arg0) {
2599:                    setMeAsLastGraphicManager();
2600:
2601:                    getLafManager().changePalette();
2602:
2603:                }
2604:
2605:                protected boolean allowed(boolean enable) {
2606:                    LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
2607:                    return getLafManager().isChangePaletteAllowed(lookAndFeel);
2608:                }
2609:
2610:            }
2611:
2612:            public class LookAndFeelAction extends
2613:                    MenuActionsMap.GlobalMenuAction {
2614:                private static final long serialVersionUID = 1L;
2615:
2616:                public void actionPerformed(ActionEvent arg0) {
2617:                    setMeAsLastGraphicManager();
2618:
2619:                }
2620:            }
2621:
2622:            public class FullScreenAction extends
2623:                    MenuActionsMap.GlobalMenuAction {
2624:                private static final long serialVersionUID = 1L;
2625:
2626:                public void actionPerformed(ActionEvent arg0) {
2627:                    setMeAsLastGraphicManager();
2628:                    encodeWorkspace(); // so new window takes this one's preferences
2629:                    // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5029025
2630:                    try {
2631:                        Class cl = Class
2632:                                .forName("netscape.javascript.JSObject");
2633:                        Object win = cl.getMethod("getWindow",
2634:                                new Class[] { Applet.class }).invoke(null,
2635:                                new Object[] { container });
2636:                        //JSObject win = JSObject.getWindow((Applet) container);
2637:                        cl.getMethod(
2638:                                "call",
2639:                                new Class[] { String.class,
2640:                                        (new Object[] {}).getClass() }).invoke(
2641:                                win, new Object[] { "fullScreen", null });
2642:                        //win.call("fullScreen", null);		  	     // Call f() in HTML page //$NON-NLS-1$
2643:
2644:                    } catch (IllegalArgumentException e) {
2645:                        // TODO Auto-generated catch block
2646:                        e.printStackTrace();
2647:                    } catch (SecurityException e) {
2648:                        // TODO Auto-generated catch block
2649:                        e.printStackTrace();
2650:                    } catch (IllegalAccessException e) {
2651:                        // TODO Auto-generated catch block
2652:                        e.printStackTrace();
2653:                    } catch (InvocationTargetException e) {
2654:                        // TODO Auto-generated catch block
2655:                        e.printStackTrace();
2656:                    } catch (NoSuchMethodException e) {
2657:                        // TODO Auto-generated catch block
2658:                        e.printStackTrace();
2659:                    } catch (ClassNotFoundException e) {
2660:                        // TODO Auto-generated catch block
2661:                        e.printStackTrace();
2662:                    }
2663:                }
2664:            }
2665:
2666:            public class RefreshAction extends MenuActionsMap.GlobalMenuAction {
2667:                private static final long serialVersionUID = 1L;
2668:
2669:                public void actionPerformed(ActionEvent arg0) {
2670:                    setMeAsLastGraphicManager();
2671:                    getStartupFactory().restart(GraphicManager.this );
2672:                }
2673:            }
2674:
2675:            /**
2676:             * Decode the current workspace (currently using XML though could be binary)
2677:             * @return workspace object decoded from lastWorkspace static
2678:             */
2679:            private Workspace decodeWorkspaceXML() {
2680:                ByteArrayInputStream stream = new ByteArrayInputStream(
2681:                        ((String) lastWorkspace).getBytes());
2682:                XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(
2683:                        stream));
2684:                Workspace workspace = (Workspace) decoder.readObject();
2685:                decoder.close();
2686:                return workspace;
2687:            }
2688:
2689:            private Workspace decodeWorkspaceBinary() {
2690:                ByteArrayInputStream bin = new ByteArrayInputStream(
2691:                        (byte[]) lastWorkspace);
2692:                ObjectInputStream in;
2693:                try {
2694:                    in = new ObjectInputStream(bin);
2695:                    return (Workspace) in.readObject();
2696:                } catch (IOException e) {
2697:                    // TODO Auto-generated catch block
2698:                    e.printStackTrace();
2699:                } catch (ClassNotFoundException e) {
2700:                    // TODO Auto-generated catch block
2701:                    e.printStackTrace();
2702:                }
2703:                return null;
2704:            }
2705:
2706:            public Workspace decodeWorkspace() {
2707:                if (lastWorkspace == null)
2708:                    return null;
2709:                return BINARY_WORKSPACE ? decodeWorkspaceBinary()
2710:                        : decodeWorkspaceXML();
2711:            }
2712:
2713:            /**
2714:             * Encode the current workspace and store it off in lastWorkspace.
2715:             * Currently I use an XML format for easier debugging. It could be serialized as binary as well since
2716:             * all objects in the graph implement Serializable
2717:             *
2718:             */
2719:            private void encodeWorkspaceXML() {
2720:                ByteArrayOutputStream stream = new ByteArrayOutputStream();
2721:                XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
2722:                        stream));
2723:                encoder.writeObject(createWorkspace(SavableToWorkspace.VIEW));
2724:                encoder.close();
2725:                lastWorkspace = stream.toString();
2726:                //		System.out.println(lastWorkspace);
2727:            }
2728:
2729:            private void encodeWorkspaceBinary() {
2730:                ByteArrayOutputStream bout = new ByteArrayOutputStream();
2731:                ObjectOutputStream out;
2732:                try {
2733:                    out = new ObjectOutputStream(bout);
2734:                    out.writeObject(createWorkspace(SavableToWorkspace.VIEW));
2735:                    out.close();
2736:                    bout.close();
2737:                    lastWorkspace = bout.toByteArray();
2738:                } catch (IOException e) {
2739:                    // TODO Auto-generated catch block
2740:                    e.printStackTrace();
2741:                }
2742:
2743:            }
2744:
2745:            public void encodeWorkspace() {
2746:                if (BINARY_WORKSPACE)
2747:                    encodeWorkspaceBinary();
2748:                else
2749:                    encodeWorkspaceXML();
2750:            }
2751:
2752:            public void restoreWorkspace(WorkspaceSetting w, int context) {
2753:                Workspace ws = (Workspace) w;
2754:                colorThemes = ws.colorThemes;
2755:                getFrameManager().restoreWorkspace(ws.frames, context);
2756:            }
2757:
2758:            public WorkspaceSetting createWorkspace(int context) {
2759:                Workspace ws = new Workspace();
2760:                ws.colorThemes = getColorThemes();
2761:                ws.frames = getFrameManager().createWorkspace(context);
2762:                //TODO The active states of BarStyles (and other styles) are currently static. This is ok for applets, but not a general restore workspace feature
2763:                return ws;
2764:            }
2765:
2766:            public static class Workspace implements  WorkspaceSetting {
2767:                private static final long serialVersionUID = -6606344141026658401L;
2768:                private HashMap colorThemes;
2769:                WorkspaceSetting frames;
2770:
2771:                public HashMap getColorThemes() {
2772:                    return colorThemes;
2773:                }
2774:
2775:                public void setColorThemes(HashMap colorThemes) {
2776:                    this .colorThemes = colorThemes;
2777:                }
2778:
2779:                public WorkspaceSetting getFrames() {
2780:                    return frames;
2781:                }
2782:
2783:                public void setFrames(WorkspaceSetting frames) {
2784:                    this .frames = frames;
2785:                }
2786:            }
2787:
2788:            public static final Object getLastWorkspace() {
2789:                return lastWorkspace;
2790:            }
2791:
2792:            public GraphicManager getGraphicManager() {
2793:                return this ;
2794:            }
2795:
2796:            public void setGraphicManager(GraphicManager manager) {
2797:                // TODO Auto-generated method stub
2798:
2799:            }
2800:
2801:            public FrameManager getFrameManager() {
2802:                return frameManager;
2803:            }
2804:
2805:            public void setFrameManager(FrameManager frameManager) {
2806:                this .frameManager = frameManager;
2807:            }
2808:
2809:            public void initView() {
2810:                RootPaneContainer root = (RootPaneContainer) container;
2811:                root.getContentPane().setLayout(new BorderLayout());
2812:                JPanel panel = new JPanel();
2813:                root.getContentPane().add(panel, "Center"); //$NON-NLS-1$
2814:                setFrameManager(new DefaultFrameManager(root, panel, this ));
2815:
2816:                initLayout();
2817:
2818:                setToolBarAndMenus(root.getContentPane());
2819:
2820:                setEnabledDocumentMenuActions(false);
2821:                Workspace workspace = decodeWorkspace();
2822:                if (workspace != null) {
2823:                    restoreWorkspace(workspace, SavableToWorkspace.VIEW);
2824:
2825:                } else
2826:                    initProject();
2827:                //        container.invalidate();
2828:            }
2829:
2830:            public BaselineDialog getBaselineDialog() {
2831:                return baselineDialog;
2832:            }
2833:
2834:            public void setBaselineDialog(BaselineDialog baselineDialog) {
2835:                this .baselineDialog = baselineDialog;
2836:            }
2837:
2838:            public StartupFactory getStartupFactory() {
2839:                return startupFactory;
2840:            }
2841:
2842:            public void setStartupFactory(StartupFactory startupFactory) {
2843:                this .startupFactory = startupFactory;
2844:            }
2845:
2846:            public boolean isEditingMasterProject() {
2847:                Project currentProject = currentFrame.getProject();
2848:                if (currentProject == null)
2849:                    return false;
2850:                return currentProject.isMaster()
2851:                        && !currentProject.isReadOnly();
2852:
2853:            }
2854:
2855:            public GlobalPreferences getPreferences() {
2856:                if (preferences == null)
2857:                    preferences = new GlobalPreferences();
2858:                return preferences;
2859:            }
2860:
2861:            //for AssignmentDialog
2862:            private ResourceInTeamFilter assignmentDialogTransformerInitializationClosure;
2863:
2864:            public Closure setAssignmentDialogTransformerInitializationClosure() {
2865:                return new Closure() {
2866:                    public void execute(Object arg) {
2867:                        ViewTransformer transformer = (ViewTransformer) arg;
2868:                        NodeFilter hiddenFilter = transformer.getHiddenFilter();
2869:                        if (hiddenFilter != null
2870:                                && hiddenFilter instanceof  ResourceInTeamFilter) {
2871:                            assignmentDialogTransformerInitializationClosure = (ResourceInTeamFilter) hiddenFilter;
2872:                            assignmentDialogTransformerInitializationClosure
2873:                                    .setFilterTeam(getGraphicManager()
2874:                                            .getPreferences()
2875:                                            .isShowProjectResourcesOnly());
2876:                        } else
2877:                            assignmentDialogTransformerInitializationClosure = null;
2878:                    }
2879:                };
2880:            }
2881:
2882:            public ResourceInTeamFilter getAssignmentDialogTransformerInitializationClosure() {
2883:                return assignmentDialogTransformerInitializationClosure;
2884:            }
2885:
2886:            public FilterToolBarManager getFilterToolBarManager() {
2887:                return filterToolBarManager;
2888:            }
2889:
2890:            private Mutex initializing = new Mutex();
2891:
2892:            public void beginInitialization() {
2893:                showWaitCursor(true);
2894:                initializing.lock();
2895:            }
2896:
2897:            public void finishInitialization() {
2898:                container.setVisible(true);
2899:                initializing.unlock();
2900:                showWaitCursor(false);
2901:            }
2902:
2903:            public void waitInitialization() {
2904:                initializing.waitUntilUnlocked();
2905:            }
2906:
2907:            /**
2908:             * Methods that are called using reflection to save workspace stuff into project
2909:             * @return
2910:             */
2911:            public static SpreadSheetFieldArray getCurrentFieldArray() {
2912:                return (SpreadSheetFieldArray) getDocumentFrameInstance()
2913:                        .getGanttView().getSpreadSheet()
2914:                        .getFieldArrayWithWidths(
2915:                                getDocumentFrameInstance().getGanttColumns());
2916:            }
2917:
2918:            public static void setCurrentFieldArray(Object fieldArray) {
2919:                getDocumentFrameInstance().getGanttView().getSpreadSheet()
2920:                        .setFieldArrayWithWidths(
2921:                                (SpreadSheetFieldArray) fieldArray);
2922:            }
2923:
2924:            public static UndoController getUndoController() {
2925:                DocumentFrame frame = GraphicManager.getDocumentFrameInstance();
2926:                if (frame == null)
2927:                    return null;
2928:                return frame.getUndoController();
2929:            }
2930:
2931:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.