Skip to content

Commit

Permalink
Merge pull request #548 from tejones/teiiddes-2791
Browse files Browse the repository at this point in the history
teiiddes-2571
  • Loading branch information
blafond committed Apr 5, 2016
2 parents 389b113 + 4a2b3a4 commit db090a1
Show file tree
Hide file tree
Showing 11 changed files with 338 additions and 434 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void createCustomControl(Composite parent) {
spacerLabel.setVisible(false);
GridDataFactory.swtDefaults().grab(false, false).applyTo(spacerLabel);

credentialsComposite = new CredentialsComposite(scrolled, SWT.BORDER);
credentialsComposite = new CredentialsComposite(scrolled, SWT.BORDER, "odata"); //$NON-NLS-1$
gd = new GridData(GridData.FILL_HORIZONTAL);
credentialsComposite.setLayoutData(gd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ui.wizards.ProfileDetailsPropertyPage;
import org.eclipse.datatools.help.ContextProviderDelegate;
Expand Down Expand Up @@ -49,8 +50,10 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
Expand All @@ -68,6 +71,7 @@
import org.teiid.designer.ui.common.ICredentialsCommon.SecurityType;
import org.teiid.designer.ui.common.table.TableViewerBuilder;
import org.teiid.designer.ui.common.util.WidgetFactory;
import org.teiid.designer.ui.common.widget.CredentialsComposite;

public class PropertyPage extends ProfileDetailsPropertyPage implements
IContextProvider, DatatoolsUiConstants {
Expand All @@ -76,16 +80,11 @@ public class PropertyPage extends ProfileDetailsPropertyPage implements
private ContextProviderDelegate contextProviderDelegate = new ContextProviderDelegate(
DatatoolsUiPlugin.getDefault().getBundle().getSymbolicName());
private Composite scrolled;
private Label usernameLabel;
private Text usernameText;
private Label passwordLabel;
private Text passwordText;
private Label urlLabel;
private Text urlText;
private Label urlPreviewLabel;
Text urlPreviewText;
private Text securityText;
private Label securityLabel;
private CredentialsComposite credentialsComposite;
private Map<String, Parameter> parameterMap = new LinkedHashMap<String, Parameter>();
private Label responseTypeLabel;
private Combo responseTypeCombo;
Expand Down Expand Up @@ -154,55 +153,15 @@ protected void createCustomContents( Composite parent ) {
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 1;
urlText.setLayoutData(gd);

Label spacerLabel = new Label(scrolled, SWT.NONE);
spacerLabel.setVisible(false);
GridDataFactory.swtDefaults().grab(false, false).applyTo(spacerLabel);

securityLabel = new Label(scrolled, SWT.NONE);
securityLabel.setText(UTIL.getString("Common.Security.Type.Label")); //$NON-NLS-1$
securityLabel.setToolTipText(UTIL.getString("Common.Security.Type.ToolTip")); //$NON-NLS-1$
gd = new GridData();
gd.verticalAlignment = GridData.CENTER;
securityLabel.setLayoutData(gd);

securityText = new Text(scrolled, SWT.SINGLE | SWT.BORDER);
securityText.setToolTipText(UTIL.getString("Common.Security.Type.ToolTip")); //$NON-NLS-1$
gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.verticalAlignment = GridData.BEGINNING;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 1;
securityText.setLayoutData(gd);

usernameLabel = new Label(scrolled, SWT.NONE);
usernameLabel.setText(UTIL.getString("Common.Username.Label")); //$NON-NLS-1$
usernameLabel.setToolTipText(UTIL.getString("Common.Username.ToolTip")); //$NON-NLS-1$
gd = new GridData();
gd.verticalAlignment = GridData.CENTER;
usernameLabel.setLayoutData(gd);

usernameText = new Text(scrolled, SWT.SINGLE | SWT.BORDER);
usernameText.setToolTipText(UTIL.getString("Common.Username.ToolTip")); //$NON-NLS-1$
gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.verticalAlignment = GridData.BEGINNING;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 1;
usernameText.setLayoutData(gd);

passwordLabel = new Label(scrolled, SWT.NONE);
passwordLabel.setText(UTIL.getString("Common.Password.Label")); //$NON-NLS-1$
passwordLabel.setToolTipText(UTIL.getString("Common.Password.ToolTip")); //$NON-NLS-1$
gd = new GridData();
gd.verticalAlignment = GridData.CENTER;
passwordLabel.setLayoutData(gd);
credentialsComposite = new CredentialsComposite(scrolled, SWT.BORDER, "rest"); //$NON-NLS-1$
gd = new GridData(GridData.FILL_HORIZONTAL);
credentialsComposite.setLayoutData(gd);

passwordText = new Text(scrolled, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
passwordText.setToolTipText(UTIL.getString("Common.Password.ToolTip")); //$NON-NLS-1$
gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.verticalAlignment = GridData.BEGINNING;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 1;
passwordText.setLayoutData(gd);

responseTypeLabel = new Label(scrolled, SWT.NONE);
responseTypeLabel.setText(UTIL.getString("Common.ResponseType.Label")); //$NON-NLS-1$
responseTypeLabel.setToolTipText(UTIL.getString("Common.ResponseType.ToolTip")); //$NON-NLS-1$
Expand Down Expand Up @@ -370,36 +329,19 @@ public boolean performOk() {
*
*/
private void addlisteners() {
usernameText.addModifyListener(new ModifyListener() {

@Override
public void modifyText( ModifyEvent e ) {
validate();
}
});

passwordText.addModifyListener(new ModifyListener() {

@Override
public void modifyText( ModifyEvent e ) {
validate();
}
});

urlText.addModifyListener(new ModifyListener() {

@Override
public void modifyText( ModifyEvent e ) {
validate();
}
});
securityText.addModifyListener(new ModifyListener() {

Listener listener = new Listener() {

@Override
public void modifyText( ModifyEvent e ) {
validate();
}
});
@Override
public void handleEvent(Event event) {
validate();
}
};

urlText.addListener(SWT.Modify, listener);
credentialsComposite.addSecurityOptionListener(SWT.Modify, listener);
credentialsComposite.addUserNameListener(SWT.Modify, listener);
credentialsComposite.addPasswordListener(SWT.Modify, listener);

}

Expand All @@ -413,34 +355,6 @@ protected void validate() {
setValid(valid);
return;
}
//An empty or null security type value is treated the same as "None"
String securityType = securityText.getText();
if (securityType!=null && (!securityType.trim().equals(StringConstants.EMPTY_STRING) &&
!SecurityType.None.name().equals(securityType)) &&
!SecurityType.HTTPBasic.name().equals(securityText.getText())) {
errorMessage = UTIL.getString("Common.Security.Error.Message"); //$NON-NLS-1$
valid = false;
setErrorMessage(errorMessage);
setValid(valid);
return;
}
if (securityType!=null && !securityType.trim().equals(StringConstants.EMPTY_STRING) &&
(!SecurityType.None.name().equals(securityType))) {
if (null == passwordText.getText() || passwordText.getText().isEmpty()) {
errorMessage = UTIL.getString("Common.Password.Error.Message"); //$NON-NLS-1$
valid = false;
setErrorMessage(errorMessage);
setValid(valid);
return;
}
if (null == usernameText.getText() || usernameText.getText().isEmpty()) {
errorMessage = UTIL.getString("Common.Username.Error.Message"); //$NON-NLS-1$
valid = false;
setErrorMessage(errorMessage);
setValid(valid);
return;
}
}
setErrorMessage(errorMessage);
setValid(valid);

Expand All @@ -456,19 +370,25 @@ private void initControls() {
// Check properties and load any existing parameters into parametersMap
loadParameters(props);

if (null != props.get(ICredentialsCommon.USERNAME_PROP_ID)) {
usernameText.setText((String)props.get(ICredentialsCommon.USERNAME_PROP_ID));
String securityType = props.getProperty(ICredentialsCommon.SECURITY_TYPE_ID);
if (null != securityType) {
credentialsComposite.setSecurityOption(securityType);
}
if (null != props.get(ICredentialsCommon.PASSWORD_PROP_ID)) {
passwordText.setText((String)props.get(ICredentialsCommon.PASSWORD_PROP_ID));

String username = props.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
if (null != username) {
credentialsComposite.setUserName(username);
}

String password = props.getProperty(ICredentialsCommon.PASSWORD_PROP_ID);
if (null != password) {
credentialsComposite.setPassword(password);
}

String url = ConnectionInfoHelper.readEndPointProperty(props);
if (null != url) {
urlText.setText(url);
}
if (null != props.get(ICredentialsCommon.SECURITY_TYPE_ID)) {
securityText.setText((String)props.get(ICredentialsCommon.SECURITY_TYPE_ID));
}

if (null != props.get(IWSProfileConstants.RESPONSE_TYPE_PROPERTY_KEY)) {
responseTypeCombo.setText((String)props.get(IWSProfileConstants.RESPONSE_TYPE_PROPERTY_KEY));
Expand Down Expand Up @@ -521,9 +441,13 @@ protected Properties collectProperties() {
result = new Properties();
}
result.setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID, urlText.getText());
result.setProperty(ICredentialsCommon.SECURITY_TYPE_ID, securityText.getText().trim());
result.setProperty(ICredentialsCommon.USERNAME_PROP_ID, usernameText.getText());
result.setProperty(ICredentialsCommon.PASSWORD_PROP_ID, passwordText.getText());
result.setProperty(ICredentialsCommon.SECURITY_TYPE_ID, credentialsComposite.getSecurityOption().name());
if( credentialsComposite.getUserName() != null ) {
result.setProperty(ICredentialsCommon.USERNAME_PROP_ID, credentialsComposite.getUserName());
}
if( credentialsComposite.getPassword() != null) {
result.setProperty(ICredentialsCommon.PASSWORD_PROP_ID, credentialsComposite.getPassword());
}
result.setProperty(IWSProfileConstants.RESPONSE_TYPE_PROPERTY_KEY, responseTypeCombo.getText());

Properties extraProps = getExtraProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package org.teiid.designer.datatools.profiles.ws;

import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
Expand All @@ -26,11 +25,9 @@
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin;
import org.eclipse.datatools.connectivity.internal.ui.dialogs.ExceptionHandler;
import org.eclipse.datatools.connectivity.ui.wizards.ConnectionProfileDetailsPage;
import org.eclipse.datatools.connectivity.ui.wizards.NewConnectionProfileWizard;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionEvent;
Expand All @@ -51,15 +48,13 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.progress.UIJob;
import org.teiid.core.designer.util.StringConstants;
import org.teiid.core.designer.util.StringUtilities;
import org.teiid.datatools.connectivity.model.Parameter;
import org.teiid.designer.datatools.ui.DatatoolsUiConstants;
import org.teiid.designer.datatools.ui.dialogs.ScrolledConnectionProfileDetailsPage;
import org.teiid.designer.ui.common.ICredentialsCommon;
import org.teiid.designer.ui.common.ICredentialsCommon.SecurityType;
import org.teiid.designer.ui.common.util.WidgetFactory;
import org.teiid.designer.ui.common.widget.CredentialsComposite;
import org.teiid.designer.ui.common.widget.DefaultScrolledComposite;

public class WSProfileDetailsWizardPage extends ScrolledConnectionProfileDetailsPage implements DatatoolsUiConstants {

Expand Down Expand Up @@ -173,7 +168,7 @@ public void widgetDefaultSelected(SelectionEvent e) {

responseTypeCombo.setVisibleItemCount(2);

credentialsComposite = new CredentialsComposite(scrolled, SWT.BORDER);
credentialsComposite = new CredentialsComposite(scrolled, SWT.BORDER, "rest"); //$NON-NLS-1$
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
credentialsComposite.setLayoutData(gd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected void createCustomContents(Composite parent) {
spacerLabel.setVisible(false);
GridDataFactory.swtDefaults().grab(false, false).applyTo(spacerLabel);

credentialsComposite = new CredentialsComposite(scrolled, SWT.BORDER);
credentialsComposite = new CredentialsComposite(scrolled, SWT.BORDER, "soap"); //$NON-NLS-1$
gd = new GridData(GridData.FILL_HORIZONTAL);
credentialsComposite.setLayoutData(gd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void addSecurityProperties(Properties source, Properties target, boolean
String securityTypeId = source.getProperty(ICredentialsCommon.SECURITY_TYPE_ID);
SecurityType securityType = SecurityType.retrieveValue(securityTypeId);
switch (securityType) {
case HTTPBasic:
case HTTPBasic: case HTTPDigest:
String username = source.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
if (username == null) {
username = source.getProperty(IWSProfileConstants.DS_AUTH_USER_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ Require-Bundle: org.apache.commons.io;bundle-version="[2.4.0,3.0.0)",
org.eclipse.search;bundle-version="[3.10.0,4.0.0)",
org.teiid.designer.udf;bundle-version="[10.0.0,11.0.0)",
org.teiid.designer.extension;bundle-version="[10.0.0,11.0.0)",
org.teiid.datatools.connectivity;bundle-version="[10.0.0,11.0.0)"
org.teiid.datatools.connectivity;bundle-version="[10.0.0,11.0.0)",
org.apache.commons.httpclient,
org.apache.httpcomponents.httpclient
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.apache.xerces.parsers
Import-Package: org.apache.commons.httpclient.auth;version="3.1.0",
org.apache.commons.httpclient.methods;version="3.1.0",
org.apache.xerces.parsers
Bundle-ClassPath: org.json-20120521.jar,
.

0 comments on commit db090a1

Please sign in to comment.