Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-31 11:36:46 +0000
committerEike Stepper2007-07-31 11:36:46 +0000
commit03826566585a2727fdb4979d96480f5f99232ee5 (patch)
tree8e870e6eb01f5c161e031ee55004c2032e4c062e
parent5d3c732134cb081daf89c5b6a1ad85bd0641777d (diff)
downloadcdo-03826566585a2727fdb4979d96480f5f99232ee5.tar.gz
cdo-03826566585a2727fdb4979d96480f5f99232ee5.tar.xz
cdo-03826566585a2727fdb4979d96480f5f99232ee5.zip
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java3
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java7
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java51
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java145
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryTextDialog.java (renamed from plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java)6
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java79
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java156
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java33
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java1
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java74
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java45
14 files changed, 530 insertions, 79 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
index 477c4f044d..c2cb186175 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
@@ -14,7 +14,7 @@ import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.net4j.internal.util.collection.PreferenceHistory;
-import org.eclipse.net4j.ui.widgets.HistoryInputDialog;
+import org.eclipse.net4j.ui.widgets.HistoryTextDialog;
import org.eclipse.net4j.util.collection.IHistory;
import org.eclipse.emf.ecore.EPackage;
@@ -45,7 +45,7 @@ public class RegisterCDOPackageAction extends RegisterPackageAction
{
Shell shell = page.getWorkbenchWindow().getShell();
IInputValidator validator = new EPackageFactoryValidator();
- InputDialog dialog = new HistoryInputDialog(shell, TITLE, "Enter a package URI:", HISTORY, validator);
+ InputDialog dialog = new HistoryTextDialog(shell, TITLE, "Enter a package URI:", HISTORY, validator);
if (dialog.open() == InputDialog.OK)
{
String uri = dialog.getValue();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
index b7d04d661b..7b9f7d595c 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
@@ -66,9 +66,12 @@ public abstract class OM
*/
public static final class Activator extends OSGiActivator
{
+ public static Activator INSTANCE;
+
public Activator()
{
super(BUNDLE);
+ INSTANCE = this;
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
index 9e649af3a1..b0dd3f4ff4 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
@@ -188,9 +188,6 @@ public class PackageManagerDialog extends TitleAreaDialog
return cdoPackage.isDynamic() ? "DYNAMIC" : "STATIC";
}
- /**
- * TODO Extend TableViewer
- */
private void addColumn(Table table, String title, int width, int alignment)
{
TableColumn column = new TableColumn(table, alignment);
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java
index 6e33616710..35354812c1 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java
@@ -10,9 +10,9 @@
**************************************************************************/
package org.eclipse.net4j.internal.ui.bundle;
+import org.eclipse.net4j.ui.UIActivator;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.log.OMLogger;
import org.eclipse.net4j.util.om.pref.OMPreference;
import org.eclipse.net4j.util.om.pref.OMPreferences;
@@ -38,11 +38,14 @@ public abstract class OM
/**
* @author Eike Stepper
*/
- public static final class Activator extends OSGiActivator
+ public static final class Activator extends UIActivator
{
+ public static Activator INSTANCE;
+
public Activator()
{
super(BUNDLE);
+ INSTANCE = this;
}
}
}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java
new file mode 100644
index 0000000000..1bf81d21ad
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.ui;
+
+import org.eclipse.net4j.internal.util.om.OSGiBundle;
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OSGiActivator;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Eike Stepper
+ */
+public class UIActivator extends AbstractUIPlugin
+{
+ private OMBundle omBundle;
+
+ public UIActivator(OMBundle omBundle)
+ {
+ this.omBundle = omBundle;
+ }
+
+ public final OMBundle getOMBundle()
+ {
+ return omBundle;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception
+ {
+ OSGiActivator.startBundle(context, (OSGiBundle)getOMBundle());
+ super.start(context);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception
+ {
+ super.stop(context);
+ OSGiActivator.stopBundle(context, (OSGiBundle)getOMBundle());
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java
new file mode 100644
index 0000000000..61bf5c54bf
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java
@@ -0,0 +1,145 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.ui.widgets;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class BaseDialog<VIEWER extends Viewer> extends TitleAreaDialog
+{
+ public static final int DEFAULT_SHELL_STYLE = SWT.SHELL_TRIM;
+
+ private String title;
+
+ private String message;
+
+ private IDialogSettings settings;
+
+ private VIEWER currentViewer;
+
+ private MenuManager contextMenu;
+
+ public BaseDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings)
+ {
+ super(parentShell);
+ setShellStyle(shellStyle);
+ this.title = title;
+ this.message = message;
+ this.settings = settings;
+ }
+
+ public BaseDialog(Shell parentShell, String title, String message, IDialogSettings settings)
+ {
+ this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(title);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ setTitle(title);
+ setMessage(message);
+
+ contextMenu = new MenuManager("#PopupMenu");
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(new IMenuListener()
+ {
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ VIEWER viewer = getCurrentViewer();
+ if (viewer != null)
+ {
+ fillContextMenu(manager, viewer);
+ }
+ }
+ });
+
+ createUI(composite);
+ return composite;
+ }
+
+ protected abstract void createUI(Composite parent);
+
+ public VIEWER getCurrentViewer()
+ {
+ return currentViewer;
+ }
+
+ public void setCurrentViewer(VIEWER currentViewer)
+ {
+ if (this.currentViewer != null)
+ {
+ Control control = this.currentViewer.getControl();
+ control.setMenu(null);
+ }
+
+ this.currentViewer = currentViewer;
+ if (this.currentViewer != null)
+ {
+ Control control = this.currentViewer.getControl();
+ Menu menu = contextMenu.createContextMenu(control);
+ control.setMenu(menu);
+ }
+ }
+
+ protected void hookContextMenu()
+ {
+ contextMenu = new MenuManager("#PopupMenu");
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(new IMenuListener()
+ {
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ fillContextMenu(manager, getCurrentViewer());
+ }
+ });
+ }
+
+ protected void fillContextMenu(IMenuManager manager, VIEWER viewer)
+ {
+ }
+
+ @Override
+ protected IDialogSettings getDialogBoundsSettings()
+ {
+ if (settings == null)
+ {
+ return null;
+ }
+
+ IDialogSettings section = settings.getSection(title);
+ if (section == null)
+ {
+ section = settings.addNewSection(title);
+ }
+
+ return section;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryTextDialog.java
index c69221869a..558e7ab402 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryTextDialog.java
@@ -27,9 +27,11 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
+ * TODO extend BaseDialog
+ *
* @author Eike Stepper
*/
-public class HistoryInputDialog extends InputDialog
+public class HistoryTextDialog extends InputDialog
{
private static final String EMPTY = "";
@@ -39,7 +41,7 @@ public class HistoryInputDialog extends InputDialog
private HistoryText historyText;
- public HistoryInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, IHistory<String> history,
+ public HistoryTextDialog(Shell parentShell, String dialogTitle, String dialogMessage, IHistory<String> history,
IInputValidator validator)
{
super(parentShell, dialogTitle, dialogMessage, history.getMostRecent(), validator);
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java
new file mode 100644
index 0000000000..75c446c626
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.ui.widgets;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Eike Stepper
+ */
+public class LogDialog extends BaseDialog
+{
+ private String log;
+
+ private Text text;
+
+ private Font font;
+
+ public LogDialog(Shell parentShell, int shellStyle, String title, String message, String log, IDialogSettings settings)
+ {
+ super(parentShell, shellStyle, title, message, settings);
+ this.log = log;
+ }
+
+ public LogDialog(Shell parentShell, String title, String message, String log, IDialogSettings settings)
+ {
+ this(parentShell, DEFAULT_SHELL_STYLE, title, message, log, settings);
+ }
+
+ @Override
+ public boolean close()
+ {
+ font.dispose();
+ return super.close();
+ }
+
+ @Override
+ protected void createUI(Composite parent)
+ {
+ GridLayout grid = new GridLayout();
+ grid.marginTop = 6;
+ grid.marginLeft = 6;
+ grid.marginRight = 6;
+ grid.marginBottom = 6;
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(grid);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ font = new Font(getShell().getDisplay(), "Courier", 8, SWT.NORMAL);
+
+ text = new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ text.setText(log);
+ text.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ text.setFont(font);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java
new file mode 100644
index 0000000000..6be3f2dd28
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java
@@ -0,0 +1,156 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.ui.widgets;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.om.monitor.IMessageHandler;
+import org.eclipse.net4j.util.om.monitor.MonitorUtil;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * @author Eike Stepper
+ */
+public class MonitorDialog extends ProgressMonitorDialog
+{
+ public static final int DEFAULT_SHELL_STYLE = SWT.SHELL_TRIM;
+
+ private String title;
+
+ private Exception exception;
+
+ private StringBuilder log = new StringBuilder();
+
+ private IMessageHandler logHandler = new IMessageHandler()
+ {
+ public void handleMessage(String msg, int level)
+ {
+ // for (int i = 0; i < level; i++)
+ // {
+ // log.append(" ");
+ // }
+
+ log.append(msg);
+ log.append("\n");
+ }
+ };
+
+ private IDialogSettings settings;
+
+ public MonitorDialog(Shell parentShell, int shellStyle, String title, IDialogSettings settings)
+ {
+ super(parentShell);
+ setShellStyle(shellStyle);
+ this.title = title;
+ this.settings = settings;
+ }
+
+ public MonitorDialog(Shell parentShell, String title, IDialogSettings settings)
+ {
+ this(parentShell, DEFAULT_SHELL_STYLE, title, settings);
+ }
+
+ public void run(boolean fork, boolean cancelable, final Runnable runnable)
+ {
+ try
+ {
+ super.run(fork, cancelable, new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ MonitorUtil.Eclipse.startMonitoring(monitor, logHandler);
+ try
+ {
+ runnable.run();
+ }
+ catch (RuntimeException ex)
+ {
+ exception = WrappedException.unwrap(ex);
+ log.append(exception.getMessage());
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ exception.printStackTrace(new PrintStream(bytes));
+ log.append(bytes);
+ }
+ finally
+ {
+ MonitorUtil.Eclipse.stopMonitoring();
+ }
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ @Override
+ protected void finishedRun()
+ {
+ super.finishedRun();
+ if (exception != null)
+ {
+ new LogDialog(getShell(), getShellStyle(), "Aborted " + title, "An error occured. See the log for details.", log
+ .toString(), settings).open();
+ }
+ else if (log.length() != 0)
+ {
+ new LogDialog(getShell(), getShellStyle(), "Finished " + title,
+ "The operation finished successfully. See the log for details.", log.toString(), settings).open();
+ }
+ else
+ {
+ MessageDialog.openInformation(getShell(), "Finished " + title, "The operation finished successfully.");
+ }
+ }
+
+ @Override
+ @Deprecated
+ public final void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
+ throws InvocationTargetException, InterruptedException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(title);
+ }
+
+ @Override
+ protected IDialogSettings getDialogBoundsSettings()
+ {
+ if (settings == null)
+ {
+ return null;
+ }
+
+ IDialogSettings section = settings.getSection(title);
+ if (section == null)
+ {
+ section = settings.addNewSection(title);
+ }
+
+ return section;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java
index 8bc99f421a..236ae6eda4 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java
@@ -16,7 +16,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
/**
* @author Eike Stepper
*/
-public final class EclipseMonitor extends Monitor
+public class EclipseMonitor extends Monitor
{
private IProgressMonitor progressMonitor;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java
index 2ba11a05b6..4a757cfab4 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java
@@ -10,20 +10,14 @@
**************************************************************************/
package org.eclipse.net4j.internal.util.om.monitor;
-import org.eclipse.net4j.internal.util.bundle.OM;
-import org.eclipse.net4j.util.om.monitor.IMessageHandler;
-
/**
* @author Eike Stepper
*/
-public final class LegacyMonitor extends Monitor
+public class LegacyMonitor extends Monitor
{
- private IMessageHandler messageHandler;
-
- public LegacyMonitor(IMessageHandler messageHandler)
+ public LegacyMonitor()
{
super(null, 0);
- this.messageHandler = messageHandler;
}
private LegacyMonitor(LegacyMonitor parent, int workFromParent)
@@ -36,27 +30,4 @@ public final class LegacyMonitor extends Monitor
{
return new LegacyMonitor(this, workFromParent);
}
-
- @Override
- protected void message(String msg, int level)
- {
- if (getParent() != null)
- {
- super.message(msg, level);
- }
- else
- {
- if (messageHandler != null)
- {
- try
- {
- messageHandler.handleMessage(msg, level);
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
- }
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java
index 3a93d4c6d6..8c2e1b8aea 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java
@@ -68,7 +68,6 @@ public abstract class Monitor implements OMMonitor, OMSubMonitor
public void setTask(String task)
{
this.task = task;
- message(task);
}
public int getTotalWork()
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java
index 76a1244695..a65011de8c 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java
@@ -35,8 +35,47 @@ public abstract class OSGiActivator implements BundleActivator
public void start(BundleContext context) throws Exception
{
+ startBundle(context, (OSGiBundle)getOMBundle());
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ stopBundle(context, (OSGiBundle)getOMBundle());
+ }
+
+ @Override
+ public final boolean equals(Object obj)
+ {
+ return super.equals(obj);
+ }
+
+ @Override
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ @Override
+ public final String toString()
+ {
+ return super.toString();
+ }
+
+ @Override
+ protected final Object clone() throws CloneNotSupportedException
+ {
+ return super.clone();
+ }
+
+ @Override
+ protected final void finalize() throws Throwable
+ {
+ super.finalize();
+ }
+
+ public static void startBundle(BundleContext context, OSGiBundle bundle) throws Error, Exception
+ {
OM.Activator.traceStart(context);
- OSGiBundle bundle = (OSGiBundle)getOMBundle();
if (bundle == null)
{
throw new IllegalStateException("bundle == null");
@@ -59,10 +98,9 @@ public abstract class OSGiActivator implements BundleActivator
}
}
- public void stop(BundleContext context) throws Exception
+ public static void stopBundle(BundleContext context, OSGiBundle bundle) throws Error, Exception
{
OM.Activator.traceStop(context);
- OSGiBundle bundle = (OSGiBundle)getOMBundle();
if (bundle == null)
{
throw new IllegalStateException("bundle == null");
@@ -84,34 +122,4 @@ public abstract class OSGiActivator implements BundleActivator
throw ex;
}
}
-
- @Override
- public final boolean equals(Object obj)
- {
- return super.equals(obj);
- }
-
- @Override
- public final int hashCode()
- {
- return super.hashCode();
- }
-
- @Override
- public final String toString()
- {
- return super.toString();
- }
-
- @Override
- protected final Object clone() throws CloneNotSupportedException
- {
- return super.clone();
- }
-
- @Override
- protected final void finalize() throws Throwable
- {
- super.finalize();
- }
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java
index d5f06e9de0..bba88c0d37 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.util.om.monitor;
+import org.eclipse.net4j.internal.util.bundle.OM;
import org.eclipse.net4j.internal.util.om.monitor.EclipseMonitor;
import org.eclipse.net4j.internal.util.om.monitor.LegacyMonitor;
import org.eclipse.net4j.internal.util.om.monitor.MON;
@@ -45,14 +46,42 @@ public final class MonitorUtil
return MON.begin(totalWork, task);
}
+ static void handleMessage(final IMessageHandler messageHandler, String msg, int level)
+ {
+ if (messageHandler != null)
+ {
+ try
+ {
+ messageHandler.handleMessage(msg, level);
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+
/**
* @author Eike Stepper
*/
public static final class Eclipse
{
+ public static void startMonitoring(IProgressMonitor progressMonitor, final IMessageHandler messageHandler)
+ {
+ MON.startMonitoring(new EclipseMonitor(progressMonitor)
+ {
+ @Override
+ protected void message(String msg, int level)
+ {
+ super.message(msg, level);
+ handleMessage(messageHandler, msg, level);
+ }
+ });
+ }
+
public static void startMonitoring(IProgressMonitor progressMonitor)
{
- MON.startMonitoring(new EclipseMonitor(progressMonitor));
+ startMonitoring(null);
}
public static void stopMonitoring()
@@ -66,14 +95,22 @@ public final class MonitorUtil
*/
public static final class Legacy
{
- public static void startMonitoring(IMessageHandler messageHandler)
+ public static void startMonitoring(final IMessageHandler messageHandler)
{
- MON.startMonitoring(new LegacyMonitor(messageHandler));
+ MON.startMonitoring(new LegacyMonitor()
+ {
+ @Override
+ protected void message(String msg, int level)
+ {
+ super.message(msg, level);
+ handleMessage(messageHandler, msg, level);
+ }
+ });
}
public static void startMonitoring()
{
- MON.startMonitoring(new LegacyMonitor(null));
+ startMonitoring(null);
}
public static void stopMonitoring()

Back to the top