Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 88411 Details for
Bug 201783
Initial Integration with DTP SQL Query Builder
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
This patch apply to datatools SqlBuilder source code in 1/31/2007.
patch(SQB_Saving&Restoring UI state0131).txt (text/plain), 62.23 KB, created by
Lin Zhu
on 2008-01-31 07:24:46 EST
(
hide
)
Description:
This patch apply to datatools SqlBuilder source code in 1/31/2007.
Filename:
MIME Type:
Creator:
Lin Zhu
Created:
2008-01-31 07:24:46 EST
Size:
62.23 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.datatools.sqltools.sqlbuilder >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInput.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInput.java,v >retrieving revision 1.1 >diff -u -r1.1 SQLBuilderEditorInput.java >--- src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInput.java 21 Nov 2007 10:02:05 -0000 1.1 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInput.java 31 Jan 2008 12:04:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright © 2005, 2007 IBM Corporation and others. >+ * Copyright © 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which is available at >@@ -7,7 +7,9 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Actuate Corporation - enhancement to maintain SQB UI control state > *******************************************************************************/ >+ > package org.eclipse.datatools.sqltools.sqlbuilder.input; > > import org.eclipse.datatools.connectivity.IConnectionProfile; >@@ -15,6 +17,7 @@ > import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.ISQLStatementInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLBuilderConnectionInfo; > import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo; >@@ -48,6 +51,9 @@ > /** Contains OmitSchemaInfo associated with this object. */ > private IOmitSchemaInfo _omitSchemaInfo; > >+ private IWindowStateInfo _windowStateInfo; >+ private ISQLBuilderEditorInputOptions _usageOption; >+ > /* > * Statement type is used for creating new statements. The value must be > * one of {@link org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper}'s >@@ -354,4 +360,20 @@ > return null; > } > >+ public IWindowStateInfo getWindowStateInfo() { >+ return _windowStateInfo; >+ } >+ >+ public void setWindowStateInfo( IWindowStateInfo windowStateInfo ) { >+ _windowStateInfo = windowStateInfo; >+ } >+ >+ public ISQLBuilderEditorInputOptions getUsageOption() { >+ return _usageOption; >+ } >+ >+ public void setUsageOption( ISQLBuilderEditorInputOptions option ) { >+ _usageOption = option; >+ } >+ > } >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderStorageEditorInput.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderStorageEditorInput.java,v >retrieving revision 1.1 >diff -u -r1.1 SQLBuilderStorageEditorInput.java >--- src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderStorageEditorInput.java 21 Nov 2007 10:02:05 -0000 1.1 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderStorageEditorInput.java 31 Jan 2008 12:04:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright © 2005, 2007 IBM Corporation and others. >+ * Copyright © 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which is available at >@@ -7,11 +7,14 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Actuate Corporation - enhancement to maintain SQB UI control state > *******************************************************************************/ >+ > package org.eclipse.datatools.sqltools.sqlbuilder.input; > > import org.eclipse.core.resources.IStorage; > import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo; > import org.eclipse.datatools.sqltools.sqleditor.SQLEditorStorage; > import org.eclipse.datatools.sqltools.sqleditor.SQLEditorStorageEditorInput; >@@ -32,7 +35,13 @@ > > /** Contains OmitSchemaInfo associated with this object. */ > private IOmitSchemaInfo fOmitSchemaInfo = null; >- >+ >+ /** Contains the IWindowStateInfo */ >+ private IWindowStateInfo fWindowStateInfo; >+ >+ /** Contains the ISQLBuilderEditorInputOptions usage option */ >+ private ISQLBuilderEditorInputOptions fUsageOption; >+ > /** > * Constructs an instance of this class with the given string as the editor > * input source. >@@ -111,5 +120,33 @@ > SQLBuilderInputFactory.saveState( memento, this ); > } > >- >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput#getWindowStateInfo() >+ */ >+ public IWindowStateInfo getWindowStateInfo() { >+ return fWindowStateInfo; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput#setWindowStateInfo(org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo) >+ */ >+ public void setWindowStateInfo( IWindowStateInfo windowStateInfo ) { >+ fWindowStateInfo = windowStateInfo; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput#getUsageOption() >+ */ >+ public ISQLBuilderEditorInputOptions getUsageOption() { >+ return fUsageOption; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput#setUsageOption(org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInputOptions) >+ */ >+ public void setUsageOption( ISQLBuilderEditorInputOptions option ) { >+ fUsageOption = option; >+ } >+ > } >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderInputFactory.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderInputFactory.java,v >retrieving revision 1.1 >diff -u -r1.1 SQLBuilderInputFactory.java >--- src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderInputFactory.java 21 Nov 2007 10:02:05 -0000 1.1 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderInputFactory.java 31 Jan 2008 12:04:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright © 2000, 2007 Sybase, Inc. and others. >+ * Copyright © 2000, 2008 Sybase, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which is available at >@@ -7,14 +7,18 @@ > * > * Contributors: > * Sybase, Inc. - initial API and implementation >+ * Actuate Corporation - enhancement to maintain SQB UI control state > *******************************************************************************/ >+ > package org.eclipse.datatools.sqltools.sqlbuilder.input; > > import org.eclipse.core.resources.IStorage; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLBuilderConstants; > import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo; > import org.eclipse.datatools.sqltools.sqleditor.SQLEditorStorage; > import org.eclipse.ui.IElementFactory; >@@ -85,10 +89,12 @@ > // Create a Storage object from the memento. > String contentName = memento.getString( KEY_STORAGE_NAME ); > IMemento sqlStmtChild = memento.getChild(KEY_STORAGE_SQLCONTENT); >- String contentSQLStatement = ""; >+ String contentSQLStatement = SQLBuilderConstants.EMPTY_STRING; > if (sqlStmtChild != null){ > contentSQLStatement = sqlStmtChild.getTextData(); >- } >+ if (contentSQLStatement == null) >+ contentSQLStatement = SQLBuilderConstants.EMPTY_STRING; >+ } > SQLEditorStorage storage = new SQLEditorStorage( contentName, contentSQLStatement ); > > // Create a SQLBuilderStorageEditorInput from the storage we just created. >@@ -117,7 +123,16 @@ > sqlStorageInput.setOmitSchemaInfo(omitSchemaInfo); > } > } >- >+ >+ // delegates to the window state factory to restore from the memento >+ SQLBuilderWindowStateFactory winStateFactory = new SQLBuilderWindowStateFactory(); >+ SQLBuilderWindowStateInput windowStateInput = >+ (SQLBuilderWindowStateInput) winStateFactory.createElement( memento ); >+ if (windowStateInput != null) >+ { >+ sqlStorageInput.setWindowStateInfo( windowStateInput.getWindowStateInfo() ); >+ } >+ > input = sqlStorageInput; > } > >@@ -131,6 +146,9 @@ > * @param input the storage editor input object that needs to be saved > */ > public static void saveState(IMemento memento, SQLBuilderStorageEditorInput input) { >+ if ( memento == null || input == null ) >+ return; >+ > // Save the editor input type. > memento.putString( KEY_EDITOR_INPUT_TYPE, ID_SQL_BUILDER_STORAGE_EDITOR_INPUT_TYPE ); > >@@ -171,5 +189,15 @@ > omitSchemaInfoChild.putTextData(omitSchemaInfoCode); > } > >+ // Save the window state info, if applicable, in the memento >+ IWindowStateInfo winStateInfo = input.getWindowStateInfo(); >+ if (winStateInfo != null && >+ ( input.getUsageOption() == null || input.getUsageOption().useWindowState() )) >+ { >+ SQLBuilderWindowStateInput windowStateInput = >+ new SQLBuilderWindowStateInput( winStateInfo ); >+ SQLBuilderWindowStateFactory.saveState( memento, windowStateInput ); >+ } > } >+ > } >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderFileEditorInput.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderFileEditorInput.java,v >retrieving revision 1.1 >diff -u -r1.1 SQLBuilderFileEditorInput.java >--- src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderFileEditorInput.java 21 Nov 2007 10:02:05 -0000 1.1 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderFileEditorInput.java 31 Jan 2008 12:04:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright © 2005, 2007 IBM Corporation and others. >+ * Copyright © 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which is available at >@@ -7,7 +7,9 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Actuate Corporation - enhancement to maintain SQB UI control state > *******************************************************************************/ >+ > package org.eclipse.datatools.sqltools.sqlbuilder.input; > > import java.io.IOException; >@@ -16,6 +18,7 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.util.FileUtil; > import org.eclipse.datatools.sqltools.sqlbuilder.util.SQLFileUtil; >@@ -38,6 +41,10 @@ > /** Contains OmitSchemaInfo associated with this object. */ > private IOmitSchemaInfo fOmitSchemaInfo; > >+ private IWindowStateInfo fWindowStateInfo; >+ >+ private ISQLBuilderEditorInputOptions fUsageOption; >+ > /** > * Creates an instance of this class with the given file. > * >@@ -134,4 +141,20 @@ > return toString(); > } > >+ public IWindowStateInfo getWindowStateInfo() { >+ return fWindowStateInfo; >+ } >+ >+ public void setWindowStateInfo( IWindowStateInfo windowStateInfo ) { >+ fWindowStateInfo = windowStateInfo; >+ } >+ >+ public ISQLBuilderEditorInputOptions getUsageOption() { >+ return fUsageOption; >+ } >+ >+ public void setUsageOption( ISQLBuilderEditorInputOptions option ) { >+ fUsageOption = option; >+ } >+ > } >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInput.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInput.java,v >retrieving revision 1.2 >diff -u -r1.2 ISQLBuilderEditorInput.java >--- src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInput.java 9 Jan 2008 11:55:09 -0000 1.2 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInput.java 31 Jan 2008 12:04:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright © 2005, 2007 IBM Corporation and others. >+ * Copyright © 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which is available at >@@ -7,11 +7,14 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Actuate Corporation - enhancement to maintain SQB UI control state > *******************************************************************************/ >+ > package org.eclipse.datatools.sqltools.sqlbuilder.input; > > import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; > import org.eclipse.datatools.sqltools.sqleditor.ISQLEditorInput; > > /** >@@ -57,5 +60,31 @@ > * @param connInfo the <code>ISQLEditorConnectionInfo</code> object to set > */ > public void setConnectionInfo( ISQLEditorConnectionInfo connInfo ); >- >+ >+ /** >+ * Gets the window state information which stores the control states of >+ * the SQL Query Builder. >+ */ >+ public IWindowStateInfo getWindowStateInfo(); >+ >+ /** >+ * Sets the window state information. >+ * >+ * @param IOmitSchemaInfo the <code>IOmitSchemaInfo</code> to be set. >+ */ >+ public void setWindowStateInfo( IWindowStateInfo windowStateInfo ); >+ >+ /** >+ * Gets the usage options of the editor input. >+ * The options may be configured independent of the existence of specific input info. >+ */ >+ public ISQLBuilderEditorInputOptions getUsageOption( ); >+ >+ /** >+ * Sets the usage options of the editor input. >+ * >+ * @param ISQLBuilderEditorInputOptions the <code>ISQLBuilderEditorInputOptions</code> to be set. >+ */ >+ public void setUsageOption( ISQLBuilderEditorInputOptions option ); >+ > } >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/model/SQLBuilderConstants.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/model/SQLBuilderConstants.java,v >retrieving revision 1.1 >diff -u -r1.1 SQLBuilderConstants.java >--- src/org/eclipse/datatools/sqltools/sqlbuilder/model/SQLBuilderConstants.java 26 Sep 2007 10:41:42 -0000 1.1 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/model/SQLBuilderConstants.java 31 Jan 2008 12:04:16 -0000 >@@ -68,10 +68,19 @@ > public static final String MAX_ROWS_IN_QUERY_OUTPUT_PREFERENCE = "Maximum rows returned from SQL statement execution"; //$NON-NLS-1$ > public static final String SET_QUERY_OUTPUT_LIMIT_PREFERENCE = "Limit rows returned from SQL statement execution"; //$NON-NLS-1$ > >+ /** SQL Query Builder window control types */ >+ public static final int CONTROL_TYPE_SQL_SOURCE_VIEWER = 1; >+ public static final int CONTROL_TYPE_DESIGN_VIEWER = 2; >+ public static final int CONTROL_TYPE_GRAPH_CONTROL = 3; >+ public static final int CONTROL_TYPE_SQL_TREE_VIEWER = 4; >+ > //file extension that the editor works with > public static final String SQL_FILE_EXTENSION = ".sql"; //$NON-NLS-1$ > > public static final String EMPTY_STRING = ""; //$NON-NLS-1$ >- >+ >+ // Constant for an unknown value of a control state attribute >+ public static final int CONTROL_STATE_UNKNOWN_VALUE = -1; >+ > } > >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java,v >retrieving revision 1.18 >diff -u -r1.18 SQLBuilder.java >--- src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java 11 Jan 2008 14:37:56 -0000 1.18 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java 31 Jan 2008 12:04:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright © 2005, 2007 IBM Corporation and others. >+ * Copyright © 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which is available at >@@ -7,7 +7,9 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Actuate Corporation - enhancement to maintain SQB UI control state > *******************************************************************************/ >+ > package org.eclipse.datatools.sqltools.sqlbuilder; > > import java.util.EventObject; >@@ -33,11 +35,15 @@ > import org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput; > import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput; > import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderFileEditorInput; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.ControlStateInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLBuilderConstants; > import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLDomainModel; > import org.eclipse.datatools.sqltools.sqlbuilder.model.SelectHelper; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.WindowStateInfo; > import org.eclipse.datatools.sqltools.sqlbuilder.util.SQLFileUtil; > import org.eclipse.datatools.sqltools.sqlbuilder.util.SQLParserUtil; > import org.eclipse.datatools.sqltools.sqlbuilder.util.ViewUtility; >@@ -70,8 +76,11 @@ > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.SashForm; >+import org.eclipse.swt.events.ControlEvent; >+import org.eclipse.swt.events.ControlListener; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.ui.IEditorPart; >@@ -92,6 +101,7 @@ > public class SQLBuilder implements IEditingDomainProvider, Observer, > IContentChangeListener, IMenuListener { > >+ private Composite _parentControl; > protected SashForm _mainSash = null; > protected SashForm _graphSash = null; > protected SQLTreeViewer _contentOutlinePage; >@@ -101,6 +111,7 @@ > protected GraphControl _graphControl; > > ISQLBuilderEditorInput _sqlBuilderEditorInput = null; >+ private IWindowStateInfo _windowStateInfo = null; > protected IFile _iFile; > > protected ListenerList _contentChangeListeners = null; >@@ -129,7 +140,6 @@ > > protected boolean _inCreateClient = false; > >- > /* > * Class for trying to establish a database connection > */ >@@ -215,6 +225,7 @@ > */ > public void createClient(Composite parent) { > _inCreateClient = true; >+ _parentControl = parent; > _mainSash = new SashForm(parent, SWT.VERTICAL); > > if (_inputLoaded){ >@@ -235,7 +246,6 @@ > Composite srcComposite = ViewUtility.createNestedComposite( > outsideSrcComp, SWT.BORDER); > createSourceViewer(srcComposite); >- > > // If it's not in an editor, put the SQLTreeView in a SashForm with the GraphViewer > _graphSash = null; >@@ -257,10 +267,14 @@ > // set _clientCreated before getting the ContentOutlinePage > _clientCreated = true; > getContentOutlinePage(_graphSash); // make sure everything is initialized >- >- // If it's not in an editor, set the weights of the graphical view's SashForm >- if (_editor == null){ >- _graphSash.setWeights(new int[] {2, 1}); >+ >+ if ( useWindowState() ) { >+ restoreWindowState(); >+ } >+ else { >+ if ( _editor == null ){ >+ _graphSash.setWeights(new int[] {2, 1}); >+ } > } > > ((IChangeNotifier) getDomainModel().getAdapterFactory()) >@@ -289,9 +303,61 @@ > if (!_inputLoaded) { > _sourceViewer.revertToDefaultSource(); > } >- >+ >+ if ( useWindowState() ) >+ addResizedListener(); > } >- >+ >+ private boolean useWindowState() >+ { >+ if ( _sqlBuilderEditorInput == null || >+ _sqlBuilderEditorInput.getWindowStateInfo() == null ) >+ return false; >+ >+ return _sqlBuilderEditorInput.getUsageOption() == null || >+ _sqlBuilderEditorInput.getUsageOption().useWindowState(); >+ } >+ >+ /** >+ * Adds resized listener to related controls. >+ * So that when one of these controls is resized, the corresponding window state info >+ * gets saved in the current IWindowStateInfo. >+ */ >+ private void addResizedListener() >+ { >+ getSourceViewer().getControl().addControlListener( new ControlListener() { >+ >+ public void controlResized( ControlEvent e ) >+ { >+ saveWindowState( ); >+ } >+ >+ public void controlMoved( ControlEvent e ) {} >+ } ); >+ >+ >+ getGraphViewer().getControl().addControlListener( new ControlListener() { >+ >+ public void controlResized( ControlEvent e ) >+ { >+ saveWindowState( ); >+ } >+ >+ public void controlMoved( ControlEvent e ) {} >+ } ); >+ >+ >+ getSQLTreeViewer().getControl().addControlListener( new ControlListener() { >+ >+ public void controlResized( ControlEvent e ) >+ { >+ saveWindowState( ); >+ } >+ >+ public void controlMoved( ControlEvent e ) {} >+ } ); >+ >+ } > > /** > * Tells the SQLBuilder to load the input SQL only after a database >@@ -833,6 +899,15 @@ > } > > /** >+ * Returns the current window state of the <code>SQLBuilder</code>. >+ * @return >+ */ >+ public IWindowStateInfo getWindowStateInfo() >+ { >+ return _windowStateInfo; >+ } >+ >+ /** > * Returns the <code>IFile</code> belonging to this <code>SQLBuilder</code>, which > * may be null. > */ >@@ -904,6 +979,8 @@ > sQLBuilderFileEditorInput.getFile(), > sQLBuilderFileEditorInput.getOmitSchemaInfo() > .encode()); >+ // TODO - is this sufficient for handling window state? >+ sQLBuilderFileEditorInput.setWindowStateInfo( getWindowStateInfo() ); > } > > setDirty(false); >@@ -944,7 +1021,133 @@ > public void setDirty(boolean dirty){ > _sqlDomainModel.setDirty(dirty); > } >+ >+ private void restoreWindowState() >+ { >+ final int DEFAULT_GRAPTH_CONTROL_WIDTH = 2; >+ final int DEFAULT_TREE_VIEWER_WIDTH = 1; >+ final int UNKNOWN_VALUE = SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE; >+ >+ int graphCtrlWidth = DEFAULT_GRAPTH_CONTROL_WIDTH, >+ treeViewerWidth = DEFAULT_TREE_VIEWER_WIDTH; >+ int sourceViewerHeight = UNKNOWN_VALUE, >+ graphCtrlHeight = UNKNOWN_VALUE, >+ designViewerHeight = UNKNOWN_VALUE; >+ >+ IWindowStateInfo windowStateInfo = _sqlBuilderEditorInput.getWindowStateInfo(); >+ if ( windowStateInfo == null ) >+ return; // no state info to restore from >+ >+ IControlStateInfo sourceViewerState = windowStateInfo.get( >+ SQLBuilderConstants.CONTROL_TYPE_SQL_SOURCE_VIEWER ); >+ if ( sourceViewerState != null ) >+ sourceViewerHeight = sourceViewerState.getHeight(); >+ >+ IControlStateInfo graphState = windowStateInfo.get( >+ SQLBuilderConstants.CONTROL_TYPE_GRAPH_CONTROL ); >+ if ( graphState != null ) >+ { >+ graphCtrlHeight = graphState.getHeight(); >+ if( graphState.getWidth() != UNKNOWN_VALUE ) >+ graphCtrlWidth = graphState.getWidth(); // override default value >+ } >+ >+ IControlStateInfo designViewerState = windowStateInfo.get( >+ SQLBuilderConstants.CONTROL_TYPE_DESIGN_VIEWER ); >+ if ( designViewerState != null ) >+ { >+ designViewerHeight = designViewerState.getHeight(); >+ } >+ >+ IControlStateInfo treeViewerState = windowStateInfo.get( >+ SQLBuilderConstants.CONTROL_TYPE_SQL_TREE_VIEWER ); >+ if ( treeViewerState != null ) >+ { >+ if( treeViewerState.getWidth() != UNKNOWN_VALUE ) >+ treeViewerWidth = treeViewerState.getWidth(); // override default value >+ } >+ >+ // if the height states exist in memento, restore the height ratio >+ if ( sourceViewerHeight*graphCtrlHeight*designViewerHeight != 0 && >+ sourceViewerHeight != UNKNOWN_VALUE && >+ graphCtrlHeight != UNKNOWN_VALUE && >+ designViewerHeight != UNKNOWN_VALUE ){ >+ _mainSash.setWeights( new int[]{sourceViewerHeight, graphCtrlHeight, designViewerHeight}) ; >+ } >+ >+ // set the weights of the graphical view's SashForm >+ _graphSash.setWeights( new int[]{ graphCtrlWidth, treeViewerWidth } ); >+ } > >+ /** >+ * Saves the current window state information into an IWindowStateInfo instance. >+ */ >+ private void saveWindowState() >+ { >+ int controlHeights[] = _mainSash.getWeights( ); >+ int controlWidths[] = _graphSash.getWeights( ); >+ >+ Control sourceViewControl = _sourceViewer.getControl( ); >+ Control graphControl = _graphControl.getControl( ); >+ Control contentOutlineControl = _contentOutlinePage.getControl( ); >+ >+ if ( controlHeights.length == 3 && controlWidths.length == 2 ) >+ { >+ IWindowStateInfo windowStateInfo = new WindowStateInfo( ); >+ windowStateInfo.setHeight( _parentControl.getSize( ).y ); >+ windowStateInfo.setWidth( _parentControl.getSize( ).x ); >+ >+ IControlStateInfo sourceViewInfo = new ControlStateInfo( ); >+ sourceViewInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_SQL_SOURCE_VIEWER ); >+ sourceViewInfo.setHeight( controlHeights[0] ); >+ sourceViewInfo.setWidth( sourceViewControl.getSize( ).x ); >+ saveControlUsabilityStates( sourceViewInfo, sourceViewControl ); >+ windowStateInfo.put( sourceViewInfo.getControlType( ), >+ sourceViewInfo ); >+ >+ IControlStateInfo designViewInfo = new ControlStateInfo( ); >+ designViewInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_DESIGN_VIEWER ); >+ designViewInfo.setHeight( controlHeights[2] ); >+ designViewInfo.setWidth( _designViewer.getSize( ).x ); >+ saveControlUsabilityStates( designViewInfo, _designViewer ); >+ windowStateInfo.put( designViewInfo.getControlType( ), >+ designViewInfo ); >+ >+ IControlStateInfo graphControlInfo = new ControlStateInfo( ); >+ graphControlInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_GRAPH_CONTROL ); >+ graphControlInfo.setHeight( controlHeights[1] ); >+ graphControlInfo.setWidth( controlWidths[0] ); >+ saveControlUsabilityStates( graphControlInfo, graphControl ); >+ windowStateInfo.put( graphControlInfo.getControlType( ), >+ graphControlInfo ); >+ >+ IControlStateInfo treeViewerInfo = new ControlStateInfo( ); >+ treeViewerInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_SQL_TREE_VIEWER ); >+ treeViewerInfo.setHeight( controlHeights[1] ); >+ treeViewerInfo.setWidth( controlWidths[1] ); >+ saveControlUsabilityStates( treeViewerInfo, contentOutlineControl ); >+ windowStateInfo.put( treeViewerInfo.getControlType( ), >+ treeViewerInfo ); >+ >+ _windowStateInfo = windowStateInfo; >+ } >+ else >+ { >+ //TODO add code to deal with hide one or more controls. >+ } >+ } >+ >+ private void saveControlUsabilityStates( IControlStateInfo controlStateInfo, Control control ) >+ { >+ // saves visibility state >+ // TODO - replace with CustomSashForm checks >+ controlStateInfo.setIsVisible( control.isVisible() ); >+ >+ // saves hideability state >+ // TODO - replace with CustomSashForm checks >+ controlStateInfo.setIsHideable( true ); >+ } >+ > /* > * > */ >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInputOptions.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInputOptions.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInputOptions.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInputOptions.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.input; >+ >+/** >+ * This class defines the usage options of ISQLBuilderEditorInput. >+ * An option may be specified to ignore a specific input info even if exists. >+ */ >+ >+public class SQLBuilderEditorInputOptions implements ISQLBuilderEditorInputOptions >+{ >+ private boolean _useWindowState = true; >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInputOptions#useWindowState() >+ */ >+ public boolean useWindowState() { >+ return _useWindowState; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInputOptions#setUseWindowState(boolean) >+ */ >+ public void setUseWindowState( boolean windowState ) { >+ _useWindowState = windowState; >+ } >+ >+} >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/model/IControlStateInfo.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/model/IControlStateInfo.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/model/IControlStateInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/model/IControlStateInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.model; >+ >+/** >+ * The interface defines the UI state of a section control in the SQL Query Builder. >+ */ >+public interface IControlStateInfo { >+ >+ /** >+ * Returns the type of section control for this state information. >+ * @return A SQLBuilderConstants.CONTROL_TYPE_* constant defined for >+ * one of the section controls >+ * @see {@link SQLBuilderConstants} >+ */ >+ public int getControlType(); >+ >+ /** >+ * Sets the type of section control for this state information. >+ * @param controlType A SQLBuilderConstants.CONTROL_TYPE_* constant defined for >+ * one of the section controls. >+ * @see {@link SQLBuilderConstants} >+ */ >+ public void setControlType( int controlType ); >+ >+ /** >+ * Returns the height of the control. >+ * @return the control height; >+ * or SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE if value is not known. >+ * @see {@link SQLBuilderConstants#CONTROL_STATE_UNKNOWN_VALUE} >+ */ >+ public int getHeight(); >+ >+ /** >+ * Sets the height of the control. >+ * @param height >+ */ >+ public void setHeight( int height ); >+ >+ /** >+ * Returns the width of the control. >+ * @return the control width; >+ * or SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE if value is not known. >+ * @see {@link SQLBuilderConstants#CONTROL_STATE_UNKNOWN_VALUE} >+ */ >+ public int getWidth(); >+ >+ /** >+ * Sets the width of the control. >+ * @param width >+ */ >+ public void setWidth( int width ); >+ >+ /** >+ * Indicates the visibility state of the control. >+ * @return true if the control is visible; false otherwise. Default value is true. >+ */ >+ public boolean isVisible(); >+ >+ /** >+ * Sets the visibility state of the control. >+ * @param isVisible true if the control is visible; false otherwise >+ */ >+ public void setIsVisible( boolean isVisible ); >+ >+ /** >+ * Indicates whether the UI option should be present to hide or restore the control. >+ * @return true if the UI option to hide or restore the control should be present; >+ * false otherwise. Default value is true. >+ */ >+ public boolean isHideable(); >+ >+ /** >+ * Sets whether the UI option should be present to hide or restore the control. >+ * @param isHideable true if the UI option to hide or restore the control should be present; >+ * false otherwise. >+ */ >+ public void setIsHideable( boolean isHideable ); >+ >+} >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateFactory.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateFactory.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,253 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.input; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.ControlStateInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLBuilderConstants; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.WindowStateInfo; >+import org.eclipse.ui.IElementFactory; >+import org.eclipse.ui.IMemento; >+ >+/** >+ * The class implements a factory which is capable of saving and recreating a >+ * SQLBuilderWindowStateInput stored in a memento. >+ */ >+public class SQLBuilderWindowStateFactory implements IElementFactory >+{ >+ >+ /** The Factory ID. */ >+ public final static String ID_SQL_BUILDER_STORAGE_EDITOR_INPUT_FACTORY = >+ "org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderWindowStateFactory"; //$NON-NLS-1$ >+ >+ public final static String KEY_WINDOW_STATE_TYPE = "windowState"; //$NON-NLS-1$ >+ >+ public final static String KEY_WINDOW_STATE_VERSION = "version"; //$NON-NLS-1$ >+ >+ public final static String KEY_WINDOW_STATE_HEIGHT = "height"; //$NON-NLS-1$ >+ >+ public final static String KEY_WINDOW_STATE_WIDTH = "width"; //$NON-NLS-1$ >+ >+ public final static String KEY_WINDOW_SECTION_TYPE = "section"; //$NON-NLS-1$ >+ >+ public final static String KEY_SECTION_NAME = "name"; //$NON-NLS-1$ >+ >+ public final static String KEY_SECTION_VISIBLE_STATE = "isVisible"; //$NON-NLS-1$ >+ >+ public final static String KEY_SECTION_HIDEABLE_STATE = "isHideable"; //$NON-NLS-1$ >+ >+ public final static String KEY_SECTION_HEIGHT = "height"; //$NON-NLS-1$ >+ >+ public final static String KEY_SECTION_WIDTH = "width"; //$NON-NLS-1$ >+ >+ public final static String NAME_SQL_SOURCE_VIEWER = "SQLSourceViewer"; //$NON-NLS-1$ >+ >+ public final static String NAME_DESIGN_VIEWER = "DesignViewer"; //$NON-NLS-1$ >+ >+ public final static String NAME_GRAPH_CONTROL = "GraphControl"; //$NON-NLS-1$ >+ >+ public final static String NAME_SQL_TREE_VIEWER = "SQLTreeViewer"; //$NON-NLS-1$ >+ >+ /** >+ * Re-creates and returns an object from the state captured within the given >+ * memento. Returns a SQLBuilderWindowStateInput. >+ * >+ * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento) >+ */ >+ public IAdaptable createElement( IMemento memento ) >+ { >+ if ( memento == null ) >+ return null; >+ >+ IMemento windowStateElement = memento.getChild( KEY_WINDOW_STATE_TYPE ); >+ if ( windowStateElement == null ) >+ return null; >+ >+ // memento element exists >+ >+ IWindowStateInfo windowStateInfo = new WindowStateInfo(); >+ >+ windowStateInfo.setVersion( windowStateElement.getString( KEY_WINDOW_STATE_VERSION ) ); >+ Integer heightValue = getAttributeValueAsInteger( windowStateElement, >+ KEY_WINDOW_STATE_HEIGHT ); >+ if ( heightValue != null ) >+ windowStateInfo.setHeight( heightValue.intValue() ); >+ >+ Integer widthValue = getAttributeValueAsInteger( windowStateElement, >+ KEY_WINDOW_STATE_WIDTH ); >+ if ( widthValue != null ) >+ windowStateInfo.setWidth( widthValue.intValue() ); >+ >+ // re-create each section found in the window state element >+ IMemento[] winStateSections = windowStateElement.getChildren( KEY_WINDOW_SECTION_TYPE ); >+ for ( int i = 0; i < winStateSections.length; i++ ) >+ { >+ IMemento sectionElement = winStateSections[i]; >+ >+ String sectionName = sectionElement.getString( KEY_SECTION_NAME ); >+ if ( sectionName == null || sectionName.length() == 0 ) >+ continue; // skip unnamed section >+ >+ IControlStateInfo ctrlStateInfo = new ControlStateInfo(); >+ if ( sectionName.equals( NAME_SQL_SOURCE_VIEWER ) ) >+ { >+ ctrlStateInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_SQL_SOURCE_VIEWER ); >+ } >+ else if (sectionName.equals( NAME_DESIGN_VIEWER )) >+ { >+ ctrlStateInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_DESIGN_VIEWER ); >+ } >+ else if (sectionName.equals( NAME_GRAPH_CONTROL )) >+ { >+ ctrlStateInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_GRAPH_CONTROL ); >+ } >+ else if (sectionName.equals( NAME_SQL_TREE_VIEWER )) >+ { >+ ctrlStateInfo.setControlType( SQLBuilderConstants.CONTROL_TYPE_SQL_TREE_VIEWER ); >+ } >+ else // invalid section name, skip section >+ continue; >+ >+ heightValue = getAttributeValueAsInteger( sectionElement, KEY_SECTION_HEIGHT ); >+ if ( heightValue != null ) >+ ctrlStateInfo.setHeight( heightValue.intValue() ); >+ >+ widthValue = getAttributeValueAsInteger( sectionElement, KEY_SECTION_WIDTH ); >+ if ( widthValue != null ) >+ ctrlStateInfo.setWidth( widthValue.intValue() ); >+ >+ String isVisibleString = getAttributeValue( sectionElement, >+ KEY_SECTION_VISIBLE_STATE ); >+ boolean isVisible = ( isVisibleString != null && isVisibleString.trim().length() > 0 ) ? >+ Boolean.valueOf( isVisibleString ).booleanValue() : >+ true; >+ ctrlStateInfo.setIsVisible( isVisible ); >+ >+ String isHideableString = getAttributeValue( sectionElement, >+ KEY_SECTION_HIDEABLE_STATE ); >+ boolean isHideable = ( isHideableString != null && isHideableString.trim().length() > 0 ) ? >+ Boolean.valueOf( isHideableString ).booleanValue() : >+ true; >+ ctrlStateInfo.setIsHideable( isHideable ); >+ >+ windowStateInfo.put( ctrlStateInfo.getControlType(), ctrlStateInfo ); >+ } >+ >+ return new SQLBuilderWindowStateInput( windowStateInfo ); >+ } >+ >+ private static String getAttributeValue( IMemento memento, String attrName ) >+ { >+ if( memento == null ) >+ return null; >+ >+ return memento.getString( attrName ); >+ } >+ >+ private static Integer getAttributeValueAsInteger( IMemento memento, String attrName ) >+ { >+ return convertToInteger( getAttributeValue( memento, attrName ) ); >+ } >+ >+ private static Integer convertToInteger( String intString ) >+ { >+ if( intString == null || intString.trim().length() == 0 ) >+ return null; >+ >+ int intValue = SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE; >+ try >+ { >+ intValue = Integer.parseInt( intString ); >+ } >+ catch( NumberFormatException ex ) >+ { >+ // ignore; use the default unknown value >+ } >+ return new Integer( intValue ); >+ } >+ >+ /** >+ * Saves the state of the given window state input object in the given memento. >+ * @param memento the storage area for object's state >+ * @param windowStateInput the window state input object that needs to be saved; >+ * must contain an IWindowStateInfo instance >+ */ >+ public static void saveState( IMemento memento, SQLBuilderWindowStateInput windowStateInput ) >+ { >+ if( memento == null || windowStateInput == null ) >+ return; >+ >+ IWindowStateInfo windowStateInfo = windowStateInput.getWindowStateInfo(); >+ >+ // a SQLBuilderWindowStateInput must contain an IWindowStateInfo instance >+ if( windowStateInfo == null ) >+ throw new IllegalArgumentException( "SQLBuilderWindowStateInput" ); //$NON-NLS-1$ >+ >+ IMemento winStateElement = memento.createChild( KEY_WINDOW_STATE_TYPE ); >+ >+ winStateElement.putString( KEY_WINDOW_STATE_VERSION, windowStateInfo.getVersion() ); >+ saveSizeAttribute( winStateElement, KEY_WINDOW_STATE_HEIGHT, >+ windowStateInfo.getHeight() ); >+ saveSizeAttribute( winStateElement, KEY_WINDOW_STATE_WIDTH, >+ windowStateInfo.getWidth() ); >+ >+ // saves each section type in the WindowStateInfo, if exists, in the memento >+ >+ // <section name="SQLSourceViewer" isVisible="true" isExpanded="true" >+ // height="300" width="400"/> >+ IControlStateInfo controlStateInfo = >+ windowStateInfo.get( SQLBuilderConstants.CONTROL_TYPE_SQL_SOURCE_VIEWER ); >+ saveControlState( winStateElement, controlStateInfo, NAME_SQL_SOURCE_VIEWER ); >+ >+ // <section name="DesignViewer" isVisible="true" isExpanded="false" >+ // height="300" width="400"/> >+ controlStateInfo = windowStateInfo.get( SQLBuilderConstants.CONTROL_TYPE_DESIGN_VIEWER ); >+ saveControlState( winStateElement, controlStateInfo, NAME_DESIGN_VIEWER ); >+ >+ // <section name="GraphControl" isVisible="false" isExpanded="false" >+ // height="300" width="400"/> >+ controlStateInfo = windowStateInfo.get( SQLBuilderConstants.CONTROL_TYPE_GRAPH_CONTROL ); >+ saveControlState( winStateElement, controlStateInfo, NAME_GRAPH_CONTROL ); >+ >+ // <section name="SQLTreeViewer" isVisible="true" isExpanded="true" >+ // height="320" width="100"/> >+ controlStateInfo = windowStateInfo.get( SQLBuilderConstants.CONTROL_TYPE_SQL_TREE_VIEWER ); >+ saveControlState( winStateElement, controlStateInfo, NAME_SQL_TREE_VIEWER ); >+ } >+ >+ private static void saveSizeAttribute( IMemento memento, String key, int length ) >+ { >+ if( length != SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE ) >+ memento.putString( key, Integer.toString( length ) ); >+ } >+ >+ private static void saveControlState( IMemento memento, >+ final IControlStateInfo controlStateInfo, >+ final String sectionName ) >+ { >+ if( controlStateInfo == null ) >+ return; // done; nothing to save >+ >+ IMemento sectionMemento = memento.createChild( KEY_WINDOW_SECTION_TYPE ); >+ sectionMemento.putString( KEY_SECTION_NAME, sectionName ); >+ sectionMemento.putString( KEY_SECTION_VISIBLE_STATE, >+ Boolean.toString( controlStateInfo.isVisible() )); >+ sectionMemento.putString( KEY_SECTION_HIDEABLE_STATE, >+ Boolean.toString( controlStateInfo.isHideable() )); >+ >+ saveSizeAttribute( sectionMemento, KEY_SECTION_HEIGHT, controlStateInfo.getHeight() ); >+ saveSizeAttribute( sectionMemento, KEY_SECTION_WIDTH, controlStateInfo.getWidth() ); >+ } >+ >+} >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/model/WindowStateInfo.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/model/WindowStateInfo.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/model/WindowStateInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/model/WindowStateInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.model; >+ >+import java.util.HashMap; >+ >+/** >+ * Defines the UI state of a window's controls. >+ */ >+public class WindowStateInfo implements IWindowStateInfo { >+ >+ // current version >+ public final static String CURRENT_VERSION = "1.0"; //$NON-NLS-1$ >+ >+ private HashMap _controlStateInfoMap = new HashMap(); >+ private String _version; >+ private int _height = SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE; >+ private int _width = SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#get(int) >+ */ >+ public IControlStateInfo get( int controlType ) { >+ return (IControlStateInfo)_controlStateInfoMap.get( new Integer( controlType )); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#put(int, org.eclipse.datatools.sqltools.sqlbuilder.model.ControlStateInfo) >+ */ >+ public void put( int controlType, IControlStateInfo controlStateInfo ) { >+ _controlStateInfoMap.put( new Integer( controlType ), controlStateInfo ); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#getVersion() >+ */ >+ public String getVersion() { >+ if( _version != null ) >+ return _version; >+ return CURRENT_VERSION; // return current version if not explicitly set >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#setVersion(java.lang.String) >+ */ >+ public void setVersion( String version ) { >+ _version = version; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#getHeight() >+ */ >+ public int getHeight() { >+ return _height; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#setHeight(int) >+ */ >+ public void setHeight( int height ) { >+ _height = height; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#getWidth() >+ */ >+ public int getWidth() { >+ return _width; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo#setWidth(int) >+ */ >+ public void setWidth( int width ) { >+ _width = width; >+ } >+ >+} >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateInput.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateInput.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateInput.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderWindowStateInput.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.input; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.datatools.sqltools.sqlbuilder.model.IWindowStateInfo; >+ >+/** >+ * The class defines the SQL Query Builder's window state input, >+ * which must contain an IWindowStateInfo instance. >+ */ >+ >+public class SQLBuilderWindowStateInput implements IAdaptable >+{ >+ >+ private IWindowStateInfo _windowStateInfo; >+ >+ SQLBuilderWindowStateInput( IWindowStateInfo windowStateInfo ) >+ { >+ setWindowStateInfo( windowStateInfo ); >+ } >+ >+ /** >+ * Returns the window state information. >+ * @return an IWindowStateInfo instance >+ */ >+ public IWindowStateInfo getWindowStateInfo(){ >+ return _windowStateInfo; >+ } >+ >+ /** >+ * Sets the window state information. >+ * @param windowStateInfo an IWindowStateInfo instance; cannot be null. >+ * @throws NullPointerException if a null IWindowStateInfo is specified >+ */ >+ public void setWindowStateInfo( IWindowStateInfo windowStateInfo ) { >+ if( windowStateInfo == null ) >+ throw new NullPointerException( "setWindowStateInfo( null )" ); >+ >+ _windowStateInfo = windowStateInfo; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) >+ */ >+ public Object getAdapter( Class adapter ) { >+ return null; >+ } >+ >+} >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInputOptions.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInputOptions.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInputOptions.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInputOptions.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.input; >+ >+/** >+ * This interface defines the usage options of ISQLBuilderEditorInput. >+ * An option may be specified to ignore a specific input info even if exists. >+ */ >+ >+public interface ISQLBuilderEditorInputOptions >+{ >+ /** >+ * Indicates whether to restore/save the window state information. >+ */ >+ public boolean useWindowState(); >+ >+ /** >+ * Specifies whether to restore/save the window state information. >+ * @param useState true to use the input's window state if exists; >+ * false to ignore the window state info even if it exists >+ */ >+ public void setUseWindowState( boolean useState ); >+ >+} >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/model/IWindowStateInfo.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/model/IWindowStateInfo.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/model/IWindowStateInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/model/IWindowStateInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.model; >+ >+/** >+ * Defines the UI state of a SQL Query Builder window's controls. >+ */ >+public interface IWindowStateInfo { >+ >+ /** >+ * Gets the control state information of the specified control type. >+ * @param controlType A SQLBuilderConstants.CONTROL_TYPE_* constant defined for >+ * one of the section controls. >+ * @return IControlStateInfo instance that represents the state >+ * of the specified control type; may be null if none is available. >+ * @see {@link SQLBuilderConstants} >+ * @see {@link IControlStateInfo} >+ */ >+ public IControlStateInfo get( int controlType ); >+ >+ /** >+ * Stores the control state information for the specified control type. >+ * @param controlType A SQLBuilderConstants.CONTROL_TYPE_* constant defined for >+ * one of the section controls. >+ * @param controlStateInfo an IControlStateInfo instance that represents the state >+ * of the specified control type. >+ * @see {@link SQLBuilderConstants} >+ * @see {@link IControlStateInfo} >+ */ >+ public void put( int controlType, IControlStateInfo controlStateInfo ); >+ >+ /** >+ * Returns the version of this window state information. >+ * @return version version defined by an IWindowStateInfo implementation >+ */ >+ public String getVersion(); >+ >+ /** >+ * Sets the version of this window state information. >+ * @param version version defined by an IWindowStateInfo implementation >+ */ >+ public void setVersion( String version ); >+ >+ /** >+ * Returns the overall height of the SQL Query Builder main control. >+ * @return the overall height; >+ * or SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE if value is not known. >+ * @see {@link SQLBuilderConstants#CONTROL_STATE_UNKNOWN_VALUE} >+ */ >+ public int getHeight(); >+ >+ /** >+ * Sets the overall height of the SQL Query Builder main control. >+ * @param height >+ */ >+ public void setHeight( int height ); >+ >+ /** >+ * Returns the overall width of the SQL Query Builder main control. >+ * @return the overall width; >+ * or SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE if value is not known. >+ * @see {@link SQLBuilderConstants#CONTROL_STATE_UNKNOWN_VALUE} >+ */ >+ public int getWidth(); >+ >+ /** >+ * Sets the overall width of the SQL Query Builder main control. >+ * @param width >+ */ >+ public void setWidth( int width ); >+ >+} >Index: src/org/eclipse/datatools/sqltools/sqlbuilder/model/ControlStateInfo.java >=================================================================== >RCS file: src/org/eclipse/datatools/sqltools/sqlbuilder/model/ControlStateInfo.java >diff -N src/org/eclipse/datatools/sqltools/sqlbuilder/model/ControlStateInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/sqltools/sqlbuilder/model/ControlStateInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/************************************************************************** >+ * Copyright (c) 2008 Actuate Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Actuate Corporation - initial API and implementation >+ **************************************************************************/ >+ >+package org.eclipse.datatools.sqltools.sqlbuilder.model; >+ >+/** >+ * Defines the UI state of a control in the SQL query builder. >+ */ >+public class ControlStateInfo implements IControlStateInfo >+{ >+ private int _controlType = SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE; >+ private int _height = SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE; >+ private int _width = SQLBuilderConstants.CONTROL_STATE_UNKNOWN_VALUE; >+ private boolean _isVisible = true; >+ private boolean _isHideable = true; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#getControlType() >+ */ >+ public int getControlType() { >+ return _controlType; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#setControlType(int) >+ */ >+ public void setControlType( int controlType ) { >+ _controlType = controlType; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#getHeight() >+ */ >+ public int getHeight() { >+ return _height; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#setHeight(int) >+ */ >+ public void setHeight(int height) { >+ _height = height; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#getWidth() >+ */ >+ public int getWidth() { >+ return _width; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#setWidth(int) >+ */ >+ public void setWidth( int width ) { >+ _width = width; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#isVisible() >+ */ >+ public boolean isVisible() { >+ return _isVisible; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#setIsVisible(boolean) >+ */ >+ public void setIsVisible( boolean isVisible ) { >+ _isVisible = isVisible; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#isHideable() >+ */ >+ public boolean isHideable() { >+ return _isHideable; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.datatools.sqltools.sqlbuilder.model.IControlStateInfo#setIsHideable(boolean) >+ */ >+ public void setIsHideable( boolean isHideable ) { >+ _isHideable = isHideable; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 201783
: 88411