aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeyhan@eclipsesource.com2012-03-03 10:03:32 (EST)
committerbeyhan@eclipsesource.com2012-03-03 10:03:32 (EST)
commitf8c85ec21cfade1fe13932232a758b65ecdb0d21 (patch)
treee09d3c74d742ffea6f1a6c916773db543d7c2c0e
parent6f981126a5bc6f54b7048b00f35d9d65cc5c474b (diff)
downloadorg.eclipse.rtp-f8c85ec21cfade1fe13932232a758b65ecdb0d21.zip
org.eclipse.rtp-f8c85ec21cfade1fe13932232a758b65ecdb0d21.tar.gz
org.eclipse.rtp-f8c85ec21cfade1fe13932232a758b65ecdb0d21.tar.bz2
364706: [Configurator][UI] Provide a configurator UI
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364706 * Search filter updated * Eventing mechanism added
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF8
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIConfigurationListener.xml7
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventService.xml8
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventing.xml6
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/build.properties23
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/IEventService.java8
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/RestTemplate.java5
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsFilter.java38
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsTab.java33
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiBody.java9
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiFooter.java4
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ConfiguratorUiHeader.java90
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ProvisioningTab.java5
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/TabContribution.java43
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/UIEntryPoint.java66
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationListener.java33
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventService.java34
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventingServiceUtil.java33
-rw-r--r--bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/IConfigurationListener.java8
19 files changed, 326 insertions, 135 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 786ef01..05027f5 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.rtp.configurator.ui/META-INF/MANIFEST.MF
@@ -8,8 +8,12 @@ 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.core.runtime;bundle-version="3.8.0"
-Service-Component: OSGI-INF/UIConfigurator.xml
+ org.eclipse.core.runtime;bundle-version="3.8.0",
+ org.eclipse.rtp.core;bundle-version="1.0.0"
+Service-Component: OSGI-INF/UIConfigurator.xml,
+ OSGI-INF/UIEventService.xml,
+ OSGI-INF/UIConfigurationListener.xml,
+ OSGI-INF/UIEventing.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)",
org.eclipse.rtp.core.model;version="1.0.0",
diff --git a/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIConfigurationListener.xml b/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIConfigurationListener.xml
new file mode 100644
index 0000000..cd8561a
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIConfigurationListener.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.rtp.configurator.ui.configuration.listener">
+ <implementation class="org.eclipse.rtp.configurator.ui.internal.event.ConfigurationListener"/>
+ <service>
+ <provide interface="org.eclipse.rtp.configurator.ui.internal.event.IConfigurationListener"/>
+ </service>
+</scr:component>
diff --git a/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventService.xml b/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventService.xml
new file mode 100644
index 0000000..5bd4fdc
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventService.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.rtp.configurator.ui.event.service">
+ <implementation class="org.eclipse.rtp.configurator.ui.internal.event.EventService"/>
+ <service>
+ <provide interface="org.eclipse.rtp.configurator.rest.IEventService"/>
+ </service>
+ <reference bind="addService" cardinality="1..n" interface="org.eclipse.rtp.configurator.ui.internal.event.IConfigurationListener" name="IConfigurationListener" policy="dynamic" unbind="removeService"/>
+</scr:component>
diff --git a/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventing.xml b/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventing.xml
new file mode 100644
index 0000000..a5b3420
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/OSGI-INF/UIEventing.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.rtp.configurator.ui.eventing">
+ <implementation class="org.eclipse.rtp.configurator.ui.internal.event.EventingServiceUtil"/>
+ <reference bind="addEventService" cardinality="1..1" interface="org.eclipse.rtp.configurator.rest.IEventService" name="IEventService" policy="static"/>
+ <reference bind="addConfigurationListenerService" cardinality="1..1" interface="org.eclipse.rtp.configurator.ui.internal.event.IConfigurationListener" name="IConfigurationListener" policy="static"/>
+</scr:component>
diff --git a/bundles/org.eclipse.rtp.configurator.ui/build.properties b/bundles/org.eclipse.rtp.configurator.ui/build.properties
index 68eccb1..e747898 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/build.properties
+++ b/bundles/org.eclipse.rtp.configurator.ui/build.properties
@@ -1,10 +1,13 @@
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- default-theme/,\
- OSGI-INF/,\
- about.html,\
- plugin.properties,\
- images/,\
- theme/
-source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ default-theme/,\
+ OSGI-INF/,\
+ about.html,\
+ plugin.properties,\
+ images/,\
+ theme/,\
+ OSGI-INF/UIEventService.xml,\
+ OSGI-INF/UIConfigurationListener.xml,\
+ OSGI-INF/UIEventing.xml
+source.. = src/
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/IEventService.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/IEventService.java
new file mode 100644
index 0000000..a427cef
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/rest/IEventService.java
@@ -0,0 +1,8 @@
+package org.eclipse.rtp.configurator.rest;
+
+import org.eclipse.rtp.configurator.ui.internal.event.IConfigurationEvent;
+
+public interface IEventService {
+
+ void fireConfigurationEvent( IConfigurationEvent event );
+}
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 08b0f6a..3cc3478 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
@@ -13,15 +13,16 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.eclipse.rtp.core.model.SourceProvider;
import org.eclipse.rtp.core.model.SourceUnMarshaller;
-import org.eclipse.rtp.core.model.internal.SourceUnMarshallerImpl;
+import org.eclipse.rtp.core.util.ModelUtil;
public class RestTemplate {
- SourceUnMarshaller unMarshaller = new SourceUnMarshallerImpl();
+ SourceUnMarshaller unMarshaller;
private final String urlBase;
public RestTemplate( String newIntanceURI ) {
this.urlBase = newIntanceURI;
+ unMarshaller = ModelUtil.getSourceUnMarshaller();
}
@SuppressWarnings( "unchecked" )
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsFilter.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsFilter.java
index 889e7e7..4ac2a30 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsFilter.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/ComponentsFilter.java
@@ -7,33 +7,37 @@
*******************************************************************************/
package org.eclipse.rtp.configurator.ui;
+import java.util.List;
+
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.rtp.core.model.Source;
-
+import org.eclipse.rtp.core.model.SourceVersion;
public class ComponentsFilter extends ViewerFilter {
+
private String searchString;
- public void setSearchText(String s) {
- // Search must be a substring of the existing value
- this.searchString = ".*" + s + ".*";
+ public void setSearchText( String s ) {
+ // Search must be a substring of the existing value
+ this.searchString = ".*" + s + ".*";
}
@Override
- public boolean select( Viewer viewer, Object parentElement, Object element) {
- if (searchString == null || searchString.length() == 0) {
- return true;
+ public boolean select( Viewer viewer, Object parentElement, Object element ) {
+ if( searchString == null || searchString.length() == 0 || element instanceof SourceVersion ) {
+ return true;
+ }
+ Source source = ( Source )element;
+ if( source.getName().matches( searchString ) ) {
+ return true;
+ }
+ List<SourceVersion> versions = source.getVersions();
+ for( SourceVersion sourceVersion : versions ) {
+ if( sourceVersion.getVersion().matches( searchString ) ) {
+ return true;
}
- Source source = (Source) element;
- if (source.getName().matches(searchString)) {
- return true;
- }
- // TODO - support multiple versions?
- if (source.getVersions().get( 0 ).getVersion().matches(searchString)) {
- return true;
- }
-
- return false;
+ }
+ return false;
}
}
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 5108f3c..5e378c4 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,17 +12,18 @@ 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.EventingServiceUtil;
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.rwt.RWT;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
@@ -34,7 +35,6 @@ 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 {
@@ -120,7 +120,12 @@ public class ComponentsTab extends AbstractTabContribution {
addInstallButton( provisioningActionsComposite );
addUninstallButton( provisioningActionsComposite );
addUpdateWorldButton( provisioningActionsComposite );
- addConfigurationListener();
+ registerTabForConfigurationChanges();
+ }
+
+ private void registerTabForConfigurationChanges() {
+ IConfigurationListener configurationListenerService = EventingServiceUtil.getConfigurationListenerService();
+ configurationListenerService.addInterestedView( RWT.getSessionStore().getId(), this );
}
private void addUninstallButton( Composite tab ) {
@@ -212,19 +217,9 @@ public class ComponentsTab extends AbstractTabContribution {
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 configurationChanged( IConfigurationEvent event ) {
+ restTemplate = new RestTemplate( event.getNewIntanceURI() );
+ refresh();
}
public void refresh() {
@@ -245,4 +240,10 @@ public class ComponentsTab extends AbstractTabContribution {
} );
}
}
+
+ @Override
+ public void dispose() {
+ IConfigurationListener configurationListenerService = EventingServiceUtil.getConfigurationListenerService();
+ configurationListenerService.removeInterestedView( RWT.getSessionStore().getId() );
+ }
}
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 d522841..7c42e1a 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
@@ -18,7 +18,10 @@ import org.eclipse.swt.widgets.TabItem;
public class ConfiguratorUiBody {
+ private List<TabContribution> contributions;
+
public void createBody( Shell shell, List<TabContribution> contributions ) {
+ this.contributions = contributions;
Composite body = UiHelper.createGreedyGridComposite( shell, 1, true );
final TabFolder tabFolder = new TabFolder( body, SWT.BORDER );
tabFolder.setLayoutData( UiHelper.createGreedyGridData() );
@@ -33,4 +36,10 @@ public class ConfiguratorUiBody {
tabFolder.setSelection( 0 );
}
}
+
+ public void dispose() {
+ for( TabContribution contribution : contributions ) {
+ contribution.dispose();
+ }
+ }
}
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 7e4bbf4..9b94ebd 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
@@ -17,4 +17,8 @@ public class ConfiguratorUiFooter {
// TODO - Get the RTP version.
UiHelper.createLabel( footer, 1, "RTP Version XZY" );
}
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+ }
}
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 b4c4fca..b44a571 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
@@ -7,12 +7,10 @@
*******************************************************************************/
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.rest.IEventService;
import org.eclipse.rtp.configurator.ui.internal.event.ConfigurationEvent;
-import org.eclipse.rtp.configurator.ui.internal.event.IConfigurationListener;
+import org.eclipse.rtp.configurator.ui.internal.event.EventingServiceUtil;
import org.eclipse.rwt.RWT;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -24,9 +22,6 @@ 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.
@@ -37,16 +32,17 @@ public class ConfiguratorUiHeader {
private Label configurationUriLabel;
private Composite header;
+ private Image logo;
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" ) );
+ header = UiHelper.createGridComposite( shell, 4, false );
+ logo = new Image( display, getClass().getResourceAsStream( "/images/rtp-icon.png" ) );
Label label = new Label( header, SWT.CENTER );
label.setImage( logo );
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 ) );
+ configurationUriLabel.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+ Label headerLabel = UiHelper.createLabel( header, 1, new UIBrandingWeb().getTitle() );
+ headerLabel.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
createConfigurationButton( display, header );
}
@@ -61,46 +57,44 @@ public class ConfiguratorUiHeader {
{
rtpInstanceManagementButton.addSelectionListener( new SelectionAdapter() {
+ @SuppressWarnings( "synthetic-access" )
@Override
public void widgetSelected( SelectionEvent e ) {
- final InputDialog inputDialog = new InputDialog( Display.getCurrent().getActiveShell(),
- "RTP Instance Configuration",
- "Enter instance URI",
- "",
- null )
- {
+ showInputDialog();
+ }
+ } );
+ }
- @Override
- protected void okPressed() {
- super.okPressed();
- configurationUriLabel.setText( getValue() );
- header.layout( true );
- fireConfigurationChagned( getValue() );
- }
+ private void showInputDialog() {
+ final InputDialog inputDialog = new InputDialog( Display.getCurrent().getActiveShell(),
+ "RTP Instance Configuration",
+ "Enter instance URI",
+ "",
+ null )
+ {
- 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();
+ @SuppressWarnings( "synthetic-access" )
+ @Override
+ protected void okPressed() {
+ super.okPressed();
+ configurationUriLabel.setText( getValue() );
+ fireConfigurationChagned( getValue() );
}
- } );
+ };
+ inputDialog.setBlockOnOpen( false );
+ inputDialog.open();
+ }
+
+ private void fireConfigurationChagned( String value ) {
+ ConfigurationEvent configurationEvent = new ConfigurationEvent( value, RWT.getSessionStore()
+ .getId() );
+ IEventService eventService = EventingServiceUtil.getEventService();
+ eventService.fireConfigurationEvent( configurationEvent );
+ }
+
+ public void dispose() {
+ if( logo != null ) {
+ logo.dispose();
+ }
}
}
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 815aeef..78c1693 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
@@ -23,4 +23,9 @@ public class ProvisioningTab extends AbstractTabContribution {
Composite planetTab = UiHelper.createGreedyGridComposite( composite, 1, true );
UiHelper.createLabel( planetTab, 1, "Provisioning Tab" );
}
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+ }
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/TabContribution.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/TabContribution.java
index 332397b..6bb928e 100644
--- a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/TabContribution.java
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/TabContribution.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;
@@ -18,18 +16,21 @@ import org.eclipse.swt.widgets.Display;
*/
public interface TabContribution {
- /**
- * Title shown in the enclosing tab folder.
- * @return String to be shown in the enclosing tab folder.
- */
- String getTitle();
+ /**
+ * Title shown in the enclosing tab folder.
+ *
+ * @return String to be shown in the enclosing tab folder.
+ */
+ String getTitle();
- /**
- * Provide the content for the tab item.
- * @param display of the application.
- * @param parent of the content to provide.
- * @return the control to put into the tab item.
- */
- Control getControl(Display display, Composite parent);
+ /**
+ * Provide the content for the tab item.
+ *
+ * @param display of the application.
+ * @param parent of the content to provide.
+ * @return the control to put into the tab item.
+ */
+ Control getControl( Display display, Composite parent );
+ void dispose();
}
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 3a9320d..70220da 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
@@ -1,37 +1,67 @@
-/*******************************************************************************
-* 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.ArrayList;
import java.util.List;
import org.eclipse.rwt.lifecycle.IEntryPoint;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class UIEntryPoint implements IEntryPoint {
- private List<TabContribution> contributions = new ArrayList<TabContribution>();
+ private final List<TabContribution> contributions = new ArrayList<TabContribution>();
+ private ConfiguratorUiHeader configuratorUiHeader;
+ private ConfiguratorUiBody configuratorUiBody;
+ private ConfiguratorUiFooter configuratorUiFooter;
@Override
public int createUI() {
- Display display = new Display();
- final Shell shell = UiHelper.createShell(display);
+ initUI();
+ openUI();
+ return 0;
+ }
- new ConfiguratorUiHeader().createHeader(display, shell);
- contributions.add( new ComponentsTab());
- contributions.add( new ProvisioningTab());
- new ConfiguratorUiBody().createBody(shell, contributions);
- new ConfiguratorUiFooter().createFooter(shell);
+ private void initUI() {
+ configuratorUiHeader = new ConfiguratorUiHeader();
+ configuratorUiBody = new ConfiguratorUiBody();
+ configuratorUiFooter = new ConfiguratorUiFooter();
+ }
+ private void openUI() {
+ Display display = new Display();
+ final Shell shell = UiHelper.createShell( display );
+ initShell( shell );
+ configuratorUiHeader.createHeader( display, shell );
+ contributions.add( new ComponentsTab() );
+ contributions.add( new ProvisioningTab() );
+ configuratorUiBody.createBody( shell, contributions );
+ configuratorUiFooter.createFooter( shell );
shell.open();
- return 0;
+ }
+
+ private void initShell( final Shell shell ) {
+ shell.addDisposeListener( new DisposeListener() {
+
+ @SuppressWarnings( "synthetic-access" )
+ @Override
+ public void widgetDisposed( DisposeEvent event ) {
+ disposeUI();
+ }
+ } );
+ }
+
+ private void disposeUI() {
+ configuratorUiHeader.dispose();
+ configuratorUiBody.dispose();
+ configuratorUiFooter.dispose();
}
}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationListener.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationListener.java
new file mode 100644
index 0000000..773e05f
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/ConfigurationListener.java
@@ -0,0 +1,33 @@
+package org.eclipse.rtp.configurator.ui.internal.event;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.rtp.configurator.ui.ComponentsTab;
+
+public class ConfigurationListener implements IConfigurationListener {
+
+ private final Map<String, ComponentsTab> sessionId2ComponentTabMap;
+
+ public ConfigurationListener() {
+ sessionId2ComponentTabMap = new HashMap<String, ComponentsTab>();
+ }
+
+ @Override
+ public void addInterestedView( String sessionId, ComponentsTab componentsTab ) {
+ sessionId2ComponentTabMap.put( sessionId, componentsTab );
+ }
+
+ @Override
+ public void removeInterestedView( String sessionId ) {
+ sessionId2ComponentTabMap.remove( sessionId );
+ }
+
+ @Override
+ public void configurationchanged( IConfigurationEvent event ) {
+ for( String key : sessionId2ComponentTabMap.keySet() ) {
+ ComponentsTab componentsTab = sessionId2ComponentTabMap.get( key );
+ componentsTab.configurationChanged( event );
+ }
+ }
+}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventService.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventService.java
new file mode 100644
index 0000000..58fac10
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventService.java
@@ -0,0 +1,34 @@
+package org.eclipse.rtp.configurator.ui.internal.event;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.rtp.configurator.rest.IEventService;
+
+public class EventService implements IEventService {
+
+ private final List<IConfigurationListener> listeners;
+
+ public EventService() {
+ listeners = new ArrayList<IConfigurationListener>();
+ }
+
+ public void addService( IConfigurationListener listener ) {
+ if( !listeners.contains( listener ) ) {
+ listeners.add( listener );
+ }
+ }
+
+ public void removeService( IConfigurationListener listener ) {
+ if( listeners.contains( listener ) ) {
+ listeners.remove( listener );
+ }
+ }
+
+ @Override
+ public void fireConfigurationEvent( IConfigurationEvent event ) {
+ for( IConfigurationListener listener : listeners ) {
+ listener.configurationchanged( event );
+ }
+ }
+}
diff --git a/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventingServiceUtil.java b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventingServiceUtil.java
new file mode 100644
index 0000000..9536289
--- /dev/null
+++ b/bundles/org.eclipse.rtp.configurator.ui/src/org/eclipse/rtp/configurator/ui/internal/event/EventingServiceUtil.java
@@ -0,0 +1,33 @@
+package org.eclipse.rtp.configurator.ui.internal.event;
+
+import org.eclipse.rtp.configurator.rest.IEventService;
+
+public class EventingServiceUtil {
+
+ private static IEventService eventService;
+ private static IConfigurationListener configurationListener;
+
+ public void addEventService( IEventService eventService ) {
+ EventingServiceUtil.eventService = eventService;
+ }
+
+ public void removeEventService( IEventService eventService ) {
+ EventingServiceUtil.eventService = null;
+ }
+
+ public void addConfigurationListenerService( IConfigurationListener configurationListener ) {
+ EventingServiceUtil.configurationListener = configurationListener;
+ }
+
+ public void removeConfigurationListenerService( IConfigurationListener configurationListener ) {
+ EventingServiceUtil.configurationListener = null;
+ }
+
+ public static IConfigurationListener getConfigurationListenerService() {
+ return configurationListener;
+ }
+
+ public static IEventService getEventService() {
+ return eventService;
+ }
+}
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
index 8d98247..0f5e93e 100644
--- 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
@@ -1,6 +1,12 @@
package org.eclipse.rtp.configurator.ui.internal.event;
+import org.eclipse.rtp.configurator.ui.ComponentsTab;
public interface IConfigurationListener {
- void configurationchanged(IConfigurationEvent event);
+
+ void addInterestedView( String sessionId, ComponentsTab componentsTab );
+
+ void removeInterestedView( String sessionId );
+
+ void configurationchanged( IConfigurationEvent event );
}