001: package com.xoetrope.carousel.testpilot;
002:
003: import com.xoetrope.editor.netbeans.wizard.XuiTopComponent;
004: import java.awt.Component;
005: import org.openide.text.CloneableEditorSupport;
006: import org.openide.windows.Mode;
007: import org.openide.windows.WindowManager;
008: import net.xoetrope.xui.XProject;
009: import net.xoetrope.xui.XProjectManager;
010: import net.xoetrope.editor.project.XEditorProject;
011: import java.util.Hashtable;
012: import net.xoetrope.xui.PageSupport;
013: import net.xoetrope.xui.XApplicationContext;
014: import net.xoetrope.xui.XPage;
015:
016: /**
017: * A TopComponent for hosting the TestPilot tool
018: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
019: * the GNU Public License (GPL), please see license.txt for more details. If
020: * you make commercial use of this software you must purchase a commercial
021: * license from Xoetrope.</p>
022: * <p> $Revision: 1.8 $</p>
023: */
024: public class TestPilotTopComponent extends XuiTopComponent {
025: /**
026: * The owner project and the context in which this object operates.
027: */
028: protected XProject currentProject = XProjectManager
029: .getCurrentProject();
030:
031: /** Creates a new instance of TestPilotTopComponent */
032: public TestPilotTopComponent() {
033: super (TestPilotTopComponent.class,
034: "com/xoetrope/carousel/testpilot/project.xui",
035: "com/xoetrope/carousel/testpilot/resources/testPilotStartup.properties");
036: currentProject.setObject("TestPilotTopComponent", this );
037:
038: setName("TestPilot ("
039: + currentProject.getStartupParam("ProjectPath") + ")");
040: currentProject.setObject("TestPilot", this );
041: }
042:
043: public void restoreViews() {
044:
045: }
046:
047: /**
048: * Setup the windowing.
049: * @param context the owner application context
050: * @param currentProject the owner project
051: * @param clientWidth the desired width of the application
052: * @param clientHeight the desired height of the application
053: */
054: public void setupWindow(XApplicationContext context,
055: XProject currentProject, int clientWidth, int clientHeight) {
056: // if ( clientFrame != null )
057: // clientFrame.setSize( clientWidth, clientHeight );
058: //
059: // appWindow = null;
060: // if ( bUseWindow ) {
061: // appWindow = new JWindow( clientFrame );
062: // appWindow.setSize( clientWidth, clientHeight );
063: // appWindow.addWindowListener( context );
064: // clientFrame.addWindowListener( context );
065: // }
066: // else {
067: // appWindow = clientFrame;
068: // if ( clientFrame != null )
069: // clientFrame.addWindowListener( context );
070: // }
071: // appWindow.setLayout( new BorderLayout());
072: // appWindow.add( pageHolder = new Panel(), BorderLayout.CENTER );
073: //
074: // Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
075: // if ( bUseWindow ) {
076: // Dimension frameSize = appWindow.getSize();
077: // appWindow.setLocation( ( screenSize.width - frameSize.width ) / 2, ( screenSize.height - frameSize.height ) / 2 );
078: // appWindow.setVisible( true );
079: // clientFrame.setLocation( screenSize.width / 2, screenSize.height / 2 );
080: // clientFrame.setSize( 0,0 );
081: // clientFrame.setVisible( true );
082: // }
083: // else if ( clientFrame != null ) {
084: // Dimension frameSize = clientFrame.getSize();
085: // String center = null;
086: // try {
087: // center = currentProject.getStartupParam( "CenterWin" );
088: // }
089: // catch ( Exception ex ) {
090: // }
091: // if ( ( center != null ) && ( center.compareTo( "true" ) == 0 ) )
092: // clientFrame.setLocation(( screenSize.width - frameSize.width ) / 2, ( screenSize.height - frameSize.height ) / 2 );
093: // clientFrame.setVisible( true );
094: // }
095: //
096: // currentProject.setApplet( this );
097: // currentProject.setStartupObject( this );
098: // currentProject.setAppFrame( clientFrame );
099: // currentProject.setAppWindow( appWindow );
100: }
101:
102: public Object getContentPaneEx() {
103: return null;//pageHolder;
104: }
105:
106: /**
107: * Get the parent object
108: * @return the parent
109: */
110: public Object getParentObject() {
111: return getParent();
112: }
113:
114: /**
115: * Get the package name for the default widget set
116: */
117: public String getWidgetClassPackage() {
118: return XPage.XUI_SWING_PACKAGE;
119: }
120:
121: public static TestPilotTopComponent getInstance() {
122: XProject currentProject = XProjectManager.getCurrentProject();
123: if (currentProject instanceof XEditorProject) {
124: Object obj = currentProject.getObject("TestPilot");
125: if ((obj == null) || !((Component) obj).isValid()) {
126: obj = new TestPilotTopComponent();
127: TestPilotTopComponent tptc = (TestPilotTopComponent) obj;
128: tptc.open();
129: tptc.requestVisible();
130: tptc.requestActive();
131: return (TestPilotTopComponent) obj;
132: } else
133: return (TestPilotTopComponent) obj;
134: }
135: return null;
136: }
137:
138: public int getPersistenceType() {
139: return PERSISTENCE_NEVER;
140: }
141:
142: public String preferredID() {
143: return "XuiProTestPilot";
144: }
145:
146: public void open() {
147: Mode mode = WindowManager.getDefault().findMode(
148: CloneableEditorSupport.EDITOR_MODE);
149: if (mode != null)
150: mode.dockInto(this );
151: super .open();
152: }
153:
154: protected boolean closeLast() {
155: // You might want to prompt the user first and maybe return false:
156: return true;
157: }
158:
159: /**
160: * Get the menubar, setting it up if it is not already added to the
161: * application frame
162: * @return the menu bar
163: */
164: public Object getApplicationMenuBar() {
165: return null;//clientFrame.getMenuBar();
166: }
167:
168: /**
169: * Set the menubar
170: * @param mb the menubar
171: */
172: public void setApplicationMenuBar(Object mb) {
173: //clientFrame.setMenuBar( (MenuBar)mb );
174: }
175:
176: /**
177: * Setup frameset. This method is called prior to the addition of any target
178: * areas in the framset and prior to the display of any pages. Since this
179: * applet does not support configurable framesets, this method ignores the
180: * parameter values passed.
181: * @param params the framset parameters if any
182: */
183: public void setupFrameset(Hashtable params) {
184: }
185:
186: /**
187: * Display a window decoration, for example a toolbar
188: * @param page the new page
189: * @param constraint a value controlling how and where the decoration is
190: * displayed, this value is application type specific
191: * @return the page being displayed
192: */
193: public Object displayDecoration(PageSupport page, String constraint) {
194: return null;
195: }
196: }
|