| author | Archana Mansukhani | 2011-09-21 23:08:20 (EDT) |
|---|---|---|
| committer | Linda Chan | 2011-09-21 23:08:20 (EDT) |
| commit | 8b0f8cb19b267d7d5590a21e118d0c45a27791f9 (patch) (side-by-side diff) | |
| tree | 2bde0026e516f396df4c95e8bb5f5715df8421ca | |
| parent | 2c0f412448605ab0ef238b1cc13938a2227b4a6e (diff) | |
| download | org.eclipse.datatools.connectivity-8b0f8cb19b267d7d5590a21e118d0c45a27791f9.zip org.eclipse.datatools.connectivity-8b0f8cb19b267d7d5590a21e118d0c45a27791f9.tar.gz org.eclipse.datatools.connectivity-8b0f8cb19b267d7d5590a21e118d0c45a27791f9.tar.bz2 | |
[357574] Support use of Relative File Path for exported Connectionv201109221139
Profile Storage in ODA Design UI Framework
16 files changed, 1666 insertions, 69 deletions
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java index a3e7b43..b25728b 100644 --- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java @@ -771,7 +771,8 @@ public class DataSourceDesignSessionBase boolean convertToRelativePath = false; // keeps absolute path by default if( promptCreateProfileStore && parentShell != null ) { - CreateProfileStoreAction createAction = new CreateProfileStoreAction( parentShell ); + CreateProfileStoreAction createAction = new CreateProfileStoreAction( parentShell, + editDataSourceDesign.getHostResourceIdentifiers() ); // pre-select the exported profile to be included in the new profile store IConnectionProfile profileElement = ( exportedProfile instanceof OdaConnectionProfile ) ? @@ -785,9 +786,8 @@ public class DataSourceDesignSessionBase ProfileStoreCreationDialog dlg = createAction.getProfileStoreCreationDialog(); if( dlg != null ) { - linkedProfileStoreFile = dlg.getFile(); - // TODO pending new method - // convertToRelativePath = true; // dlg.isProfileFilePathRelative(); + linkedProfileStoreFile = dlg.getFile(); + convertToRelativePath = dlg.isProfileStorePathRelative(); } } } diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/CreateProfileStoreAction.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/CreateProfileStoreAction.java index f695654..e929bc3 100644 --- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/CreateProfileStoreAction.java +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/CreateProfileStoreAction.java @@ -1,6 +1,6 @@ /* ************************************************************************* - * Copyright (c) 2009 Actuate Corporation. + * Copyright (c) 2009, 2011 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 @@ -16,6 +16,7 @@ package org.eclipse.datatools.connectivity.oda.design.internal.ui.profile; import org.eclipse.datatools.connectivity.IConnectionProfile; import org.eclipse.datatools.connectivity.internal.ui.wizards.ExportProfilesDialog; +import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers; import org.eclipse.datatools.connectivity.ui.actions.ExportProfileViewAction; import org.eclipse.swt.widgets.Shell; @@ -27,10 +28,12 @@ public class CreateProfileStoreAction extends ExportProfileViewAction { private ProfileStoreCreationDialog m_dialog; private IConnectionProfile m_preSelectProfile; + private ResourceIdentifiers m_resourceIdentifiers; - public CreateProfileStoreAction( Shell dialogShell ) + public CreateProfileStoreAction( Shell dialogShell, ResourceIdentifiers resourceIdentifiers ) { super(); + m_resourceIdentifiers = resourceIdentifiers; init( dialogShell ); } @@ -43,6 +46,7 @@ public class CreateProfileStoreAction extends ExportProfileViewAction m_dialog = new ProfileStoreCreationDialog( parentShell ); m_dialog.setPreSelectedProfile( m_preSelectProfile ); m_dialog.setBlockOnOpen( true ); + m_dialog.setHostResourceIdentifiers( m_resourceIdentifiers ); return m_dialog; } diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionEditorPage.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionEditorPage.java index 69a9e3a..58deb23 100644 --- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionEditorPage.java +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionEditorPage.java @@ -20,6 +20,7 @@ import org.eclipse.datatools.connectivity.IConnectionProfile; import org.eclipse.datatools.connectivity.oda.OdaException; import org.eclipse.datatools.connectivity.oda.design.DataSourceDesign; import org.eclipse.datatools.connectivity.oda.design.OdaDesignSession; +import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers; import org.eclipse.datatools.connectivity.oda.design.SessionStatus; import org.eclipse.datatools.connectivity.oda.design.internal.designsession.DesignerLogger; import org.eclipse.datatools.connectivity.oda.design.internal.designsession.DataSourceDesignSessionBase.ProfileReferenceBase; @@ -195,7 +196,7 @@ public class ProfileSelectionEditorPage extends DataSourceEditorPage if( profileRef != null && profileRef.maintainExternalLink() ) { design.setLinkedProfileName( profileRef.getName() ); - design.setLinkedProfileStoreFile( profileRef.getStorageFile() ); + design.setLinkedProfileStoreFilePath( profileRef.getStorageFilePathPropertyValue() ); } else { @@ -247,6 +248,16 @@ public class ProfileSelectionEditorPage extends DataSourceEditorPage return m_pageHelper.requiresExternalProfileLink(); } + /* + * (non-Javadoc) + * @see org.eclipse.datatools.connectivity.oda.design.internal.ui.DataSourceEditorPageCore#getHostResourceIdentifiers() + */ + protected ResourceIdentifiers getHostResourceIdentifiers() + { + // exposes visibility to the page helper + return super.getHostResourceIdentifiers(); + } + /** * Assigns the delegated task to perform collectDataSourceDesign and update the data source design. * @param task the delegated task; may be null to unset the delegation diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionPageHelper.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionPageHelper.java index e1e1fde..6d03946 100644 --- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionPageHelper.java +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileSelectionPageHelper.java @@ -14,6 +14,7 @@ package org.eclipse.datatools.connectivity.oda.design.internal.ui.profile; +import java.io.File; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -25,10 +26,16 @@ import java.util.TreeSet; import org.eclipse.core.runtime.Path; import org.eclipse.datatools.connectivity.ICategory; import org.eclipse.datatools.connectivity.oda.OdaException; +import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers; import org.eclipse.datatools.connectivity.oda.design.internal.designsession.DataSourceDesignSessionBase.IDesignNameValidatorBase; import org.eclipse.datatools.connectivity.oda.design.internal.designsession.DataSourceDesignSessionBase.ProfileReferenceBase; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IBrowseButtonHost; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IMenuButtonProvider; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.MenuButtonProvider; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.ProfileStoreBrowseButton; import org.eclipse.datatools.connectivity.oda.design.ui.nls.Messages; import org.eclipse.datatools.connectivity.oda.design.ui.nls.TextProcessorWrapper; +import org.eclipse.datatools.connectivity.oda.design.util.DesignUtil; import org.eclipse.datatools.connectivity.oda.profile.Constants; import org.eclipse.datatools.connectivity.oda.profile.OdaProfileExplorer; import org.eclipse.datatools.connectivity.oda.profile.internal.ProfileCategoryUtil; @@ -49,7 +56,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; @@ -64,7 +70,7 @@ import org.eclipse.ui.dialogs.PropertyPage; * a connection profile instance. * @since 3.0.4 */ -class ProfileSelectionPageHelper +class ProfileSelectionPageHelper implements IBrowseButtonHost { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String CONTEXT_ID_CONNECTIONPROFILE = @@ -84,6 +90,7 @@ class ProfileSelectionPageHelper private transient String m_profileID; private transient String m_odaDataSourceID; private transient Button m_useDefaultDSNameCheckBox = null; + private transient ProfileStoreBrowseButton m_browseButton = null; private transient Tree m_odaDataSourceTree = null; private transient String m_treeFilter; private transient SortedSet<OdaProfileCategoryInfo> m_dataSourceIDs = null; @@ -92,6 +99,7 @@ class ProfileSelectionPageHelper new HashMap<String, String>(); // key= deprecated odaDataSourceId; value= replacing odaDataSourceId private String m_dataSourceDesignName = EMPTY_STRING; + private ResourceIdentifiers m_hostResourceIdentifiers = null; ProfileSelectionPageHelper( WizardPage page ) { @@ -133,7 +141,7 @@ class ProfileSelectionPageHelper ProfileReferenceBase profileRef = selectedProfile.getProfileRef(); if( profileRef != null ) { - String profileStorePath = profileRef.getStorageFilePath(); + String profileStorePath = profileRef.getStorageFilePathPropertyValue(); if( profileStorePath != null ) { // triggers tree population; disable auto item selection @@ -204,18 +212,25 @@ class ProfileSelectionPageHelper { if( ! hasSelectedProfile() || ! isPageComplete() ) return null; - + + String profileStorePathText = getConnProfilePathControlText(); + String resolvedProfileStorePath = resolveProfileStorePath( profileStorePathText ); + boolean isProfileStorePathRelative = false; // default behavior + if( resolvedProfileStorePath != null && + ! resolvedProfileStorePath.equals( profileStorePathText ) ) // was resolved from relative path + isProfileStorePathRelative = true; + + File profileStoreFile = new Path( resolvedProfileStorePath ).toFile( ); + return new ProfileSelection( m_odaDataSourceID, m_dataSourceDesignName, new ProfileReferenceBase( m_profileID, - new Path( getConnProfilePathControlText() ).toFile( ), + profileStoreFile, m_linkRefCheckBox.getSelection(), - getConnProfilePathControlText() ) ); - // TODO replace last argument with -// DesignUtil.convertFileToResourcePath( new Path( getConnProfilePathControlText() ).toFile( ), -// getHostResourceIdentifiers(), -// convertToRelativePath ) ); + DesignUtil.convertFileToResourcePath( profileStoreFile, + m_hostResourceIdentifiers, + isProfileStorePathRelative ) )) ; } private boolean isPageComplete() @@ -259,7 +274,7 @@ class ProfileSelectionPageHelper else if( m_propertyPage != null ) { // use default title instead of leaving the message area empty - if( newMessage == EMPTY_STRING && newType == IMessageProvider.NONE ) + if( newMessage.length() == 0 && newType == IMessageProvider.NONE ) newMessage = Messages.profilePage_pageTitle; m_propertyPage.setMessage( newMessage, newType ); } @@ -315,7 +330,7 @@ class ProfileSelectionPageHelper setSelectedDataSourceName( EMPTY_STRING ); setDefaultMessageAsError( hasConnectionProfilePath() ); - if( hasConnectionProfilePath() && ! new Path( getConnProfilePathControlText() ).toFile().exists() ) + if( hasConnectionProfilePath() && ! new Path( getResolvedConnProfilePathControlText() ).toFile().exists() ) setMessage( Messages.profilePage_error_invalidProfileStorePath, IMessageProvider.ERROR ); // check if profile tree has only one profile item, @@ -336,23 +351,31 @@ class ProfileSelectionPageHelper } ); // Browse... button - Button browseButton = new Button( composite, SWT.PUSH ); - browseButton.setText( Messages.profilePage_button_browse ); + IMenuButtonProvider provider = new MenuButtonProvider( ); + m_browseButton = new ProfileStoreBrowseButton( composite, + SWT.PUSH, + provider, + this ); + GridData data = new GridData(); + data.widthHint = m_browseButton.computeButtonWidth( ); + m_browseButton.setLayoutData(data); + + if( m_wizardPage != null && m_wizardPage instanceof ProfileSelectionWizardPage ) { - GridData data = new GridData(); - data.widthHint = computeButtonWidth( browseButton ); - browseButton.setLayoutData( data ); + m_hostResourceIdentifiers = ((ProfileSelectionWizardPage)m_wizardPage).getHostResourceIdentifiers(); } - browseButton.addSelectionListener( new SelectionAdapter() + if( m_propertyPage != null && m_propertyPage instanceof ProfileSelectionEditorPage ) { - public void widgetSelected( SelectionEvent e ) - { - FileDialog dialog = new FileDialog( getShell() ); - String text = dialog.open(); - if( text != null ) - setConnProfilePathControlText( text, false ); - } - } ); + m_hostResourceIdentifiers = ((ProfileSelectionEditorPage)m_propertyPage).getHostResourceIdentifiers(); + } + if( m_hostResourceIdentifiers != null ) + { + File resourceBase = new File(m_hostResourceIdentifiers.getApplResourceBaseURI( )); + m_browseButton.getMenuButtonProvider( ).setProperty( RESOURCE_FILE_DIR, resourceBase ); + } + m_browseButton.getMenuButtonProvider( ).setProperty( IS_CREATE_PROFILE, Boolean.FALSE ); + + m_browseButton.refreshMenuItems( ); // New... button createNewProfileStoreButton( composite ); @@ -380,14 +403,20 @@ class ProfileSelectionPageHelper private void handleNewProfileStore() { CreateProfileStoreAction createAction = - new CreateProfileStoreAction( getShell() ); + new CreateProfileStoreAction( getShell(), m_hostResourceIdentifiers ); createAction.run(); if( createAction.isCompleted() ) { // copy the newly created profile store file path ProfileStoreCreationDialog dlg = createAction.getProfileStoreCreationDialog(); if( dlg != null && dlg.getFile() != null ) - setConnProfilePathControlText( dlg.getFile().getPath(), false ); + { + String profileStoreTextPath = + DesignUtil.convertFileToResourcePath( dlg.getFile(), + m_hostResourceIdentifiers, + dlg.isProfileStorePathRelative() ); + setConnProfilePathControlText( profileStoreTextPath, false ); + } } } } ); @@ -782,7 +811,7 @@ class ProfileSelectionPageHelper { return OdaProfileExplorer.getInstance().getProfileIdsAndNamesByCategory( categoryId, - new Path( getConnProfilePathControlText() ).toFile( ) ); + new Path( getResolvedConnProfilePathControlText() ).toFile( ) ); } catch ( OdaException ex ) { @@ -1055,13 +1084,54 @@ class ProfileSelectionPageHelper /** * Return a de-processed text value in the connection profile store file path * UI text control. - * @return + * @return the user-specified text in the profile store path control; + * may be in relative or absolute format; and may point to a non-existing file */ private String getConnProfilePathControlText() { String localizedText = m_connectionProfilePath.getText(); return TextProcessorWrapper.deprocess( localizedText ); } + + private String getResolvedConnProfilePathControlText() + { + return resolveProfileStorePath( getConnProfilePathControlText() ); + } + + private String resolveProfileStorePath( String filePathText ) + { + if( filePathText == null || filePathText.trim().length() == 0 || + m_hostResourceIdentifiers == null ) + return filePathText; // nothing to resolve with + + String resolvedFilePathText = + DesignUtil.resolveToApplResourcePath( filePathText, m_hostResourceIdentifiers ); + return ( resolvedFilePathText != null ) ? + resolvedFilePathText : + filePathText; // unable to resolve invalid filePathText, return original value + } + + /* + * (non-Javadoc) + * @see org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IBrowseButtonParent#setConnProfilePath(java.lang.String, boolean) + */ + public void setProfileStorePath( String path, boolean isRelative ) + { + if( path == null ) + path = EMPTY_STRING; + setConnProfilePathControlText( path, false ); + } + + /* + * (non-Javadoc) + * @see org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IBrowseButtonHost#browseSelected() + */ + public void browseSelected() + { + m_browseButton.getMenuButtonProvider().setProperty( + IBrowseButtonHost.STORED_PATH, + getResolvedConnProfilePathControlText() ); + } /** * Compute the preferred width of the specified button based on diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileStoreCreationDialog.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileStoreCreationDialog.java index 7bbdfa3..4acbdf9 100644 --- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileStoreCreationDialog.java +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileStoreCreationDialog.java @@ -1,6 +1,6 @@ /* ************************************************************************* - * Copyright (c) 2007, 2009 Actuate Corporation. + * Copyright (c) 2007, 2011 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 @@ -14,31 +14,38 @@ package org.eclipse.datatools.connectivity.oda.design.internal.ui.profile; +import java.io.File; + import org.eclipse.datatools.connectivity.IConnectionProfile; import org.eclipse.datatools.connectivity.internal.ui.wizards.ExportProfilesDialog; +import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IBrowseButtonHost; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IMenuButtonProvider; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.MenuButtonProvider; +import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.ProfileStoreBrowseButton; import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.filter.NewProfileAction; import org.eclipse.datatools.connectivity.oda.design.ui.nls.Messages; +import org.eclipse.datatools.connectivity.oda.design.util.DesignUtil; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -public class ProfileStoreCreationDialog extends ExportProfilesDialog +public class ProfileStoreCreationDialog extends ExportProfilesDialog + implements IBrowseButtonHost { private CheckboxTableViewer m_profilesViewer; + private ProfileStoreBrowseButton m_browseButton; private IConnectionProfile m_preSelectProfile; + private ResourceIdentifiers m_resourceIdentifiers = null; + private boolean m_isProfileStorePathRelative = false; public ProfileStoreCreationDialog( Shell parentShell ) { @@ -121,7 +128,7 @@ public class ProfileStoreCreationDialog extends ExportProfilesDialog } } - Label spacingLabel = createVerticalSpacingLabel( container ); + createVerticalSpacingLabel( container ); // composite for the new profile store file controls Composite composite = new Composite( container, SWT.NONE ); @@ -132,26 +139,40 @@ public class ProfileStoreCreationDialog extends ExportProfilesDialog gridData.minimumWidth = 410; composite.setLayoutData( gridData ); } - composite.setLayout( new FormLayout() ); + GridLayout layout = new GridLayout( ); + layout.numColumns = 3; + composite.setLayout( layout ); // File path label - final Label fileNameLabel = createFilePathLabel( composite, null ); - // File path text control - Text filenameText; - { - FormData data = new FormData(); - data.left = new FormAttachment( fileNameLabel, 6 ); - data.width = 290; - filenameText = setupFilePathText( composite, data ); - } - // Browse... button - { - FormData data = new FormData(); - data.left = new FormAttachment( filenameText, 12 ); - data.top = new FormAttachment( spacingLabel, -1 ); - - Button browseButton = createFilePathBrowseButton( composite, data ); - data.width = ProfileSelectionPageHelper.computeButtonWidth( browseButton ); - } + createFilePathLabel( composite, null ); + + // File path text control + { + GridData data = new GridData( GridData.FILL_HORIZONTAL ); + data.widthHint = 290; + setupFilePathText( composite, data ); + } + + // Browse... button + { + IMenuButtonProvider provider = new MenuButtonProvider( ); + m_browseButton = new ProfileStoreBrowseButton( composite, + SWT.PUSH, + provider, + this ); + GridData data = new GridData(); + data.widthHint = m_browseButton.computeButtonWidth( ); + m_browseButton.setLayoutData(data); + + if( m_resourceIdentifiers != null ) + { + File resourceBase= new File( m_resourceIdentifiers.getApplResourceBaseURI()); + m_browseButton.getMenuButtonProvider( ).setProperty( + IBrowseButtonHost.RESOURCE_FILE_DIR, resourceBase ); + } + m_browseButton.getMenuButtonProvider( ).setProperty( + IBrowseButtonHost.IS_CREATE_PROFILE, Boolean.TRUE ); + m_browseButton.refreshMenuItems( ); + } // Encrypt file checkbox setupEncryptContentCheckbox( container ); @@ -180,6 +201,56 @@ public class ProfileStoreCreationDialog extends ExportProfilesDialog m_profilesViewer.setChecked( m_preSelectProfile, true ); } + + void setHostResourceIdentifiers( ResourceIdentifiers resourceIdentifiers ) + { + m_resourceIdentifiers = resourceIdentifiers; + } + + /* + * (non-Javadoc) + * @see org.eclipse.datatools.connectivity.internal.ui.wizards.ExportProfilesDialog#getFilePathText() + */ + protected String getFilePathText() + { + String profileStorePath = super.getFilePathText(); + if( profileStorePath == null || profileStorePath.trim().length() == 0 ) + { + m_isProfileStorePathRelative = false; // default setting + return profileStorePath; + } + + // override base class method to resolve profile store file path, + // if a relative path is specified; + // also reset flag based on latest value found in text control + m_isProfileStorePathRelative = ! new File( profileStorePath ).isAbsolute(); + return DesignUtil.resolveToApplResourcePath( profileStorePath, m_resourceIdentifiers ); + } + + /* + * (non-Javadoc) + * @see org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IBrowseButtonHost#setProfileStorePath(java.lang.String, boolean) + */ + public void setProfileStorePath( String path, boolean isRelative ) + { + m_isProfileStorePathRelative = isRelative; + super.setFilePathText( path ); + } + + /* + * (non-Javadoc) + * @see org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.IBrowseButtonHost#browseSelected() + */ + public void browseSelected() + { + m_browseButton.getMenuButtonProvider().setProperty( + IBrowseButtonHost.STORED_PATH, getFilePathText() ); + } + + public boolean isProfileStorePathRelative() + { + return m_isProfileStorePathRelative; + } } diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/IBrowseButtonHost.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/IBrowseButtonHost.java new file mode 100644 index 0000000..cf295e0 --- a/dev/null +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/IBrowseButtonHost.java @@ -0,0 +1,43 @@ +/*
+ *************************************************************************
+ * Copyright (c) 2011 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.connectivity.oda.design.internal.ui.profile.browse;
+
+/**
+ * Internal interface that must be implemented by all classes
+ * that consumes the {@link ProfileStoreBrowseButton}.
+ *
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public abstract interface IBrowseButtonHost
+{
+ public static final String RESOURCE_FILE_DIR = "ResourceFileDIR"; //$NON-NLS-1$
+ public static final String IS_CREATE_PROFILE = "IsCreateProfile"; //$NON-NLS-1$
+ public static final String STORED_PATH = "StoredPath"; //$NON-NLS-1$
+
+ /**
+ * This function should be used by the Browse Button host to get
+ * back the path to the file
+ * @param path - absolute or relative path to the file
+ * @param isRelative - true if path is relative; false otherwise
+ */
+ public void setProfileStorePath( String path, boolean isRelative );
+
+ /**
+ * This function is called whenever a menu in the browse button is selected.
+ * This serves as a notification to the host, so that the host can perform
+ * some operations before the dialog is launched.
+ */
+ public void browseSelected();
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/IMenuButtonProvider.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/IMenuButtonProvider.java new file mode 100644 index 0000000..f83e6e9 --- a/dev/null +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/IMenuButtonProvider.java @@ -0,0 +1,79 @@ +/*
+ *************************************************************************
+ * Copyright (c) 2011 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.connectivity.oda.design.internal.ui.profile.browse;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Internal interface for the menu button provider.
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public interface IMenuButtonProvider
+{
+ /**
+ * Set Menu button for the provider
+ * @param input - ProfileStoreBrowseButton to use
+ */
+ public void setInput( ProfileStoreBrowseButton input );
+
+ /**
+ * @return the menu items that should be added to the
+ * ProfileStoreBrowseButton
+ */
+ public String[] getMenuItems( );
+
+ /**
+ * @param menuItem
+ * @return image to display for the menuItem
+ */
+ public Image getMenuItemImage( String menuItem );
+
+ /**
+ * @param menuItem
+ * @return text to display for the menuItem
+ */
+ public String getMenuItemText( String menuItem );
+
+ /**
+ * Selection event passed when a menu item is selected
+ * @param type - absolute or relative
+ */
+ public void handleSelectionEvent( String type );
+
+ /**
+ * @return the text to display on the button
+ */
+ public String getButtonText( );
+
+ /**
+ * @return the tooltip text to display for the button
+ */
+ public String getToolTipText( );
+
+ /**
+ * The IBrowseButton host can call this function on the
+ * provider to set a property
+ * @param key
+ * @param value
+ */
+ public void setProperty( String key, Object value );
+
+ /**
+ * @param key the property key to look up
+ * @return the value of a property
+ */
+ public Object getProperty( String key );
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java new file mode 100644 index 0000000..352be6e --- a/dev/null +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java @@ -0,0 +1,402 @@ +/*
+ *************************************************************************
+ * Copyright (c) 2011 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.connectivity.oda.design.internal.ui.profile.browse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+
+/**
+ * Internal class for a button that contains menu items.
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public class MenuButton extends Composite
+{
+ private Button button;
+
+ private String text;
+ private Image image;
+
+ public String getText( )
+ {
+ return text;
+ }
+
+ public Image getImage( )
+ {
+ return image;
+ }
+
+ private static final int IMAGE_HEIGHT = 16, IMAGE_WIDTH = 16;
+
+ private static int DRAW_FLAGS = SWT.DRAW_MNEMONIC
+ | SWT.DRAW_TAB
+ | SWT.DRAW_TRANSPARENT
+ | SWT.DRAW_DELIMITER;
+
+ private static final int MARGIN_GAP = 4;
+
+ private static final int TRIANGLE_WIDTH = 5;
+
+ private static final int WIDTH_MORE = 2 * MARGIN_GAP + TRIANGLE_WIDTH + 1;
+
+ private void layoutControl( )
+ {
+ getParent( ).layout( );
+ button.redraw( );
+ }
+
+ private Point defaultSize = new Point( 0, 0 );
+
+ public Point computeSize( int wHint, int hHint, boolean changed )
+ {
+ int width;
+ int height;
+
+ Button tmp = new Button( this, button.getStyle( ) );
+ if ( text != null )
+ {
+ height = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
+ }
+ else
+ {
+ tmp.setText( "" ); //$NON-NLS-1$
+ height = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
+ }
+ if ( image != null )
+ tmp.setImage( image );
+ Point size = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT );
+ tmp.dispose( );
+
+ if ( menu != null )
+ {
+ width = size.x + WIDTH_MORE;
+ }
+ else
+ width = size.x;
+
+ if ( isFixed && image != null )
+ {
+ int imageWidth = image.getImageData( ).width;
+ if ( imageWidth > IMAGE_WIDTH )
+ width -= ( imageWidth - IMAGE_WIDTH );
+
+ }
+ if ( !isFixed )
+ height = size.y;
+ defaultSize = new Point( width, height );
+ if ( wHint != SWT.DEFAULT )
+ width = wHint;
+ if ( hHint != SWT.DEFAULT )
+ height = hHint;
+
+ return new Point( width, height );
+ }
+
+ public void setImage( Image image )
+ {
+ this.image = image;
+ layoutControl( );
+ }
+
+ public void setToolTipText( String toolTipText )
+ {
+ super.setToolTipText( toolTipText );
+ button.setToolTipText( toolTipText );
+ }
+
+ public void setBackground( Color color )
+ {
+ super.setBackground( color );
+ button.setBackground( color );
+ button.redraw( );
+ }
+
+ public void setForeground( Color color )
+ {
+ super.setBackground( color );
+ button.setForeground( color );
+ button.redraw( );
+ }
+
+ public void setFont( Font font )
+ {
+ super.setFont( font );
+ button.setFont( font );
+ button.redraw( );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ super.setEnabled( enable );
+ button.setEnabled( enable );
+ button.redraw( );
+ }
+
+ public MenuButton( Composite parent, int style, String text )
+ {
+ this( parent, style, false, text );
+ }
+
+ private boolean isFixed = true;
+
+ private boolean mouseSelection = false;
+
+ public MenuButton( Composite parent, int style, boolean fixed, String text )
+ {
+ super( parent, SWT.NONE );
+ isFixed = fixed;
+ GridLayout layout = new GridLayout( );
+ layout.marginHeight = layout.marginWidth = 0;
+ this.setLayout( layout );
+
+ button = new Button( this, style );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ button.setText(text);
+ button.setLayoutData( gd );
+ button.addPaintListener( new PaintListener( ) {
+
+ public void paintControl( PaintEvent e )
+ {
+ MenuButton.this.paintControl( e );
+ }
+ } );
+ button.addListener( SWT.MouseUp, new Listener( ) {
+
+ public void handleEvent( Event e )
+ {
+ if ( !button.isEnabled( ) || e.button != 1 )
+ return;
+ mouseSelection = true;
+ Rectangle size = button.getBounds( );
+ if ( !size.contains( e.x, e.y ) )
+ return;
+ int left = WIDTH_MORE + MARGIN_GAP - 1;
+ if ( menu == null )
+ left = 0;
+
+ if ( e.x < size.width - left )
+ {
+ if ( listeners == null )
+ return;
+
+ e.widget = MenuButton.this;
+
+ for ( int i = 0; i < listeners.size( ); i++ )
+ {
+ ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
+ }
+ }
+ else
+ {
+ if ( menu != null )
+ {
+ menu.setLocation( button.toDisplay( new Point( 0,
+ size.height - 1 ) ) );
+ menu.setVisible( true );
+ }
+ }
+ }
+
+ } );
+ button.addListener( SWT.KeyUp, new Listener( ) {
+
+ public void handleEvent( Event e )
+ {
+ if ( e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_UP )
+ {
+ if ( menu != null )
+ {
+ Rectangle size = button.getBounds( );
+ menu.setLocation( button.toDisplay( new Point( 0,
+ size.height - 1 ) ) );
+ menu.setVisible( true );
+ }
+ }
+ }
+
+ } );
+ button.addListener( SWT.Selection, new Listener( ) {
+
+ public void handleEvent( Event e )
+ {
+ if ( mouseSelection == true )
+ {
+ mouseSelection = false;
+ return;
+ }
+
+ if ( listeners == null )
+ return;
+
+ e.widget = MenuButton.this;
+
+ for ( int i = 0; i < listeners.size( ); i++ )
+ {
+ ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
+ }
+ }
+
+ } );
+ }
+
+ private Menu menu;
+
+ public void setDropDownMenu( Menu menu )
+ {
+ this.menu = menu;
+ }
+
+ private List<SelectionListener> listeners;
+
+ public void addSelectionListener( SelectionListener listener )
+ {
+ if ( listeners == null )
+ listeners = new ArrayList<SelectionListener>( );
+ listeners.add( listener );
+ }
+
+ public void removeSelectionListener( SelectionListener listener )
+ {
+ if ( listeners != null )
+ {
+ listeners.remove( listener );
+ if ( listeners.size( ) == 0 )
+ listeners = null;
+ }
+ }
+
+ protected void paintControl( PaintEvent e )
+ {
+ e.gc.setFont( getFont( ) );
+ Color fg = isEnabled( ) ? getForeground( )
+ : new Color( e.gc.getDevice( ),
+ UIUtil.blend( getBackground( ).getRGB( ),
+ getForeground( ).getRGB( ),
+ 70 ) );
+ try
+ {
+ e.gc.setForeground( fg );
+ Color bgColor = e.gc.getBackground( );
+ e.gc.setBackground( e.gc.getForeground( ) );
+ Rectangle size = button.getBounds( );
+
+ if ( menu != null )
+ {
+ Rectangle rect = new Rectangle( size.width - 12,
+ 0,
+ TRIANGLE_WIDTH,
+ size.height );
+ UIUtil.drawArrow( e.gc, rect, SWT.DOWN );
+ }
+
+ e.gc.setBackground( bgColor );
+
+ int height = e.gc.textExtent( "", DRAW_FLAGS ).y; //$NON-NLS-1$
+
+ if ( !isFixed && image != null )
+ {
+ int imageHeight = image.getImageData( ).height;
+ if ( height < imageHeight )
+ height = imageHeight;
+ }
+
+ if ( defaultSize.y > size.height )
+ {
+ height = height - ( defaultSize.y - size.height );
+ height = e.gc.textExtent( "", DRAW_FLAGS ).y > height ? e.gc.textExtent( "", //$NON-NLS-1$ //$NON-NLS-2$
+ DRAW_FLAGS ).y
+ : height;
+ }
+
+ int left = WIDTH_MORE + MARGIN_GAP - 1;
+
+ if ( menu == null )
+ left = MARGIN_GAP - 1;
+
+ if ( menu != null )
+ {
+ Color fgColor = e.gc.getForeground( );
+ e.gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
+ e.gc.drawLine( size.width - left,
+ ( size.height - height ) / 2,
+ size.width - left,
+ ( size.height - height ) / 2 + height );
+ e.gc.setForeground( fgColor );
+ }
+
+ if ( image != null )
+ {
+ int imageWidth = image.getImageData( ).width;
+ int imageHeight = image.getImageData( ).height;
+
+ Image imageTemp;
+
+ if ( isEnabled( ) )
+ imageTemp = new Image( e.gc.getDevice( ),
+ image,
+ SWT.IMAGE_COPY );
+ else
+ imageTemp = new Image( e.gc.getDevice( ),
+ image,
+ SWT.IMAGE_DISABLE );
+
+ if ( isFixed )
+ {
+ imageWidth = imageWidth > IMAGE_WIDTH ? IMAGE_WIDTH
+ : imageWidth;
+ imageHeight = imageHeight > IMAGE_HEIGHT ? IMAGE_HEIGHT
+ : imageHeight;
+ }
+
+ left += ( MARGIN_GAP + imageWidth );
+ e.gc.drawImage( imageTemp,
+ 0,
+ 0,
+ imageTemp.getImageData( ).width,
+ imageTemp.getImageData( ).height,
+ ( size.width - left ) / 2 + MARGIN_GAP,
+ Math.round( ( (float) ( size.height - imageHeight ) / 2 ) ),
+ imageWidth,
+ imageHeight );
+
+ imageTemp.dispose( );
+ }
+ }
+ finally
+ {
+ if ( !isEnabled( ) && fg != null )
+ fg.dispose( );
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButtonProvider.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButtonProvider.java new file mode 100644 index 0000000..ec0f672 --- a/dev/null +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButtonProvider.java @@ -0,0 +1,168 @@ +/*
+ *************************************************************************
+ * Copyright (c) 2011 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.connectivity.oda.design.internal.ui.profile.browse;
+
+import java.io.File;
+
+import org.eclipse.datatools.connectivity.oda.design.ui.nls.Messages;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.MessageBox;
+
+/**
+ * Internal provider for ProfileStoreBrowseButton.
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public class MenuButtonProvider implements IMenuButtonProvider
+{
+ private static String BUTTON_BROWSE_TEXT = Messages.profilePage_button_browse;
+ private static String RELATIVE_PATH_MENU = Messages.profilePage_button_relativepath;
+ private static String ABSOLUTE_PATH_MENU = Messages.profilePage_button_absolutepath;
+ private static String BUTTON_BROWSE_TOOLTIP_TEXT = Messages.profilePage_button_browse_tooltip;
+
+ private static String RELATIVE_PATH_TYPE = "RelativePath"; //$NON-NLS-1$
+ private static String ABSOLUTE_PATH_TYPE = "AbsolutePath"; //$NON-NLS-1$
+
+ private ProfileStoreBrowseButton button;
+ private String[] optionTypes;
+
+ public MenuButtonProvider( )
+ {
+ optionTypes = new String[]{
+ ABSOLUTE_PATH_TYPE
+ };
+ }
+
+ public String getDefaultOptionType( )
+ {
+ return optionTypes == null || optionTypes.length == 0 ? null
+ : optionTypes[0];
+ }
+
+ public String[] getMenuItems( )
+ {
+ return optionTypes;
+ }
+
+ public Image getMenuItemImage( String type )
+ {
+ return null;
+ }
+
+ public String getMenuItemText( String type )
+ {
+ if ( RELATIVE_PATH_TYPE.equals( type ) )
+ {
+ return RELATIVE_PATH_MENU;
+ }
+ return ABSOLUTE_PATH_MENU;
+ }
+
+ /**
+ * Selection event passed when a menu item is selected.
+ * If absolute menu option is selected a standard eclipse swt FileDialog
+ * is displayed. If a relative path is selected a ProfilePathSelectionDialog
+ * is displayed
+ */
+ public void handleSelectionEvent( String type )
+ {
+ Object value = getProperty( IBrowseButtonHost.RESOURCE_FILE_DIR );
+ Object cpvalue = getProperty( IBrowseButtonHost.IS_CREATE_PROFILE );
+ Object spvalue = getProperty( IBrowseButtonHost.STORED_PATH );
+ String[] fileNames = null;
+ boolean isRelative = RELATIVE_PATH_TYPE.equals( type );
+ if ( isRelative )
+ {
+ if ( value != null && value instanceof File &&
+ cpvalue != null && cpvalue instanceof Boolean )
+ {
+ ProfilePathSelectionDialog dialog = new ProfilePathSelectionDialog( button.getControl( )
+ .getShell( ),
+ (File) value,
+ ((Boolean) cpvalue).booleanValue(),
+ (String)spvalue);
+ if ( dialog.open( ) == Window.OK )
+ {
+ fileNames = dialog.getSelectedItems( );
+ }
+ }
+ else
+ {
+ MessageBox box = new MessageBox( UIUtil.getDefaultShell( ), SWT.ICON_ERROR );
+ box.setText( Messages.ui_errorLabel );
+ box.setMessage( Messages.profilePage_resourcebaseuri_failure );
+ box.open( );
+ }
+ }
+ else
+ {
+ FileDialog dialog = new FileDialog( button.getControl( ).getShell( ) );
+ if( spvalue instanceof String )
+ dialog.setFileName( (String)spvalue );
+ fileNames = new String[1];
+ fileNames[0] = dialog.open();
+ }
+
+ if ( fileNames != null && fileNames[0] != null)
+ button.handleSelection( fileNames[0], isRelative );
+
+ }
+
+ public void setInput( ProfileStoreBrowseButton input )
+ {
+ this.button = input;
+ }
+
+ public void resetProperties( )
+ {
+ boolean supportsRelativePath = getProperty( IBrowseButtonHost.RESOURCE_FILE_DIR ) instanceof File;
+ if ( supportsRelativePath )
+ {
+ optionTypes = new String[]{
+ RELATIVE_PATH_TYPE,
+ ABSOLUTE_PATH_TYPE
+ };
+ }
+ else
+ {
+ optionTypes = new String[]{
+ ABSOLUTE_PATH_TYPE
+ };
+ }
+ }
+
+ public String getButtonText( )
+ {
+ return BUTTON_BROWSE_TEXT;
+ }
+
+ public String getToolTipText()
+ {
+ return BUTTON_BROWSE_TOOLTIP_TEXT;
+ }
+
+ public Object getProperty( String key )
+ {
+ return button.getControl( ).getData( key );
+ }
+
+ public void setProperty( String key, Object value )
+ {
+ button.getControl( ).setData( key, value );
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfilePathSelectionDialog.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfilePathSelectionDialog.java new file mode 100644 index 0000000..fd32c2b --- a/dev/null +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfilePathSelectionDialog.java @@ -0,0 +1,407 @@ +/*
+ *************************************************************************
+ * Copyright (c) 2011 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.connectivity.oda.design.internal.ui.profile.browse;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin;
+import org.eclipse.datatools.connectivity.oda.design.ui.nls.Messages;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+
+/**
+ * Internal class that displays the contents of the host resource folder.
+ * It is used when creating a connection profile store and when selecting
+ * a connection profile store for use.
+ *
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
+{
+ static final String PLUGIN_ID = "org.eclipse.datatools.connectivity.oda.design.ui"; //$NON-NLS-1$
+ static final String TITLE = Messages.profilePage_pageTitle;
+ static final String TITLE_CREATE = Messages.profileStoreCreationDialog_title;
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ private final static Image IMG_FOLDER = PlatformUI.getWorkbench( )
+ .getSharedImages( )
+ .getImage( ISharedImages.IMG_OBJ_FOLDER );
+
+ private final static Image IMG_FILE = PlatformUI.getWorkbench( )
+ .getSharedImages( )
+ .getImage( ISharedImages.IMG_OBJ_FILE );
+
+ private File topDir;
+ private boolean isProfileStoreCreation = false;
+ private Text txtFile;
+ private String txtFileContent = null;
+ String storedPath = null;
+
+ public ProfilePathSelectionDialog( Shell parent, File topDir, boolean isProfileCreation, String storedPath )
+ {
+ super( parent, new LabelProvider( ), new ContentProvider( isProfileCreation ) );
+
+ assert topDir != null;
+
+ this.setValidator( new SelectionValidator( ) );
+ this.setInput( topDir.getAbsolutePath( ) );
+ this.topDir = topDir;
+ this.isProfileStoreCreation = isProfileCreation;
+ if( isProfileCreation )
+ this.setTitle( TITLE_CREATE );
+ else
+ this.setTitle( TITLE );
+ this.storedPath = storedPath;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.ElementTreeSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea( Composite parent )
+ {
+ Control c = super.createDialogArea( parent );
+
+ if( isProfileStoreCreation )
+ {
+ Composite composite = new Composite( parent, SWT.NONE );
+ {
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 3;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.minimumWidth = 360;
+ gridData.horizontalIndent = 10;
+ composite.setLayoutData( gridData );
+ }
+
+ FormLayout layout = new FormLayout( );
+ composite.setLayout( layout );
+
+ final Label label = new Label(composite, SWT.NONE);
+ label.setText(ConnectivityUIPlugin.getDefault().getResourceString(
+ "ExportProfilesDialog.label.text")); //$NON-NLS-1$
+ {
+ FormData data = new FormData( );
+ data.top = new FormAttachment( 0, 5 );
+ data.left = new FormAttachment( 0, 5 );
+ label.setLayoutData( data );
+ }
+
+ txtFile = new Text(composite, SWT.BORDER);
+ {
+ FormData data = new FormData( );
+ data.top = new FormAttachment( 0, 5 );
+ data.left = new FormAttachment( label, 5, 5 );
+ data.right = new FormAttachment( 100, -10 );
+ txtFile.setLayoutData(data);
+ }
+ }
+
+ if( storedPath != null && storedPath.trim().length() > 0 )
+ {
+ File f = new File(storedPath);
+ if( !f.exists() && isProfileStoreCreation )
+ {
+ String newFileName = f.getName();
+ f = f.getParentFile();
+ txtFile.setText(newFileName);
+ }
+ int level = 1;
+ File parentFile = f.getParentFile();
+ while( parentFile != null &&
+ !parentFile.getAbsolutePath().equals( topDir.getAbsolutePath() ) )
+ {
+ parentFile = parentFile.getParentFile();
+ level++;
+ }
+ getTreeViewer( ).expandToLevel(parentFile, level);
+ Widget w = getTreeViewer( ).testFindItem(f);
+ if( w == null )
+ {
+ getTreeViewer( ).expandAll(); //Worse case approach
+ }
+ setInitialSelection(f); //The selection needs to be visible in the TreeViewer for this to work
+ }
+ else
+ getTreeViewer( ).expandToLevel(2);
+
+ return c;
+ }
+
+ protected void okPressed()
+ {
+ if(isProfileStoreCreation)
+ {
+ txtFileContent = txtFile.getText();
+ if( txtFileContent.trim().length() == 0 )
+ {
+ MessageDialog.openError(getShell(), Messages.ui_errorLabel,
+ Messages.profilePage_browse_noselection_error);
+ return;
+ }
+ }
+ super.okPressed();
+ }
+
+ private static class ContentProvider implements ITreeContentProvider
+ {
+ private boolean isProfileCreation = false;
+
+ public ContentProvider(boolean isProfileCreation)
+ {
+ this.isProfileCreation = isProfileCreation;
+ }
+
+ public Object[] getChildren( Object arg )
+ {
+ if ( arg instanceof File )
+ {
+ return ProfilePathSelectionDialog.getChildren( (File)arg, isProfileCreation );
+ }
+ return null;
+ }
+
+ public Object getParent( Object arg0 )
+ {
+ return null;
+ }
+
+ public boolean hasChildren( Object arg )
+ {
+ if ( arg instanceof File )
+ {
+ return ProfilePathSelectionDialog.getChildren( (File)arg, isProfileCreation ).length > 0;
+ }
+ return false;
+ }
+
+ public Object[] getElements( Object arg )
+ {
+ if ( arg instanceof String )
+ {
+ return new Object[]{ new File((String)arg) };
+ }
+ return null;
+ }
+
+ public void dispose( )
+ {
+
+ }
+
+ public void inputChanged( Viewer arg0, Object arg1, Object arg2 )
+ {
+
+ }
+ }
+
+ private static class LabelProvider implements ILabelProvider
+ {
+
+ public Image getImage( Object arg )
+ {
+ if ( arg instanceof File )
+ {
+ if ( ((File)arg).isFile( ) )
+ {
+ return IMG_FILE;
+ }
+ return IMG_FOLDER;
+ }
+ return null;
+ }
+
+ public String getText( Object arg0 )
+ {
+ if ( arg0 instanceof File )
+ {
+ File f = (File)arg0;
+ if ( f.getName( ).trim( ).length() == 0 )
+ {
+ //For the case "File("C:\\")"
+ return f.getPath( );
+ }
+ return f.getName( );
+ }
+ return EMPTY_STRING;
+ }
+
+ public void addListener( ILabelProviderListener arg0 )
+ {
+
+ }
+
+ public void dispose( )
+ {
+
+ }
+
+ public boolean isLabelProperty( Object arg0, String arg1 )
+ {
+ return false;
+ }
+
+ public void removeListener( ILabelProviderListener arg0 )
+ {
+
+ }
+
+ }
+
+ private class SelectionValidator implements ISelectionStatusValidator
+ {
+
+ public IStatus validate( Object[] selections )
+ {
+ if ( selections != null && selections.length > 0 )
+ {
+ for ( Object o : selections )
+ {
+ if ( o instanceof File )
+ {
+ File selFile = ((File)o);
+ if ( isProfileStoreCreation ||
+ (!isProfileStoreCreation && selFile.isFile( )) )
+ {
+ if( isProfileStoreCreation && selFile.isFile( ) )
+ {
+ txtFile.setText( selFile.getName() );
+ }
+ return new Status( IStatus.OK,
+ PLUGIN_ID,
+ IStatus.OK,
+ EMPTY_STRING,
+ null );
+ }
+ }
+ }
+ }
+ return new Status( IStatus.ERROR,
+ PLUGIN_ID,
+ IStatus.ERROR,
+ EMPTY_STRING,
+ null );
+ }
+
+
+ }
+
+ private static File[] getChildren( File f, final boolean isProfileCreation )
+ {
+ if ( !f.isDirectory( ) )
+ {
+ return new File[0];
+ }
+ File[] result
+ = f.listFiles( new FileFilter( )
+ {
+ public boolean accept( File child )
+ {
+ //A profile store does not have an associated extension therefore
+ //show all files and folders.
+ return true;
+ }
+ });
+ if ( result != null )
+ {
+ Arrays.sort( result, new FileComparator( ) );
+ }
+ return result == null ? new File[0] : result;
+ }
+
+ public String[] getSelectedItems( )
+ {
+ List<String> result = new ArrayList<String>( );
+ Object[] selected = this.getResult( ) == null ? new Object[0] : this.getResult( );
+ for ( Object o : selected )
+ {
+ File f = (File)o;
+ if ( isProfileStoreCreation )
+ {
+ String path = EMPTY_STRING;
+ if( !f.getName().equals(txtFileContent) )
+ path = f.getParentFile().toURI().toString() + txtFileContent;
+ else
+ path = f.toURI( ).toString();
+
+ if( !f.isFile( ) )
+ path = f.toURI( ).toString() + txtFileContent;
+ URI filePath = URI.create(path);
+ URI relative = topDir.toURI( ).relativize( filePath );
+ result.add( relative.getPath( ) );
+ }
+ else if ( !isProfileStoreCreation && f.isFile( ) )
+ {
+ URI relative = topDir.toURI( ).relativize( f.toURI( ) );
+ result.add( relative.getPath( ) );
+ }
+ }
+ return result.toArray( new String[0] );
+ }
+
+ public static class FileComparator implements Comparator<File>, Serializable
+ {
+ private static final long serialVersionUID = 1L;
+
+ public int compare( File o1, File o2 )
+ {
+ if ( o1.isDirectory( ) && o2.isDirectory( ) )
+ {
+ return o1.getName( ).compareTo( o2.getName( ) );
+ }
+ else if ( o1.isFile( ) && o2.isFile( ) )
+ {
+ return o1.getName( ).compareTo( o2.getName( ) );
+ }
+ else if ( o1.isDirectory( ) && !o2.isDirectory( ))
+ {
+ return -1;
+ }
+ else
+ {
+ //o1 is not a directory but o2 is a directory
+ return 1;
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java new file mode 100644 index 0000000..68e9356 --- a/dev/null +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java @@ -0,0 +1,173 @@ +/*
+ *************************************************************************
+ * Copyright (c) 2011 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.connectivity.oda.design.internal.ui.profile.browse;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Internal class for implementing a Browse button with two
+ * menu items - one for browsing using a path relative to
+ * the host resource folder, and the second one for
+ * browsing using an absolute path.
+ *
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public class ProfileStoreBrowseButton
+{
+ private static final int BUTTON_MIN_WIDTH = 80;
+
+ private MenuButton button;
+ private Menu menu;
+
+ private IMenuButtonProvider provider;
+ private IBrowseButtonHost host;
+
+ private SelectionAdapter listener = new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ Widget widget = e.widget;
+ if ( widget instanceof MenuItem )
+ {
+ host.browseSelected();
+ provider.handleSelectionEvent( (String) widget.getData( ) );
+ }
+ if ( widget instanceof MenuButton )
+ {
+ host.browseSelected();
+ provider.handleSelectionEvent( ( (MenuButtonProvider) provider ).getDefaultOptionType( ) );
+ }
+ }
+
+ };
+
+ public ProfileStoreBrowseButton( Composite parent, int style,
+ IMenuButtonProvider provider, IBrowseButtonHost host)
+ {
+ this.host = host;
+ button = new MenuButton( parent, style, provider.getButtonText() );
+ button.addSelectionListener( listener );
+ button.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ refreshMenuItems( );
+ }
+
+ } );
+
+ menu = new Menu( parent.getShell( ), SWT.POP_UP );
+ button.setDropDownMenu( menu );
+ button.setToolTipText( provider.getToolTipText() );
+ setMenuButtonProvider( provider );
+ refresh( );
+ }
+
+ public void setLayoutData(Object layoutData)
+ {
+ button.setLayoutData( layoutData );
+ }
+
+ public void refreshMenuItems( )
+ {
+ ( (MenuButtonProvider) this.provider ).resetProperties( );
+ populateMenuItems( );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ button.setEnabled( enable );
+ }
+
+ public boolean isEnabled( )
+ {
+ return button.isEnabled( );
+ }
+
+ public MenuButton getControl( )
+ {
+ return button;
+ }
+
+ public IMenuButtonProvider getMenuButtonProvider()
+ {
+ return provider;
+ }
+
+ public void refresh( )
+ {
+ }
+
+ public void setMenuButtonProvider( IMenuButtonProvider provider )
+ {
+ if ( provider != null && provider != this.provider )
+ {
+ this.provider = provider;
+
+ provider.setInput( this );
+
+ populateMenuItems( );
+ }
+ }
+
+ private void populateMenuItems( )
+ {
+ for ( int i = 0; i < menu.getItemCount( ); i++ )
+ {
+ menu.getItem( i ).dispose( );
+ i--;
+ }
+
+ String[] types = this.provider.getMenuItems( );
+ for ( int i = 0; i < types.length; i++ )
+ {
+ MenuItem item = new MenuItem( menu, SWT.PUSH );
+ item.setText( provider.getMenuItemText( types[i] ) );
+ item.setData( types[i] );
+ item.setImage( this.provider.getMenuItemImage( types[i] ) );
+ item.addSelectionListener( listener );
+ }
+
+ if ( menu.getItemCount( ) <= 0 )
+ {
+ button.setDropDownMenu( null );
+ }
+ refresh( );
+ }
+
+ public void handleSelection( String path, boolean isRelative )
+ {
+ host.setProfileStorePath( path, isRelative);
+ }
+
+ public int computeButtonWidth( )
+ {
+ return computeButtonWidth(button);
+ }
+
+ static int computeButtonWidth( MenuButton button )
+ {
+ int defaultWidth = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x;
+ return ( defaultWidth < BUTTON_MIN_WIDTH ) ?
+ BUTTON_MIN_WIDTH : defaultWidth;
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/UIUtil.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/UIUtil.java new file mode 100644 index 0000000..17acfc8 --- a/dev/null +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/UIUtil.java @@ -0,0 +1,140 @@ +/*
+ *************************************************************************
+ * Copyright (c) 2011 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.connectivity.oda.design.internal.ui.profile.browse;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Internal utility class.
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public class UIUtil
+{
+ /**
+ * Blends c1 and c2 based in the provided ratio.
+ * @param c1 first color
+ * @param c2 second color
+ * @param ratio percentage of the first color in the blend (0-100)
+ * @return the RGB value of the blended color
+ */
+ static RGB blend( RGB c1, RGB c2, int ratio )
+ {
+ int r = blend( c1.red, c2.red, ratio );
+ int g = blend( c1.green, c2.green, ratio );
+ int b = blend( c1.blue, c2.blue, ratio );
+ return new RGB( r, g, b );
+ }
+
+ /**
+ * Blends two primary color components based on the provided ratio.
+ * @param v1 first component
+ * @param v2 second component
+ * @param ratio percentage of the first component in the blend
+ * @return
+ */
+ private static int blend( int v1, int v2, int ratio )
+ {
+ int b = ( ratio * v1 + ( 100 - ratio ) * v2 ) / 100;
+ return Math.min( 255, b );
+ }
+
+ static void drawArrow( GC gc, Rectangle rect, int style )
+ {
+ Point point = new Point( rect.x + ( rect.width / 2 ), rect.y
+ + ( rect.height / 2 ) );
+ int[] points = null;
+ switch ( style )
+ {
+ case SWT.LEFT :
+ points = new int[]{
+ point.x + 2,
+ point.y - 4,
+ point.x + 2,
+ point.y + 4,
+ point.x - 2,
+ point.y
+ };
+ gc.fillPolygon( points );
+ break;
+
+ /*
+ * Low efficiency because of Win98 bug.
+ */
+ case SWT.UP :
+ gc.fillRectangle( new Rectangle( point.x, point.y - 1, 1, 1 ) );
+ gc.fillRectangle( new Rectangle( point.x - 1, point.y, 3, 1 ) );
+ gc.fillRectangle( new Rectangle( point.x - 2, point.y + 1, 5, 1 ) );
+ break;
+
+ case SWT.RIGHT :
+ points = new int[]{
+ point.x - 2,
+ point.y - 4,
+ point.x - 2,
+ point.y + 4,
+ point.x + 2,
+ point.y
+ };
+ gc.fillPolygon( points );
+ break;
+
+ /*
+ * Low efficiency because of Win98 bug.
+ */
+ default :
+ gc.fillRectangle( new Rectangle( point.x - 2, point.y - 1, 5, 1 ) );
+ gc.fillRectangle( new Rectangle( point.x - 1, point.y, 3, 1 ) );
+ gc.fillRectangle( new Rectangle( point.x, point.y + 1, 1, 1 ) );
+ break;
+ }
+
+ }
+
+ static Shell getDefaultShell( )
+ {
+ Shell shell = null;
+ try
+ {
+ shell = PlatformUI.getWorkbench( ).getDisplay( ).getActiveShell( );
+ if ( shell == null )
+ {
+ shell = Display.getCurrent( ).getActiveShell( );
+ }
+ if ( shell == null )
+ {
+ shell = PlatformUI.getWorkbench( )
+ .getActiveWorkbenchWindow( )
+ .getShell( );
+ }
+ }
+ catch ( Exception e )
+ {
+ //do nothing
+ }
+ if ( shell == null )
+ {
+ return new Shell( );
+ }
+ return shell;
+ }
+
+}
\ No newline at end of file diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/Messages.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/Messages.java index ee9c94c..ce6e053 100644 --- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/Messages.java +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/Messages.java @@ -43,7 +43,11 @@ public class Messages extends NLS public static String extension_mustInheritFromODAWizard; public static String extension_missingManifestElement; public static String extension_missingPropertyPage; + public static String profilePage_browse_noselection_error; public static String profilePage_button_browse; + public static String profilePage_button_browse_tooltip; + public static String profilePage_button_relativepath; + public static String profilePage_button_absolutepath; public static String profilePage_button_new; public static String profilePage_checkboxLabel_maintainLink; public static String profilePage_checkboxLabel_useDefaultName; @@ -57,6 +61,7 @@ public class Messages extends NLS public static String profilePage_odaTreeName; public static String profilePage_pageLabel; public static String profilePage_pageTitle; + public static String profilePage_resourcebaseuri_failure; public static String profilePage_selectProfileDefaultMessage; public static String wizard_dataSource_defaultTitle; public static String wizard_missingDataSourceId; diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/messages.properties b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/messages.properties index e239c73..2edecf1 100644 --- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/messages.properties +++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/messages.properties @@ -46,7 +46,12 @@ profilePage_pageLabel=Connection Profile profilePage_selectProfileDefaultMessage=Select the connection profile from which to create a data source profilePage_label_profileStore=Connection Profile &Store: profilePage_button_browse=B&rowse... +profilePage_button_relativepath=Relative Path +profilePage_button_absolutepath=Absolute Path profilePage_button_new=Ne&w... +profilePage_button_browse_tooltip=Browse for a connection profile store file.\nRelative path: the relative path based on the host resources.\nAbsolute path: the absolute path of the file system. +profilePage_resourcebaseuri_failure=Failed to get the application resource base URI! +profilePage_browse_noselection_error=Please specify a connection profile store file name profilePage_odaTreeName=ODA Data Sources profilePage_checkboxLabel_useDefaultName=&Use the default data source name profilePage_label_dataSourceName=&Data Source Name: diff --git a/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF index 8bab206..81868c5 100644 --- a/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.Name Bundle-SymbolicName: org.eclipse.datatools.connectivity.ui; singleton:=true -Bundle-Version: 1.2.1.qualifier +Bundle-Version: 1.2.2.qualifier Bundle-Activator: org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin Bundle-Vendor: %Plugin.ProviderName Bundle-Localization: plugin diff --git a/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/internal/ui/wizards/ExportProfilesDialog.java b/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/internal/ui/wizards/ExportProfilesDialog.java index 1169a49..a0e6110 100644 --- a/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/internal/ui/wizards/ExportProfilesDialog.java +++ b/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/internal/ui/wizards/ExportProfilesDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Sybase, Inc. + * Copyright (c) 2005, 2011 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 @@ -33,6 +33,7 @@ import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.osgi.util.TextProcessor; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -270,7 +271,7 @@ public class ExportProfilesDialog extends TrayDialog implements IContextProvider public void widgetSelected(SelectionEvent e) { String filePath = new FileDialog(getShell()).open(); if( filePath != null ) - txtFile.setText(filePath); + setFilePathText(filePath); } }); button.setLayoutData( layoutData ); @@ -344,7 +345,7 @@ public class ExportProfilesDialog extends TrayDialog implements IContextProvider return; } - if (txtFile.getText().length() == 0) { + if (getFilePathText().length() == 0) { MessageDialog.openError(getShell(), ConnectivityUIPlugin .getDefault().getResourceString("dialog.title.error"), //$NON-NLS-1$ ConnectivityUIPlugin.getDefault().getResourceString( @@ -357,7 +358,7 @@ public class ExportProfilesDialog extends TrayDialog implements IContextProvider } mProfiles = (IConnectionProfile[]) vec .toArray(new IConnectionProfile[0]); - mFile = new File(txtFile.getText()); + mFile = new File(getFilePathText()); /* validate that the file name has a valid directory as parent */ String fileParent = mFile.getParent(); @@ -379,6 +380,24 @@ public class ExportProfilesDialog extends TrayDialog implements IContextProvider mNeedEncryption = btnEncryption.getSelection(); super.okPressed(); } + + /* + * @since DTP 1.9.2 + */ + protected String getFilePathText() + { + String localizedText = txtFile.getText(); + return TextProcessor.deprocess( localizedText ); + } + + /* + * @since DTP 1.9.2 + */ + protected void setFilePathText( String text ) + { + String localizedText = TextProcessor.process( text ); + txtFile.setText( localizedText ); + } public IContext getContext(Object target) { return contextProviderDelegate.getContext(target); |

