refactored external service provider for more flexibility
diff --git a/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/dummy_provider1.properties b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/dummy_provider1.properties
new file mode 100644
index 0000000..864a0c2
--- /dev/null
+++ b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/dummy_provider1.properties
@@ -0,0 +1,4 @@
+label=External Services Provider Two
+description=Even more features and plugins!
+icon=external.png
+url=http://example.com/serviceprovider_two
diff --git a/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/dummy_provider2.properties b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/dummy_provider2.properties
new file mode 100644
index 0000000..f25bbc1
--- /dev/null
+++ b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/dummy_provider2.properties
@@ -0,0 +1,4 @@
+label=External Services Provider One
+description=Even more features and plugins!
+icon=external.png
+url=http://example.com/serviceprovider_one
diff --git a/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/echo_provider.properties b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/echo_provider.properties
new file mode 100644
index 0000000..b2bab02
--- /dev/null
+++ b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/echo_provider.properties
@@ -0,0 +1,4 @@
+label=External Services Provider (Echo Test)
+description=Even more features and plugins!
+icon=external.png
+url=http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi
diff --git a/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/external.png b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/external.png
new file mode 100644
index 0000000..cc12d2b
--- /dev/null
+++ b/plugins/org.eclipse.epp.wizard/data/externalServiceProviders/external.png
Binary files differ
diff --git a/plugins/org.eclipse.epp.wizard/data/outgoing/outgoing.properties b/plugins/org.eclipse.epp.wizard/data/outgoing/outgoing.properties
deleted file mode 100644
index 8287d34..0000000
--- a/plugins/org.eclipse.epp.wizard/data/outgoing/outgoing.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-extservprovider=External Services Provider (Echo Test)
-extservprovider.description=Even more features and plugins!
-extservprovider.icon=external.png
-extservprovider.url=http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi
-
-extservprovider2=External Provider for Services
-extservprovider2.description=Even more features and plugins! Even more stable!
-extservprovider2.icon=external.png
-extservprovider2.url=http://localhost/provider2/servlet?features=%s
-
-extservprovider3=Services by External Provider
-extservprovider3.description=Even less NullPointerExceptions!
-extservprovider3.icon=external.png
-extservprovider3.url=http://localhost/provider3/servlet?features=%s
\ No newline at end of file
diff --git a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/Configuration.java b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/Configuration.java
index a5946db..af2441a 100644
--- a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/Configuration.java
+++ b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/Configuration.java
@@ -16,7 +16,7 @@
public class Configuration {
final static String MODEL = "model";
- final static String OUTGOING = "outgoing";
+ final static String EXTERNAL_SERVICE_PROVIDERS = "externalServiceProviders";
final static String EPP_METADATA_REPOSITORY = "epp.metadata";
final static String INSTALLER_URL = "installer.url";
final static String BASE_IUS = "baseIUs";
@@ -25,7 +25,7 @@
final public static String P2_ROOTS = "eclipse.p2.roots";
protected File modelDirectory;
- protected File outgoingDirectory;
+ protected File externalServiceProviderDirectory;
protected String eppMetadataRepository;
protected String installerURL;
protected String baseIUs;
@@ -52,10 +52,10 @@
return artifactRepositories;
}
- protected OutgoingApiConfiguration outgoingApiConfiguration;
+ protected ExternalServiceProviderConfiguration externalServiceProviderConfiguration;
- public OutgoingApiConfiguration getOutgoingApiConfiguration() {
- return outgoingApiConfiguration;
+ public ExternalServiceProviderConfiguration getExternalServiceProviderConfiguration() {
+ return externalServiceProviderConfiguration;
}
private Properties properties;
@@ -64,8 +64,8 @@
return modelDirectory;
}
- public File getOutgoingDirectory() {
- return outgoingDirectory;
+ public File getExternalServiceProviderDirectory() {
+ return externalServiceProviderDirectory;
}
@@ -73,8 +73,8 @@
{
this.properties = properties;
modelDirectory = createDirectoryObject(MODEL);
- outgoingDirectory = createDirectoryObject(OUTGOING);
- loadOutgoingApiConfiguration();
+ externalServiceProviderDirectory = createDirectoryObject(EXTERNAL_SERVICE_PROVIDERS);
+ loadExternalServiceProviderConfiguration();
installerURL = properties.getProperty(INSTALLER_URL);
@@ -84,8 +84,8 @@
baseIUs = properties.getProperty(BASE_IUS,"");
}
- private void loadOutgoingApiConfiguration() {
- outgoingApiConfiguration = new OutgoingApiConfiguration(outgoingDirectory);
+ private void loadExternalServiceProviderConfiguration() {
+ externalServiceProviderConfiguration = new ExternalServiceProviderConfiguration(externalServiceProviderDirectory);
}
diff --git a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ExternalServiceProviderConfiguration.java b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ExternalServiceProviderConfiguration.java
new file mode 100644
index 0000000..892d0e4
--- /dev/null
+++ b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ExternalServiceProviderConfiguration.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
+ * 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:
+ * Innoopract Informationssysteme GmbH - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.epp.wizard.internal;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class ExternalServiceProviderConfiguration {
+ private static final String URL = "url";
+ private static final String ICON = "icon";
+ private static final String DESCRIPTION = "description";
+ private static final String LABEL = "label";
+ private static final String PROPERTIES_EXTENSION = ".properties";
+
+ public static class Entry {
+ public String label;
+ public String description;
+ public File icon;
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public File getIcon() {
+ return icon;
+ }
+
+ public String getUrlTemplate() {
+ return urlTemplate;
+ }
+
+ public Entry(String label, File icon, String description,
+ String urlTemplate) {
+ super();
+ this.description = description;
+ this.icon = icon;
+ this.label = label;
+ this.urlTemplate = urlTemplate;
+ }
+
+ public String urlTemplate;
+ }
+
+ private List<Entry> entries = new ArrayList<Entry>();
+
+ public ExternalServiceProviderConfiguration(File externalServiceProviderDirectory) {
+ for (File propertiesFile : externalServiceProviderDirectory.listFiles()) {
+ if (propertiesFile.getName().endsWith(PROPERTIES_EXTENSION)) {
+ try {
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(propertiesFile));
+
+ String label = getMandatoryProperty(properties, LABEL);
+ String description = getMandatoryProperty(properties,
+ DESCRIPTION);
+ String icon = getMandatoryProperty(properties, ICON);
+ String url = getMandatoryProperty(properties, URL);
+ Entry entry = new Entry(label, new File(externalServiceProviderDirectory,
+ icon), description, url);
+ entries.add(entry);
+ } catch (Exception exc) {
+ throw new RuntimeException(
+ "Could not load external service provider configuration file'"
+ + propertiesFile.getAbsolutePath() + "'",
+ exc);
+ }
+ }
+ }
+ }
+
+ private String getMandatoryProperty(Properties properties, String string) {
+ String result = properties.getProperty(string);
+ if (result == null) {
+ throw new RuntimeException("External service provider key '"
+ + string + "' not found in properties");
+ }
+ return result;
+ }
+
+ public List<Entry> getEntries() {
+ return entries;
+ }
+}
diff --git a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/OutgoingApiConfiguration.java b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/OutgoingApiConfiguration.java
deleted file mode 100644
index aa7376b..0000000
--- a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/OutgoingApiConfiguration.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
- * 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:
- * Innoopract Informationssysteme GmbH - initial API and implementation
- ******************************************************************************/
-package org.eclipse.epp.wizard.internal;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-
-public class OutgoingApiConfiguration {
- public static class Entry
- {
- public String label;
- public String description;
- public File icon;
-
- public String getLabel() {
- return label;
- }
-
- public String getDescription() {
- return description;
- }
-
- public File getIcon() {
- return icon;
- }
-
- public String getUrlTemplate() {
- return urlTemplate;
- }
- public Entry( String label,
- File icon,
- String description,
- String urlTemplate )
- {
- super();
- this.description = description;
- this.icon = icon;
- this.label = label;
- this.urlTemplate = urlTemplate;
- }
- public String urlTemplate;
- }
-
- private List<Entry> entries = new ArrayList<Entry>();
-
-
- @SuppressWarnings("unchecked")
- public OutgoingApiConfiguration(File outgoingDirectory) {
- Properties properties = new Properties();
- File propertiesFile = new File(outgoingDirectory, "outgoing.properties");
- try {
- properties.load( new FileInputStream(propertiesFile ));
- Enumeration<String> propertyNames = ( Enumeration<String> )properties.propertyNames();
- while( propertyNames.hasMoreElements() ) {
- String key = ( String )propertyNames.nextElement();
- if(!key.contains( "." ))
- {
- String label = properties.getProperty( key );
- String description = properties.getProperty( key + ".description" );
- String icon = properties.getProperty( key + ".icon" );
- String url = properties.getProperty( key + ".url" );
- Entry entry = new Entry(label,new File(outgoingDirectory, icon ),description, url);
- entries.add( entry );
- }
- }
- } catch( Exception exc ) {
- throw new RuntimeException("Could not load configuration file'"+propertiesFile.getAbsolutePath()+"'", exc);
- }
- }
-
-
- public List<Entry> getEntries() {
- return entries;
- }
-}
diff --git a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/Wizard.java b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/Wizard.java
index 24e3846..3e2c115 100644
--- a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/Wizard.java
+++ b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/Wizard.java
@@ -18,7 +18,7 @@
import org.eclipse.epp.wizard.internal.Activator;
import org.eclipse.epp.wizard.internal.Configuration;
-import org.eclipse.epp.wizard.internal.OutgoingApiConfiguration;
+import org.eclipse.epp.wizard.internal.ExternalServiceProviderConfiguration;
import org.eclipse.epp.wizard.internal.Wishlist;
import org.eclipse.epp.wizard.internal.ui.Roadmap.IRoadmapListener;
import org.eclipse.epp.wizard.model.EPPModel;
@@ -84,7 +84,7 @@
sashForm.setWeights( new int[]{
2, 1
} );
- OutgoingApiConfiguration outgoingApiConfiguration = Activator.getDefault().getConfiguration().getOutgoingApiConfiguration();
+ ExternalServiceProviderConfiguration externalServiceProviderConfiguration = Activator.getDefault().getConfiguration().getExternalServiceProviderConfiguration();
@@ -98,7 +98,7 @@
addWizardScreen( wizardScreen );
}
downloadScreen = new WizardDownloadScreen(
- screenArea, outgoingApiConfiguration);
+ screenArea, externalServiceProviderConfiguration);
addWizardScreen(downloadScreen);
screenArea.layout();
Roadmap roadmap = createRoadmap( parent );
diff --git a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/WizardDownloadScreen.java b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/WizardDownloadScreen.java
index 6625716..653edc2 100644
--- a/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/WizardDownloadScreen.java
+++ b/plugins/org.eclipse.epp.wizard/src/org/eclipse/epp/wizard/internal/ui/WizardDownloadScreen.java
@@ -16,7 +16,7 @@
import org.eclipse.epp.wizard.internal.Configuration;
import org.eclipse.epp.wizard.internal.IWishlistListener;
import org.eclipse.epp.wizard.internal.OsUtil;
-import org.eclipse.epp.wizard.internal.OutgoingApiConfiguration;
+import org.eclipse.epp.wizard.internal.ExternalServiceProviderConfiguration;
import org.eclipse.epp.wizard.internal.Wishlist;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
@@ -43,15 +43,16 @@
private Browser browser;
private Wishlist wishlist;
- private OutgoingApiConfiguration outgoingApiConfiguration;
+ private ExternalServiceProviderConfiguration externalServiceProviderConfiguration;
private Label notificationLabel;
private String noItemsText;
private String gotItemsText;
public WizardDownloadScreen(final Composite parent,
- OutgoingApiConfiguration outgoingApiConfiguration) {
+ ExternalServiceProviderConfiguration externalServiceProviderConfiguration
+ ) {
super(parent, SWT.NONE);
- this.outgoingApiConfiguration = outgoingApiConfiguration;
+ this.externalServiceProviderConfiguration = externalServiceProviderConfiguration;
createContent(this);
}
@@ -71,7 +72,7 @@
createDownloadButton(downloadArea);
createWebstartButton(downloadArea);
createSpacing(parent);
- createOutgoingApiComposite(parent);
+ createExternalServiceProviderComposite(parent);
}
private void createSpacing(Composite parent) {
@@ -88,7 +89,7 @@
.create());
}
- private void createOutgoingApiComposite(final Composite parent) {
+ private void createExternalServiceProviderComposite(final Composite parent) {
final ScrolledComposite scrolledComposite = new ScrolledComposite(
parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setLayoutData(GridDataFactory.fillDefaults().grab(
@@ -119,7 +120,7 @@
separator.setLayoutData(GridDataFactory.fillDefaults().span(2, 1)
.minSize(10, 10).create());
separator.setForeground(Colors.ECLIPSE_BLUE.get());
- for (final OutgoingApiConfiguration.Entry entry : outgoingApiConfiguration
+ for (final ExternalServiceProviderConfiguration.Entry entry : externalServiceProviderConfiguration
.getEntries()) {
Label icon = new Label(composite, SWT.NONE);
icon.setImage(Images.load(entry.getIcon()));