summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArchana Mansukhani2011-09-27 21:07:21 (EDT)
committer Linda Chan2011-09-27 21:07:21 (EDT)
commit2173b901076927bfb6e154c052e29a648951d2b5 (patch)
treed5d25dfbfde1f0cad3cbfbf65e58aeeef1511423
parentffb2e9b0ad55677f8917cd6d9ab471f699482f3a (diff)
downloadorg.eclipse.datatools.connectivity-2173b901076927bfb6e154c052e29a648951d2b5.zip
org.eclipse.datatools.connectivity-2173b901076927bfb6e154c052e29a648951d2b5.tar.gz
org.eclipse.datatools.connectivity-2173b901076927bfb6e154c052e29a648951d2b5.tar.bz2
[359154] Enforce default file extension for ODA connection profilesv201109280929
store
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/AdaptableDataSourceProfile.java13
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/ProfileStoreCreationDialog.java62
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java32
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButtonProvider.java31
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfilePathSelectionDialog.java246
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java5
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/Messages.java4
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/ui/nls/messages.properties8
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.profile/build.properties3
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.properties3
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.xml4
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.profile/schema/profileStore.exsd123
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/ProfileFileExtension.java127
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/Messages.java2
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/messages.properties2
-rw-r--r--plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/internal/ui/wizards/ExportProfilesDialog.java27
16 files changed, 614 insertions, 78 deletions
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/AdaptableDataSourceProfile.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/AdaptableDataSourceProfile.java
index 9c02b30..2e371bd 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/AdaptableDataSourceProfile.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/AdaptableDataSourceProfile.java
@@ -1,6 +1,6 @@
/*
*************************************************************************
- * Copyright (c) 2006, 2009 Actuate Corporation.
+ * Copyright (c) 2006, 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
@@ -15,6 +15,7 @@
package org.eclipse.datatools.connectivity.oda.design.internal.ui;
import java.util.Properties;
+import java.util.logging.Logger;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -27,6 +28,7 @@ import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.design.DataSourceDesign;
import org.eclipse.datatools.connectivity.oda.design.DesignFactory;
import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSessionUtil;
+import org.eclipse.datatools.connectivity.oda.design.ui.nls.Messages;
import org.eclipse.datatools.connectivity.oda.design.util.DesignUtil;
import org.eclipse.datatools.connectivity.oda.profile.internal.OdaConnectionProfile;
import org.eclipse.datatools.connectivity.oda.profile.internal.ProfileCategoryUtil;
@@ -45,7 +47,9 @@ public class AdaptableDataSourceProfile extends OdaConnectionProfile implements
private DataSourceDesign m_dataSourceDesign;
private String m_instanceID;
-
+
+ private static final String sm_className = AdaptableDataSourceProfile.class.getName();
+
/**
* Internal constructor.
* @param design
@@ -62,7 +66,10 @@ public class AdaptableDataSourceProfile extends OdaConnectionProfile implements
}
catch( OdaException ex )
{
- // ignore; proceed without having a wrapped profile
+ // log, and proceed without having a wrapped profile
+ Logger.getLogger( sm_className ).warning(
+ Messages.bind( Messages.adaptableDataSourceProfile_unableAccessProfile,
+ design.getLinkedProfileStoreFilePath(), ex.toString() ));
}
if( linkedProfile != null )
setWrappedProfile( linkedProfile ); // cache the profile referenced in the design
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 4acbdf9..4deb4d1 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
@@ -26,6 +26,9 @@ import org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse.
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.datatools.connectivity.oda.profile.ProfileFileExtension;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -41,6 +44,8 @@ import org.eclipse.swt.widgets.Shell;
public class ProfileStoreCreationDialog extends ExportProfilesDialog
implements IBrowseButtonHost
{
+ private static final String EXT_SEPARATOR = ProfileFileExtension.FILE_EXT_SEPARATOR;
+
private CheckboxTableViewer m_profilesViewer;
private ProfileStoreBrowseButton m_browseButton;
private IConnectionProfile m_preSelectProfile;
@@ -223,8 +228,61 @@ public class ProfileStoreCreationDialog extends ExportProfilesDialog
// 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 );
+ String trimmedPath = profileStorePath.trim();
+ m_isProfileStorePathRelative = ! new File( trimmedPath ).isAbsolute();
+ String resolvedProfilePath = DesignUtil.resolveToApplResourcePath( trimmedPath, m_resourceIdentifiers );
+ return resolvedProfilePath != null && ! resolvedProfilePath.equals( trimmedPath ) ?
+ resolvedProfilePath : // got resolved to absolute value
+ profileStorePath; // unable to resolve profileStorePath, return original file path text
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.internal.ui.wizards.ExportProfilesDialog#validateFilePath()
+ */
+ protected boolean validateFilePath()
+ {
+ if( ! super.validateFilePath() )
+ return false;
+
+ // Overrides to further validate the file extension, if a default extension is defined
+ String defaultExtension = ProfileFileExtension.getDefault();
+ if( ! ProfileFileExtension.exists( defaultExtension ) )
+ return true; // no default file extension is defined, no need to validate further
+
+ File file = new File( getFilePathText() );
+ String fileName = file.getName();
+
+ int lastIndex = fileName.lastIndexOf( EXT_SEPARATOR );
+ if( lastIndex >= 0 && fileName.length() > lastIndex+1 ) // file has file extension
+ return true;
+
+ // raise error dialog about missing file extension in the file name
+ String[] dialogLabels = new String[] {
+ IDialogConstants.OK_LABEL,
+ IDialogConstants.CANCEL_LABEL };
+ MessageDialog dialog = new MessageDialog( getShell(),
+ Messages.ui_errorLabel,
+ null,
+ Messages.bind( Messages.profileStoreCreationDialog_fileext_error, defaultExtension ),
+ MessageDialog.ERROR,
+ dialogLabels,
+ 0);
+
+ int response = dialog.open();
+ if( response != 0 ) // user presses Cancel
+ return false;
+
+ // user presses Ok,
+ // append the default extension to the user-input file path
+ String userFilePathText = super.getFilePathText();
+ StringBuilder revisedFilePathText = new StringBuilder( userFilePathText );
+ if( ! userFilePathText.endsWith( EXT_SEPARATOR ) )
+ revisedFilePathText.append( EXT_SEPARATOR );
+ revisedFilePathText.append( defaultExtension );
+
+ super.setFilePathText( revisedFilePathText.toString() );
+ return false; // requires user to verify the filePath and press Ok to continue
}
/*
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
index 352be6e..95c0138 100644
--- 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
@@ -258,12 +258,32 @@ public class MenuButton extends Composite
if ( listeners == null )
return;
- e.widget = MenuButton.this;
-
- for ( int i = 0; i < listeners.size( ); i++ )
- {
- ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
- }
+ // separate the mouse click from the key press event on the button
+ boolean keyPress = false;
+ if( e.widget instanceof Button )
+ {
+ if( ((Button)e.widget).getParent() instanceof MenuButton )
+ {
+ if ( menu != null )
+ {
+ keyPress = true;
+ Rectangle size = button.getBounds( );
+ menu.setLocation( button.toDisplay( new Point( 0,
+ size.height - 1 ) ) );
+ menu.setVisible( true );
+ }
+ }
+ }
+
+ if( !keyPress )
+ {
+ e.widget = MenuButton.this;
+
+ for ( int i = 0; i < listeners.size( ); i++ )
+ {
+ ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
+ }
+ }
}
} );
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
index ec0f672..3893348 100644
--- 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
@@ -17,6 +17,7 @@ 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.datatools.connectivity.oda.profile.ProfileFileExtension;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
@@ -34,8 +35,11 @@ public class MenuButtonProvider implements IMenuButtonProvider
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 static final String RELATIVE_PATH_TYPE = "RelativePath"; //$NON-NLS-1$
+ private static final String ABSOLUTE_PATH_TYPE = "AbsolutePath"; //$NON-NLS-1$
+ private static final String EXT_SEPARATOR = ProfileFileExtension.FILE_EXT_SEPARATOR;
+ private static final String FILE_DIALOG_FILTER_PREFIX = "*"; //$NON-NLS-1$
+ private static final String FILE_DIALOG_FILTER_ALLOW_ALL = FILE_DIALOG_FILTER_PREFIX + ProfilePathSelectionDialog.FILTER_ALLOW_ALL;
private ProfileStoreBrowseButton button;
private String[] optionTypes;
@@ -83,8 +87,11 @@ public class MenuButtonProvider implements IMenuButtonProvider
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 );
+ String defaultExtension = ProfileFileExtension.getDefault();
+
+ String[] fileNames = null;
if ( isRelative )
{
if ( value != null && value instanceof File &&
@@ -94,7 +101,8 @@ public class MenuButtonProvider implements IMenuButtonProvider
.getShell( ),
(File) value,
((Boolean) cpvalue).booleanValue(),
- (String)spvalue);
+ (String)spvalue,
+ defaultExtension );
if ( dialog.open( ) == Window.OK )
{
fileNames = dialog.getSelectedItems( );
@@ -111,10 +119,25 @@ public class MenuButtonProvider implements IMenuButtonProvider
else
{
FileDialog dialog = new FileDialog( button.getControl( ).getShell( ) );
+ if( ProfileFileExtension.exists( defaultExtension ) )
+ {
+ String[] filterExt = new String[2];
+ filterExt[0] = FILE_DIALOG_FILTER_PREFIX + EXT_SEPARATOR + defaultExtension;
+ filterExt[1] = FILE_DIALOG_FILTER_ALLOW_ALL;
+ dialog.setFilterExtensions(filterExt);
+ }
if( spvalue instanceof String )
dialog.setFileName( (String)spvalue );
fileNames = new String[1];
fileNames[0] = dialog.open();
+
+ // If a file does not have an extension provided by the user,
+ // apply the default extension
+ String fileExtension = fileNames[0];
+ if( fileExtension != null && fileExtension.trim().length() > 0 &&
+ ! fileExtension.contains( EXT_SEPARATOR ) &&
+ ProfileFileExtension.exists( defaultExtension ) )
+ fileNames[0] = fileExtension.trim() + EXT_SEPARATOR + defaultExtension;
}
if ( fileNames != null && fileNames[0] != null)
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
index fd32c2b..1f4a95e 100644
--- 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
@@ -26,12 +26,16 @@ 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.datatools.connectivity.oda.profile.ProfileFileExtension;
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.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
@@ -60,6 +64,9 @@ 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;
+ static final String FILTER_ALLOW_ALL = ".*"; //$NON-NLS-1$
+
+ private static final String EXT_SEPERATOR = ProfileFileExtension.FILE_EXT_SEPARATOR;
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private final static Image IMG_FOLDER = PlatformUI.getWorkbench( )
@@ -72,11 +79,15 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
private File topDir;
private boolean isProfileStoreCreation = false;
+ private Text txtFilter;
private Text txtFile;
private String txtFileContent = null;
- String storedPath = null;
+ private String storedPath = null;
+ private String defaultExtension;
+ private TreeViewerFilter treeViewerFilter = new TreeViewerFilter();
- public ProfilePathSelectionDialog( Shell parent, File topDir, boolean isProfileCreation, String storedPath )
+ public ProfilePathSelectionDialog( Shell parent, File topDir, boolean isProfileCreation,
+ String storedPath, String defaultExtension )
{
super( parent, new LabelProvider( ), new ContentProvider( isProfileCreation ) );
@@ -91,6 +102,7 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
else
this.setTitle( TITLE );
this.storedPath = storedPath;
+ this.defaultExtension = defaultExtension;
}
/* (non-Javadoc)
@@ -99,41 +111,24 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
@Override
protected Control createDialogArea( Composite parent )
{
+ createFilterControl(parent);
+
+ if( ProfileFileExtension.exists( defaultExtension ) )
+ txtFilter.setText(EXT_SEPERATOR + defaultExtension);
+
+ txtFilter.addModifyListener( new ModifyListener( ) {
+
+ public void modifyText(ModifyEvent arg0)
+ {
+ getTreeViewer().refresh();
+ }
+ } );
+
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);
- }
+ createFileControl(parent);
}
if( storedPath != null && storedPath.trim().length() > 0 )
@@ -146,7 +141,7 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
txtFile.setText(newFileName);
}
int level = 1;
- File parentFile = f.getParentFile();
+ File parentFile = (f != null) ? f.getParentFile() : null;
while( parentFile != null &&
!parentFile.getAbsolutePath().equals( topDir.getAbsolutePath() ) )
{
@@ -164,8 +159,88 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
else
getTreeViewer( ).expandToLevel(2);
+ getTreeViewer().addFilter( treeViewerFilter );
return c;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.SelectionDialog#createMessageArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Label createMessageArea( Composite composite )
+ {
+ // A message area is not required, therefore do not create the empty message label
+ return null;
+ }
+
+ private void createFilterControl(Composite parent)
+ {
+ Composite compositeFilter = new Composite( parent, SWT.NONE );
+ {
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 3;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.minimumWidth = 360;
+ gridData.horizontalIndent = 10;
+ compositeFilter.setLayoutData( gridData );
+ FormLayout layout = new FormLayout( );
+ compositeFilter.setLayout( layout );
+ }
+
+ final Label filterLabel = new Label(compositeFilter, SWT.NONE);
+ filterLabel.setText(Messages.profilePage_button_browse_filter);
+ {
+ FormData data = new FormData( );
+ data.top = new FormAttachment( 0, 18 );
+ data.left = new FormAttachment( 0, 5 );
+ filterLabel.setLayoutData( data );
+ }
+ filterLabel.setToolTipText(Messages.profilePage_button_browse_filter_tooltiptext);
+
+ txtFilter = new Text(compositeFilter, SWT.BORDER);
+ {
+ FormData data = new FormData( );
+ data.top = new FormAttachment( 0, 15 );
+ data.left = new FormAttachment( filterLabel, 5, 5 );
+ data.right = new FormAttachment( 100, -10 );
+ txtFilter.setLayoutData(data);
+ }
+ txtFilter.setToolTipText(Messages.profilePage_button_browse_filter_tooltiptext);
+ }
+
+ private void createFileControl(Composite parent)
+ {
+ 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 fileLabel = new Label(composite, SWT.NONE);
+ fileLabel.setText(ConnectivityUIPlugin.getDefault().getResourceString(
+ "ExportProfilesDialog.label.text")); //$NON-NLS-1$
+ {
+ FormData data = new FormData( );
+ data.top = new FormAttachment( 0, 8 );
+ data.left = new FormAttachment( 0, 5 );
+ fileLabel.setLayoutData( data );
+ }
+
+ txtFile = new Text(composite, SWT.BORDER);
+ {
+ FormData data = new FormData( );
+ data.top = new FormAttachment( 0, 5 );
+ data.left = new FormAttachment( fileLabel, 5, 5 );
+ data.right = new FormAttachment( 100, -10 );
+ txtFile.setLayoutData(data);
+ }
+ }
protected void okPressed()
{
@@ -207,11 +282,8 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
public boolean hasChildren( Object arg )
{
- if ( arg instanceof File )
- {
- return ProfilePathSelectionDialog.getChildren( (File)arg, isProfileCreation ).length > 0;
- }
- return false;
+ Object[] children = getChildren( arg );
+ return children != null ? children.length > 0 : false;
}
public Object[] getElements( Object arg )
@@ -336,8 +408,8 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
{
public boolean accept( File child )
{
- //A profile store does not have an associated extension therefore
- //show all files and folders.
+ //Return true so that the content provider provides all files
+ //Files are filtered out based on the ViewerFilter
return true;
}
});
@@ -358,13 +430,18 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
if ( isProfileStoreCreation )
{
String path = EMPTY_STRING;
- if( !f.getName().equals(txtFileContent) )
+
+ //If a file does not have an extension provided by the user
+ //apply the default extension.
+ if( txtFileContent != null && txtFileContent.length() > 0 &&
+ ! txtFileContent.contains(EXT_SEPERATOR) &&
+ ProfileFileExtension.exists( defaultExtension ) )
+ txtFileContent += EXT_SEPERATOR + defaultExtension;
+
+ if( f.isFile( ) )
path = f.getParentFile().toURI().toString() + txtFileContent;
else
- path = f.toURI( ).toString();
-
- if( !f.isFile( ) )
- path = f.toURI( ).toString() + txtFileContent;
+ path = f.toURI( ).toString() + txtFileContent;
URI filePath = URI.create(path);
URI relative = topDir.toURI( ).relativize( filePath );
result.add( relative.getPath( ) );
@@ -378,7 +455,12 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
return result.toArray( new String[0] );
}
- public static class FileComparator implements Comparator<File>, Serializable
+ /**
+ * Helps compare two files so that directories are all displayed before
+ * the files. In addition the files and directories are sorted
+ * in their groups.
+ */
+ private static class FileComparator implements Comparator<File>, Serializable
{
private static final long serialVersionUID = 1L;
@@ -403,5 +485,75 @@ public class ProfilePathSelectionDialog extends ElementTreeSelectionDialog
}
}
}
+
+ /**
+ * A TreeViewer Filter class that decides which files should be visible in the
+ * tree viewer.
+ * It gets the filter to use from the ProfilePathSelectionDialog's txtFilter
+ * Text control.
+ */
+ private class TreeViewerFilter extends ViewerFilter
+ {
+ private static final String FILTER_SEPARATOR = ","; //$NON-NLS-1$
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public boolean select(Viewer arg0, Object arg1, Object arg2)
+ {
+ if( arg2 instanceof File )
+ {
+ File file = ((File)arg2);
+ if( file.isDirectory() ) //Don't filter out any directories
+ return true;
+ else
+ {
+ String txtFilterContent = txtFilter.getText();
+ if( txtFilterContent.contains(FILTER_SEPARATOR)) //list of filters separated
+ {
+ String[] filters = txtFilterContent.split(FILTER_SEPARATOR);
+ for( String filter : filters )
+ {
+ if( showFile(file, filter) )
+ return true;
+ }
+ }
+ else //single filter
+ {
+ return showFile(file, txtFilterContent);
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Decides whether the file should be displayed in the TreeViewer or not based on the filter
+ * @param file
+ * @param filter
+ * @return true if file should be shown false if it should be hidden
+ */
+ private boolean showFile( File file, String filter )
+ {
+ if( !filter.contains( EXT_SEPERATOR ) ) //Not valid filter format, so don't filter anything
+ return true;
+
+ filter = filter.trim();
+ if( filter.endsWith( FILTER_ALLOW_ALL ) ) //Allow everything
+ return true;
+
+ String filterExt = filter.substring( filter.lastIndexOf(EXT_SEPERATOR)+1 );
+
+ String fileName = file.getName();
+ if( fileName.contains( EXT_SEPERATOR ) )
+ {
+ String fileExt = fileName.substring( fileName.lastIndexOf(EXT_SEPERATOR)+1 );
+ if( fileExt.equals( filterExt ) )
+ return true;
+ }
+ return false;
+ }
+ }
}
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
index 68e9356..946d0f1 100644
--- 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
@@ -45,14 +45,13 @@ public class ProfileStoreBrowseButton
public void widgetSelected( SelectionEvent e )
{
Widget widget = e.widget;
+ host.browseSelected();
if ( widget instanceof MenuItem )
{
- host.browseSelected();
provider.handleSelectionEvent( (String) widget.getData( ) );
}
- if ( widget instanceof MenuButton )
+ else if ( widget instanceof MenuButton )
{
- host.browseSelected();
provider.handleSelectionEvent( ( (MenuButtonProvider) provider ).getDefaultOptionType( ) );
}
}
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 ce6e053..cac04c7 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
@@ -30,6 +30,7 @@ public class Messages extends NLS
NLS.initializeMessages( BUNDLE_NAME, Messages.class );
}
+ public static String adaptableDataSourceProfile_unableAccessProfile;
public static String common_notInDesignSession;
public static String common_nullArgument;
public static String common_missingDataSourceDesign;
@@ -46,6 +47,8 @@ public class Messages extends NLS
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_browse_filter;
+ public static String profilePage_button_browse_filter_tooltiptext;
public static String profilePage_button_relativepath;
public static String profilePage_button_absolutepath;
public static String profilePage_button_new;
@@ -89,5 +92,6 @@ public class Messages extends NLS
public static String profileStoreCreationDialog_title;
public static String profileStoreCreationDialog_grouptext;
public static String profileStoreCreationDialog_newbutton_tooltiptext;
+ public static String profileStoreCreationDialog_fileext_error;
public static String preferencesPage_openDataAccessDescription;
}
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 2edecf1..b148832 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
@@ -11,6 +11,7 @@
#
#************************************************************************
#
+adaptableDataSourceProfile_unableAccessProfile=Unable to access the linked profile in ({0}); using the local properties in the data source design instead.\n Caused by exception: {1}
common_notInDesignSession=Not currently in a design session.
common_nullArgument=Argument must not be null.
common_missingDataSourceDesign=Missing data source design in OdaDesignSession argument.
@@ -46,8 +47,10 @@ 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_relativepath=&Relative Path
+profilePage_button_absolutepath=&Absolute Path
+profilePage_button_browse_filter=File &extension(s) to display:
+profilePage_button_browse_filter_tooltiptext=Specify one or more comma-separated file extensions to filter the files displayed below.\nFor example: .txt, .profiles
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!
@@ -65,6 +68,7 @@ profileStoreCreationDialog_button_new=Ne&w...
profileStoreCreationDialog_title=Create a Connection Profile Store
profileStoreCreationDialog_grouptext=Select the connection &profiles to be included in the store:
profileStoreCreationDialog_newbutton_tooltiptext=Create a new connection profile
+profileStoreCreationDialog_fileext_error=A connection profile store file must have a file extension.\nPress OK to add the default file extension ".{0}" to the file name.
dbProfilePage_defaultPageMessage=Verify the JDBC Driver and Connection Details
dbProfilePage_editPageMessage=Edit the JDBC Driver and Connection Details
dbProfilePage_invalidDataSource=Invalid data source. Update the connection profile reference, or create a new data source instead.
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/build.properties b/plugins/org.eclipse.datatools.connectivity.oda.profile/build.properties
index a8651db..0debb23 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.profile/build.properties
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/build.properties
@@ -4,7 +4,8 @@ bin.includes = plugin.xml,\
plugin.properties,\
.,\
about.html,\
- META-INF/
+ META-INF/,\
+ schema/
javac.source = 1.5
javac.target = 1.5
javadoc.dir = doc/api/
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.properties b/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.properties
index e25c460..f0f72fb 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.properties
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2006 Actuate Corporation.
+# Copyright (c) 2005, 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,3 +14,4 @@
#
plugin.name=DTP ODA Connection Profile Framework Plug-in
+extension-point.name.profileStore = ODA Connection Profiles Store
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.xml b/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.xml
index 838ffb0..d097a68 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.xml
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/plugin.xml
@@ -3,7 +3,7 @@
<!--
/**
*************************************************************************
- * Copyright (c) 2005, 2007 Actuate Corporation.
+ * Copyright (c) 2005, 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
@@ -19,6 +19,8 @@
-->
<plugin>
+ <extension-point id="profileStore" name="%extension-point.name.profileStore" schema="schema/profileStore.exsd"/>
+
<extension
point="org.eclipse.datatools.connectivity.oda.consumer.propertyProvider">
<dataSourcePropertyService
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/schema/profileStore.exsd b/plugins/org.eclipse.datatools.connectivity.oda.profile/schema/profileStore.exsd
new file mode 100644
index 0000000..b9f9d52
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/schema/profileStore.exsd
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.datatools.connectivity.oda.profile" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.datatools.connectivity.oda.profile" id="profileStore" name="ODA Connection Profiles Store"/>
+ </appInfo>
+ <documentation>
+ The profileStore extension point allows a client to define a default file extension for any connection profiles store that has no file extension. If no extensions of this extension point are registered, an user may specify a profile stores file with no extension. If multiple default fileExtension elements are registered, only one will be applied. Adopters should ensure that its client application installs only one extension of this extension point.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="fileExtension"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="fileExtension">
+ <annotation>
+ <documentation>
+ Defines the file extension to be associated with a connection profile store.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="default" type="string" use="required">
+ <annotation>
+ <documentation>
+ Defines the default file extension to be automatically associated with a connection profile store that has no user-defined file extension.
+This attribute value may include an optional dot before the file extension (e.g. &quot;profiles&quot; or &quot;.profiles&quot;).
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.2.7 (DTP 1.9.2)
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;code&gt;&lt;pre&gt;
+ &lt;extension
+ point=&quot;org.eclipse.datatools.connectivity.oda.profile.profileStore&quot;&gt;
+ &lt;fileExtension
+ default=&quot;profiles&quot;&gt;
+ &lt;/fileExtension&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;&lt;/code&gt;
+
+This extension example specifies the default file extension &quot;profiles&quot; to be automatically associated with a connection profile store that has no user-defined file extension.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ No API implementation is applicable.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ N/A
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ 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.
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/ProfileFileExtension.java b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/ProfileFileExtension.java
new file mode 100644
index 0000000..11a3a0a
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/ProfileFileExtension.java
@@ -0,0 +1,127 @@
+/*
+ *************************************************************************
+ * 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.profile;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.datatools.connectivity.oda.profile.nls.Messages;
+
+/**
+ * Provides helper methods for loading and processing extensions that implement
+ * the org.eclipse.datatools.connectivity.oda.profile.profileStore of extension point.
+ * @since 3.2.7 (DTP 1.9.2)
+ */
+public class ProfileFileExtension
+{
+ public static final String FILE_EXT_SEPARATOR = "."; //$NON-NLS-1$
+
+ private static final String PROFILE_STORE_EXT_POINT = "org.eclipse.datatools.connectivity.oda.profile.profileStore"; //$NON-NLS-1$
+ private static final String FILE_EXT_ELEMENT = "fileExtension"; //$NON-NLS-1$
+ private static final String DEFAULT_ATTRIBUTE = "default"; //$NON-NLS-1$
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ private static String sm_defaultFileExtension;
+ // logging variables
+ private static final String sm_className = ProfileFileExtension.class.getName();
+
+ /**
+ * Returns the default file extension specified in an extension.
+ * The first extension found will be applied.
+ * @return the default file extension; or null if no valid extension exists
+ */
+ public static String getDefault()
+ {
+ if( sm_defaultFileExtension == null )
+ {
+ synchronized( ProfileFileExtension.class )
+ {
+ if( sm_defaultFileExtension == null )
+ sm_defaultFileExtension = loadDefaultFileExtension();
+ }
+ }
+ return sm_defaultFileExtension;
+ }
+
+ /**
+ * Convenience method to indicate whether the specified defaultFileExtension exists
+ * and can be applied to a profile store file.
+ * @param defaultFileExtension a default file extension, normally returned by {@link #getDefault()}
+ * @return true if the specified defaultFileExtension can be applied to a profile store file;
+ * false otherwise
+ */
+ public static boolean exists( String defaultFileExtension )
+ {
+ return defaultFileExtension != null && defaultFileExtension.trim().length() > 0;
+ }
+
+ private static String loadDefaultFileExtension()
+ {
+ IExtensionRegistry extReg = Platform.getExtensionRegistry( );
+ IExtensionPoint extPoint = extReg.getExtensionPoint( PROFILE_STORE_EXT_POINT );
+ if ( extPoint == null )
+ return EMPTY_STRING;
+
+ IExtension[] extensions = extPoint.getExtensions( );
+ if( extensions.length < 1 )
+ return EMPTY_STRING; // no extension is found in registry
+
+ if( extensions.length > 1 )
+ {
+ // log that multiple extensions are found, but only one will get used
+ String warningMsg = Messages.bind( Messages.profileFileExtension_MULTIPLE_EXTENSIONS_FOUND,
+ PROFILE_STORE_EXT_POINT );
+ Logger.getLogger( sm_className ).warning( warningMsg );
+ }
+
+ for( int i = 0; i < extensions.length; i++ )
+ {
+ IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+ if( configElements.length < 1 )
+ continue; // skip this extension with no configuration element
+
+ for ( int j = 0; j < configElements.length; j++ )
+ {
+ IConfigurationElement configElement = configElements[j];
+ if( ! configElement.getName().equals( FILE_EXT_ELEMENT ) )
+ continue; // skip
+
+ String defaultFileExt = configElement.getAttribute( DEFAULT_ATTRIBUTE );
+ if ( defaultFileExt != null )
+ {
+ defaultFileExt = defaultFileExt.trim();
+ // strips out any leading file extension separator
+ if( defaultFileExt.startsWith( FILE_EXT_SEPARATOR ) )
+ defaultFileExt = defaultFileExt.substring( FILE_EXT_SEPARATOR.length() );
+
+ if( defaultFileExt.length() > 0 )
+ {
+ Logger.getLogger( sm_className ).info(
+ Messages.bind( Messages.profileFileExtension_APPLIED_DEFAULT_FILE_EXT,
+ new Object[]{ defaultFileExt, PROFILE_STORE_EXT_POINT,
+ extensions[i].getContributor().getName()} ));
+ return defaultFileExt; // accepts the first valid extension element
+ }
+ }
+ }
+ }
+ return EMPTY_STRING;
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/Messages.java b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/Messages.java
index 45de22c..0cb47b4 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/Messages.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/Messages.java
@@ -31,6 +31,8 @@ public class Messages extends NLS
}
public static String constants_componentName;
+ public static String profileFileExtension_APPLIED_DEFAULT_FILE_EXT;
+ public static String profileFileExtension_MULTIPLE_EXTENSIONS_FOUND;
public static String propertyProvider_CANNOT_FIND_PROFILE;
public static String propertyProvider_UNABLE_TO_RESOLVE_PATH;
}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/messages.properties b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/messages.properties
index 96bee47..c108cdb 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/messages.properties
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/nls/messages.properties
@@ -12,5 +12,7 @@
#************************************************************************
#
constants_componentName=DTP Open Data Access
+profileFileExtension_APPLIED_DEFAULT_FILE_EXT=Applied the default file extension ({0}) contributed by the {1} extension in {2}.
+profileFileExtension_MULTIPLE_EXTENSIONS_FOUND=Multiple extensions of the {0} extension point are found. Only one of them will be applied.
propertyProvider_CANNOT_FIND_PROFILE=Unable to find or access the named profile ({0}) in profile store path ({1}).
propertyProvider_UNABLE_TO_RESOLVE_PATH=The ResourceIdentifiers ({0}) provided in the appContext was unable to resolve the connection profile store file's relative path ((1}).
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 a0e6110..5698ae4 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
@@ -8,7 +8,7 @@
*
* Contributors:
* shongxum - initial API and implementation
- * Actuate Corporation - refactored to improve extensibility
+ * Actuate Corporation - refactored to improve extendability
******************************************************************************/
package org.eclipse.datatools.connectivity.internal.ui.wizards;
@@ -345,13 +345,8 @@ public class ExportProfilesDialog extends TrayDialog implements IContextProvider
return;
}
- if (getFilePathText().length() == 0) {
- MessageDialog.openError(getShell(), ConnectivityUIPlugin
- .getDefault().getResourceString("dialog.title.error"), //$NON-NLS-1$
- ConnectivityUIPlugin.getDefault().getResourceString(
- "actions.export.nofile")); //$NON-NLS-1$
- return;
- }
+ if ( !validateFilePath() )
+ return;
for (int i = 0; i < elements.length; i++) {
vec.add(elements[i]);
@@ -399,6 +394,22 @@ public class ExportProfilesDialog extends TrayDialog implements IContextProvider
txtFile.setText( localizedText );
}
+ /*
+ * @since DTP 1.9.2
+ */
+ protected boolean validateFilePath()
+ {
+ if ( getFilePathText().trim().length() == 0 )
+ {
+ MessageDialog.openError(getShell(), ConnectivityUIPlugin
+ .getDefault().getResourceString("dialog.title.error"), //$NON-NLS-1$
+ ConnectivityUIPlugin.getDefault().getResourceString(
+ "actions.export.nofile")); //$NON-NLS-1$
+ return false;
+ }
+ return true;
+ }
+
public IContext getContext(Object target) {
return contextProviderDelegate.getContext(target);
}