aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeyhan@eclipsesource.com2012-03-16 13:28:51 (EDT)
committerbeyhan@eclipsesource.com2012-03-16 13:28:51 (EDT)
commit89128523ae2be34157c8852ed49157ce71be9107 (patch)
tree130657a12802c215bd32822d5f92a5a5c572e494
parentf1c52854afcd4e34029e94a138901e4d42fc3b2e (diff)
downloadorg.eclipse.rtp-89128523ae2be34157c8852ed49157ce71be9107.zip
org.eclipse.rtp-89128523ae2be34157c8852ed49157ce71be9107.tar.gz
org.eclipse.rtp-89128523ae2be34157c8852ed49157ce71be9107.tar.bz2
364706: [Configurator][UI] Provide a configurator UI
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364706 * Entered URI is validated * small fixes in the filter algorithm
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTabContentUtil.java10
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiHeader.java33
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UIEntryPoint.java2
3 files changed, 39 insertions, 6 deletions
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTabContentUtil.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTabContentUtil.java
index 0941645..d6d9420 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTabContentUtil.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTabContentUtil.java
@@ -22,7 +22,7 @@ public class ComponentsTabContentUtil {
{
put( comboLabels[ 0 ], "/rt/list" );
put( comboLabels[ 1 ], "/rt/list/installed" );
- put( comboLabels[ 2 ], "/rt/list/uninstaller" );
+ put( comboLabels[ 2 ], "/rt/list/uninstalled" );
}
};
@@ -46,7 +46,11 @@ public class ComponentsTabContentUtil {
boolean result = false;
for( int i = 0; i < installedSources.size() && result == false; i++ ) {
Source source = installedSources.get( i );
- result = source.getVersions().contains( sourceVersion );
+ // TODO Fix me. This is a hack!
+ List<SourceVersion> versions = source.getVersions();
+ for( int j = 0; j < versions.size() && result == false; j++ ) {
+ result = versions.get( j ).toString().equals( sourceVersion.toString() );
+ }
}
return result;
}
@@ -69,7 +73,7 @@ public class ComponentsTabContentUtil {
public void refresh( String componentsFilter ) {
restTemplate = new RestTemplate( configurationURI );
sources = restTemplate.getForEntitiesAsList( listMapping.get( componentsFilter ), Source.class );
- installedSources = restTemplate.getForEntitiesAsList( listMapping.get( componentsFilter ),
+ installedSources = restTemplate.getForEntitiesAsList( listMapping.get( comboLabels[ 1 ] ),
Source.class );
}
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiHeader.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiHeader.java
index b44a571..9827f57 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiHeader.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiHeader.java
@@ -9,9 +9,12 @@ package org.eclipse.rtp.configurator.ui;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.rtp.configurator.rest.IEventService;
+import org.eclipse.rtp.configurator.rest.RestTemplate;
import org.eclipse.rtp.configurator.ui.internal.event.ConfigurationEvent;
import org.eclipse.rtp.configurator.ui.internal.event.EventingServiceUtil;
+import org.eclipse.rtp.core.model.Source;
import org.eclipse.rwt.RWT;
+import org.eclipse.rwt.widgets.DialogUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -21,6 +24,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
/**
@@ -77,14 +81,39 @@ public class ConfiguratorUiHeader {
@Override
protected void okPressed() {
super.okPressed();
- configurationUriLabel.setText( getValue() );
- fireConfigurationChagned( getValue() );
+ if( isValidLocation( getValue() ) ) {
+ configurationUriLabel.setText( getValue() );
+ fireConfigurationChagned( getValue() );
+ } else {
+ showWarningDialog();
+ }
}
};
inputDialog.setBlockOnOpen( false );
inputDialog.open();
}
+ private boolean isValidLocation( String configurationURI ) {
+ boolean result = false;
+ try {
+ // do a test rest call to test the entered URI.
+ RestTemplate restTemplate = new RestTemplate( configurationURI );
+ restTemplate.getForEntitiesAsList( "/rt/list", Source.class );
+ result = true;
+ } catch( Exception e ) {
+ result = false;
+ }
+ return result;
+ }
+
+ private void showWarningDialog() {
+ MessageBox infoDialog = new MessageBox( Display.getDefault().getActiveShell(),
+ SWT.OK | SWT.ICON_WARNING | SWT.APPLICATION_MODAL );
+ infoDialog.setText( "Invalide Location" );
+ infoDialog.setMessage( "No instance found." );
+ DialogUtil.open( infoDialog, null );
+ }
+
private void fireConfigurationChagned( String value ) {
ConfigurationEvent configurationEvent = new ConfigurationEvent( value, RWT.getSessionStore()
.getId() );
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UIEntryPoint.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UIEntryPoint.java
index 70220da..c15e675 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UIEntryPoint.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UIEntryPoint.java
@@ -42,7 +42,7 @@ public class UIEntryPoint implements IEntryPoint {
initShell( shell );
configuratorUiHeader.createHeader( display, shell );
contributions.add( new ComponentsTab() );
- contributions.add( new ProvisioningTab() );
+ // contributions.add( new ProvisioningTab() );
configuratorUiBody.createBody( shell, contributions );
configuratorUiFooter.createFooter( shell );
shell.open();