fixed headers/warnings
diff --git a/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/EMFStoreTransactionalCommandStack.java b/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/EMFStoreTransactionalCommandStack.java
index 9b0f9a7..ee0ad5f 100644
--- a/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/EMFStoreTransactionalCommandStack.java
+++ b/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/EMFStoreTransactionalCommandStack.java
@@ -33,7 +33,7 @@
private EMFStoreCommandNotifier notifier;
/**
- * Dafault Constructor.
+ * Default Constructor.
*/
public EMFStoreTransactionalCommandStack() {
notifier = new EMFStoreCommandNotifier();
@@ -140,4 +140,4 @@
public void removeCommandStackObserver(CommandObserver observer) {
notifier.removeCommandStackObserver(observer);
}
-}
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/TransactionalEditingDomainProvider.java b/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/TransactionalEditingDomainProvider.java
index 282ba17..5f6feaa 100644
--- a/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/TransactionalEditingDomainProvider.java
+++ b/org.eclipse.emf.emfstore.client.transaction/src/org/eclipse/emf/emfstore/client/transaction/TransactionalEditingDomainProvider.java
@@ -41,4 +41,4 @@
return domain;
}
-}
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/Activator.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/Activator.java
index 3d32f7b..958b6f0 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/Activator.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/Activator.java
@@ -1,63 +1,63 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * Activator class for the error reporting plugin.
- */
-public class Activator extends AbstractUIPlugin {
-
- /**
- * Error reporting plugin ID.
- */
- public static final String PLUGIN_ID = "org.eclipse.emf.emfstore.client.ui.errorreporting"; //$NON-NLS-1$
-
- private static Activator plugin;
-
- /**
- * Constructor.
- */
- public Activator() {
- }
-
- /**
- * {@inheritDoc}
- */
- // BEGIN SUPRESS CATCH EXCEPTION
- public void start(BundleContext context) throws Exception {
- // END SUPRESS CATCH EXCEPTION
- super.start(context);
- plugin = this;
- }
-
- /**
- * {@inheritDoc}
- */
- // BEGIN SUPRESS CATCH EXCEPTION
- public void stop(BundleContext context) throws Exception {
- // END SUPRESS CATCH EXCEPTION
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Activator class for the error reporting plugin.
+ */
+public class Activator extends AbstractUIPlugin {
+
+ /**
+ * Error reporting plugin ID.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.emf.emfstore.client.ui.errorreporting"; //$NON-NLS-1$
+
+ private static Activator plugin;
+
+ /**
+ * Constructor.
+ */
+ public Activator() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ // BEGIN SUPRESS CATCH EXCEPTION
+ public void start(BundleContext context) throws Exception {
+ // END SUPRESS CATCH EXCEPTION
+ super.start(context);
+ plugin = this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ // BEGIN SUPRESS CATCH EXCEPTION
+ public void stop(BundleContext context) throws Exception {
+ // END SUPRESS CATCH EXCEPTION
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/DefaultMailBugConfigurationProvider.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/DefaultMailBugConfigurationProvider.java
index f87a330..4f69dcd 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/DefaultMailBugConfigurationProvider.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/DefaultMailBugConfigurationProvider.java
@@ -1,63 +1,63 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.eclipse.emf.emfstore.common.CommonUtil;
-
-/**
- * Error reporting configuration provider with default values.<br/>
- * Only the E-Mail address must be configured.
- *
- * @author emueller
- *
- */
-public abstract class DefaultMailBugConfigurationProvider implements IMailBugConfigurationProvider {
-
- private static final String EMAIL_BODY = "Thank you for reporting this bug. Please help us to fix the problem by following these steps:\n\n"
- + "1. Give a summary\n"
- + "<Description>\n\n"
- + "2. Describe steps to reproduce the error\n"
- + "\t1. <Step 1>\n"
- + "\t2. <Step 2>\n\n";
-
- private static final String EMAIL_BODY_ADDITIONAL_TEXT =
- "3. Paste (Ctrl+v) the content of the clipboard below (parts of the log file have been copied to it)\n"
- + "\t<Content from Log File>";
-
- /**
- * {@inheritDoc}
- */
- public String getEmailSubject() {
- return "EMFStore Error Report";
- }
-
- /**
- * {@inheritDoc}
- */
- public String getEmailBody(boolean errorDiagnosisCaptured) {
-
- StringBuffer body = new StringBuffer(EMAIL_BODY);
-
- if (errorDiagnosisCaptured) {
- try {
- body.append(URLEncoder.encode(EMAIL_BODY_ADDITIONAL_TEXT, CommonUtil.getEncoding()));
- } catch (UnsupportedEncodingException e) {
- // ignore
- }
- }
-
- return body.toString();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.eclipse.emf.emfstore.common.CommonUtil;
+
+/**
+ * Error reporting configuration provider with default values.<br/>
+ * Only the E-Mail address must be configured.
+ *
+ * @author emueller
+ *
+ */
+public abstract class DefaultMailBugConfigurationProvider implements IMailBugConfigurationProvider {
+
+ private static final String EMAIL_BODY = "Thank you for reporting this bug. Please help us to fix the problem by following these steps:\n\n"
+ + "1. Give a summary\n"
+ + "<Description>\n\n"
+ + "2. Describe steps to reproduce the error\n"
+ + "\t1. <Step 1>\n"
+ + "\t2. <Step 2>\n\n";
+
+ private static final String EMAIL_BODY_ADDITIONAL_TEXT =
+ "3. Paste (Ctrl+v) the content of the clipboard below (parts of the log file have been copied to it)\n"
+ + "\t<Content from Log File>";
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getEmailSubject() {
+ return "EMFStore Error Report";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getEmailBody(boolean errorDiagnosisCaptured) {
+
+ StringBuffer body = new StringBuffer(EMAIL_BODY);
+
+ if (errorDiagnosisCaptured) {
+ try {
+ body.append(URLEncoder.encode(EMAIL_BODY_ADDITIONAL_TEXT, CommonUtil.getEncoding()));
+ } catch (UnsupportedEncodingException e) {
+ // ignore
+ }
+ }
+
+ return body.toString();
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreExceptionObserver.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreExceptionObserver.java
index 0cf6d6c..4459f1e 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreExceptionObserver.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreExceptionObserver.java
@@ -1,135 +1,135 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.emfstore.client.model.Configuration;
-import org.eclipse.emf.emfstore.client.model.exceptions.MissingCommandException;
-import org.eclipse.emf.emfstore.client.model.observers.ExceptionObserver;
-import org.eclipse.emf.emfstore.client.model.util.WorkspaceUtil;
-import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionPoint;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * An exception observer that collects logs.
- *
- * @author Maximilian Koegel
- */
-public class EmfStoreExceptionObserver implements ExceptionObserver {
-
- private static EmfStoreExceptionObserver instance;
- private Set<ExceptionLog> exceptionLogs;
- private Boolean enabled;
-
- /**
- * Constructor.
- */
- public EmfStoreExceptionObserver() {
- instance = this;
- exceptionLogs = new HashSet<ExceptionLog>();
- ExtensionPoint extensionPoint = new ExtensionPoint(Activator.PLUGIN_ID);
- enabled = extensionPoint.getBoolean("enabled", true);
- }
-
- /**
- * Returns the instance.
- *
- * @return the instance
- */
- public static EmfStoreExceptionObserver getInstance() {
- if (instance == null) {
- instance = new EmfStoreExceptionObserver();
- }
- return instance;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean handleError(RuntimeException e) {
-
- if (!enabled) {
- return false;
- }
-
- if (Configuration.isDebugMode()) {
-
- MailBugHandler bugHandler = new MailBugHandler();
-
- try {
- bugHandler.execute(new ExecutionEvent());
- } catch (ExecutionException exception) {
- WorkspaceUtil.handleException(exception);
- }
-
- ErrorDialog
- .openError(
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- "DEBUG MODE ACTIVE: An Error Occured",
- MessageFormat.format(
- "This error message only appears if debug mode is active. \n"
- + "Although this error message might be an error itself, it might help to find bugs faster. \n"
- + "The most recent log has been copied to the clipboard, please add it to the bug report. Thanks! \n"
- + "To disable, launch without {0}={1} switch.",
- Configuration.DEBUG_SWITCH, Configuration.DEBUG_SWITCH_ENABLED_VALUE),
- new Status(Status.ERROR, "org.eclipse.emf.emfstore.client", "An error occured.", e));
-
- throw e;
- }
-
- // MissingCommandException should only be logged if the debug switch is not set
- if (e.getCause() instanceof MissingCommandException) {
- return true;
- }
-
- for (ExceptionLog exceptionLog : exceptionLogs) {
- exceptionLog.addException(e);
- }
-
- return true;
- }
-
- /**
- * Adds a log.
- *
- * @param log
- * the log being added
- */
- public void addLog(ExceptionLog log) {
- exceptionLogs.add(log);
- }
-
- /**
- * Removes a log.
- *
- * @param log
- * the log to be removed
- */
- public void removeLog(ExceptionLog log) {
- exceptionLogs.remove(log);
- }
-
- /**
- * Returns the log.
- * @return the log
- */
- public ExceptionLog getLog() {
- return new ExceptionLog(this);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.emfstore.client.model.Configuration;
+import org.eclipse.emf.emfstore.client.model.exceptions.MissingCommandException;
+import org.eclipse.emf.emfstore.client.model.observers.ExceptionObserver;
+import org.eclipse.emf.emfstore.client.model.util.WorkspaceUtil;
+import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionPoint;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * An exception observer that collects logs.
+ *
+ * @author Maximilian Koegel
+ */
+public class EmfStoreExceptionObserver implements ExceptionObserver {
+
+ private static EmfStoreExceptionObserver instance;
+ private Set<ExceptionLog> exceptionLogs;
+ private Boolean enabled;
+
+ /**
+ * Constructor.
+ */
+ public EmfStoreExceptionObserver() {
+ instance = this;
+ exceptionLogs = new HashSet<ExceptionLog>();
+ ExtensionPoint extensionPoint = new ExtensionPoint(Activator.PLUGIN_ID);
+ enabled = extensionPoint.getBoolean("enabled", true);
+ }
+
+ /**
+ * Returns the instance.
+ *
+ * @return the instance
+ */
+ public static EmfStoreExceptionObserver getInstance() {
+ if (instance == null) {
+ instance = new EmfStoreExceptionObserver();
+ }
+ return instance;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean handleError(RuntimeException e) {
+
+ if (!enabled) {
+ return false;
+ }
+
+ if (Configuration.isDebugMode()) {
+
+ MailBugHandler bugHandler = new MailBugHandler();
+
+ try {
+ bugHandler.execute(new ExecutionEvent());
+ } catch (ExecutionException exception) {
+ WorkspaceUtil.handleException(exception);
+ }
+
+ ErrorDialog
+ .openError(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "DEBUG MODE ACTIVE: An Error Occured",
+ MessageFormat.format(
+ "This error message only appears if debug mode is active. \n"
+ + "Although this error message might be an error itself, it might help to find bugs faster. \n"
+ + "The most recent log has been copied to the clipboard, please add it to the bug report. Thanks! \n"
+ + "To disable, launch without {0}={1} switch.",
+ Configuration.DEBUG_SWITCH, Configuration.DEBUG_SWITCH_ENABLED_VALUE),
+ new Status(Status.ERROR, "org.eclipse.emf.emfstore.client", "An error occured.", e));
+
+ throw e;
+ }
+
+ // MissingCommandException should only be logged if the debug switch is not set
+ if (e.getCause() instanceof MissingCommandException) {
+ return true;
+ }
+
+ for (ExceptionLog exceptionLog : exceptionLogs) {
+ exceptionLog.addException(e);
+ }
+
+ return true;
+ }
+
+ /**
+ * Adds a log.
+ *
+ * @param log
+ * the log being added
+ */
+ public void addLog(ExceptionLog log) {
+ exceptionLogs.add(log);
+ }
+
+ /**
+ * Removes a log.
+ *
+ * @param log
+ * the log to be removed
+ */
+ public void removeLog(ExceptionLog log) {
+ exceptionLogs.remove(log);
+ }
+
+ /**
+ * Returns the log.
+ * @return the log
+ */
+ public ExceptionLog getLog() {
+ return new ExceptionLog(this);
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreStatusHandler.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreStatusHandler.java
index 730f4ed..885de2a 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreStatusHandler.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/EmfStoreStatusHandler.java
@@ -1,29 +1,29 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import org.eclipse.ui.statushandlers.WorkbenchErrorHandler;
-import org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager;
-
-/**
- * Status handler for enabling the submission of a bug via mail.
- *
- * @author Maximilian Koegel
- */
-public class EmfStoreStatusHandler extends WorkbenchErrorHandler {
-
- @Override
- protected void configureStatusDialog(WorkbenchStatusDialogManager statusDialog) {
- super.configureStatusDialog(statusDialog);
- statusDialog.enableDefaultSupportArea(true);
- statusDialog.setSupportAreaProvider(new MailBugStatusAreaProvider());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import org.eclipse.ui.statushandlers.WorkbenchErrorHandler;
+import org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager;
+
+/**
+ * Status handler for enabling the submission of a bug via mail.
+ *
+ * @author Maximilian Koegel
+ */
+public class EmfStoreStatusHandler extends WorkbenchErrorHandler {
+
+ @Override
+ protected void configureStatusDialog(WorkbenchStatusDialogManager statusDialog) {
+ super.configureStatusDialog(statusDialog);
+ statusDialog.enableDefaultSupportArea(true);
+ statusDialog.setSupportAreaProvider(new MailBugStatusAreaProvider());
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferencePage.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferencePage.java
index 913f9e3..0c031b7 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferencePage.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferencePage.java
@@ -1,90 +1,90 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.io.File;
-
-import org.eclipse.jface.preference.DirectoryFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-/**
- * Preference page for error reporting feature.
- *
- * @author emueller
- *
- */
-public class ErrorReportingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
- private DirectoryFieldEditor zipPathEditor;
-
- /**
- * Default constructor.
- */
- public ErrorReportingPreferencePage() {
+import java.io.File;
+
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * Preference page for error reporting feature.
+ *
+ * @author emueller
+ *
+ */
+public class ErrorReportingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ private DirectoryFieldEditor zipPathEditor;
+
+ /**
+ * Default constructor.
+ */
+ public ErrorReportingPreferencePage() {
super(GRID);
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(IWorkbench workbench) {
- setPreferenceStore(Activator.getDefault().getPreferenceStore());
- getPreferenceStore().setDefault(ErrorReportingPreferences.ZIP_PATH_KEY, ErrorReportingPreferences.ZIP_PATH_DEFAULT);
- }
-
-
- private boolean validateZipPath(String zipPath) {
- return new File(zipPath).exists();
- }
+ }
- /**
- * {@inheritDoc}
- */
- @Override
+ /**
+ * {@inheritDoc}
+ */
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ getPreferenceStore().setDefault(ErrorReportingPreferences.ZIP_PATH_KEY, ErrorReportingPreferences.ZIP_PATH_DEFAULT);
+ }
+
+
+ private boolean validateZipPath(String zipPath) {
+ return new File(zipPath).exists();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected void createFieldEditors() {
- zipPathEditor = new DirectoryFieldEditor(ErrorReportingPreferences.ZIP_PATH_KEY, "&Zip path:", getFieldEditorParent());
+ zipPathEditor = new DirectoryFieldEditor(ErrorReportingPreferences.ZIP_PATH_KEY, "&Zip path:", getFieldEditorParent());
addField(zipPathEditor);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void checkState() {
-
- super.checkState();
- boolean validZipPath = validateZipPath(zipPathEditor.getStringValue());
-
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void checkState() {
+
+ super.checkState();
+ boolean validZipPath = validateZipPath(zipPathEditor.getStringValue());
+
if (validZipPath) {
- setValid(true);
- setErrorMessage(null);
- } else {
- setValid(false);
+ setValid(true);
+ setErrorMessage(null);
+ } else {
+ setValid(false);
setErrorMessage("Invalid zip path. \n");
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void propertyChange(PropertyChangeEvent event) {
-
- if (event.getProperty().equals("field_editor_value")) {
- checkState();
- }
-
- }
-}
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+
+ if (event.getProperty().equals("field_editor_value")) {
+ checkState();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferences.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferences.java
index 6deab48..84bbc34 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferences.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingPreferences.java
@@ -1,46 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.io.File;
-import java.util.Arrays;
-
-import org.apache.commons.lang.StringUtils;
-
-/**
- * Preference keys and default values for error reporting feature.
- *
- * @author emueller
- *
- */
-public final class ErrorReportingPreferences {
-
- private ErrorReportingPreferences() {
-
- }
-
- /**
- * The qualifier of the preferences used by the error reporting feature.
- */
- public static final String QUALIFIER = "org.eclipse.emf.emfstore.client.ui.errorreporting";
-
- /**
- * Preference key for the zip path.
- */
- public static final String ZIP_PATH_KEY = "zipPath";
-
- /**
- * Default value for the zip path.
- */
- public static final String ZIP_PATH_DEFAULT = StringUtils.join(
- Arrays.asList(System.getProperty("user.home"), "Desktop"),
- File.separatorChar);
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.io.File;
+import java.util.Arrays;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Preference keys and default values for error reporting feature.
+ *
+ * @author emueller
+ *
+ */
+public final class ErrorReportingPreferences {
+
+ private ErrorReportingPreferences() {
+
+ }
+
+ /**
+ * The qualifier of the preferences used by the error reporting feature.
+ */
+ public static final String QUALIFIER = "org.eclipse.emf.emfstore.client.ui.errorreporting";
+
+ /**
+ * Preference key for the zip path.
+ */
+ public static final String ZIP_PATH_KEY = "zipPath";
+
+ /**
+ * Default value for the zip path.
+ */
+ public static final String ZIP_PATH_DEFAULT = StringUtils.join(
+ Arrays.asList(System.getProperty("user.home"), "Desktop"),
+ File.separatorChar);
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingUtil.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingUtil.java
index 5dab5a4..2af2f9d 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingUtil.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ErrorReportingUtil.java
@@ -1,357 +1,357 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.awt.AWTException;
-import java.awt.HeadlessException;
-import java.awt.Rectangle;
-import java.awt.Robot;
-import java.awt.Toolkit;
-import java.awt.image.BufferedImage;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import javax.imageio.ImageIO;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.commons.lang.StringUtils;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.emfstore.client.model.Configuration;
-import org.eclipse.emf.emfstore.client.model.util.WorkspaceUtil;
-import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionElement;
-import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionPoint;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.statushandlers.StatusAdapter;
-
-/**
- * Utility class for capturing system specific information for debugging purposes.
- *
- * @author emueller
- */
-public final class ErrorReportingUtil {
-
- private static final String CUSTOMLOG_EXTENSION_POINT_ID = "org.eclipse.emf.emfstore.client.ui.errorreporting";
- private static final String SCREENSHOT_FOLDER_NAME = "screenshots";
- private static final String DEFAULT_SCREENSHOT_PREFIX = "emfstore-screenshot-";
- private static final String DEFAULT_SYSINFO_PREFIX = "emfstore-sysinfo-";
- private static final String SYSINFO_SUFFIX = "txt";
-
- private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
-
- /**
- * Private constructor.
- */
- private ErrorReportingUtil() {
-
- }
-
- private static String getLogText() {
-
- String filename = Platform.getLogFileLocation().toOSString();
- File log = new File(filename);
-
- try {
- String version = Configuration.getClientVersion().getVersion();
- String logFileContent = FileUtils.readFileToString(log);
-
- StringBuffer result = new StringBuffer(16384);
- result.append(
- MessageFormat.format("EMFStore client {0}. Log copied at {1}\n\n",
- version, SimpleDateFormat.getDateTimeInstance().format(new Date())));
- result.append(logFileContent);
-
- return result.toString();
- } catch (IOException ex) {
- WorkspaceUtil.logException("Exception while copying log to clipboard", ex);
- }
-
- return null;
- }
-
- /**
- * Copies the content of the current log file to the clipboard.
- *
- * @param window
- * the window that is used to determine which Display to copy to
- */
- public static void copyLogToClipboard(IWorkbenchWindow window) {
- String text = getLogText();
- Clipboard clipboard = null;
-
- if (text == null) {
- return;
- }
-
- try {
- clipboard = new Clipboard(window.getShell().getDisplay());
- clipboard.setContents(new Object[] { text }, new Transfer[] { TextTransfer.getInstance() });
- } finally {
- if (clipboard != null) {
- clipboard.dispose();
- }
- }
- }
-
- /**
- * Creates the error diagnosis file.
- *
- * @param date
- * the date that will be written to the error diagnosis file in order to indicate when the
- * file was created
- * @param path
- * the parent path under which the error diagnosis file will be put
- * @param statusAdapter
- * a status adapter that may contain the most recent stack trace, that will be copied
- * into the error diagnosis file
- * @return the absolute path to the created error diagnosis file
- */
- public static String captureSysInfo(Date date, String path, StatusAdapter statusAdapter) {
-
- File temp = new File(path);
- FileWriter fileWriter = null;
- BufferedWriter bufferedWriter = null;
-
- temp.deleteOnExit();
-
- try {
- Runtime runtime = Runtime.getRuntime();
- RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
- fileWriter = new FileWriter(temp);
-
- bufferedWriter = new BufferedWriter(fileWriter);
- bufferedWriter.write(MessageFormat.format("Log file created on {0}\n", new Date()));
- bufferedWriter.write(MessageFormat.format("Client version: {0} {1}\n",
- Configuration.getClientVersion().getName(), Configuration.getClientVersion().getVersion()));
- bufferedWriter.write("List of open editors:\n");
-
- if (getOpenEditorIDs().size() == 0) {
- bufferedWriter.write("\t<None>\n");
- } else {
- for (String viewId : getOpenEditorIDs()) {
- bufferedWriter.write(MessageFormat.format("\t{0}\n", viewId));
- }
- }
-
- bufferedWriter.write(MessageFormat.format("Working directory: {0}",
- System.getProperty("user.dir")));
- bufferedWriter.write(MessageFormat.format("System user: {0}",
- System.getProperty("user.name")));
- bufferedWriter.write(MessageFormat.format("Memory usage: {0}/{1} MB",
- toMb(runtime.totalMemory() - runtime.freeMemory()), toMb(runtime.maxMemory())));
- bufferedWriter.write(MessageFormat.format("Available processors (cores): {0}\n",
- runtime.availableProcessors()));
- bufferedWriter.write(MessageFormat.format("Java version: {0}",
- System.getProperty("java.version")));
- bufferedWriter.write(MessageFormat.format("OS version: {0}",
- System.getProperty("os.version")));
- bufferedWriter.write("VM Startup parameters:\n");
-
- for (String vmArg : runtimeMXBean.getInputArguments()) {
- bufferedWriter.write(MessageFormat.format("\t{0}\n", vmArg));
- }
-
- ExtensionPoint extPoint = new ExtensionPoint(CUSTOMLOG_EXTENSION_POINT_ID);
- for (ExtensionElement el : extPoint.getExtensionElements()) {
- ILoggable loggable = el.getClass("loggableClass", ILoggable.class);
-
- if (loggable == null) {
- continue;
- }
-
- bufferedWriter.write(loggable.getLoggable());
- }
-
- if (statusAdapter != null) {
- bufferedWriter.write(MessageFormat.format("Stacktrace: {0}\n", getStatus(statusAdapter)));
- }
-
- return temp.getAbsolutePath();
- } catch (IOException e) {
- WorkspaceUtil.logException("Error while writing error diagnosis file: ", e);
- } finally {
- try {
- if (bufferedWriter != null) {
- bufferedWriter.close();
- }
-
- if (fileWriter != null) {
- fileWriter.close();
- }
- } catch (IOException e) {
- WorkspaceUtil.logException("Error while closing error diagnosis stream.", e);
- }
- }
-
- return null;
- }
-
- /**
- * Creates the error diagnosis file.
- *
- * @param date
- * the date that will be written to the error diagnosis file in order to indicate when the
- * file was created
- * @param path
- * the parent path under which the error diagnosis file will be put
- * @return the absolute path to the created error diagnosis file
- */
- public static String captureSysInfo(Date date, String path) {
- return captureSysInfo(date, path, null);
- }
-
- /**
- * Returns a list of strings containing the IDs of all opened editors.
- *
- * @return a list of strings containing the IDs of all opened editors
- */
- private static List<String> getOpenEditorIDs() {
-
- List<String> openedEditors = new ArrayList<String>();
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-
- for (IEditorReference editorRef : activePage.getEditorReferences()) {
- openedEditors.add(editorRef.getId());
- }
-
- return openedEditors;
- }
-
- private static String getStatus(StatusAdapter statusAdapter) {
- StringBuilder sb = new StringBuilder();
- addException(sb, statusAdapter.getStatus());
- String logText = sb.toString();
- if (logText == null || logText.length() == 0) {
- logText = "Could not find exception";
- }
- return logText;
- }
-
-
- private static void addException(StringBuilder collector, IStatus iStatus) {
- if (iStatus instanceof MultiStatus) {
- MultiStatus ms = (MultiStatus) iStatus;
- IStatus[] children = ms.getChildren();
- for (IStatus childStatus : children) {
- addException(collector, childStatus);
- }
- } else {
- Throwable ex = iStatus.getException();
- if (ex != null) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintWriter pw = new PrintWriter(baos);
- ex.printStackTrace(pw);
- pw.flush();
- collector.append(new String(baos.toByteArray()));
- }
- }
- }
-
- private static int toMb(long value) {
- return (int) (value / 1024 / 1024);
- }
-
- /**
- * Returns the path to the file that contains error diagnosis and system specific information.
- *
- * @param date
- * the date to be used as a part of the constructed path
- * @return the constructed path
- */
- public static String getSysInfoPath(Date date) {
- String errorDiagnosisFilename = DEFAULT_SYSINFO_PREFIX + formatDate(date) + "." + SYSINFO_SUFFIX;
- return StringUtils.join(Arrays.asList(Configuration.getErrorLogDirectory(), errorDiagnosisFilename),
- File.separatorChar);
- }
-
- /**
- * Formats the given date.
- * @param date
- * the date to be formatted
- * @return the formatted date
- */
- public static String formatDate(Date date) {
- return format.format(date);
- }
-
- /**
- * Takes a screenshot.
- * @param screenshotPath
- * the path under which the screenshot will be put
- * @param format
- * the format of the screenshot being created
- * @return the path to the taken screenshot
- */
- public static String makeScreenshot(String screenshotPath, ScreenshotFormat format) {
-
- try {
- BufferedImage bufferedImage = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit()
- .getScreenSize()));
- File temp = new File(screenshotPath);
- temp.deleteOnExit();
- ImageIO.write(bufferedImage, format.getType(), temp);
- return temp.getAbsolutePath();
- } catch (HeadlessException e) {
- WorkspaceUtil.logException("Could not create screenshot.", e);
- } catch (AWTException e) {
- WorkspaceUtil.logException("Could not create screenshot.", e);
- } catch (IOException e) {
- WorkspaceUtil.logException("Could not create screenshot.", e);
- }
-
- return null;
- }
-
- /**
- * Returns the screenshot path.
- * @param date
- * the date that will be part of the screenshot name
- * @param format
- * the format of the screenshot
- * @return the constructed path to the screenshot
- */
- public static String getScreenshotPath(Date date, ScreenshotFormat format) {
- String screenShotFilename = DEFAULT_SCREENSHOT_PREFIX + formatDate(date) + "." + format.getType();
- return StringUtils.join(Arrays.asList(getScreenshotFolder(), screenShotFilename),
- File.separatorChar);
- }
-
-
- private static String getScreenshotFolder() {
- File screenshotDir = new File(StringUtils.join(Arrays.asList(Configuration.getErrorLogDirectory(),
- SCREENSHOT_FOLDER_NAME), File.separatorChar));
-
- if (!screenshotDir.exists()) {
- screenshotDir.mkdir();
- }
-
- return screenshotDir.getAbsolutePath();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.awt.AWTException;
+import java.awt.HeadlessException;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.image.BufferedImage;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.emfstore.client.model.Configuration;
+import org.eclipse.emf.emfstore.client.model.util.WorkspaceUtil;
+import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionElement;
+import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionPoint;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+
+/**
+ * Utility class for capturing system specific information for debugging purposes.
+ *
+ * @author emueller
+ */
+public final class ErrorReportingUtil {
+
+ private static final String CUSTOMLOG_EXTENSION_POINT_ID = "org.eclipse.emf.emfstore.client.ui.errorreporting";
+ private static final String SCREENSHOT_FOLDER_NAME = "screenshots";
+ private static final String DEFAULT_SCREENSHOT_PREFIX = "emfstore-screenshot-";
+ private static final String DEFAULT_SYSINFO_PREFIX = "emfstore-sysinfo-";
+ private static final String SYSINFO_SUFFIX = "txt";
+
+ private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
+
+ /**
+ * Private constructor.
+ */
+ private ErrorReportingUtil() {
+
+ }
+
+ private static String getLogText() {
+
+ String filename = Platform.getLogFileLocation().toOSString();
+ File log = new File(filename);
+
+ try {
+ String version = Configuration.getClientVersion().getVersion();
+ String logFileContent = FileUtils.readFileToString(log);
+
+ StringBuffer result = new StringBuffer(16384);
+ result.append(
+ MessageFormat.format("EMFStore client {0}. Log copied at {1}\n\n",
+ version, SimpleDateFormat.getDateTimeInstance().format(new Date())));
+ result.append(logFileContent);
+
+ return result.toString();
+ } catch (IOException ex) {
+ WorkspaceUtil.logException("Exception while copying log to clipboard", ex);
+ }
+
+ return null;
+ }
+
+ /**
+ * Copies the content of the current log file to the clipboard.
+ *
+ * @param window
+ * the window that is used to determine which Display to copy to
+ */
+ public static void copyLogToClipboard(IWorkbenchWindow window) {
+ String text = getLogText();
+ Clipboard clipboard = null;
+
+ if (text == null) {
+ return;
+ }
+
+ try {
+ clipboard = new Clipboard(window.getShell().getDisplay());
+ clipboard.setContents(new Object[] { text }, new Transfer[] { TextTransfer.getInstance() });
+ } finally {
+ if (clipboard != null) {
+ clipboard.dispose();
+ }
+ }
+ }
+
+ /**
+ * Creates the error diagnosis file.
+ *
+ * @param date
+ * the date that will be written to the error diagnosis file in order to indicate when the
+ * file was created
+ * @param path
+ * the parent path under which the error diagnosis file will be put
+ * @param statusAdapter
+ * a status adapter that may contain the most recent stack trace, that will be copied
+ * into the error diagnosis file
+ * @return the absolute path to the created error diagnosis file
+ */
+ public static String captureSysInfo(Date date, String path, StatusAdapter statusAdapter) {
+
+ File temp = new File(path);
+ FileWriter fileWriter = null;
+ BufferedWriter bufferedWriter = null;
+
+ temp.deleteOnExit();
+
+ try {
+ Runtime runtime = Runtime.getRuntime();
+ RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
+ fileWriter = new FileWriter(temp);
+
+ bufferedWriter = new BufferedWriter(fileWriter);
+ bufferedWriter.write(MessageFormat.format("Log file created on {0}\n", new Date()));
+ bufferedWriter.write(MessageFormat.format("Client version: {0} {1}\n",
+ Configuration.getClientVersion().getName(), Configuration.getClientVersion().getVersion()));
+ bufferedWriter.write("List of open editors:\n");
+
+ if (getOpenEditorIDs().size() == 0) {
+ bufferedWriter.write("\t<None>\n");
+ } else {
+ for (String viewId : getOpenEditorIDs()) {
+ bufferedWriter.write(MessageFormat.format("\t{0}\n", viewId));
+ }
+ }
+
+ bufferedWriter.write(MessageFormat.format("Working directory: {0}",
+ System.getProperty("user.dir")));
+ bufferedWriter.write(MessageFormat.format("System user: {0}",
+ System.getProperty("user.name")));
+ bufferedWriter.write(MessageFormat.format("Memory usage: {0}/{1} MB",
+ toMb(runtime.totalMemory() - runtime.freeMemory()), toMb(runtime.maxMemory())));
+ bufferedWriter.write(MessageFormat.format("Available processors (cores): {0}\n",
+ runtime.availableProcessors()));
+ bufferedWriter.write(MessageFormat.format("Java version: {0}",
+ System.getProperty("java.version")));
+ bufferedWriter.write(MessageFormat.format("OS version: {0}",
+ System.getProperty("os.version")));
+ bufferedWriter.write("VM Startup parameters:\n");
+
+ for (String vmArg : runtimeMXBean.getInputArguments()) {
+ bufferedWriter.write(MessageFormat.format("\t{0}\n", vmArg));
+ }
+
+ ExtensionPoint extPoint = new ExtensionPoint(CUSTOMLOG_EXTENSION_POINT_ID);
+ for (ExtensionElement el : extPoint.getExtensionElements()) {
+ ILoggable loggable = el.getClass("loggableClass", ILoggable.class);
+
+ if (loggable == null) {
+ continue;
+ }
+
+ bufferedWriter.write(loggable.getLoggable());
+ }
+
+ if (statusAdapter != null) {
+ bufferedWriter.write(MessageFormat.format("Stacktrace: {0}\n", getStatus(statusAdapter)));
+ }
+
+ return temp.getAbsolutePath();
+ } catch (IOException e) {
+ WorkspaceUtil.logException("Error while writing error diagnosis file: ", e);
+ } finally {
+ try {
+ if (bufferedWriter != null) {
+ bufferedWriter.close();
+ }
+
+ if (fileWriter != null) {
+ fileWriter.close();
+ }
+ } catch (IOException e) {
+ WorkspaceUtil.logException("Error while closing error diagnosis stream.", e);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates the error diagnosis file.
+ *
+ * @param date
+ * the date that will be written to the error diagnosis file in order to indicate when the
+ * file was created
+ * @param path
+ * the parent path under which the error diagnosis file will be put
+ * @return the absolute path to the created error diagnosis file
+ */
+ public static String captureSysInfo(Date date, String path) {
+ return captureSysInfo(date, path, null);
+ }
+
+ /**
+ * Returns a list of strings containing the IDs of all opened editors.
+ *
+ * @return a list of strings containing the IDs of all opened editors
+ */
+ private static List<String> getOpenEditorIDs() {
+
+ List<String> openedEditors = new ArrayList<String>();
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ for (IEditorReference editorRef : activePage.getEditorReferences()) {
+ openedEditors.add(editorRef.getId());
+ }
+
+ return openedEditors;
+ }
+
+ private static String getStatus(StatusAdapter statusAdapter) {
+ StringBuilder sb = new StringBuilder();
+ addException(sb, statusAdapter.getStatus());
+ String logText = sb.toString();
+ if (logText == null || logText.length() == 0) {
+ logText = "Could not find exception";
+ }
+ return logText;
+ }
+
+
+ private static void addException(StringBuilder collector, IStatus iStatus) {
+ if (iStatus instanceof MultiStatus) {
+ MultiStatus ms = (MultiStatus) iStatus;
+ IStatus[] children = ms.getChildren();
+ for (IStatus childStatus : children) {
+ addException(collector, childStatus);
+ }
+ } else {
+ Throwable ex = iStatus.getException();
+ if (ex != null) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(baos);
+ ex.printStackTrace(pw);
+ pw.flush();
+ collector.append(new String(baos.toByteArray()));
+ }
+ }
+ }
+
+ private static int toMb(long value) {
+ return (int) (value / 1024 / 1024);
+ }
+
+ /**
+ * Returns the path to the file that contains error diagnosis and system specific information.
+ *
+ * @param date
+ * the date to be used as a part of the constructed path
+ * @return the constructed path
+ */
+ public static String getSysInfoPath(Date date) {
+ String errorDiagnosisFilename = DEFAULT_SYSINFO_PREFIX + formatDate(date) + "." + SYSINFO_SUFFIX;
+ return StringUtils.join(Arrays.asList(Configuration.getErrorLogDirectory(), errorDiagnosisFilename),
+ File.separatorChar);
+ }
+
+ /**
+ * Formats the given date.
+ * @param date
+ * the date to be formatted
+ * @return the formatted date
+ */
+ public static String formatDate(Date date) {
+ return format.format(date);
+ }
+
+ /**
+ * Takes a screenshot.
+ * @param screenshotPath
+ * the path under which the screenshot will be put
+ * @param format
+ * the format of the screenshot being created
+ * @return the path to the taken screenshot
+ */
+ public static String makeScreenshot(String screenshotPath, ScreenshotFormat format) {
+
+ try {
+ BufferedImage bufferedImage = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit()
+ .getScreenSize()));
+ File temp = new File(screenshotPath);
+ temp.deleteOnExit();
+ ImageIO.write(bufferedImage, format.getType(), temp);
+ return temp.getAbsolutePath();
+ } catch (HeadlessException e) {
+ WorkspaceUtil.logException("Could not create screenshot.", e);
+ } catch (AWTException e) {
+ WorkspaceUtil.logException("Could not create screenshot.", e);
+ } catch (IOException e) {
+ WorkspaceUtil.logException("Could not create screenshot.", e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the screenshot path.
+ * @param date
+ * the date that will be part of the screenshot name
+ * @param format
+ * the format of the screenshot
+ * @return the constructed path to the screenshot
+ */
+ public static String getScreenshotPath(Date date, ScreenshotFormat format) {
+ String screenShotFilename = DEFAULT_SCREENSHOT_PREFIX + formatDate(date) + "." + format.getType();
+ return StringUtils.join(Arrays.asList(getScreenshotFolder(), screenShotFilename),
+ File.separatorChar);
+ }
+
+
+ private static String getScreenshotFolder() {
+ File screenshotDir = new File(StringUtils.join(Arrays.asList(Configuration.getErrorLogDirectory(),
+ SCREENSHOT_FOLDER_NAME), File.separatorChar));
+
+ if (!screenshotDir.exists()) {
+ screenshotDir.mkdir();
+ }
+
+ return screenshotDir.getAbsolutePath();
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ExceptionLog.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ExceptionLog.java
index 16c2abd..c75b380 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ExceptionLog.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ExceptionLog.java
@@ -1,57 +1,57 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class for logging exceptions.
- *
- * @author Maximilian Koegel
- */
-public class ExceptionLog {
-
- private List<Exception> exceptions;
- private EmfStoreExceptionObserver exceptionObserver;
-
- /**
- * Constructor.
- *
- * @param exceptionObserver
- * the exception that is used to notify this class when to add exceptions
- */
- public ExceptionLog(EmfStoreExceptionObserver exceptionObserver) {
- this.exceptions = new ArrayList<Exception>();
- this.exceptionObserver = exceptionObserver;
- exceptionObserver.addLog(this);
- }
-
- /**
- * Adds and exception to the log.
- *
- * @param exception
- * the exception to be added
- */
- public void addException(Exception exception) {
- exceptions.add(exception);
- }
-
- /**
- * Destroys the exception log.
- *
- * @return the list of collected exceptions
- */
- public List<Exception> destroy() {
- exceptionObserver.removeLog(this);
- return exceptions;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class for logging exceptions.
+ *
+ * @author Maximilian Koegel
+ */
+public class ExceptionLog {
+
+ private List<Exception> exceptions;
+ private EmfStoreExceptionObserver exceptionObserver;
+
+ /**
+ * Constructor.
+ *
+ * @param exceptionObserver
+ * the exception that is used to notify this class when to add exceptions
+ */
+ public ExceptionLog(EmfStoreExceptionObserver exceptionObserver) {
+ this.exceptions = new ArrayList<Exception>();
+ this.exceptionObserver = exceptionObserver;
+ exceptionObserver.addLog(this);
+ }
+
+ /**
+ * Adds and exception to the log.
+ *
+ * @param exception
+ * the exception to be added
+ */
+ public void addException(Exception exception) {
+ exceptions.add(exception);
+ }
+
+ /**
+ * Destroys the exception log.
+ *
+ * @return the list of collected exceptions
+ */
+ public List<Exception> destroy() {
+ exceptionObserver.removeLog(this);
+ return exceptions;
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ILoggable.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ILoggable.java
index 869b0b9..c675447 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ILoggable.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ILoggable.java
@@ -1,27 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-/**
- * Interface for adding information to the error diagnosis and system information file that
- * is created via {@link ErrorReportingUtil#captureSysInfo(java.util.Date, String)}.
- *
- * @author emueller
- */
-public interface ILoggable {
-
- /**
- * Returns the string to be logged.
- *
- * @return the string to be logged
- */
- String getLoggable();
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+/**
+ * Interface for adding information to the error diagnosis and system information file that
+ * is created via {@link ErrorReportingUtil#captureSysInfo(java.util.Date, String)}.
+ *
+ * @author emueller
+ */
+public interface ILoggable {
+
+ /**
+ * Returns the string to be logged.
+ *
+ * @return the string to be logged
+ */
+ String getLoggable();
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/IMailBugConfigurationProvider.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/IMailBugConfigurationProvider.java
index 0fe2ca7..6d8346b 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/IMailBugConfigurationProvider.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/IMailBugConfigurationProvider.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-/**
- * Interface used for error reporting feature.
- *
- * @author emueller
- *
- */
-public interface IMailBugConfigurationProvider {
-
- /**
- * Returns the E-Mail address used for error reporting.
- *
- * @return the E-Mail address
- */
- String getEmailAddress();
-
- /**
- * Returns the E-Mail subject used within the error reporting feature.
- *
- * @return the E-Mail subject
- */
- String getEmailSubject();
-
- /**
- * Returns the E-Mail body text used within the error reporting feature.
- *
- * @param errorDiagnosisCaptured
- * whether error diagnosis information has been captured
- *
- * @return the E-Mail message body
- */
- String getEmailBody(boolean errorDiagnosisCaptured);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+/**
+ * Interface used for error reporting feature.
+ *
+ * @author emueller
+ *
+ */
+public interface IMailBugConfigurationProvider {
+
+ /**
+ * Returns the E-Mail address used for error reporting.
+ *
+ * @return the E-Mail address
+ */
+ String getEmailAddress();
+
+ /**
+ * Returns the E-Mail subject used within the error reporting feature.
+ *
+ * @return the E-Mail subject
+ */
+ String getEmailSubject();
+
+ /**
+ * Returns the E-Mail body text used within the error reporting feature.
+ *
+ * @param errorDiagnosisCaptured
+ * whether error diagnosis information has been captured
+ *
+ * @return the E-Mail message body
+ */
+ String getEmailBody(boolean errorDiagnosisCaptured);
+
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/LogFilenameFilter.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/LogFilenameFilter.java
index 1aa923a..f48d11e 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/LogFilenameFilter.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/LogFilenameFilter.java
@@ -1,27 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-/**
- * Filter for log files.
- */
-public class LogFilenameFilter implements FilenameFilter {
-
- /**
- * {@inheritDoc}
- */
- public boolean accept(File file, String name) {
- return name.toLowerCase().endsWith(".log");
- }
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * Filter for log files.
+ */
+public class LogFilenameFilter implements FilenameFilter {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean accept(File file, String name) {
+ return name.toLowerCase().endsWith(".log");
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugHandler.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugHandler.java
index f60b027..1c4a147 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugHandler.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugHandler.java
@@ -1,274 +1,274 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Date;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.emfstore.client.model.Configuration;
-import org.eclipse.emf.emfstore.client.model.util.WorkspaceUtil;
-import org.eclipse.emf.emfstore.common.CommonUtil;
-import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionPoint;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWebBrowser;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-import org.eclipse.ui.progress.IProgressService;
-import org.eclipse.ui.statushandlers.StatusAdapter;
-
-/**
- * Handler for submitting a bug via mail.
- *
- * @author emueller
- */
-public class MailBugHandler extends AbstractHandler implements IWorkbenchWindowActionDelegate {
-
- private IWorkbenchWindow window;
- private StatusAdapter statusAdapter;
- private IMailBugConfigurationProvider configurationProvider;
-
- /**
- * Constructor.
- */
- public MailBugHandler() {
- this.window = null;
- this.statusAdapter = null;
- initConfigurationProvider();
- }
-
- /**
- * Constructor.
- * @param window
- * a window that is used to determine the shell
- * @param statusAdapter
- * a status adapter that may contain the most recent stack trace
- */
- public MailBugHandler(IWorkbenchWindow window, StatusAdapter statusAdapter) {
- this.window = window;
- this.statusAdapter = statusAdapter;
- initConfigurationProvider();
- }
-
- private void initConfigurationProvider() {
- ExtensionPoint extensionPoint = new ExtensionPoint(Activator.PLUGIN_ID);
- configurationProvider = extensionPoint.getClass("providerClass", IMailBugConfigurationProvider.class);
- if (configurationProvider == null) {
- throw new IllegalStateException("Error reporting configuration provider extension point not configured");
- }
- }
-
- private void archive(final Date currentDate, IProgressMonitor monitor, String[] paths)
- throws FileNotFoundException {
- monitor.beginTask("Creating error report...", paths.length);
- try {
- ZipHandle zipHandle = ZipHandle.openZipHandle(getZipPathname(currentDate));
-
- for (String path : paths) {
- File file = new File(path);
-
- if (!file.exists()) {
- continue;
- }
-
- if (file.isDirectory()) {
- zipHandle.addFile(StringUtils.EMPTY, path + "/");
- } else {
- zipHandle.addFile(StringUtils.EMPTY, path);
- }
-
- monitor.worked(1);
- }
-
- zipHandle.close();
- } catch (IOException e) {
- MessageDialog.openError(window.getShell(), "Error while creating zip",
- MessageFormat.format("An error occurred while trying to archive the workspace folder {0}: {1}",
- Configuration.getErrorLogDirectory(), e.getMessage()));
- }
-
- monitor.done();
- }
-
- private String getZipPathname(Date currentDate) {
- String zipPath = Platform.getPreferencesService().getString(ErrorReportingPreferences.QUALIFIER,
- ErrorReportingPreferences.ZIP_PATH_KEY, ErrorReportingPreferences.ZIP_PATH_DEFAULT, null);
-
- if (zipPath.endsWith(File.separator)) {
- zipPath = zipPath.substring(0, zipPath.length() - 2);
- }
-
- return StringUtils.join(Arrays.asList(zipPath, ZipHandle.ZIP_PREFIX + ErrorReportingUtil.formatDate(currentDate) + ".zip"),
- File.separatorChar);
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(IWorkbenchWindow window) {
- this.window = window;
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(IAction action, ISelection selection) {
-
- }
-
- /**
- * Display an error message.
- */
- private void openWebBrowserError(final String href, final Throwable t) {
- String title = "Send Bug Report";
- String msg = "Unable to open URL " + href + " exception: " + t.getLocalizedMessage();
- MessageDialog.openError(window.getShell(), title, msg);
- }
-
- /**
- * {@inheritDoc}
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- final Date date = new Date();
- boolean shouldCaptureErrorDiagnosis = openShouldCreateErrorReportDialog(date);
-
- if (shouldCaptureErrorDiagnosis) {
- IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
- try {
- progressService.run(false, false, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- String screenshotPath = ErrorReportingUtil.makeScreenshot(
- ErrorReportingUtil.getScreenshotPath(date, ScreenshotFormat.JPG), ScreenshotFormat.JPG);
- String sysInfoPath = ErrorReportingUtil.captureSysInfo(date, ErrorReportingUtil.getSysInfoPath(date), statusAdapter);
- IPath logFolder = Platform.getLogFileLocation().removeLastSegments(1);
- String[] logFiles = getLogFilePaths(logFolder);
-
- archive(date, monitor, (String[]) ArrayUtils.addAll(new String[] { screenshotPath, sysInfoPath, Configuration.getWorkspaceDirectory() },
- logFiles));
- } catch (FileNotFoundException exception) {
- WorkspaceUtil.logException("Could not capture error diagnosis information.", exception);
- }
- }
-
- });
- } catch (InvocationTargetException exception) {
- WorkspaceUtil.logException("Could not capture error diagnosis information.", exception);
- } catch (InterruptedException exception) {
- WorkspaceUtil.logException("Could not capture error diagnosis information.", exception);
- }
- }
-
- ErrorReportingUtil.copyLogToClipboard(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
-
- String url;
-
- try {
- url = buildUrl(shouldCaptureErrorDiagnosis);
- } catch (UnsupportedEncodingException e) {
- MessageDialog.openError(window.getShell(), "Could not create E-Mail", e.getMessage());
- return null;
- }
-
- IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
-
- try {
- IWebBrowser browser = support.getExternalBrowser();
- browser.openURL(new URL(url));
- } catch (MalformedURLException exception) {
- openWebBrowserError(url, exception);
- } catch (PartInitException exception) {
- openWebBrowserError(url, exception);
- }
-
- return null;
- }
-
- private String buildUrl(boolean shouldCaptureErrorDiagnosis) throws UnsupportedEncodingException {
-
- StringBuffer url = new StringBuffer("mailto:");
- String email = configurationProvider.getEmailAddress();
- String subject = configurationProvider.getEmailSubject();
- String body = configurationProvider.getEmailBody(shouldCaptureErrorDiagnosis);
-
- url.append(email + "?");
- url.append("subject=" + URLEncoder.encode(subject, CommonUtil.getEncoding()) + "&");
- url.append("body=" + URLEncoder.encode(body.toString(), CommonUtil.getEncoding()));
-
- return url.toString();
- }
-
- private String[] getLogFilePaths(IPath logFolder) {
- String[] logFiles = new File(logFolder.toOSString()).list(new LogFilenameFilter());
-
- for (int i = 0; i < logFiles.length; i++) {
- logFiles[i] = logFolder.toOSString() + File.separatorChar + logFiles[i];
- }
-
- return logFiles;
- }
-
- private boolean openShouldCreateErrorReportDialog(final Date date) {
- return MessageDialog.openQuestion(window == null ? Display.getDefault().getActiveShell() : window.getShell(),
- "Error diagnosis information capture", MessageFormat.format("Would you like to capture error diagnosis information?\n"
- + "The data will be stored in a zip file under \"{0}\".",
- getZipPathname(date)));
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(IAction action) {
- execute();
- }
-
- /**
- * Executes the handler.
- */
- public void execute() {
- try {
- execute(new ExecutionEvent());
- } catch (ExecutionException e) {
- WorkspaceUtil.logException(e.getMessage(), e);
- }
- }
-
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.Date;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.emfstore.client.model.Configuration;
+import org.eclipse.emf.emfstore.client.model.util.WorkspaceUtil;
+import org.eclipse.emf.emfstore.common.CommonUtil;
+import org.eclipse.emf.emfstore.common.extensionpoint.ExtensionPoint;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.progress.IProgressService;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+
+/**
+ * Handler for submitting a bug via mail.
+ *
+ * @author emueller
+ */
+public class MailBugHandler extends AbstractHandler implements IWorkbenchWindowActionDelegate {
+
+ private IWorkbenchWindow window;
+ private StatusAdapter statusAdapter;
+ private IMailBugConfigurationProvider configurationProvider;
+
+ /**
+ * Constructor.
+ */
+ public MailBugHandler() {
+ this.window = null;
+ this.statusAdapter = null;
+ initConfigurationProvider();
+ }
+
+ /**
+ * Constructor.
+ * @param window
+ * a window that is used to determine the shell
+ * @param statusAdapter
+ * a status adapter that may contain the most recent stack trace
+ */
+ public MailBugHandler(IWorkbenchWindow window, StatusAdapter statusAdapter) {
+ this.window = window;
+ this.statusAdapter = statusAdapter;
+ initConfigurationProvider();
+ }
+
+ private void initConfigurationProvider() {
+ ExtensionPoint extensionPoint = new ExtensionPoint(Activator.PLUGIN_ID);
+ configurationProvider = extensionPoint.getClass("providerClass", IMailBugConfigurationProvider.class);
+ if (configurationProvider == null) {
+ throw new IllegalStateException("Error reporting configuration provider extension point not configured");
+ }
+ }
+
+ private void archive(final Date currentDate, IProgressMonitor monitor, String[] paths)
+ throws FileNotFoundException {
+ monitor.beginTask("Creating error report...", paths.length);
+ try {
+ ZipHandle zipHandle = ZipHandle.openZipHandle(getZipPathname(currentDate));
+
+ for (String path : paths) {
+ File file = new File(path);
+
+ if (!file.exists()) {
+ continue;
+ }
+
+ if (file.isDirectory()) {
+ zipHandle.addFile(StringUtils.EMPTY, path + "/");
+ } else {
+ zipHandle.addFile(StringUtils.EMPTY, path);
+ }
+
+ monitor.worked(1);
+ }
+
+ zipHandle.close();
+ } catch (IOException e) {
+ MessageDialog.openError(window.getShell(), "Error while creating zip",
+ MessageFormat.format("An error occurred while trying to archive the workspace folder {0}: {1}",
+ Configuration.getErrorLogDirectory(), e.getMessage()));
+ }
+
+ monitor.done();
+ }
+
+ private String getZipPathname(Date currentDate) {
+ String zipPath = Platform.getPreferencesService().getString(ErrorReportingPreferences.QUALIFIER,
+ ErrorReportingPreferences.ZIP_PATH_KEY, ErrorReportingPreferences.ZIP_PATH_DEFAULT, null);
+
+ if (zipPath.endsWith(File.separator)) {
+ zipPath = zipPath.substring(0, zipPath.length() - 2);
+ }
+
+ return StringUtils.join(Arrays.asList(zipPath, ZipHandle.ZIP_PREFIX + ErrorReportingUtil.formatDate(currentDate) + ".zip"),
+ File.separatorChar);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+
+ }
+
+ /**
+ * Display an error message.
+ */
+ private void openWebBrowserError(final String href, final Throwable t) {
+ String title = "Send Bug Report";
+ String msg = "Unable to open URL " + href + " exception: " + t.getLocalizedMessage();
+ MessageDialog.openError(window.getShell(), title, msg);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ final Date date = new Date();
+ boolean shouldCaptureErrorDiagnosis = openShouldCreateErrorReportDialog(date);
+
+ if (shouldCaptureErrorDiagnosis) {
+ IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
+ try {
+ progressService.run(false, false, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ String screenshotPath = ErrorReportingUtil.makeScreenshot(
+ ErrorReportingUtil.getScreenshotPath(date, ScreenshotFormat.JPG), ScreenshotFormat.JPG);
+ String sysInfoPath = ErrorReportingUtil.captureSysInfo(date, ErrorReportingUtil.getSysInfoPath(date), statusAdapter);
+ IPath logFolder = Platform.getLogFileLocation().removeLastSegments(1);
+ String[] logFiles = getLogFilePaths(logFolder);
+
+ archive(date, monitor, (String[]) ArrayUtils.addAll(new String[] { screenshotPath, sysInfoPath, Configuration.getWorkspaceDirectory() },
+ logFiles));
+ } catch (FileNotFoundException exception) {
+ WorkspaceUtil.logException("Could not capture error diagnosis information.", exception);
+ }
+ }
+
+ });
+ } catch (InvocationTargetException exception) {
+ WorkspaceUtil.logException("Could not capture error diagnosis information.", exception);
+ } catch (InterruptedException exception) {
+ WorkspaceUtil.logException("Could not capture error diagnosis information.", exception);
+ }
+ }
+
+ ErrorReportingUtil.copyLogToClipboard(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+
+ String url;
+
+ try {
+ url = buildUrl(shouldCaptureErrorDiagnosis);
+ } catch (UnsupportedEncodingException e) {
+ MessageDialog.openError(window.getShell(), "Could not create E-Mail", e.getMessage());
+ return null;
+ }
+
+ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
+
+ try {
+ IWebBrowser browser = support.getExternalBrowser();
+ browser.openURL(new URL(url));
+ } catch (MalformedURLException exception) {
+ openWebBrowserError(url, exception);
+ } catch (PartInitException exception) {
+ openWebBrowserError(url, exception);
+ }
+
+ return null;
+ }
+
+ private String buildUrl(boolean shouldCaptureErrorDiagnosis) throws UnsupportedEncodingException {
+
+ StringBuffer url = new StringBuffer("mailto:");
+ String email = configurationProvider.getEmailAddress();
+ String subject = configurationProvider.getEmailSubject();
+ String body = configurationProvider.getEmailBody(shouldCaptureErrorDiagnosis);
+
+ url.append(email + "?");
+ url.append("subject=" + URLEncoder.encode(subject, CommonUtil.getEncoding()) + "&");
+ url.append("body=" + URLEncoder.encode(body.toString(), CommonUtil.getEncoding()));
+
+ return url.toString();
+ }
+
+ private String[] getLogFilePaths(IPath logFolder) {
+ String[] logFiles = new File(logFolder.toOSString()).list(new LogFilenameFilter());
+
+ for (int i = 0; i < logFiles.length; i++) {
+ logFiles[i] = logFolder.toOSString() + File.separatorChar + logFiles[i];
+ }
+
+ return logFiles;
+ }
+
+ private boolean openShouldCreateErrorReportDialog(final Date date) {
+ return MessageDialog.openQuestion(window == null ? Display.getDefault().getActiveShell() : window.getShell(),
+ "Error diagnosis information capture", MessageFormat.format("Would you like to capture error diagnosis information?\n"
+ + "The data will be stored in a zip file under \"{0}\".",
+ getZipPathname(date)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run(IAction action) {
+ execute();
+ }
+
+ /**
+ * Executes the handler.
+ */
+ public void execute() {
+ try {
+ execute(new ExecutionEvent());
+ } catch (ExecutionException e) {
+ WorkspaceUtil.logException(e.getMessage(), e);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugStatusAreaProvider.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugStatusAreaProvider.java
index f5e2232..845a320 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugStatusAreaProvider.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/MailBugStatusAreaProvider.java
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.statushandlers.AbstractStatusAreaProvider;
-import org.eclipse.ui.statushandlers.StatusAdapter;
-
-/**
- * Status area provider for sending a bug report via mail.
- *
- * @author Maximilian Koegel
- *
- */
-public class MailBugStatusAreaProvider extends AbstractStatusAreaProvider {
-
- /**
- * {@inheritDoc}
- */
- public Control createSupportArea(final Composite parent, final StatusAdapter statusAdapter) {
- Link link = new Link(parent, SWT.NONE);
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- final MailBugHandler bugHandler = new MailBugHandler(window, statusAdapter);
- link.setText("Please <a>send us a bug report</a>. Clicking\nthe link will create a new mail with\nyour default mail program. Before\nsending the mail please follow the\ninstructions in the mail body.");
- link.setToolTipText("Mail a bug report");
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- bugHandler.execute();
- }
- });
- Dialog.applyDialogFont(link);
- return parent;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.statushandlers.AbstractStatusAreaProvider;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+
+/**
+ * Status area provider for sending a bug report via mail.
+ *
+ * @author Maximilian Koegel
+ *
+ */
+public class MailBugStatusAreaProvider extends AbstractStatusAreaProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Control createSupportArea(final Composite parent, final StatusAdapter statusAdapter) {
+ Link link = new Link(parent, SWT.NONE);
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ final MailBugHandler bugHandler = new MailBugHandler(window, statusAdapter);
+ link.setText("Please <a>send us a bug report</a>. Clicking\nthe link will create a new mail with\nyour default mail program. Before\nsending the mail please follow the\ninstructions in the mail body.");
+ link.setToolTipText("Mail a bug report");
+ link.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ bugHandler.execute();
+ }
+ });
+ Dialog.applyDialogFont(link);
+ return parent;
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ScreenshotFormat.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ScreenshotFormat.java
index 6cba162..c2f3b5f 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ScreenshotFormat.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ScreenshotFormat.java
@@ -1,46 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-/**
- * Represents the format of a screenshot.
- *
- * @author emueller
- *
- */
-public enum ScreenshotFormat {
-
- /**
- * JPG format.
- */
- JPG("jpg");
-
- private final String type;
-
- /**
- * Constructor.
- *
- * @param type
- * the format type
- */
- ScreenshotFormat(String type) {
- this.type = type;
- }
-
- /**
- * Returns the format type as a string.
- * @return the format type as a string
- */
- public String getType() {
- return type;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+/**
+ * Represents the format of a screenshot.
+ *
+ * @author emueller
+ *
+ */
+public enum ScreenshotFormat {
+
+ /**
+ * JPG format.
+ */
+ JPG("jpg");
+
+ private final String type;
+
+ /**
+ * Constructor.
+ *
+ * @param type
+ * the format type
+ */
+ ScreenshotFormat(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns the format type as a string.
+ * @return the format type as a string
+ */
+ public String getType() {
+ return type;
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ZipHandle.java b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ZipHandle.java
index d76b5e9..3cff70f 100644
--- a/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ZipHandle.java
+++ b/org.eclipse.emf.emfstore.client.ui.errorreporting/src/org/eclipse/emf/emfstore/client/ui/errorreporting/ZipHandle.java
@@ -1,141 +1,141 @@
-/*******************************************************************************
- * Copyright (c) 2008-2012 EclipseSource Muenchen 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:
- ******************************************************************************/
-package org.eclipse.emf.emfstore.client.ui.errorreporting;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.apache.commons.io.IOUtils;
-
-/**
- * A zip handle for creating zip files.
- *
- * @author emueller
- */
-public final class ZipHandle {
-
- /**
- * The prefix that will be used as part of the zip file.
- */
- public static final String ZIP_PREFIX = "EMFStoreErrorLog_";
-
- private final ZipOutputStream zipOutputStream;
- private final FileOutputStream fileOutputStream;
- private final BufferedOutputStream bufferedOutputStream;
-
- private ZipHandle(FileOutputStream fileOutputStream, BufferedOutputStream bufferedOutputStream,
- ZipOutputStream zipOutputStream) {
- this.fileOutputStream = fileOutputStream;
- this.bufferedOutputStream = bufferedOutputStream;
- this.zipOutputStream = zipOutputStream;
- }
-
- /**
- * Adds a file to the zip.
- *
- * @param base
- * the base name of the file being added
- * @param path
- * the actual path of file to be added to the zip
- * @throws IOException in case the file could not be added
- */
- public void addFile(String base, String path) throws IOException {
-
- if (path == null) {
- return;
- }
-
- addFileToZip(zipOutputStream, path, base);
- }
-
- /**
- * Closes the handle.
- *
- * @throws IOException in case anything goes wrong during the closing of the handle
- */
- public void close() throws IOException {
- if (zipOutputStream != null) {
- zipOutputStream.finish();
- zipOutputStream.close();
- }
-
- if (bufferedOutputStream != null) {
- bufferedOutputStream.close();
- }
-
- if (fileOutputStream != null) {
- fileOutputStream.close();
- }
- }
-
- /**
- * Creates a zip entry for the path specified with a name built from the base passed in and the file/directory
- * name. If the path is a directory, a recursive call is made such that the full directory is added to the zip.
- *
- * @param zipOutputStream
- * the zip file's output stream
- * @param path
- * the filesystem path of the file/directory being added
- * @param base
- * the base prefix to for the name of the zip file entry
- *
- * @throws IOException in case of an error during addition of the file to the zip
- */
- private void addFileToZip(ZipOutputStream zipOutputStream, String path, String base) throws IOException {
- File file = new File(path);
- String entryName = base + file.getName();
- ZipEntry zipEntry = new ZipEntry(entryName);
-
-
- if (file.isFile()) {
- zipOutputStream.putNextEntry(zipEntry);
- FileInputStream fileInputStream = null;
- try {
- fileInputStream = new FileInputStream(file);
- IOUtils.copy(fileInputStream, zipOutputStream);
- } finally {
- }
- } else {
- File[] children = file.listFiles();
-
- if (children != null) {
- for (File child : children) {
- addFileToZip(zipOutputStream, child.getAbsolutePath(), entryName + "/");
- }
- }
- }
- }
-
- /**
- * Opens up a zip handle.
- * @param zipPath
- * the path of the zip file being created
- * @return the created zip handle
- * @throws FileNotFoundException in case intial zip file creation fails
- */
- public static ZipHandle openZipHandle(String zipPath) throws FileNotFoundException {
- FileOutputStream fileOutputStream = null;
- BufferedOutputStream bufferedOutputStream = null;
- ZipOutputStream zipOutputStream = null;
-
- fileOutputStream = new FileOutputStream(new File(zipPath));
- bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
- zipOutputStream = new ZipOutputStream(bufferedOutputStream);
- ZipHandle zipHandle = new ZipHandle(fileOutputStream, bufferedOutputStream, zipOutputStream);
- return zipHandle;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Muenchen 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:
+ ******************************************************************************/
+package org.eclipse.emf.emfstore.client.ui.errorreporting;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.commons.io.IOUtils;
+
+/**
+ * A zip handle for creating zip files.
+ *
+ * @author emueller
+ */
+public final class ZipHandle {
+
+ /**
+ * The prefix that will be used as part of the zip file.
+ */
+ public static final String ZIP_PREFIX = "EMFStoreErrorLog_";
+
+ private final ZipOutputStream zipOutputStream;
+ private final FileOutputStream fileOutputStream;
+ private final BufferedOutputStream bufferedOutputStream;
+
+ private ZipHandle(FileOutputStream fileOutputStream, BufferedOutputStream bufferedOutputStream,
+ ZipOutputStream zipOutputStream) {
+ this.fileOutputStream = fileOutputStream;
+ this.bufferedOutputStream = bufferedOutputStream;
+ this.zipOutputStream = zipOutputStream;
+ }
+
+ /**
+ * Adds a file to the zip.
+ *
+ * @param base
+ * the base name of the file being added
+ * @param path
+ * the actual path of file to be added to the zip
+ * @throws IOException in case the file could not be added
+ */
+ public void addFile(String base, String path) throws IOException {
+
+ if (path == null) {
+ return;
+ }
+
+ addFileToZip(zipOutputStream, path, base);
+ }
+
+ /**
+ * Closes the handle.
+ *
+ * @throws IOException in case anything goes wrong during the closing of the handle
+ */
+ public void close() throws IOException {
+ if (zipOutputStream != null) {
+ zipOutputStream.finish();
+ zipOutputStream.close();
+ }
+
+ if (bufferedOutputStream != null) {
+ bufferedOutputStream.close();
+ }
+
+ if (fileOutputStream != null) {
+ fileOutputStream.close();
+ }
+ }
+
+ /**
+ * Creates a zip entry for the path specified with a name built from the base passed in and the file/directory
+ * name. If the path is a directory, a recursive call is made such that the full directory is added to the zip.
+ *
+ * @param zipOutputStream
+ * the zip file's output stream
+ * @param path
+ * the filesystem path of the file/directory being added
+ * @param base
+ * the base prefix to for the name of the zip file entry
+ *
+ * @throws IOException in case of an error during addition of the file to the zip
+ */
+ private void addFileToZip(ZipOutputStream zipOutputStream, String path, String base) throws IOException {
+ File file = new File(path);
+ String entryName = base + file.getName();
+ ZipEntry zipEntry = new ZipEntry(entryName);
+
+
+ if (file.isFile()) {
+ zipOutputStream.putNextEntry(zipEntry);
+ FileInputStream fileInputStream = null;
+ try {
+ fileInputStream = new FileInputStream(file);
+ IOUtils.copy(fileInputStream, zipOutputStream);
+ } finally {
+ }
+ } else {
+ File[] children = file.listFiles();
+
+ if (children != null) {
+ for (File child : children) {
+ addFileToZip(zipOutputStream, child.getAbsolutePath(), entryName + "/");
+ }
+ }
+ }
+ }
+
+ /**
+ * Opens up a zip handle.
+ * @param zipPath
+ * the path of the zip file being created
+ * @return the created zip handle
+ * @throws FileNotFoundException in case intial zip file creation fails
+ */
+ public static ZipHandle openZipHandle(String zipPath) throws FileNotFoundException {
+ FileOutputStream fileOutputStream = null;
+ BufferedOutputStream bufferedOutputStream = null;
+ ZipOutputStream zipOutputStream = null;
+
+ fileOutputStream = new FileOutputStream(new File(zipPath));
+ bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
+ zipOutputStream = new ZipOutputStream(bufferedOutputStream);
+ ZipHandle zipHandle = new ZipHandle(fileOutputStream, bufferedOutputStream, zipOutputStream);
+ return zipHandle;
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Activator.java b/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Activator.java
index 1395287..2339927 100644
--- a/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Activator.java
+++ b/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Activator.java
@@ -1,8 +1,8 @@
/*******************************************************************************
- * Copyright 2011 Chair for Applied Software Engineering,
+ * Copyright (c) 2008-2011 Chair for Applied Software Engineering,
* Technische Universitaet Muenchen.
* All rights reserved. This program and the accompanying materials
- * are made available under the Eclipse Public License v1.0
+ * 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
*
@@ -60,4 +60,4 @@
return plugin;
}
-}
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Application.java b/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Application.java
index 66a0a00..7c96d06 100644
--- a/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Application.java
+++ b/org.eclipse.emf.emfstore.example.helloworld/src/org/eclipse/emf/emfstore/exampleclient/Application.java
@@ -1,8 +1,8 @@
/*******************************************************************************
- * Copyright 2011 Chair for Applied Software Engineering,
+ * Copyright (c) 2008-2011 Chair for Applied Software Engineering,
* Technische Universitaet Muenchen.
* All rights reserved. This program and the accompanying materials
- * are made available under the Eclipse Public License v1.0
+ * 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
*
@@ -188,4 +188,4 @@
*/
public void stop() {
}
-}
+}
\ No newline at end of file