--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Fri Jul 16 15:39:47 2010 -0500
@@ -16,9 +16,21 @@
*/
package com.nokia.carbide.discovery.ui;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -83,4 +95,29 @@
public static void logError(String message, Throwable t) {
getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, t));
}
+
+ /**
+ * Get a value from the server.properties file
+ * @param key
+ * @return
+ */
+ public static String getFromServerProperties(String key) {
+ Location installLocation = Platform.getInstallLocation();
+ URL url = installLocation.getURL();
+ IPath path = new Path(url.getPath());
+ path = path.append("configuration/server.properties"); //$NON-NLS-1$
+ File file = path.toFile();
+ Properties properties = new Properties();
+ try {
+ InputStream is = new FileInputStream(file);
+ properties.load(is);
+ is.close();
+ } catch (IOException e) {
+ String message =
+ MessageFormat.format("Could not find URL in configuration/server.properties file for key={0}", key);
+ Activator.logError(message, e);
+ }
+ return (String) properties.get(key);
+ }
+
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties Fri Jul 16 15:39:47 2010 -0500
@@ -3,7 +3,6 @@
DiscoveryView_GatherExtensionsTitle=Gathering Extensions
DiscoveryView_GatheringInstallInfoTitle=Gathering Install Information
DiscoveryView_InstallLabel=Install Checked Items...
-DiscoveryView_MissingDirectoryURLError=Could not find URL in configuration/server.properties file for key={0}
DiscoveryView_RefreshLabel=Refresh
DiscoveryView_StatusLineFmt={0} item(s) checked
DiscoveryView_UncheckAllLabel=Uncheck All Items
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java Fri Jul 16 15:39:47 2010 -0500
@@ -19,7 +19,6 @@
import java.util.LinkedHashMap;
import java.util.Map;
-import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.RowDataFactory;
import org.eclipse.jface.layout.RowLayoutFactory;
import org.eclipse.jface.resource.FontDescriptor;
@@ -59,7 +58,6 @@
parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
this.portalEditor = portalEditor;
buttonToPageMap = new LinkedHashMap<Button, IPortalPage>();
- GridDataFactory.swtDefaults().grab(true, false).align(SWT.CENTER, SWT.TOP).indent(10, 10).applyTo(this);
RowLayoutFactory.swtDefaults().margins(3, 3).wrap(false).applyTo(this);
listener = new ButtonListener();
selectedButtonFont = JFaceResources.getHeaderFont();
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java Fri Jul 16 15:39:47 2010 -0500
@@ -153,6 +153,7 @@
GridLayoutFactory.fillDefaults().applyTo(backgroundParent);
// create top naviation bar
navigationBar = createNavigationBar(backgroundParent);
+ GridDataFactory.swtDefaults().grab(true, false).align(SWT.CENTER, SWT.TOP).indent(10, 10).applyTo(navigationBar);
// create stack composite
createStackComposite(backgroundParent, navigationBar);
return backgroundParent;
@@ -178,7 +179,7 @@
GridDataFactory.fillDefaults().grab(false, true).applyTo(taskComposite);
for (IActionBar actionBar : commandBars) {
Control control = createTaskBarControl(taskComposite, actionBar, updater);
- GridDataFactory.fillDefaults().indent(0, 0).applyTo(control);
+ GridDataFactory.fillDefaults().minSize(150, SWT.DEFAULT).grab(true, false).indent(0, 0).applyTo(control);
}
}
Composite pageControl = new RoundedCornerComposite(pageComposite, backgroundParent,
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java Fri Jul 16 15:39:47 2010 -0500
@@ -21,7 +21,6 @@
import java.util.Map.Entry;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.RowDataFactory;
import org.eclipse.jface.layout.RowLayoutFactory;
import org.eclipse.jface.resource.JFaceResources;
@@ -65,7 +64,6 @@
parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
createTitle(actionBar);
createActions(actionBar);
- GridDataFactory.swtDefaults().grab(true, true).align(SWT.CENTER, SWT.BEGINNING).applyTo(this);
RowLayoutFactory.swtDefaults().type(SWT.VERTICAL).margins(10, 10).extendedMargins(5, 5, 5, 10).fill(true).wrap(false).applyTo(this);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPage.java Fri Jul 16 15:39:47 2010 -0500
@@ -0,0 +1,205 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.extension;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.LocationAdapter;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.browser.ProgressAdapter;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorPart;
+
+import com.nokia.carbide.discovery.ui.Activator;
+
+public abstract class AbstractBrowserPortalPage implements IPortalPage {
+
+ private final class NavigationActionBar implements IActionBar {
+ private List<IAction> actions;
+ private IActionUIUpdater updater;
+ private boolean loading;
+
+ private NavigationActionBar(IActionUIUpdater updater) {
+ this.updater = updater;
+ makeActions();
+ }
+
+ public void hookBrowser() {
+ browser.addLocationListener(new LocationAdapter() {
+ @Override
+ public void changed(LocationEvent event) {
+ NavigationActionBar.this.updater.updateAll();
+ }
+ });
+ browser.addProgressListener(new ProgressAdapter() {
+ @Override
+ public void changed(ProgressEvent event) {
+ if (event.total == 0)
+ return;
+ loading = (event.current != event.total);
+ NavigationActionBar.this.updater.updateAll();
+ }
+ @Override
+ public void completed(ProgressEvent event) {
+ loading = false;
+ NavigationActionBar.this.updater.updateAll();
+ }
+ });
+ }
+
+ @Override
+ public String getTitle() {
+ return "Navigation";
+ }
+
+ @Override
+ public IAction[] getActions() {
+ return (IAction[]) actions.toArray(new IAction[actions.size()]);
+ }
+
+ private void makeActions() {
+ actions = new ArrayList<IAction>();
+ IAction a = new Action("Back") {
+ @Override
+ public void run() {
+ if (browser != null) {
+ browser.back();
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return browser != null ? browser.isBackEnabled() : false;
+ }
+ };
+ actions.add(a);
+
+ a = new Action("Forward") {
+ @Override
+ public void run() {
+ if (browser != null) {
+ browser.forward();
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return browser != null ? browser.isForwardEnabled() : false;
+ }
+ };
+ actions.add(a);
+
+ a = new Action("Refresh Page") {
+ @Override
+ public void run() {
+ if (browser != null) {
+ browser.refresh();
+ update();
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return browser != null ? !loading : false;
+ }
+ };
+ actions.add(a);
+
+ a = new Action("Stop Loading") {
+ @Override
+ public void run() {
+ if (browser != null) {
+ browser.stop();
+ update();
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return browser != null ? loading : false;
+ }
+ };
+ actions.add(a);
+ }
+
+ public void update() {
+ updater.updateAll();
+ }
+
+ }
+
+ private Browser browser;
+ private NavigationActionBar actionBar;
+
+ @Override
+ public Control createControl(Composite parent, IEditorPart part) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ composite.setLayout(new FillLayout());
+ try {
+ browser = new Browser(composite, SWT.NONE);
+ } catch (SWTError e) {
+ e.printStackTrace();
+ }
+
+ return composite;
+ }
+
+ protected String getURL() {
+ try {
+ URL url = new URL(Activator.getFromServerProperties(getClass().getName()));
+ return url.toString();
+ } catch (MalformedURLException e) {
+ Activator.logError("Could not load page due to bad URL", e);
+ }
+
+ return null;
+ }
+
+ @Override
+ public void init() {
+ if (browser != null) {
+ browser.setUrl(getURL());
+ actionBar.hookBrowser();
+ }
+ actionBar.update();
+ }
+
+ @Override
+ public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) {
+ actionBar = new NavigationActionBar(updater);
+ return new IActionBar[] {
+ actionBar
+ };
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/DiscoveryView.java Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/DiscoveryView.java Fri Jul 16 15:39:47 2010 -0500
@@ -17,24 +17,15 @@
package com.nokia.carbide.internal.discovery.ui.view;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.internal.p2.discovery.Catalog;
import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
import org.eclipse.equinox.internal.p2.discovery.compatibility.BundleDiscoveryStrategy;
@@ -59,7 +50,6 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
@@ -143,7 +133,7 @@
// look for remote descriptor
RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
- String url = getFromServerProperties(DIRECTORY_KEY);
+ String url = Activator.getFromServerProperties(DIRECTORY_KEY);
if (url != null) {
remoteDiscoveryStrategy.setDirectoryUrl(url);
catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
@@ -154,25 +144,6 @@
return catalog;
}
- public static String getFromServerProperties(String key) {
- Location installLocation = Platform.getInstallLocation();
- URL url = installLocation.getURL();
- IPath path = new Path(url.getPath());
- path = path.append("configuration/server.properties"); //$NON-NLS-1$
- File file = path.toFile();
- Properties properties = new Properties();
- try {
- InputStream is = new FileInputStream(file);
- properties.load(is);
- is.close();
- } catch (IOException e) {
- String message =
- MessageFormat.format(Messages.DiscoveryView_MissingDirectoryURLError, key);
- Activator.logError(message, e);
- }
- return (String) properties.get(key);
- }
-
private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPage.java Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPage.java Fri Jul 16 15:39:47 2010 -0500
@@ -1,9 +1,5 @@
package com.nokia.carbide.internal.discovery.ui.view;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -13,12 +9,8 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.internal.p2.discovery.Catalog;
import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
import org.eclipse.equinox.internal.p2.discovery.compatibility.BundleDiscoveryStrategy;
@@ -42,7 +34,6 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -191,7 +182,7 @@
// look for remote descriptor
RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
- String url = getFromServerProperties(DIRECTORY_KEY);
+ String url = Activator.getFromServerProperties(DIRECTORY_KEY);
if (url != null) {
remoteDiscoveryStrategy.setDirectoryUrl(url);
catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
@@ -202,25 +193,6 @@
return catalog;
}
- public static String getFromServerProperties(String key) {
- Location installLocation = Platform.getInstallLocation();
- URL url = installLocation.getURL();
- IPath path = new Path(url.getPath());
- path = path.append("configuration/server.properties"); //$NON-NLS-1$
- File file = path.toFile();
- Properties properties = new Properties();
- try {
- InputStream is = new FileInputStream(file);
- properties.load(is);
- is.close();
- } catch (IOException e) {
- String message =
- MessageFormat.format(Messages.DiscoveryView_MissingDirectoryURLError, key);
- Activator.logError(message, e);
- }
- return (String) properties.get(key);
- }
-
private IAction[] makeActions(final IEditorPart part) {
selectionListeners = new ArrayList<ISelectionChangedListener>();
List<IAction> actions = new ArrayList<IAction>();
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java Fri Jul 16 14:42:52 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java Fri Jul 16 15:39:47 2010 -0500
@@ -1,16 +1,12 @@
package com.nokia.carbide.internal.discovery.ui.view;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IEditorPart;
import com.nokia.carbide.discovery.ui.Activator;
import com.nokia.carbide.discovery.ui.Messages;
-import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage;
+import com.nokia.carbide.internal.discovery.ui.extension.AbstractBrowserPortalPage;
-public class SupportPage implements IPortalPage {
+public class SupportPage extends AbstractBrowserPortalPage {
public SupportPage() {
}
@@ -25,24 +21,4 @@
return Activator.getImageDescriptor("icons/Carbide_c_icon_16x16.png"); //$NON-NLS-1$
}
- @Override
- public Control createControl(Composite parent, IEditorPart part) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- return composite;
- }
-
- @Override
- public void init() {
- }
-
- @Override
- public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) {
- return new IActionBar[0];
- }
-
- @Override
- public void dispose() {
- }
-
}