aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeyhan@eclipsesource.com2012-03-01 12:06:09 (EST)
committerbeyhan@eclipsesource.com2012-03-01 12:06:09 (EST)
commit6f981126a5bc6f54b7048b00f35d9d65cc5c474b (patch)
tree92f653642523f0af1f7c29b80cfd94191fad6c51
parentea312dc320c9801b9a42b086de7f26715f144e39 (diff)
downloadorg.eclipse.rtp-6f981126a5bc6f54b7048b00f35d9d65cc5c474b.zip
org.eclipse.rtp-6f981126a5bc6f54b7048b00f35d9d65cc5c474b.tar.gz
org.eclipse.rtp-6f981126a5bc6f54b7048b00f35d9d65cc5c474b.tar.bz2
364706: [Configurator][UI] Provide a configurator UI
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364706
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/RestTemplate.java8
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/AbstractTabContribution.java2
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTab.java157
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiBody.java18
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiFooter.java18
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiHeader.java102
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ProvisioningTab.java39
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesContentProvider.java10
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesLabelProvider.java37
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UiHelper.java58
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationEvent.java23
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationEvent.java8
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationListener.java6
14 files changed, 344 insertions, 145 deletions
diff --git a/bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF
index c13dd4e..786ef01 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@ Bundle-Vendor: %bundleVendor
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.rap.rwt;bundle-version="[1.5.0,1.6.0)",
- org.eclipse.rap.jface;bundle-version="[1.5.0,1.6.0)"
+ org.eclipse.rap.jface;bundle-version="[1.5.0,1.6.0)",
+ org.eclipse.core.runtime;bundle-version="3.8.0"
Service-Component: OSGI-INF/UIConfigurator.xml
Import-Package: org.apache.commons.httpclient;version="[3.1.0,4.0.0)",
org.apache.commons.httpclient.methods;version="[3.1.0,4.0.0)",
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/RestTemplate.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/RestTemplate.java
index a0b5ce1..08b0f6a 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/RestTemplate.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/RestTemplate.java
@@ -18,10 +18,10 @@ import org.eclipse.rtp.core.model.internal.SourceUnMarshallerImpl;
public class RestTemplate {
SourceUnMarshaller unMarshaller = new SourceUnMarshallerImpl();
- private String urlBase = "http://localhost:8888";
+ private final String urlBase;
- public void setUrlBase( String urlBase ) {
- this.urlBase = urlBase;
+ public RestTemplate( String newIntanceURI ) {
+ this.urlBase = newIntanceURI;
}
@SuppressWarnings( "unchecked" )
@@ -61,7 +61,7 @@ public class RestTemplate {
}
public void delete( String string ) {
- DeleteMethod method = new DeleteMethod( urlBase + string);
+ DeleteMethod method = new DeleteMethod( urlBase + string );
executeMethod( method );
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/AbstractTabContribution.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/AbstractTabContribution.java
index 0c83345..7ec9feb 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/AbstractTabContribution.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/AbstractTabContribution.java
@@ -15,7 +15,7 @@ public abstract class AbstractTabContribution implements TabContribution {
@Override
public Control getControl( Display display, Composite parent ) {
- Composite composite = UiHelper.createGridComposite( parent, 1 );
+ Composite composite = UiHelper.createGridComposite( parent, 1, true );
populateControl( display, composite );
return composite;
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTab.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTab.java
index 7f945ec..5108f3c 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTab.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTab.java
@@ -12,32 +12,38 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.rtp.configurator.rest.RestTemplate;
+import org.eclipse.rtp.configurator.ui.internal.event.IConfigurationEvent;
+import org.eclipse.rtp.configurator.ui.internal.event.IConfigurationListener;
import org.eclipse.rtp.core.model.Source;
+import org.eclipse.rtp.core.model.SourceVersion;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.osgi.framework.Bundle;
public class ComponentsTab extends AbstractTabContribution {
- private SourcesContentProvider contentProvider = new SourcesContentProvider();
- RestTemplate restTemplate = new RestTemplate();
+ private final SourcesContentProvider contentProvider = new SourcesContentProvider();
+ private RestTemplate restTemplate;
protected static String[] comboLabels = new String[]{
"all", "installed", "uninstalled"
};
- private Map<String, String> listMapping = new HashMap<String, String>() {
+ private final Map<String, String> listMapping = new HashMap<String, String>() {
{
put( comboLabels[ 0 ], "/rt/list" );
@@ -50,6 +56,9 @@ public class ComponentsTab extends AbstractTabContribution {
private Button addSource;
private Button removeSource;
private Button updateWorld;
+ private List<Source> sources;
+ private List<Source> installedSources;
+ private Display display;
@Override
public String getTitle() {
@@ -59,10 +68,12 @@ public class ComponentsTab extends AbstractTabContribution {
@Override
@SuppressWarnings( "serial" )
protected void populateControl( Display display, Composite composite ) {
- Composite tab = UiHelper.createGreedyGridComposite( composite, 4 );
- Button refreshButton = UiHelper.createPushButton( tab, "refresh" );
- refreshButton.addSelectionListener( new RefreshButtonSelectionListener( this ) );
- final Text filterText = UiHelper.createText( tab, 1, "Please enter filter" );
+ this.display = display;
+ Composite tab = UiHelper.createGreedyGridComposite( composite, 1, true );
+ Composite tabToolbarComposite = UiHelper.createGridComposite( tab, 5, false );
+ Label searchLabel = new Label( tabToolbarComposite, SWT.NONE );
+ searchLabel.setText( "Search: " );
+ final Text filterText = UiHelper.createText( tabToolbarComposite, 1, "Please enter filter" );
final ComponentsFilter filter = new ComponentsFilter();
filterText.addKeyListener( new KeyAdapter() {
@@ -72,20 +83,20 @@ public class ComponentsTab extends AbstractTabContribution {
viewer.refresh();
}
} );
- UiHelper.createLabel( tab, 1, "Show:" );
- combo = UiHelper.createComboBox( tab, 1, comboLabels );
- combo.addSelectionListener( new SelectionListener() {
+ Label filterLabel = new Label( tabToolbarComposite, SWT.NONE );
+ filterLabel.setText( "Filter: " );
+ combo = UiHelper.createComboBox( tabToolbarComposite, 1, comboLabels );
+ combo.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e ) {
refresh();
}
-
- @Override
- public void widgetDefaultSelected( SelectionEvent e ) {
- }
} );
- viewer = UiHelper.createTreeViewer( tab );
+ Button refreshButton = UiHelper.createPushButton( tabToolbarComposite, "refresh" );
+ refreshButton.addSelectionListener( new RefreshButtonSelectionListener( this ) );
+ Composite treeComposite = UiHelper.createGreedyGridComposite( tab, 1, true );
+ viewer = UiHelper.createTreeViewer( new Composite( treeComposite, SWT.NONE ) );
viewer.addFilter( filter );
ISelectionChangedListener listener = new ISelectionChangedListener() {
@@ -95,23 +106,25 @@ public class ComponentsTab extends AbstractTabContribution {
TreeViewer viewer = ( TreeViewer )eventSource;
ISelection selection = viewer.getSelection();
TreeSelection treeSelection = ( TreeSelection )selection;
- Source source = ( Source )treeSelection.getFirstElement();
- updateButtons( source );
+ Object selectedElement = treeSelection.getFirstElement();
+ updateButtons( selectedElement );
}
};
viewer.addSelectionChangedListener( listener );
viewer.setContentProvider( contentProvider );
- SourcesLabelProvider labelProvider = new SourcesLabelProvider();
+ SourcesLabelProvider labelProvider = new SourcesLabelProvider( this );
labelProvider.init( display );
viewer.setLabelProvider( labelProvider );
viewer.setInput( new ArrayList<Source>() );
- addInstallButton( tab );
- addUninstallButton( tab );
- addUodateWorldButton( tab );
+ Composite provisioningActionsComposite = UiHelper.createGridComposite( tab, 2, false );
+ addInstallButton( provisioningActionsComposite );
+ addUninstallButton( provisioningActionsComposite );
+ addUpdateWorldButton( provisioningActionsComposite );
+ addConfigurationListener();
}
private void addUninstallButton( Composite tab ) {
- removeSource = UiHelper.createPushButton( tab, 2, "remove" );
+ removeSource = UiHelper.createPushButton( tab, 1, "remove" );
removeSource.addSelectionListener( new SelectionAdapter() {
@Override
@@ -121,32 +134,37 @@ public class ComponentsTab extends AbstractTabContribution {
} );
}
- private void addUodateWorldButton( Composite tab ) {
- updateWorld = UiHelper.createPushButton( tab, 4, "updateWorld" );
+ private void addUpdateWorldButton( Composite tab ) {
+ updateWorld = UiHelper.createPushButton( tab, 2, "updateWorld" );
updateWorld.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e ) {
- restTemplate.delete( "/rt/updateworld" );
+ restTemplate.put( "/rt/updateworld" );
}
} );
- refresh();
}
private void addInstallButton( Composite tab ) {
- addSource = UiHelper.createPushButton( tab, 2, "add" );
+ addSource = UiHelper.createPushButton( tab, 1, "add" );
addSource.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e ) {
String uri = "/rt/install" + generateSelectedSourceUri();
- restTemplate.get( uri );
+ restTemplate.put( uri );
}
} );
}
- void updateButtons( Source source ) {
- if( isInstalled( source ) ) {
+ void updateButtons( Object selectedElement ) {
+ SourceVersion sourceVersion;
+ if( selectedElement instanceof Source ) {
+ sourceVersion = ( ( Source )selectedElement ).getVersions().get( 0 );
+ } else {
+ sourceVersion = ( SourceVersion )selectedElement;
+ }
+ if( isInstalled( sourceVersion ) ) {
addSource.setEnabled( false );
removeSource.setEnabled( true );
} else {
@@ -155,25 +173,76 @@ public class ComponentsTab extends AbstractTabContribution {
}
}
- private boolean isInstalled( Source source ) {
- List<Source> installedSources = new RestTemplate().getForEntitiesAsList( listMapping.get( ComponentsTab.comboLabels[ 1 ] ),
- Source.class );
- return installedSources.contains( source );
+ public boolean isInstalled( SourceVersion sourceVersion ) {
+ boolean result = false;
+ for( int i = 0; i < installedSources.size() && result == false; i++ ) {
+ Source source = installedSources.get( i );
+ result = source.getVersions().contains( sourceVersion );
+ }
+ return result;
}
String generateSelectedSourceUri() {
- Source source = ( Source )viewer.getTree().getSelection()[ 0 ].getData();
- String version = source.getVersions().get( 0 ).getVersion();
- String uri = "/" + source.getName() + "/" + version;
+ String version = null;
+ String name = null;
+ Object selectedElement = viewer.getTree().getSelection()[ 0 ].getData();
+ if( selectedElement instanceof Source ) {
+ version = ( ( Source )selectedElement ).getVersions().get( 0 ).getVersion();
+ name = ( ( Source )selectedElement ).getName();
+ } else if( selectedElement instanceof SourceVersion ) {
+ version = ( ( SourceVersion )selectedElement ).getVersion();
+ name = getSourceVersionSource( ( SourceVersion )selectedElement ).getName();
+ }
+ String uri = "/" + name + "/" + version;
return uri;
}
+ private Source getSourceVersionSource( SourceVersion sourceVersion ) {
+ Source result = null;
+ if( sources != null ) {
+ for( Source source : sources ) {
+ List<SourceVersion> versions = source.getVersions();
+ for( SourceVersion version : versions ) {
+ if( version.equals( sourceVersion ) ) {
+ result = source;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ private void addConfigurationListener() {
+ Bundle bundle = Platform.getBundle( "org.eclipse.rtp.configurator.ui" );
+ IConfigurationListener configurationListener = new IConfigurationListener() {
+
+ @Override
+ public void configurationchanged( IConfigurationEvent event ) {
+ restTemplate = new RestTemplate( event.getNewIntanceURI() );
+ refresh();
+ }
+ };
+ bundle.getBundleContext().registerService( IConfigurationListener.class,
+ configurationListener,
+ null );
+ }
+
public void refresh() {
- int selectionIndex = this.combo.getSelectionIndex();
- List<Source> sources = new RestTemplate().getForEntitiesAsList( listMapping.get( ComponentsTab.comboLabels[ selectionIndex ] ),
- Source.class );
- viewer.setInput( sources );
- addSource.setEnabled( false );
- removeSource.setEnabled( false );
+ if( restTemplate != null && !display.isDisposed() ) {
+ display.asyncExec( new Runnable() {
+
+ @Override
+ public void run() {
+ int selectionIndex = combo.getSelectionIndex();
+ sources = restTemplate.getForEntitiesAsList( listMapping.get( ComponentsTab.comboLabels[ selectionIndex ] ),
+ Source.class );
+ installedSources = restTemplate.getForEntitiesAsList( listMapping.get( ComponentsTab.comboLabels[ 1 ] ),
+ Source.class );
+ viewer.setInput( sources );
+ addSource.setEnabled( false );
+ removeSource.setEnabled( false );
+ }
+ } );
+ }
}
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiBody.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiBody.java
index 29a81e7..d522841 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiBody.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiBody.java
@@ -1,12 +1,10 @@
-/*******************************************************************************
-* Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.ui;
import java.util.List;
@@ -21,7 +19,7 @@ import org.eclipse.swt.widgets.TabItem;
public class ConfiguratorUiBody {
public void createBody( Shell shell, List<TabContribution> contributions ) {
- Composite body = UiHelper.createGreedyGridComposite( shell, 1 );
+ Composite body = UiHelper.createGreedyGridComposite( shell, 1, true );
final TabFolder tabFolder = new TabFolder( body, SWT.BORDER );
tabFolder.setLayoutData( UiHelper.createGreedyGridData() );
for( TabContribution contribution : contributions ) {
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiFooter.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiFooter.java
index 06c2eb3..7e4bbf4 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiFooter.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiFooter.java
@@ -1,12 +1,10 @@
-/*******************************************************************************
-* Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.ui;
import org.eclipse.swt.widgets.Composite;
@@ -15,7 +13,7 @@ import org.eclipse.swt.widgets.Shell;
public class ConfiguratorUiFooter {
public void createFooter( Shell shell ) {
- Composite footer = UiHelper.createGridComposite( shell, 1 );
+ Composite footer = UiHelper.createGridComposite( shell, 1, true );
// TODO - Get the RTP version.
UiHelper.createLabel( footer, 1, "RTP Version XZY" );
}
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 81531da..b4c4fca 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
@@ -1,32 +1,106 @@
-/*******************************************************************************
-* Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.ui;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.rtp.configurator.ui.internal.event.ConfigurationEvent;
+import org.eclipse.rtp.configurator.ui.internal.event.IConfigurationListener;
+import org.eclipse.rwt.RWT;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+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.Shell;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
/**
* Constructs the Configurator UI header.
+ *
* @author fluffi
- *
*/
public class ConfiguratorUiHeader {
- public void createHeader( Display display, Shell shell ) {
- Composite header = UiHelper.createGridComposite( shell, 3 );
+ private Label configurationUriLabel;
+ private Composite header;
+
+ public void createHeader( final Display display, Shell shell ) {
+ header = UiHelper.createGridComposite( shell, 5, false );
Image logo = new Image( display, getClass().getResourceAsStream( "/images/rtp-icon.png" ) );
- Label label = UiHelper.createLabel( header, 1, "" );
+ Label label = new Label( header, SWT.CENTER );
label.setImage( logo );
- UiHelper.createLabel( header, 2, new UIBrandingWeb().getTitle() );
+ configurationUriLabel = new Label( header, SWT.NONE );
+ configurationUriLabel.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, false, false ) );
+ Label headerLabel = UiHelper.createLabel( header, 2, new UIBrandingWeb().getTitle() );
+ headerLabel.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, true, false ) );
+ createConfigurationButton( display, header );
+ }
+
+ private void createConfigurationButton( final Display display, Composite header ) {
+ final Button rtpInstanceManagementButton = new Button( header, SWT.NONE );
+ rtpInstanceManagementButton.setText( "manage" );
+ addConfiguratinListener( display, rtpInstanceManagementButton );
+ }
+
+ private void addConfiguratinListener( final Display display,
+ final Button rtpInstanceManagementButton )
+ {
+ rtpInstanceManagementButton.addSelectionListener( new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ final InputDialog inputDialog = new InputDialog( Display.getCurrent().getActiveShell(),
+ "RTP Instance Configuration",
+ "Enter instance URI",
+ "",
+ null )
+ {
+
+ @Override
+ protected void okPressed() {
+ super.okPressed();
+ configurationUriLabel.setText( getValue() );
+ header.layout( true );
+ fireConfigurationChagned( getValue() );
+ }
+
+ private void fireConfigurationChagned( String value ) {
+ try {
+ ConfigurationEvent configurationEvent = new ConfigurationEvent( value,
+ RWT.getSessionStore()
+ .getId() );
+ Bundle bundle = Platform.getBundle( "org.eclipse.rtp.configurator.ui" );
+ Collection<ServiceReference<IConfigurationListener>> serviceReferences = bundle.getBundleContext()
+ .getServiceReferences( IConfigurationListener.class, null );
+ for( ServiceReference<IConfigurationListener> serviceReference : serviceReferences ) {
+ IConfigurationListener service = bundle.getBundleContext()
+ .getService( serviceReference );
+ service.configurationchanged( configurationEvent );
+ bundle.getBundleContext().ungetService( serviceReference );
+ }
+ } catch( InvalidSyntaxException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ };
+ inputDialog.setBlockOnOpen( false );
+ inputDialog.open();
+ }
+ } );
}
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ProvisioningTab.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ProvisioningTab.java
index 28932ee..815aeef 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ProvisioningTab.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ProvisioningTab.java
@@ -1,12 +1,10 @@
-/*******************************************************************************
-* Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.ui;
import org.eclipse.swt.widgets.Composite;
@@ -14,18 +12,15 @@ import org.eclipse.swt.widgets.Display;
public class ProvisioningTab extends AbstractTabContribution {
- @Override
- public String getTitle() {
- return "Provisioning";
- }
-
- @Override
- @SuppressWarnings("serial")
- protected void populateControl(Display display, Composite composite) {
-
- Composite planetTab = UiHelper.createGreedyGridComposite(composite, 1);
-
- UiHelper.createLabel(planetTab, 1, "Provisioning Tab");
- }
+ @Override
+ public String getTitle() {
+ return "Provisioning";
+ }
+ @Override
+ @SuppressWarnings( "serial" )
+ protected void populateControl( Display display, Composite composite ) {
+ Composite planetTab = UiHelper.createGreedyGridComposite( composite, 1, true );
+ UiHelper.createLabel( planetTab, 1, "Provisioning Tab" );
+ }
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesContentProvider.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesContentProvider.java
index 2ac4fc8..25eec23 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesContentProvider.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesContentProvider.java
@@ -37,7 +37,11 @@ class SourcesContentProvider implements ITreeContentProvider {
@Override
public Object[] getChildren( Object parentElement ) {
- return null;
+ Object[] result = null;
+ if( parentElement instanceof Source ) {
+ result = ( ( Source )parentElement ).getVersions().toArray();
+ }
+ return result;
}
@Override
@@ -47,6 +51,6 @@ class SourcesContentProvider implements ITreeContentProvider {
@Override
public boolean hasChildren( Object element ) {
- return false;
+ return getChildren( element ) != null;
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesLabelProvider.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesLabelProvider.java
index 64ddcf8..b6cbbdf 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesLabelProvider.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/SourcesLabelProvider.java
@@ -10,16 +10,19 @@ package org.eclipse.rtp.configurator.ui;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.rtp.core.model.Source;
+import org.eclipse.rtp.core.model.SourceVersion;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
class SourcesLabelProvider implements ITableLabelProvider {
private Image httpSource;
+ private final ComponentsTab componentsTab;
// TODO check supported sources...
// private Image fileSource;
- public SourcesLabelProvider() {
+ public SourcesLabelProvider( ComponentsTab componentsTab ) {
+ this.componentsTab = componentsTab;
}
public void init( Display display ) {
@@ -30,23 +33,33 @@ class SourcesLabelProvider implements ITableLabelProvider {
@Override
public Image getColumnImage( Object element, int columnIndex ) {
- if( columnIndex == 0 ) {
- return httpSource;
+ Image result = null;
+ if( columnIndex == 0 && element instanceof Source ) {
+ result = httpSource;
}
- return null;
+ return result;
}
@Override
public String getColumnText( Object element, int columnIndex ) {
- Source row = ( Source )element;
+ String result = "";
if( columnIndex == 0 ) {
- // source name
- return row.getName();
- } else if (columnIndex == 1) {
- // TODO - support multiple versions
- return row.getVersions().get( 0 ).getVersion();
+ if( element instanceof Source ) {
+ result = ( ( Source )element ).getName();
+ } else if( element instanceof SourceVersion ) {
+ result = ( ( SourceVersion )element ).getVersion();
+ }
+ } else if( columnIndex == 1 && element instanceof SourceVersion ) {
+ result = ( ( SourceVersion )element ).getRepositoryUrl().toString();
+ } else if( columnIndex == 2 && element instanceof SourceVersion ) {
+ boolean installed = componentsTab.isInstalled( ( SourceVersion )element );
+ if( installed ) {
+ result = "installed";
+ } else {
+ result = "uninstalled";
+ }
}
- return null;
+ return result;
}
@Override
@@ -68,4 +81,4 @@ class SourcesLabelProvider implements ITableLabelProvider {
public void removeListener( ILabelProviderListener listener ) {
// No listeners used.
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UiHelper.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UiHelper.java
index 10848c8..d8e6b4f 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UiHelper.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UiHelper.java
@@ -1,16 +1,15 @@
-/*******************************************************************************
-* Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.ui;
+import org.eclipse.jface.layout.TreeColumnLayout;
+import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -55,7 +54,10 @@ public class UiHelper {
return label;
}
- public static TreeViewer createTreeViewer(Composite tab) {
+ public static TreeViewer createTreeViewer( Composite tab ) {
+ TreeColumnLayout treeColumnLayout = new TreeColumnLayout();
+ tab.setLayout( treeColumnLayout );
+ tab.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
TreeViewer viewer = new TreeViewer( tab, SWT.H_SCROLL | SWT.V_SCROLL );
Tree tree = viewer.getTree();
tree.setHeaderVisible( true );
@@ -66,11 +68,16 @@ public class UiHelper {
TreeColumn column0 = new TreeColumn( viewer.getTree(), SWT.LEFT );
column0.setText( "Component" );
column0.setAlignment( SWT.LEFT );
+ treeColumnLayout.setColumnData( column0, new ColumnWeightData( 1, true ) );
column0.setWidth( 300 );
TreeColumn column1 = new TreeColumn( viewer.getTree(), SWT.LEFT );
- column1.setText( "Version" );
+ column1.setText( "Repository" );
column1.setAlignment( SWT.LEFT );
- column1.setWidth( 260 );
+ treeColumnLayout.setColumnData( column1, new ColumnWeightData( 4, true ) );
+ TreeColumn column3 = new TreeColumn( viewer.getTree(), SWT.LEFT );
+ column3.setText( "Status" );
+ column3.setAlignment( SWT.LEFT );
+ treeColumnLayout.setColumnData( column3, new ColumnWeightData( 1, true ) );
return viewer;
}
@@ -100,29 +107,33 @@ public class UiHelper {
return gridData;
}
- public static Composite createGreedyGridComposite( Composite parent, int numColumns ) {
+ public static Composite createGreedyGridComposite( Composite parent,
+ int numColumns,
+ boolean equalWidth )
+ {
Composite composite = new Composite( parent, SWT.INHERIT_DEFAULT );
- composite.setLayout( UiHelper.createGridLayout( numColumns ) );
+ composite.setLayout( UiHelper.createGridLayout( numColumns, equalWidth ) );
composite.setLayoutData( UiHelper.createGreedyGridData() );
return composite;
}
- public static Composite createGridComposite( Composite parent, int numColumns ) {
+ public static Composite createGridComposite( Composite parent, int numColumns, boolean equalWidth )
+ {
Composite composite = new Composite( parent, SWT.INHERIT_DEFAULT );
- composite.setLayout( UiHelper.createGridLayout( numColumns ) );
+ composite.setLayout( UiHelper.createGridLayout( numColumns, equalWidth ) );
composite.setLayoutData( UiHelper.createOneLinerGridData( numColumns ) );
return composite;
}
- private static Layout createGridLayout( int numColumns ) {
- GridLayout layout = new GridLayout( numColumns, true );
+ private static Layout createGridLayout( int numColumns, boolean equalWidth ) {
+ GridLayout layout = new GridLayout( numColumns, equalWidth );
layout.marginWidth = 0;
layout.marginHeight = 0;
return layout;
}
public static Layout createGreedyGridLayout() {
- return createGridLayout( 1 );
+ return createGridLayout( 1, true );
}
public static Text createText( Composite composite, String toolTip ) {
@@ -137,11 +148,10 @@ public class UiHelper {
}
public static Combo createComboBox( Composite parent, int horizontalSpan, String... labels ) {
- Combo combo = new Combo (parent, SWT.READ_ONLY);
- combo.setItems (labels);
+ Combo combo = new Combo( parent, SWT.READ_ONLY );
+ combo.setItems( labels );
combo.setLayoutData( createOneLinerGridData( horizontalSpan ) );
- combo.setText( labels[0] );
+ combo.setText( labels[ 0 ] );
return combo;
}
-
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationEvent.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationEvent.java
new file mode 100644
index 0000000..f69ea28
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationEvent.java
@@ -0,0 +1,23 @@
+package org.eclipse.rtp.configurator.ui.internal.event;
+
+public class ConfigurationEvent implements IConfigurationEvent {
+
+ private final String instanceURI;
+ private final String sessionId;
+
+ public ConfigurationEvent( String instanceURI, String sessionId ) {
+ this.instanceURI = instanceURI;
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public String getNewIntanceURI() {
+ return instanceURI;
+ }
+
+ @Override
+ public String getSessionId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationEvent.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationEvent.java
new file mode 100644
index 0000000..1df2fe0
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationEvent.java
@@ -0,0 +1,8 @@
+package org.eclipse.rtp.configurator.ui.internal.event;
+
+public interface IConfigurationEvent {
+
+ String getNewIntanceURI();
+
+ String getSessionId();
+}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationListener.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationListener.java
new file mode 100644
index 0000000..8d98247
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationListener.java
@@ -0,0 +1,6 @@
+package org.eclipse.rtp.configurator.ui.internal.event;
+
+
+public interface IConfigurationListener {
+ void configurationchanged(IConfigurationEvent event);
+}