Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java5
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/Messages.java1
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/messages.properties1
-rw-r--r--org.eclipse.jubula.client.cmd/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/AbstractCmdlineClient.java7
-rw-r--r--org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/batch/ProgressController.java41
-rw-r--r--org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/progess/HeadlessProgressMonitor.java44
-rw-r--r--org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/progess/HeadlessProgressProvider.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ImportProjectHandler.java)22
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java2
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties4
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Hibernator.java256
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/JobChangeListener.java63
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/ResultStatus.java67
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/DatabaseStateDispatcher.java (renamed from org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ProgressEventDispatcher.java)42
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/DatabaseStateEvent.java45
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IDatabaseStateListener.java (renamed from org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IProgressListener.java)14
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ProgressEvent.java88
-rw-r--r--org.eclipse.jubula.client.ui/plugin.xml20
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/Plugin.java30
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ImportFileBP.java172
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ToolkitBP.java7
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/CommandIDs.java3
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/PMExceptionHandler.java2
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/ProgressController.java315
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java7
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/extensions/ProjectPropertyExtensionHandler.java2
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AbstractTestResultViewHandler.java6
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AddTestResultSummaryCommentHandler.java2
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshTestresultsHandler.java31
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/SelectDatabaseHandler.java227
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ToggleRelevanceHandler.java2
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractProjectHandler.java49
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/DeleteProjectHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/DeleteProjectHandler.java)33
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ExportAllHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExportAllHandler.java)60
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ExportProjectHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExportProjectHandler.java)15
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ImportProjectHandler.java81
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/NewProjectHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/NewProjectHandler.java)44
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/OpenProjectHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/OpenProjectHandler.java)421
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ProjectPropertiesHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ProjectPropertiesHandler.java)8
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/RefreshProjectHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshProjectHandler.java)7
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/SaveProjectAsHandler.java (renamed from org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/SaveProjectAsHandler.java)11
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/SelectDatabaseHandler.java154
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java4
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties4
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/sourceprovider/ActiveProjectSourceProvider.java15
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/JBThread.java73
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java2
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/problemview/JBMarkerResolutionGenerator.java2
48 files changed, 975 insertions, 1537 deletions
diff --git a/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java b/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java
index c585079f5..88f64b94b 100644
--- a/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java
+++ b/org.eclipse.jubula.app.cmd/src/org/eclipse/jubula/app/cmd/batch/ExecutionController.java
@@ -28,7 +28,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.jubula.app.cmd.i18n.Messages;
import org.eclipse.jubula.client.cmd.AbstractCmdlineClient;
-import org.eclipse.jubula.client.cmd.batch.ProgressController;
import org.eclipse.jubula.client.cmd.controller.IClcServer;
import org.eclipse.jubula.client.cmd.controller.intern.RmiBase;
import org.eclipse.jubula.client.core.AUTEvent;
@@ -66,7 +65,6 @@ import org.eclipse.jubula.client.core.model.ReentryProperty;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
import org.eclipse.jubula.client.core.persistence.Hibernator;
import org.eclipse.jubula.client.core.persistence.ProjectPM;
-import org.eclipse.jubula.client.core.utils.ProgressEventDispatcher;
import org.eclipse.jubula.toolkit.common.exception.ToolkitPluginException;
import org.eclipse.jubula.tools.constants.AutConfigConstants;
import org.eclipse.jubula.tools.constants.StringConstants;
@@ -286,8 +284,6 @@ public class ExecutionController implements IAUTServerEventListener,
/** process for watching test execution */
private TestExecutionWatcher m_progress = new TestExecutionWatcher();
- /** controller to listen to db connection progress */
- private ProgressController m_progressController = new ProgressController();
/** the ID of the AUT that was started for test execution */
private AutIdentifier m_startedAutId = null;
@@ -538,7 +534,6 @@ public class ExecutionController implements IAUTServerEventListener,
// init Hibernator
// Hibernate.properties and mapping files
// have to be in classpath
- ProgressEventDispatcher.addProgressListener(m_progressController);
Hibernator.setDbConnectionName(m_job.getDbscheme());
Hibernator.setUser(m_job.getDbuser());
Hibernator.setPw(m_job.getDbpw());
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/Messages.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/Messages.java
index 367ee0279..7dd0be7b3 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/Messages.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/Messages.java
@@ -66,6 +66,7 @@ public class Messages extends NLS {
public static String ImportFileSingleActionProjMessage;
public static String ImportOf;
public static String ImportWithoutName;
+ public static String ImportUnboundModulesJob;
public static String IncompatibleToolkitVersion;
public static String InvalidImportFile;
public static String MalformedXMLData;
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/messages.properties b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/messages.properties
index 162d9b4ae..a05813a5f 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/messages.properties
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/i18n/messages.properties
@@ -27,6 +27,7 @@ ImportFileActionProjShell=Rename Project
ImportFileActionProjTitle=Project
ImportFileComboActionProjMessage=The imported Project shares a GUID with one or more Projects in the database, but the names differ. Please choose a single name for all Projects with this GUID in the database.
ImportFileSingleActionProjMessage=The imported Project shares a GUID with one or more Projects in the database, but the names differ. Click 'OK' to rename the imported Project, or 'Cancel' to cancel the import.
+ImportUnboundModulesJob=Importing library projects...
ErrorWhileImportingProject=Error occurred while importing a Project.
SaveOf=Save of
Reading=: Reading '
diff --git a/org.eclipse.jubula.client.cmd/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.cmd/META-INF/MANIFEST.MF
index 075465985..0a4780015 100644
--- a/org.eclipse.jubula.client.cmd/META-INF/MANIFEST.MF
+++ b/org.eclipse.jubula.client.cmd/META-INF/MANIFEST.MF
@@ -11,7 +11,6 @@ Require-Bundle: org.eclipse.jubula.client.core;bundle-version="[0.9.0,1.0.0)",
org.apache.commons.lang;bundle-version="[2.4.0,3.0.0)",
org.apache.commons.cli;bundle-version="[1.2.0,2.0.0)"
Export-Package: org.eclipse.jubula.client.cmd,
- org.eclipse.jubula.client.cmd.batch,
org.eclipse.jubula.client.cmd.i18n,
org.eclipse.jubula.client.cmd.utils
Bundle-ClassPath: .
diff --git a/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/AbstractCmdlineClient.java b/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/AbstractCmdlineClient.java
index 90ebb63dd..503792b5f 100644
--- a/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/AbstractCmdlineClient.java
+++ b/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/AbstractCmdlineClient.java
@@ -27,7 +27,9 @@ import org.apache.commons.cli.ParseException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jubula.client.cmd.i18n.Messages;
+import org.eclipse.jubula.client.cmd.progess.HeadlessProgressProvider;
import org.eclipse.jubula.client.core.ClientTestFactory;
import org.eclipse.jubula.client.core.businessprocess.ClientTestStrings;
import org.eclipse.jubula.client.core.businessprocess.JobConfiguration;
@@ -285,7 +287,6 @@ public abstract class AbstractCmdlineClient implements IProgressConsole {
* Message
* @param printTimestamp should a timestamp be printed
*/
-
public static void printConsoleLn(String text, boolean printTimestamp) {
if (printTimestamp) {
Date now = new Date();
@@ -344,6 +345,8 @@ public abstract class AbstractCmdlineClient implements IProgressConsole {
* Exit Code
*/
public int run(String[] args) {
+ Job.getJobManager().setProgressProvider(new HeadlessProgressProvider());
+
ErrorMessagePresenter.setPresenter(new IErrorMessagePresenter() {
public void showErrorMessage(JBException ex, Object[] params,
String[] details) {
@@ -578,12 +581,10 @@ public abstract class AbstractCmdlineClient implements IProgressConsole {
return exitCode;
}
-
/**
* @return the job
*/
public JobConfiguration getJob() {
return m_job;
}
-
}
diff --git a/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/batch/ProgressController.java b/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/batch/ProgressController.java
deleted file mode 100644
index befd78ea0..000000000
--- a/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/batch/ProgressController.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 BREDEX 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:
- * BREDEX GmbH - initial API and implementation and/or initial documentation
- *******************************************************************************/
-package org.eclipse.jubula.client.cmd.batch;
-
-import org.eclipse.jubula.client.cmd.AbstractCmdlineClient;
-import org.eclipse.jubula.client.cmd.i18n.Messages;
-import org.eclipse.jubula.client.core.persistence.Hibernator;
-import org.eclipse.jubula.client.core.utils.IProgressListener;
-import org.eclipse.jubula.client.core.utils.ProgressEvent;
-
-
-/**
- * @author BREDEX GmbH
- * @created Nov 17, 2006
- */
-public class ProgressController implements IProgressListener {
- /**
- * {@inheritDoc}
- */
- public void reactOnProgressEvent(ProgressEvent e) {
- // After first try stop connecting to database
- if (e.getId() == ProgressEvent.OPEN_PROGRESS_BAR) {
- AbstractCmdlineClient.printConsoleLn(
- Messages.ExecutionControllerDatabase
- + Messages.ExecutionControllerDatabaseStart, true);
- } else if (e.getId() == ProgressEvent.CLOSE_PROGRESS_BAR) {
- AbstractCmdlineClient.printConsoleLn(
- Messages.ExecutionControllerDatabase
- + Messages.ExecutionControllerDataBaseEnd, true);
- Hibernator.setUser(null);
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/progess/HeadlessProgressMonitor.java b/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/progess/HeadlessProgressMonitor.java
new file mode 100644
index 000000000..0b73ef284
--- /dev/null
+++ b/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/progess/HeadlessProgressMonitor.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BREDEX 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.cmd.progess;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jubula.client.cmd.AbstractCmdlineClient;
+
+/**
+ * @author BREDEX GmbH
+ * @created Apr 1, 2011
+ */
+public class HeadlessProgressMonitor extends NullProgressMonitor {
+ /**
+ * {@inheritDoc}
+ */
+ public void beginTask(String name, int totalWork) {
+ AbstractCmdlineClient.printConsoleLn(name, true);
+ super.beginTask(name, totalWork);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setTaskName(String name) {
+ AbstractCmdlineClient.printConsoleLn(name, true);
+ super.setTaskName(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void subTask(String name) {
+ AbstractCmdlineClient.printConsoleLn(name, true);
+ super.subTask(name);
+ }
+}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ImportProjectHandler.java b/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/progess/HeadlessProgressProvider.java
index 60985df4d..fb5c17110 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ImportProjectHandler.java
+++ b/org.eclipse.jubula.client.cmd/src/org/eclipse/jubula/client/cmd/progess/HeadlessProgressProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 BREDEX GmbH.
+ * Copyright (c) 2004, 2011 BREDEX 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
@@ -8,23 +8,21 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jubula.client.ui.businessprocess.ImportFileBP;
+package org.eclipse.jubula.client.cmd.progess;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.ProgressProvider;
/**
* @author BREDEX GmbH
- * @created 08.11.2004
+ * @created Apr 1, 2011
*/
-public class ImportProjectHandler extends AbstractHandler {
+public class HeadlessProgressProvider extends ProgressProvider {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
- ImportFileBP.getInstance().importFile();
- return null;
+ public IProgressMonitor createMonitor(Job job) {
+ return new HeadlessProgressMonitor();
}
-} \ No newline at end of file
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java
index 016bbbe59..f17779fec 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java
@@ -83,6 +83,7 @@ public class Messages extends NLS {
public static String ConnectingFailed;
public static String ConnectingTheAUTAgentFailed;
public static String ConnectingToAUT;
+ public static String ConnectingToDatabase;
public static String ConnectionEstablishedOnPort;
public static String ConnectionToAUTAgentClosed;
public static String ConnectionToAUTCouldNotBeEstablished;
@@ -111,6 +112,7 @@ public class Messages extends NLS {
public static String CreatingMessageSharedInstanceFailed;
public static String CurrenActionNotAvailabelForSelectedToolkit;
public static String DatabaseConnectionInvalidPreferenceString;
+ public static String DatabaseConnectionEstablished;
public static String DataEventDispatcherReopenProject;
public static String DataSource;
public static String DBEntryMissingAmbiguous;
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties
index 53687a514..8292957bf 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties
@@ -147,6 +147,7 @@ CannotEstablishNewConnectionToAUT=Cannot establish new connection to AUT\: Conne
CommunicationErrorWhileSettingResourceBundle=communication error while setting Resource Bundle
ErrorOccurredWhileGettingComponentsFromAUT=Error occurred while getting components from AUT. Error code
ConnectedTo=connected to
+ConnectingToDatabase=Database:\tConnecting...
SecurityViolationGettingHostNameFromIP=security violation while getting the host name from ip address
ConnectionToAUTServerClosed=connection to AUTServer closed
ClosingConnectionToTheAutStarter=closing connection to the AutStarter
@@ -403,4 +404,5 @@ ProblemIncompleteObjectMappingMarkerText=Object Mapping incomplete for Test Suit
ProblemIncompleteObjectMappingMarkerTooltip=Object Mapping in this Test Suite is incomplete.
ProblemMissingReferencedTestCaseMarkerText="{0}" contains a reference to a Test Case that does not exist.
ProblemMissingReferencedTestCaseMarkerTooltip=Reference in children to a Test Case that does not exist.
-DatabaseConnectionInvalidPreferenceString=Invalid Database Connection will not be loaded from Preference Store\:\n{0} \ No newline at end of file
+DatabaseConnectionInvalidPreferenceString=Invalid Database Connection will not be loaded from Preference Store\:\n{0}
+DatabaseConnectionEstablished=Database:\tConnection established. \ No newline at end of file
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Hibernator.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Hibernator.java
index 8ccf8a53e..02e2d71d4 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Hibernator.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Hibernator.java
@@ -35,20 +35,26 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jubula.client.core.ClientTestFactory;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jubula.client.core.Activator;
import org.eclipse.jubula.client.core.constants.PluginConstants;
import org.eclipse.jubula.client.core.errorhandling.IDatabaseVersionErrorHandler;
import org.eclipse.jubula.client.core.i18n.Messages;
import org.eclipse.jubula.client.core.model.DBVersionPO;
import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.persistence.locking.LockManager;
-import org.eclipse.jubula.client.core.preferences.database.DatabaseConnection;
-import org.eclipse.jubula.client.core.preferences.database.DatabaseConnectionConverter;
-import org.eclipse.jubula.client.core.utils.ProgressEvent;
-import org.eclipse.jubula.client.core.utils.ProgressEventDispatcher;
+import org.eclipse.jubula.client.core.progress.JobChangeListener;
+import org.eclipse.jubula.client.core.utils.DatabaseStateDispatcher;
+import org.eclipse.jubula.client.core.utils.DatabaseStateEvent;
+import org.eclipse.jubula.client.core.utils.DatabaseStateEvent.DatabaseState;
import org.eclipse.jubula.tools.constants.StringConstants;
import org.eclipse.jubula.tools.exception.JBException;
import org.eclipse.jubula.tools.exception.JBFatalAbortException;
@@ -117,9 +123,6 @@ public class Hibernator {
/** contains information regarding how to connect to the database */
private static DatabaseConnectionInfo dbConnectionInfo = null;
- /** is Select DB action */
- private static boolean isSelectDbAction = false;
-
/** is headless */
private static boolean headless = false;
@@ -134,8 +137,8 @@ public class Hibernator {
/** counts the number of threads which needs this instance of the DB.*/
private AtomicInteger m_dbLockCnt = new AtomicInteger();
-
- /**
+
+ /**
* Create the instance.
*
* @param userName
@@ -144,20 +147,16 @@ public class Hibernator {
* The password.
* @param url
* The password.
+ * @param monitor
+ * the progress monitor to use
* @throws JBException
* in case of configuration problems.
*/
- private Hibernator(String userName, String pwd, String url)
+ private Hibernator(String userName, String pwd, String url,
+ IProgressMonitor monitor)
throws JBException, DatabaseVersionConflictException {
-
try {
- if (!isSelectDbAction) {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.OPEN_PROGRESS_BAR, null,
- Messages.PluginConnectProgress));
- }
-
- buildSessionFactoryWithLoginData(userName, pwd, url);
+ buildSessionFactoryWithLoginData(userName, pwd, url, monitor);
} catch (PersistenceException e) {
String msg = Messages.CantSetupHibernate;
log.fatal(msg, e);
@@ -177,112 +176,78 @@ public class Hibernator {
*/
public static synchronized boolean init() throws JBFatalException {
if (instance == null) {
- if (!isSelectDbAction) {
- List<DatabaseConnection> availableConnections =
- DatabaseConnectionConverter.computeAvailableConnections();
- if (availableConnections.size() == 1) {
- connectWithoutDialog(
- availableConnections.get(0).getConnectionInfo());
- } else {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.LOGIN, null, null));
- }
- }
- } else {
- return true;
+ return connectToDB();
}
- while (user != null) {
- try {
- instance(user, pw, dburl);
- user = null;
- pw = null;
- if (instance.m_newDbSchemeInstalled) {
- instance.m_newDbSchemeInstalled = false;
- instance.importUnboundModules();
- }
- fireTestresultSummaryChanged();
- return true;
- } catch (PMDatabaseConfException e) {
- if (e.getErrorId().equals(MessageIDs.E_INVALID_DB_VERSION)) {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_INVALID_DB_VERSION, null));
- } else if (e.getErrorId().equals(
- MessageIDs.E_NOT_CHECKABLE_DB_VERSION)) {
- ProgressEventDispatcher
- .notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_NOT_CHECKABLE_DB_VERSION,
- null));
- } else if (e.getErrorId().equals(MessageIDs.E_NO_DB_SCHEME)) {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_NO_DB_SCHEME, null));
- } else if (e.getErrorId().equals(
- MessageIDs.E_ERROR_IN_SCHEMA_CONFIG)) {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_ERROR_IN_SCHEMA_CONFIG, null));
-
- } else {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_UNEXPECTED_EXCEPTION, null));
- }
- return false;
- } catch (JBException e) {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.CLOSE_PROGRESS_BAR, null, null));
- if (e.getErrorId().equals(MessageIDs.E_NO_DB_CONNECTION)) {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_NO_DB_CONNECTION, null));
- }
- if (e.getErrorId().equals(MessageIDs.E_DB_IN_USE)) {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE, MessageIDs.E_DB_IN_USE,
- null));
- }
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.LOGIN, null, null));
- }
- }
- return false;
+ return true;
}
/**
- * fire test result summary changed event, when new connected to database
- */
- private static void fireTestresultSummaryChanged() {
- if (!headless) {
- ClientTestFactory.getClientTest().fireTestresultSummaryChanged();
- }
- }
-
- /**
- * Initializes the Hibernator using the given connection information.
- * If the information contains a username <em>and</em> password, then these
- * are used for initialization. If not, then a login dialog is presented.
- *
- * @param connectionInfo The information to use to initialize the
- * Hibernator.
+ * @return true if successfull; false otherwise
*/
- private static void connectWithoutDialog(
- DatabaseConnectionInfo connectionInfo) {
-
- String predefinedUsername = connectionInfo
- .getProperty(PersistenceUnitProperties.JDBC_USER);
- String predefinedPassword = connectionInfo
- .getProperty(PersistenceUnitProperties.JDBC_PASSWORD);
- if (predefinedUsername != null && predefinedPassword != null) {
- user = predefinedUsername;
- pw = predefinedPassword;
- dbConnectionInfo = connectionInfo;
- } else {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.LOGIN, null, null));
+ private static boolean connectToDB() {
+ Job connectToDBJob = new Job(Messages.ConnectingToDatabase) {
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask(Messages.ConnectingToDatabase,
+ IProgressMonitor.UNKNOWN);
+ Integer message = 0;
+ try {
+ instance(user, pw, dburl, monitor);
+ user = null;
+ pw = null;
+ if (instance.m_newDbSchemeInstalled) {
+ instance.m_newDbSchemeInstalled = false;
+ DatabaseStateDispatcher
+ .notifyListener(new DatabaseStateEvent(
+ DatabaseState.DB_SCHEME_CREATED));
+ }
+ return Status.OK_STATUS;
+ } catch (PMDatabaseConfException e) {
+ if (e.getErrorId().equals(MessageIDs.
+ E_INVALID_DB_VERSION)) {
+ message = MessageIDs.E_INVALID_DB_VERSION;
+ } else if (e.getErrorId().equals(
+ MessageIDs.E_NOT_CHECKABLE_DB_VERSION)) {
+ message = MessageIDs.E_NOT_CHECKABLE_DB_VERSION;
+ } else if (e.getErrorId().equals(MessageIDs.
+ E_NO_DB_SCHEME)) {
+ message = MessageIDs.E_NO_DB_SCHEME;
+ } else if (e.getErrorId().equals(
+ MessageIDs.E_ERROR_IN_SCHEMA_CONFIG)) {
+ message = MessageIDs.E_ERROR_IN_SCHEMA_CONFIG;
+ } else {
+ message = MessageIDs.E_UNEXPECTED_EXCEPTION;
+ }
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ StringConstants.EMPTY, e);
+ } catch (JBException e) {
+ if (e.getErrorId().equals(MessageIDs.E_NO_DB_CONNECTION)) {
+ message = MessageIDs.E_NO_DB_CONNECTION;
+ }
+ if (e.getErrorId().equals(MessageIDs.E_DB_IN_USE)) {
+ message = MessageIDs.E_DB_IN_USE;
+ }
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ StringConstants.EMPTY, e);
+ }
+ }
+ };
+ final AtomicBoolean connectionGained = new AtomicBoolean();
+ connectToDBJob.addJobChangeListener(new JobChangeListener() {
+ /** {@inheritDoc} */
+ public void done(IJobChangeEvent event) {
+ connectionGained.set(event.getResult().isOK());
+ }
+ });
+ connectToDBJob.setUser(true);
+ connectToDBJob.schedule();
+ try {
+ connectToDBJob.join();
+ } catch (InterruptedException e) {
+ log.error(e);
+ connectionGained.set(false);
}
+ return connectionGained.get();
}
/**
@@ -298,6 +263,8 @@ public class Hibernator {
* The password.
* @param url
* url connection string
+ * @param monitor
+ * the progress monitor to use
* @throws PersistenceException
* in case of configuration problems.
* @throws JBException
@@ -306,8 +273,8 @@ public class Hibernator {
* in case of invalid db scheme
*/
private void buildSessionFactoryWithLoginData(String userName, String pwd,
- String url) throws PersistenceException, PMDatabaseConfException,
- JBException, DatabaseVersionConflictException {
+ String url, IProgressMonitor monitor) throws PersistenceException,
+ PMDatabaseConfException, JBException, DatabaseVersionConflictException {
m_sf = createEntityManagerFactory(dbConnectionInfo, userName, pwd, url);
@@ -316,7 +283,9 @@ public class Hibernator {
em = m_sf.createEntityManager();
try {
validateDBVersion(em);
-
+ monitor.subTask(Messages.DatabaseConnectionEstablished);
+ DatabaseStateDispatcher.notifyListener(new DatabaseStateEvent(
+ DatabaseState.DB_LOGIN_SUCCEEDED));
} catch (AmbiguousDatabaseVersionException e) {
throw new PMDatabaseConfException(
Messages.DBVersionProblem + StringConstants.DOT,
@@ -534,14 +503,6 @@ public class Hibernator {
}
/**
- * import all unbound modules into the DB
- */
- private void importUnboundModules() {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.DB_SCHEME_CREATE, null, null));
- }
-
- /**
*
* @param em
* entity manager
@@ -618,16 +579,18 @@ public class Hibernator {
* The password.
* @param url
* connection string / url
+ * @param monitor the progress monitor to use
* @return the only instance of the Hibernator, building the connection to
* the database
* @throws JBFatalException .
* @throws JBException .
*/
- private static Hibernator instance(String userName, String pwd, String url)
+ private static Hibernator instance(String userName, String pwd, String url,
+ IProgressMonitor monitor)
throws JBFatalException, JBException {
if (instance == null) {
try {
- instance = new Hibernator(userName, pwd, url);
+ instance = new Hibernator(userName, pwd, url, monitor);
} catch (DatabaseVersionConflictException e) {
if (IVersion.JB_DB_MAJOR_VERSION > e
.getDatabaseMajorVersion()
@@ -648,15 +611,6 @@ public class Hibernator {
Messages.DBVersionProblem + StringConstants.DOT,
MessageIDs.E_INVALID_DB_VERSION);
}
- } finally {
- if (!isSelectDbAction) {
- ProgressEventDispatcher
- .notifyListener(new ProgressEvent(
- ProgressEvent.CLOSE_PROGRESS_BAR, null,
- null));
- }
- setSelectDBAction(false);
-
}
LockManager.instance().startKeepAlive();
@@ -1152,18 +1106,15 @@ public class Hibernator {
public static void migrateDatabaseStructure() throws JBFatalException,
JBException {
- boolean wasSelectingDatabase = getSelectDBAction();
- setSelectDBAction(true);
EntityManagerFactory migrationEntityManagerFactory = null;
try {
migrationEntityManagerFactory =
createEntityManagerFactory(dbConnectionInfo, user, pw, dburl);
installDbScheme(migrationEntityManagerFactory);
- instance = instance(user, pw, dburl);
+ instance = instance(user, pw, dburl, new NullProgressMonitor());
instance.m_newDbSchemeInstalled = true;
} finally {
- setSelectDBAction(wasSelectingDatabase);
if (migrationEntityManagerFactory != null) {
migrationEntityManagerFactory.close();
}
@@ -1224,23 +1175,6 @@ public class Hibernator {
}
/**
- * true if new DB is selected
- *
- * @param isSelDbAction
- * boolean
- */
- public static void setSelectDBAction(boolean isSelDbAction) {
- Hibernator.isSelectDbAction = isSelDbAction;
- }
-
- /**
- * @return true if new DB is selected
- */
- public static boolean getSelectDBAction() {
- return isSelectDbAction;
- }
-
- /**
* @return the name of the JDBC driver class used in the currently active
* Entity Manager Factory. Returns <code>null</code> if no
* Entity Manager Factory is currently active or if the active
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/JobChangeListener.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/JobChangeListener.java
new file mode 100644
index 000000000..8f26b6e97
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/JobChangeListener.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BREDEX 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.progress;
+
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+
+/**
+ * @author BREDEX GmbH
+ * @created Mar 31, 2011
+ */
+public abstract class JobChangeListener implements IJobChangeListener {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void aboutToRun(IJobChangeEvent event) {
+ // empty stub
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void awake(IJobChangeEvent event) {
+ // empty stub
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void done(IJobChangeEvent event) {
+ // empty stub
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void running(IJobChangeEvent event) {
+ // empty stub
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void scheduled(IJobChangeEvent event) {
+ // empty stub
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void sleeping(IJobChangeEvent event) {
+ // empty stub
+ }
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/ResultStatus.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/ResultStatus.java
new file mode 100644
index 000000000..4414383d1
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/progress/ResultStatus.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BREDEX 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.progress;
+
+import org.eclipse.core.runtime.Status;
+
+/**
+ * @author BREDEX GmbH
+ * @created Apr 1, 2011
+ * @param <T>
+ * The type of the return result.
+ */
+public class ResultStatus<T> extends Status {
+ /** the return result */
+ private T m_result;
+
+ /**
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ */
+ public ResultStatus(int severity, String pluginId, String message) {
+ super(severity, pluginId, message);
+ }
+
+ /**
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @param result
+ * the result
+ */
+ public ResultStatus(int severity, String pluginId, String message,
+ T result) {
+ this(severity, pluginId, message);
+ setResult(result);
+ }
+
+ /**
+ * @param result
+ * the result to use.
+ */
+ protected void setResult(T result) {
+ m_result = result;
+ }
+
+ /**
+ * @return the result.
+ */
+ public T getResult() {
+ return m_result;
+ }
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ProgressEventDispatcher.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/DatabaseStateDispatcher.java
index c44bf1902..a5de31ab9 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ProgressEventDispatcher.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/DatabaseStateDispatcher.java
@@ -14,50 +14,56 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-
/**
* @author BREDEX GmbH
* @created Nov 17, 2006
*/
-public class ProgressEventDispatcher {
-
+public class DatabaseStateDispatcher {
+
/**
* gui listener for showing connection window
*/
- private static transient Set<IProgressListener> listener;
+ private static transient Set<IDatabaseStateListener> listener;
/**
* Private utility constructor.
*/
- private ProgressEventDispatcher() {
+ private DatabaseStateDispatcher() {
// do nothing
}
-
+
/**
* Adds a new progress listener to progress listener list.
- * @param l The progressListener to add.
+ *
+ * @param l
+ * The progressListener to add.
*/
- public static void addProgressListener(IProgressListener l) {
+ public static void addDatabaseStateListener(IDatabaseStateListener l) {
getListeners().add(l);
}
/**
* Removes a new progress listener from progress listener list.
- * @param l The progressListener to remove.
+ *
+ * @param l
+ * The progressListener to remove.
*/
- public static void removeProgressListener(IProgressListener l) {
+ public static void removeDatabaseStateListener(IDatabaseStateListener l) {
getListeners().remove(l);
}
/**
- * Notifies all progressListeners of the progress listener list and calls <code>progressListener.reactOnProgressEvent(ProgressEvent e)</code>
- * @param e the progressEvent
+ * Notifies all progressListeners of the progress listener list and calls
+ * <code>progressListener.reactOnProgressEvent(ProgressEvent e)</code>
+ *
+ * @param e
+ * the progressEvent
*/
- public static void notifyListener(ProgressEvent e) {
+ public static void notifyListener(DatabaseStateEvent e) {
Iterator iter = getListeners().iterator();
while (iter.hasNext()) {
- IProgressListener progressListener = (IProgressListener)iter
- .next();
+ IDatabaseStateListener progressListener =
+ (IDatabaseStateListener)iter.next();
if (progressListener != null) {
progressListener.reactOnProgressEvent(e);
} else {
@@ -69,11 +75,11 @@ public class ProgressEventDispatcher {
}
/**
- * @return Set<IProgressListener>
+ * @return Set<IProgressListener>
*/
- private static Set<IProgressListener> getListeners() {
+ private static Set<IDatabaseStateListener> getListeners() {
if (listener == null) {
- listener = new HashSet<IProgressListener>();
+ listener = new HashSet<IDatabaseStateListener>();
}
return listener;
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/DatabaseStateEvent.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/DatabaseStateEvent.java
new file mode 100644
index 000000000..f0bc52ff1
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/DatabaseStateEvent.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BREDEX 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.utils;
+
+/**
+ * @author BREDEX GmbH
+ * @created 25.08.2005
+ */
+public class DatabaseStateEvent {
+ /** The available database states */
+ public enum DatabaseState {
+ /** the database scheme has just been created */
+ DB_SCHEME_CREATED,
+ /** successfull login */
+ DB_LOGIN_SUCCEEDED
+ }
+
+ /** The ID of the event */
+ private DatabaseState m_state;
+
+ /**
+ * The constructor.
+ *
+ * @param state
+ * the database state event
+ */
+ public DatabaseStateEvent(DatabaseState state) {
+ m_state = state;
+ }
+
+ /**
+ * @return Returns the ID of the Event.
+ */
+ public DatabaseState getState() {
+ return m_state;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IProgressListener.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IDatabaseStateListener.java
index 8a5719973..ed5875b86 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IProgressListener.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IDatabaseStateListener.java
@@ -10,19 +10,19 @@
*******************************************************************************/
package org.eclipse.jubula.client.core.utils;
-
-
/**
* Listener interface to show a ProgressMonitor for a long running operation.
- *
+ *
* @author BREDEX GmbH
* @created 25.08.2005
*/
-public interface IProgressListener {
-
+public interface IDatabaseStateListener {
+
/**
* Updates the object, which listens to this listener.
- * @param e The ProgressEvent.
+ *
+ * @param e
+ * The ProgressEvent.
*/
- public void reactOnProgressEvent(ProgressEvent e);
+ public void reactOnProgressEvent(DatabaseStateEvent e);
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ProgressEvent.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ProgressEvent.java
deleted file mode 100644
index ba9a29b2e..000000000
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ProgressEvent.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 BREDEX 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:
- * BREDEX GmbH - initial API and implementation and/or initial documentation
- *******************************************************************************/
-package org.eclipse.jubula.client.core.utils;
-
-
-/**
- * @author BREDEX GmbH
- * @created 25.08.2005
- *
- */
-public class ProgressEvent {
- /** Default ID : value = 1 */
- public static final Integer LOGIN = 1;
-
- /** ID for open progress bar : value = 2 */
- public static final Integer OPEN_PROGRESS_BAR = 2;
-
- /** ID for close progress bar : value = 3 */
- public static final Integer CLOSE_PROGRESS_BAR = 3;
-
- /** Show an error message, code is supplied in constructor : value = 4 */
- public static final Integer SHOW_MESSAGE = 4;
-
- /** The DB scheme has just been created : value = 5*/
- public static final Integer DB_SCHEME_CREATE = 5;
-
- /** The ID of the event */
- private Integer m_id;
- /** The ErrorMessage code to be used */
- private Integer m_msgId;
- /** The text of the progress dialog */
- private String m_progressText;
-
- /**
- * The long running Thread.
- */
- private Thread m_thread;
-
- /**
- * The constructor.
- * @param id the id of this Event.
- * @param msgId id of the error message to display if id is SHOW_MESSAGE (<code>null</code> otherwise)
- * @param text text of the progress dialog if id is OPEN_PROGRESS_BAR (<code>null</code> otherwise)
- */
- public ProgressEvent(Integer id, Integer msgId, String text) {
-
- m_id = id;
- m_msgId = msgId;
- m_progressText = text;
- }
-
- /**
- * @return Returns the ID of the Event.
- */
- public Integer getId() {
- return m_id;
- }
-
- /**
- * @return Returns the msgId.
- */
- public Integer getMsgId() {
- return m_msgId;
- }
-
- /**
- * @return the progressText
- */
- public String getProgressText() {
- return m_progressText;
- }
-
- /**
- * @return the long running Thread.<br>
- * <b> Can be null!</b>
- */
- public Thread getThread() {
- return m_thread;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/plugin.xml b/org.eclipse.jubula.client.ui/plugin.xml
index b919ceafc..587c2f7a1 100644
--- a/org.eclipse.jubula.client.ui/plugin.xml
+++ b/org.eclipse.jubula.client.ui/plugin.xml
@@ -2181,7 +2181,7 @@
</enabledWhen>
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.ProjectPropertiesHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.ProjectPropertiesHandler"
commandId="org.eclipse.jubula.client.ui.commands.ProjectProperties">
<enabledWhen>
<with variable="org.eclipse.jubula.client.ui.variable.isProjectActive">
@@ -2238,7 +2238,7 @@
</activeWhen>
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.RefreshProjectHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.RefreshProjectHandler"
commandId="org.eclipse.ui.file.refresh">
<activeWhen>
<and>
@@ -2453,15 +2453,15 @@
commandId="org.eclipse.jubula.client.ui.commands.ShowFromClipboard">
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.DeleteProjectHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.DeleteProjectHandler"
commandId="org.eclipse.jubula.client.ui.commands.DeleteProject">
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.NewProjectHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.NewProjectHandler"
commandId="org.eclipse.jubula.client.ui.commands.NewProject">
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.ImportProjectHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.ImportProjectHandler"
commandId="org.eclipse.jubula.client.ui.commands.ImportProject">
</handler>
<handler
@@ -2474,15 +2474,15 @@
</activeWhen>
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.OpenProjectHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.OpenProjectHandler"
commandId="org.eclipse.jubula.client.ui.commands.OpenProject">
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.ExportAllHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.ExportAllHandler"
commandId="org.eclipse.jubula.client.ui.commands.ExportAll">
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.SaveProjectAsHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.SaveProjectAsHandler"
commandId="org.eclipse.jubula.client.ui.commands.SaveProjectAs">
<activeWhen>
<with variable="org.eclipse.jubula.client.ui.variable.isProjectActive">
@@ -2491,7 +2491,7 @@
</activeWhen>
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.ExportProjectHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.ExportProjectHandler"
commandId="org.eclipse.jubula.client.ui.commands.ExportProject">
<activeWhen>
<with variable="org.eclipse.jubula.client.ui.variable.isProjectActive">
@@ -2500,7 +2500,7 @@
</activeWhen>
</handler>
<handler
- class="org.eclipse.jubula.client.ui.handlers.SelectDatabaseHandler"
+ class="org.eclipse.jubula.client.ui.handlers.project.SelectDatabaseHandler"
commandId="org.eclipse.jubula.client.ui.commands.SelectDatabase">
</handler>
</extension>
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/Plugin.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/Plugin.java
index c37fdcb0e..c073da5b1 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/Plugin.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/Plugin.java
@@ -39,25 +39,21 @@ import org.eclipse.jubula.client.core.businessprocess.MasterSessionComponentName
import org.eclipse.jubula.client.core.businessprocess.progress.OperationCanceledUtil;
import org.eclipse.jubula.client.core.errorhandling.ErrorMessagePresenter;
import org.eclipse.jubula.client.core.errorhandling.IErrorMessagePresenter;
-import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.model.IProjectPO;
import org.eclipse.jubula.client.core.model.IReusedProjectPO;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
import org.eclipse.jubula.client.core.persistence.Hibernator;
import org.eclipse.jubula.client.core.persistence.ISpecPersistable;
import org.eclipse.jubula.client.core.progress.IProgressConsole;
-import org.eclipse.jubula.client.core.utils.IProgressListener;
import org.eclipse.jubula.client.core.utils.Languages;
import org.eclipse.jubula.client.core.utils.PrefStoreHelper;
-import org.eclipse.jubula.client.core.utils.ProgressEvent;
-import org.eclipse.jubula.client.core.utils.ProgressEventDispatcher;
import org.eclipse.jubula.client.ui.businessprocess.CompletenessBP;
import org.eclipse.jubula.client.ui.businessprocess.ComponentNameReuseBP;
+import org.eclipse.jubula.client.ui.businessprocess.ImportFileBP;
import org.eclipse.jubula.client.ui.businessprocess.ToolkitBP;
import org.eclipse.jubula.client.ui.businessprocess.WorkingLanguageBP;
import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.constants.IconConstants;
-import org.eclipse.jubula.client.ui.controllers.ProgressController;
import org.eclipse.jubula.client.ui.editors.AbstractJBEditor;
import org.eclipse.jubula.client.ui.editors.AbstractTestCaseEditor;
import org.eclipse.jubula.client.ui.editors.IJBEditor;
@@ -162,8 +158,6 @@ public class Plugin extends AbstractUIPlugin implements IProgressConsole {
private List < String > m_dirtyEditors;
/** true, if preference store was initialized */
private boolean m_isPrefStoreInitialized = false;
- /** the global progress controller */
- private IProgressListener m_progressController = new ProgressController();
/** the console */
private MessageConsole m_console;
/** standard message stream for the console */
@@ -228,12 +222,7 @@ public class Plugin extends AbstractUIPlugin implements IProgressConsole {
* {@inheritDoc}
*/
public void stop(BundleContext context) throws Exception {
- try {
- ProgressEventDispatcher.removeProgressListener(
- m_progressController);
- } finally {
- super.stop(context);
- }
+ super.stop(context);
}
/**
@@ -1285,10 +1274,8 @@ public class Plugin extends AbstractUIPlugin implements IProgressConsole {
* - ComponentNamesListBP
*/
private void registerPermanentServices() {
- // register progress controller
- ProgressEventDispatcher.addProgressListener(
- m_progressController);
-
+ ImportFileBP.getInstance();
+
// register service for checking completeness
CompletenessBP.getInstance();
@@ -1296,11 +1283,7 @@ public class Plugin extends AbstractUIPlugin implements IProgressConsole {
ComponentNameReuseBP.getInstance();
// register service for toolkit
- final ToolkitBP toolkitBP = ToolkitBP.getInstance();
- DataEventDispatcher.getInstance().addProjectLoadedListener(
- toolkitBP, true);
- DataEventDispatcher.getInstance().addDataChangedListener(
- toolkitBP, true);
+ ToolkitBP.getInstance();
}
/**
@@ -1411,9 +1394,6 @@ public class Plugin extends AbstractUIPlugin implements IProgressConsole {
Display.getDefault().syncExec(new Runnable() {
@SuppressWarnings("synthetic-access")
public void run() {
- // FIXME enhance / remove our progress event dispatching mechanism
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.CLOSE_PROGRESS_BAR, null, null));
getStatusLineManager().setErrorMessage(null);
setNormalCursor();
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ImportFileBP.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ImportFileBP.java
index 18d53cc20..a6084eba6 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ImportFileBP.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ImportFileBP.java
@@ -20,34 +20,32 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jubula.client.archive.businessprocess.FileStorageBP;
import org.eclipse.jubula.client.archive.errorhandling.IProjectNameConflictResolver;
import org.eclipse.jubula.client.archive.i18n.Messages;
import org.eclipse.jubula.client.core.model.IProjectPO;
-import org.eclipse.jubula.client.core.persistence.GeneralStorage;
-import org.eclipse.jubula.client.core.persistence.Hibernator;
import org.eclipse.jubula.client.core.persistence.PMException;
import org.eclipse.jubula.client.core.progress.AbstractRunnableWithProgress;
import org.eclipse.jubula.client.core.progress.IProgressConsole;
+import org.eclipse.jubula.client.core.utils.DatabaseStateDispatcher;
+import org.eclipse.jubula.client.core.utils.DatabaseStateEvent;
+import org.eclipse.jubula.client.core.utils.IDatabaseStateListener;
import org.eclipse.jubula.client.ui.Plugin;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.dialogs.ComboBoxDialog;
-import org.eclipse.jubula.client.ui.dialogs.ImportProjectDialog;
-import org.eclipse.jubula.client.ui.handlers.OpenProjectHandler;
-import org.eclipse.jubula.client.ui.handlers.OpenProjectHandler.OpenProjectOperation;
+import org.eclipse.jubula.client.ui.handlers.project.OpenProjectHandler;
+import org.eclipse.jubula.client.ui.handlers.project.OpenProjectHandler.OpenProjectOperation;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
-import org.eclipse.jubula.client.ui.utils.JBThread;
import org.eclipse.jubula.tools.exception.ProjectDeletedException;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
@@ -56,8 +54,8 @@ import org.eclipse.ui.PlatformUI;
* @created 08.11.2004
*/
@SuppressWarnings("synthetic-access")
-public class ImportFileBP implements IProjectNameConflictResolver {
-
+public class ImportFileBP implements IProjectNameConflictResolver,
+ IDatabaseStateListener {
/**
* Interface for classes wishing to provide information for an import
* operation (i.e. which projects to import and which parts to import).
@@ -88,6 +86,7 @@ public class ImportFileBP implements IProjectNameConflictResolver {
/** Constructor */
public ImportFileBP() {
FileStorageBP.setProjectNameConflictResolver(this);
+ DatabaseStateDispatcher.addDatabaseStateListener(this);
}
/**
@@ -101,74 +100,6 @@ public class ImportFileBP implements IProjectNameConflictResolver {
}
return instance;
}
-
- /**
- *
- *
- */
- public void importFile() {
- Plugin.startLongRunning();
- JBThread t = new JBThread() {
- public void run() {
- if (!Hibernator.init()) {
- Plugin.stopLongRunning();
- return;
- }
- Plugin.getDisplay().syncExec(new Runnable() {
- public void run() {
- if (GeneralStorage.getInstance().getProject() != null
- && Plugin.getDefault().anyDirtyStar()) {
-
- if (Plugin.getDefault().
- showSaveEditorDialog()) {
-
- showImportDialog();
- }
- Plugin.stopLongRunning();
- return;
- }
- showImportDialog();
- }
- });
- }
- /**
- * {@inheritDoc}
- */
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
- };
- t.start();
- Plugin.stopLongRunning();
- }
-
- /**
- *
- */
- public void importUnboundModules() {
- Plugin.startLongRunning();
- JBThread t = new JBThread() {
- public void run() {
- Plugin.getDisplay().syncExec(new ImportUnboundThread());
- }
- /**
- * {@inheritDoc}
- */
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
- };
- t.start();
- while (t.isAlive()) {
- try {
- t.join();
- } catch (InterruptedException e) {
- // ignore
- }
- }
- Plugin.stopLongRunning();
-
- }
/**
* Imports a choosed project from a file.
@@ -181,9 +112,8 @@ public class ImportFileBP implements IProjectNameConflictResolver {
* Flag indicating whether the imported project should be
* immediately opened after import.
*/
- private void importProject(final int elements, final String [] fileNames,
+ public void importProject(final int elements, final String [] fileNames,
final boolean openProject) {
- Plugin.startLongRunning(Messages.ImportFileBPWaitWhileImporting);
try {
if (fileNames == null) {
return;
@@ -193,7 +123,8 @@ public class ImportFileBP implements IProjectNameConflictResolver {
public void run(IProgressMonitor monitor)
throws InterruptedException {
-
+ monitor.setTaskName(Messages.
+ ImportFileBPWaitWhileImporting);
try {
setResult(FileStorageBP.importProject(
elements, fileNames,
@@ -252,34 +183,6 @@ public class ImportFileBP implements IProjectNameConflictResolver {
}
/**
- * brings up the ImportDiaog
- *
- */
- void showImportDialog() {
- ImportProjectDialog importProjectWizard = new ImportProjectDialog();
- WizardDialog dialog =
- new WizardDialog(Plugin.getShell(), importProjectWizard) {
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- Button finishButton = getButton(IDialogConstants.FINISH_ID);
- finishButton.setText(IDialogConstants.OK_LABEL);
- }
- };
- importProjectWizard.setWindowTitle(
- org.eclipse.jubula.client.ui.i18n.
- Messages.ImportProjectDialogTitle);
- dialog.setHelpAvailable(true);
-
- int val = dialog.open();
- if (val == Window.OK) {
- importProjects(importProjectWizard.getImportInfoProvider());
- }
-
- }
-
-
-
- /**
* Performs an import using the information provided by the argument.
*
* @param importInfo Provides information relevant to the import.
@@ -306,30 +209,32 @@ public class ImportFileBP implements IProjectNameConflictResolver {
}
/**
- * Performs an import using the information provided by the argument.
- *
- * @param importInfo Provides information relevant to the import.
- */
- public void importProjects(IProjectImportInfoProvider importInfo) {
- String [] fileNames = importInfo.getFiles();
- boolean openProject = importInfo.getIsOpenProject();
- importProject(0, fileNames, openProject);
- }
-
- /**
*
* Import the unbound modules library into a database
*
* @author BREDEX GmbH
* @created 05.06.2008
*/
- private final class ImportUnboundThread implements Runnable {
-
+ private final class ImportUnboundModulesJob extends Job {
+ /**
+ * @param name
+ * the name of the job
+ */
+ public ImportUnboundModulesJob(String name) {
+ super(name);
+ }
+
/**
* {@inheritDoc}
*/
- public void run() {
- importProject(0, findUnboundModules(), false); // load all elements
+ protected IStatus run(IProgressMonitor monitor) {
+ Plugin.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // load all elements;
+ importProject(0, findUnboundModules(), false);
+ }
+ });
+ return Status.OK_STATUS;
}
/**
@@ -469,4 +374,19 @@ public class ImportFileBP implements IProjectNameConflictResolver {
ImportOperationCancelledByUser}));
}
+ /**
+ * {@inheritDoc}
+ */
+ public void reactOnProgressEvent(DatabaseStateEvent e) {
+ switch (e.getState()) {
+ case DB_SCHEME_CREATED:
+ Job importUnboundModules = new ImportUnboundModulesJob(
+ Messages.ImportUnboundModulesJob);
+ importUnboundModules.setUser(true);
+ importUnboundModules.schedule();
+ break;
+ default:
+ break;
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ToolkitBP.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ToolkitBP.java
index cdf3091d5..29194b662 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ToolkitBP.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/ToolkitBP.java
@@ -18,6 +18,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jubula.client.core.businessprocess.UsedToolkitBP;
import org.eclipse.jubula.client.core.businessprocess.UsedToolkitBP.ToolkitPluginError;
import org.eclipse.jubula.client.core.businessprocess.UsedToolkitBP.ToolkitPluginError.ERROR;
+import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.IDataChangedListener;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.IProjectLoadedListener;
@@ -54,8 +55,10 @@ public class ToolkitBP implements IProjectLoadedListener, IDataChangedListener {
/**
* Constructor
*/
- private ToolkitBP() {
- // nothing
+ private ToolkitBP() {
+ DataEventDispatcher ded = DataEventDispatcher.getInstance();
+ ded.addProjectLoadedListener(this, true);
+ ded.addDataChangedListener(this, true);
}
/**
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/CommandIDs.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/CommandIDs.java
index 3b53d0f43..71d811ce9 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/CommandIDs.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/CommandIDs.java
@@ -161,4 +161,7 @@ public interface CommandIDs {
/** the ID of the "open project" command */
public static final String OPEN_PROJECT_COMMAND_ID = "org.eclipse.jubula.client.ui.commands.OpenProject"; //$NON-NLS-1$
+
+ /** the ID of the "select database" command */
+ public static final String SELECT_DATABASE_COMMAND_ID = "org.eclipse.jubula.client.ui.commands.SelectDatabase"; //$NON-NLS-1$
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/PMExceptionHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/PMExceptionHandler.java
index caabc2255..ee3efb342 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/PMExceptionHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/PMExceptionHandler.java
@@ -25,7 +25,7 @@ import org.eclipse.jubula.client.core.persistence.PMObjectDeletedException;
import org.eclipse.jubula.client.core.persistence.PMSaveException;
import org.eclipse.jubula.client.ui.actions.AbstractAction;
import org.eclipse.jubula.client.ui.editors.IJBEditor;
-import org.eclipse.jubula.client.ui.handlers.RefreshProjectHandler.RefreshProjectOperation;
+import org.eclipse.jubula.client.ui.handlers.project.RefreshProjectHandler.RefreshProjectOperation;
import org.eclipse.jubula.client.ui.utils.Utils;
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
import org.eclipse.swt.widgets.Display;
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/ProgressController.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/ProgressController.java
deleted file mode 100644
index 3b7b595aa..000000000
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/ProgressController.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 BREDEX 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:
- * BREDEX GmbH - initial API and implementation and/or initial documentation
- *******************************************************************************/
-package org.eclipse.jubula.client.ui.controllers;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jubula.client.core.events.DataEventDispatcher;
-import org.eclipse.jubula.client.core.events.DataEventDispatcher.AutState;
-import org.eclipse.jubula.client.core.events.DataEventDispatcher.IAutStateListener;
-import org.eclipse.jubula.client.core.events.DataEventDispatcher.IProjectLoadedListener;
-import org.eclipse.jubula.client.core.model.IProjectPO;
-import org.eclipse.jubula.client.core.persistence.CompNamePM;
-import org.eclipse.jubula.client.core.persistence.GeneralStorage;
-import org.eclipse.jubula.client.core.persistence.Hibernator;
-import org.eclipse.jubula.client.core.persistence.locking.LockManager;
-import org.eclipse.jubula.client.core.utils.IProgressListener;
-import org.eclipse.jubula.client.core.utils.ProgressEvent;
-import org.eclipse.jubula.client.core.utils.ProgressEventDispatcher;
-import org.eclipse.jubula.client.ui.Plugin;
-import org.eclipse.jubula.client.ui.businessprocess.ImportFileBP;
-import org.eclipse.jubula.client.ui.dialogs.DBLoginDialog;
-import org.eclipse.jubula.client.ui.i18n.Messages;
-import org.eclipse.jubula.client.ui.utils.DialogUtils;
-import org.eclipse.jubula.client.ui.utils.Utils;
-import org.eclipse.jubula.tools.exception.JBFatalException;
-import org.eclipse.jubula.tools.messagehandling.MessageIDs;
-import org.eclipse.jubula.tools.utils.TimeUtil;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
-
-
-/**
- * @author BREDEX GmbH
- * @created 14.02.2007
- */
-public class ProgressController implements IProgressListener,
- IAutStateListener, IProjectLoadedListener {
-
- /** for log messages */
- private static Log log = LogFactory.getLog(ProgressController.class);
-
- /** true, if hibernate init was successful */
- private static boolean hibernateInit = false;
-
- /** progress operation */
- private ProgressOperation m_prog;
-
- /**
- * Constructor
- */
- public ProgressController() {
- DataEventDispatcher ded = DataEventDispatcher.getInstance();
- ded.addAutStateListener(this, true);
- ded.addProjectLoadedListener(this, true);
- }
-
- /**
- * {@inheritDoc}
- */
- public void reactOnProgressEvent(final ProgressEvent e) {
- Integer eventId = e.getId();
- if (eventId == ProgressEvent.LOGIN) {
- showLoginDataDialog();
- } else if (eventId == ProgressEvent.DB_SCHEME_CREATE) {
- importUnboundModules();
- } else if (eventId == ProgressEvent.OPEN_PROGRESS_BAR) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- m_prog = new ProgressOperation(
- e.getProgressText());
- try {
- IProgressService progressService =
- PlatformUI.getWorkbench().getProgressService();
- progressService.run(true, false, m_prog);
- } catch (InvocationTargetException ex) {
- log.error(ex);
- Utils.createMessageDialog(MessageIDs.E_SYNCHRONIZATION);
- } catch (InterruptedException ex) {
- log.error(ex);
- Utils.createMessageDialog(MessageIDs.E_SYNCHRONIZATION);
- }
- }
- });
- } else if (eventId == ProgressEvent.CLOSE_PROGRESS_BAR) {
- stopProgressOperation();
-
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- IProjectPO project =
- GeneralStorage.getInstance().getProject();
- String projectName = null;
- Integer majorVersion = null;
- Integer minorVersion = null;
- if (project != null) {
- projectName = project.getName();
- majorVersion = project.getMajorProjectVersion();
- minorVersion = project.getMinorProjectVersion();
- }
- Plugin.setProjectNameInTitlebar(projectName,
- majorVersion, minorVersion);
- }
- });
-
- } else {
- final Integer code;
- stopProgressOperation();
- if (e.getMsgId() == null) {
- code = MessageIDs.E_UNEXPECTED_EXCEPTION;
- } else {
- code = e.getMsgId();
- }
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- Utils.createMessageDialog(code);
- }
- });
- }
- }
-
- /**
- *
- */
- private void importUnboundModules() {
- ImportFileBP.getInstance().importUnboundModules();
- }
-
- /**
- * Stops the ProgressOperation (m_prog).
- */
- private void stopProgressOperation() {
- if (m_prog != null) {
- m_prog.stop();
- }
- }
-
- /**
- * Shows the db login dialog.
- */
- private void showLoginDataDialog() {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- DBLoginDialog dialog = new DBLoginDialog(Plugin.getShell());
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- dialog.open();
- if (dialog.getReturnCode() == Window.OK) {
- Utils.clearClient();
- //if db is embedded do not set user and pwd here
- if (!(dialog.isEmbeddedDb())) {
- Hibernator.setUser(dialog.getUser());
- Hibernator.setPw(dialog.getPwd());
- }
- Hibernator.setDbConnectionName(
- dialog.getDatabaseConnection().getConnectionInfo());
-
- if (Hibernator.getSelectDBAction()) {
- if (Hibernator.instance() != null) {
- CompNamePM.dispose();
- GeneralStorage.getInstance().dispose();
- if (LockManager.isRunning()) {
- LockManager.instance().dispose();
- }
- Hibernator.instance().dispose();
- }
-
- ConnectDbOperation connDbOp = new ConnectDbOperation();
- try {
- PlatformUI.getWorkbench().getProgressService()
- .run(true, false, connDbOp);
- } catch (InvocationTargetException e) {
- hibernateInit = false;
- } catch (InterruptedException e) {
- hibernateInit = false;
- }
-
- if (hibernateInit) {
- LockManager.instance();
- Plugin.getDefault().writeLineToConsole(Messages.
- SelectDatabaseActionInfoConnectSuccessful,
- true);
- } else {
- Plugin.getDefault().writeLineToConsole(Messages.
- SelectDatabaseActionInfoConnectFailed
- , true);
- }
- Plugin.stopLongRunning();
- }
- } else {
- Hibernator.setUser(null);
- }
- }
- });
- }
-
- /**
- *
- *
- * @author BREDEX GmbH
- * @created Jan 2, 2008
- */
- public class ConnectDbOperation implements IRunnableWithProgress {
-
- /**
- * constructor
- */
- public ConnectDbOperation() {
- //default constructor
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(IProgressMonitor monitor) {
-
- monitor.beginTask(Messages.PluginConnectProgress,
- IProgressMonitor.UNKNOWN);
-
- try {
- if (Hibernator.init()) {
- hibernateInit = true;
- } else {
- hibernateInit = false;
- }
- } catch (JBFatalException e) {
- hibernateInit = false;
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_ERROR_IN_SCHEMA_CONFIG, null));
- } finally {
- monitor.done();
- }
- }
- }
-
- /**
- * This class represents a long running operation.
- * @author BREDEX GmbH
- * @created 26.08.2005
- */
- private class ProgressOperation implements IRunnableWithProgress {
- /** the m_text, that is shown in the progress dialog */
- private String m_text;
-
- /**
- * <code>m_monitor</code> the monitor used in this progress operation
- */
- private IProgressMonitor m_monitor = null;
-
- /**
- * ProgressOperation constructor.
- * @param text The text to set.
- */
- public ProgressOperation(String text) {
- m_text = text;
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(final IProgressMonitor monitor) {
- m_monitor = monitor;
- monitor.beginTask(m_text, IProgressMonitor.UNKNOWN);
- while (!monitor.isCanceled()) {
- TimeUtil.delay(50);
- }
- }
-
- /**
- */
- public synchronized void stop() {
- if (m_monitor != null) {
- m_monitor.setCanceled(true);
- m_monitor.done();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void handleAutStateChanged(AutState state) {
- reactOnProgressEvent(new ProgressEvent(ProgressEvent.CLOSE_PROGRESS_BAR,
- null, null));
- }
-
- /**
- *
- * @return true, if hibernate init was successful
- */
- public static boolean initHibernate() {
- return hibernateInit;
- }
-
- /**
- * {@inheritDoc}
- */
- public void handleProjectLoaded() {
- reactOnProgressEvent(new ProgressEvent(ProgressEvent.CLOSE_PROGRESS_BAR,
- null, null));
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java
index 5df643ca7..4815f94d7 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java
@@ -480,11 +480,4 @@ public class DBLoginDialog extends TitleAreaDialog {
public DatabaseConnection getDatabaseConnection() {
return m_dbConn;
}
-
- /**
- * @return true, if selected database if embedded db.
- */
- public boolean isEmbeddedDb() {
- return m_isEmbeddedOrNoSelection;
- }
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/extensions/ProjectPropertyExtensionHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/extensions/ProjectPropertyExtensionHandler.java
index c3071507d..b9c7c2afd 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/extensions/ProjectPropertyExtensionHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/extensions/ProjectPropertyExtensionHandler.java
@@ -20,7 +20,7 @@ import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.preference.PreferenceNode;
import org.eclipse.jubula.client.core.persistence.EditSupport;
-import org.eclipse.jubula.client.ui.handlers.ProjectPropertiesHandler;
+import org.eclipse.jubula.client.ui.handlers.project.ProjectPropertiesHandler;
import org.eclipse.jubula.client.ui.i18n.Messages;
import org.eclipse.jubula.client.ui.properties.AbstractProjectPropertyPage;
import org.slf4j.Logger;
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AbstractTestResultViewHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AbstractTestResultViewHandler.java
index f6e9f0b7d..62a9ad0ca 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AbstractTestResultViewHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AbstractTestResultViewHandler.java
@@ -10,19 +10,19 @@
*******************************************************************************/
package org.eclipse.jubula.client.ui.handlers;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jubula.client.core.model.ITestResultSummaryPO;
+import org.eclipse.jubula.client.ui.handlers.project.AbstractProjectHandler;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* @author BREDEX GmbH
* @created Mar 3, 2011
*/
-public abstract class AbstractTestResultViewHandler extends AbstractHandler {
-
+public abstract class AbstractTestResultViewHandler
+ extends AbstractProjectHandler {
/**
* @param event
* the execution event
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AddTestResultSummaryCommentHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AddTestResultSummaryCommentHandler.java
index 4382cbe87..d8da9a8c2 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AddTestResultSummaryCommentHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AddTestResultSummaryCommentHandler.java
@@ -43,7 +43,7 @@ public class AddTestResultSummaryCommentHandler
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
+ public Object executeImpl(ExecutionEvent event) {
ITestResultSummaryPO selectedSummary = getSelectedSummary(event);
if (selectedSummary != null) {
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshTestresultsHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshTestresultsHandler.java
index bf9599928..7f60e1320 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshTestresultsHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshTestresultsHandler.java
@@ -10,48 +10,29 @@
*******************************************************************************/
package org.eclipse.jubula.client.ui.handlers;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jubula.client.core.persistence.Hibernator;
import org.eclipse.jubula.client.ui.Plugin;
-import org.eclipse.jubula.client.ui.utils.JBThread;
+import org.eclipse.jubula.client.ui.handlers.project.AbstractProjectHandler;
import org.eclipse.jubula.client.ui.views.TestresultSummaryView;
import org.eclipse.ui.IWorkbenchPart;
-
/**
- * handler for refreshing testresults in testresult summary view
- *
+ * Handler for refreshing testresults in testresult summary view
+ *
* @author BREDEX GmbH
* @created Feb 4, 2010
*/
-public class RefreshTestresultsHandler extends AbstractHandler {
-
+public class RefreshTestresultsHandler extends AbstractProjectHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
+ public Object executeImpl(ExecutionEvent event) {
IWorkbenchPart activePart = Plugin.getActivePart();
if (activePart instanceof TestresultSummaryView) {
final TestresultSummaryView summary =
(TestresultSummaryView)activePart;
- JBThread t = new JBThread() {
- public void run() {
- if (!Hibernator.init()) {
- Plugin.stopLongRunning();
- return;
- }
- summary.refreshView();
- }
-
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
- };
- t.start();
+ summary.refreshView();
}
-
return null;
}
-
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/SelectDatabaseHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/SelectDatabaseHandler.java
deleted file mode 100644
index 9f79edd55..000000000
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/SelectDatabaseHandler.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 BREDEX 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:
- * BREDEX GmbH - initial API and implementation and/or initial documentation
- *******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jubula.client.core.persistence.CompNamePM;
-import org.eclipse.jubula.client.core.persistence.DatabaseConnectionInfo;
-import org.eclipse.jubula.client.core.persistence.GeneralStorage;
-import org.eclipse.jubula.client.core.persistence.Hibernator;
-import org.eclipse.jubula.client.core.persistence.locking.LockManager;
-import org.eclipse.jubula.client.core.preferences.database.DatabaseConnection;
-import org.eclipse.jubula.client.core.preferences.database.DatabaseConnectionConverter;
-import org.eclipse.jubula.client.core.utils.ProgressEvent;
-import org.eclipse.jubula.client.core.utils.ProgressEventDispatcher;
-import org.eclipse.jubula.client.ui.Plugin;
-import org.eclipse.jubula.client.ui.i18n.Messages;
-import org.eclipse.jubula.client.ui.utils.JBThread;
-import org.eclipse.jubula.client.ui.utils.Utils;
-import org.eclipse.jubula.tools.exception.JBFatalException;
-import org.eclipse.jubula.tools.messagehandling.MessageIDs;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author BREDEX GmbH
- * @created 18.04.2005
- */
-public class SelectDatabaseHandler extends AbstractHandler {
- /**
- * <code>HIBERNATE_CONNECTION_PASSWORD</code>
- */
- private static final String HIBERNATE_CONNECTION_PASSWORD = "javax.persistence.jdbc.password"; //$NON-NLS-1$
-
- /**
- * key for the username property for Hibernate
- */
- private static final String HIBERNATE_CONNECTION_USERNAME = "javax.persistence.jdbc.user"; //$NON-NLS-1$
-
- /** true, if hibernate init was successful */
- private static boolean hibernateInit = false;
-
- /**
- * Runnable to connect to DB
- *
- * @author BREDEX GmbH
- *
- */
- private static class Loader extends JBThread {
-
- /**
- * run method
- */
- public void run() {
- Plugin.startLongRunning();
-
- Hibernator.setSelectDBAction(true);
-
- List<DatabaseConnection> availableConnections =
- DatabaseConnectionConverter.computeAvailableConnections();
-
- // if only one scheme with user and password is defined don't show
- // login dialog
- if (availableConnections.size() == 1) {
- connectWithoutLoginDialog(
- availableConnections.get(0).getConnectionInfo());
- } else {
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.LOGIN, null, null));
- }
-
- Hibernator.setSelectDBAction(false);
- }
-
- /**
- * Initializes the Hibernator using the given connection information.
- * If the information contains a username <em>and</em> password, then
- * these are used for initialization. If not, then a login dialog is
- * presented.
- *
- * @param connectionInfo The information to use to initialize the
- * Hibernator.
- */
- private void connectWithoutLoginDialog(
- final DatabaseConnectionInfo connectionInfo) {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- Utils.clearClient();
-
- String predefinedUsername =
- connectionInfo.getProperty(
- HIBERNATE_CONNECTION_USERNAME);
- String predefinedPassword =
- connectionInfo.getProperty(
- HIBERNATE_CONNECTION_PASSWORD);
- if (predefinedUsername != null
- && predefinedPassword != null) {
- Hibernator.setUser(predefinedUsername);
- Hibernator.setPw(predefinedPassword);
- Hibernator.setDbConnectionName(connectionInfo);
-
- if (Hibernator.instance() != null) {
- CompNamePM.dispose();
- GeneralStorage.getInstance().dispose();
- if (LockManager.isRunning()) {
- LockManager.instance().dispose();
- }
- Hibernator.instance().dispose();
- }
-
- ConnectDbOperation connDbOp =
- new ConnectDbOperation();
- try {
- PlatformUI.getWorkbench().getProgressService()
- .run(true, false, connDbOp);
- } catch (InvocationTargetException e) {
- hibernateInit = false;
- } catch (InterruptedException e) {
- hibernateInit = false;
- }
-
- if (hibernateInit) {
- LockManager.instance();
- Plugin.getDefault().writeLineToConsole(Messages.
- SelectDatabaseActionInfoConnectSuccessful,
- true);
- } else {
- Plugin.getDefault().writeLineToConsole(
- Messages.
- SelectDatabaseActionInfoConnectFailed,
- true);
- }
- Plugin.stopLongRunning();
- } else {
- ProgressEventDispatcher
- .notifyListener(new ProgressEvent(
- ProgressEvent.LOGIN, null, null));
- }
- }
- });
- }
-
- /**
- *
- *
- * @author BREDEX GmbH
- * @created Jan 2, 2008
- */
- public class ConnectDbOperation implements IRunnableWithProgress {
-
- /**
- * constructor
- */
- public ConnectDbOperation() {
- // default constructor
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(IProgressMonitor monitor) {
-
- monitor.beginTask(Messages.PluginConnectProgress,
- IProgressMonitor.UNKNOWN);
-
- try {
- if (Hibernator.init()) {
- hibernateInit = true;
- } else {
- hibernateInit = false;
- }
- } catch (JBFatalException e) {
- hibernateInit = false;
- ProgressEventDispatcher.notifyListener(new ProgressEvent(
- ProgressEvent.SHOW_MESSAGE,
- MessageIDs.E_ERROR_IN_SCHEMA_CONFIG, null));
- } finally {
- monitor.done();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- if (GeneralStorage.getInstance().getProject() != null
- && Plugin.getDefault().anyDirtyStar()
- && !Plugin.getDefault().showSaveEditorDialog()) {
-
- Plugin.stopLongRunning();
- return null;
- }
-
- if ((Hibernator.instance() != null)
- && Hibernator.instance().isDBLocked()) {
- Plugin.stopLongRunning();
- Utils.createMessageDialog(MessageIDs.I_DB_BACKGROUND_JOB,
- null, null);
- return null;
- }
- new Loader().start();
- return null;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ToggleRelevanceHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ToggleRelevanceHandler.java
index 2be476dad..11bffe908 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ToggleRelevanceHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ToggleRelevanceHandler.java
@@ -31,7 +31,7 @@ public class ToggleRelevanceHandler extends AbstractTestResultViewHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
+ public Object executeImpl(ExecutionEvent event) {
ITestResultSummaryPO selectedSummary = getSelectedSummary(event);
if (selectedSummary != null) {
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractProjectHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractProjectHandler.java
new file mode 100644
index 000000000..80fae9e10
--- /dev/null
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractProjectHandler.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BREDEX 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.ui.handlers.project;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jubula.client.core.persistence.Hibernator;
+import org.eclipse.jubula.client.ui.constants.CommandIDs;
+import org.eclipse.jubula.client.ui.utils.CommandHelper;
+
+/**
+ * @author BREDEX GmbH
+ * @created Mar 31, 2011
+ */
+public abstract class AbstractProjectHandler extends AbstractHandler {
+ /**
+ * {@inheritDoc}
+ */
+ public final Object execute(ExecutionEvent event)
+ throws ExecutionException {
+ if (Hibernator.instance() == null) {
+ Object result = CommandHelper
+ .executeCommand(CommandIDs.SELECT_DATABASE_COMMAND_ID);
+ if (Status.OK_STATUS.equals(result)) {
+ return executeImpl(event);
+ }
+ } else {
+ return executeImpl(event);
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract Object executeImpl(ExecutionEvent event)
+ throws ExecutionException;
+}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/DeleteProjectHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/DeleteProjectHandler.java
index 74e49fa09..e77cca9c5 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/DeleteProjectHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/DeleteProjectHandler.java
@@ -8,14 +8,13 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import javax.persistence.EntityManager;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -45,13 +44,11 @@ import org.eclipse.jubula.client.ui.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.dialogs.ProjectDialog;
import org.eclipse.jubula.client.ui.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
-import org.eclipse.jubula.client.ui.utils.JBThread;
import org.eclipse.jubula.client.ui.utils.Utils;
import org.eclipse.jubula.tools.exception.JBException;
import org.eclipse.jubula.tools.exception.ProjectDeletedException;
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -59,7 +56,7 @@ import org.eclipse.ui.PlatformUI;
* @author BREDEX GmbH
* @created 06.07.2005
*/
-public class DeleteProjectHandler extends AbstractHandler {
+public class DeleteProjectHandler extends AbstractProjectHandler {
/** number of hibernate event types with progress listeners */
// Event types:
@@ -319,30 +316,8 @@ public class DeleteProjectHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
- Plugin.startLongRunning();
- JBThread t = new JBThread() {
- public void run() {
- if (!Hibernator.init()) {
- Plugin.stopLongRunning();
- return;
- }
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- try {
- selectProject();
- } finally {
- Plugin.stopLongRunning();
- }
- }
- });
- }
-
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
- };
- t.start();
+ public Object executeImpl(ExecutionEvent event) {
+ selectProject();
return null;
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExportAllHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ExportAllHandler.java
index 86b73c9f4..faa971594 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExportAllHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ExportAllHandler.java
@@ -8,7 +8,7 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
@@ -18,7 +18,6 @@ import javax.persistence.EntityManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -30,7 +29,6 @@ import org.eclipse.jubula.client.core.persistence.ProjectPM;
import org.eclipse.jubula.client.ui.Plugin;
import org.eclipse.jubula.client.ui.businessprocess.ExportAllBP;
import org.eclipse.jubula.client.ui.i18n.Messages;
-import org.eclipse.jubula.client.ui.utils.JBThread;
import org.eclipse.jubula.client.ui.utils.Utils;
import org.eclipse.jubula.tools.exception.JBException;
import org.eclipse.osgi.util.NLS;
@@ -44,7 +42,7 @@ import org.eclipse.ui.PlatformUI;
* @author BREDEX GmbH
* @created Jul 25, 2007
*/
-public class ExportAllHandler extends AbstractHandler {
+public class ExportAllHandler extends AbstractProjectHandler {
/** the logger */
private static Log log = LogFactory.getLog(ExportAllHandler.class);
@@ -115,15 +113,6 @@ public class ExportAllHandler extends AbstractHandler {
}
}
}
-
- /**
- *
- * {@inheritDoc}
- */
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
-
}
/**
@@ -184,41 +173,18 @@ public class ExportAllHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
- JBThread showDialog = new JBThread() {
-
- public void run() {
- Plugin.startLongRunning();
- if (Hibernator.init()) {
- Plugin.getDisplay().syncExec(new Runnable() {
- public void run() {
- if (GeneralStorage.getInstance()
- .getProject() != null
- && Plugin.getDefault().anyDirtyStar()) {
-
- if (Plugin.getDefault()
- .showSaveEditorDialog()) {
- showExportDialog();
- }
- Plugin.stopLongRunning();
- return;
- }
- showExportDialog();
- Plugin.stopLongRunning();
- }
- });
- } else {
- Plugin.stopLongRunning();
- }
+ public Object executeImpl(ExecutionEvent event) {
+ if (GeneralStorage.getInstance()
+ .getProject() != null
+ && Plugin.getDefault().anyDirtyStar()) {
+
+ if (Plugin.getDefault()
+ .showSaveEditorDialog()) {
+ showExportDialog();
}
-
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
-
- };
-
- showDialog.start();
+ return null;
+ }
+ showExportDialog();
return null;
}
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExportProjectHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ExportProjectHandler.java
index 2caea4325..2ea4bb751 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExportProjectHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ExportProjectHandler.java
@@ -8,7 +8,7 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
@@ -16,7 +16,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -41,7 +40,7 @@ import org.eclipse.ui.PlatformUI;
* @author BREDEX GmbH
* @created 08.11.2004
*/
-public class ExportProjectHandler extends AbstractHandler {
+public class ExportProjectHandler extends AbstractProjectHandler {
/**
* @author BREDEX GmbH
* @created Jan 22, 2010
@@ -73,7 +72,7 @@ public class ExportProjectHandler extends AbstractHandler {
public void run() {
RefreshProjectHandler rph =
new RefreshProjectHandler();
- statusOfRefresh.set((IStatus)rph.execute(null));
+ statusOfRefresh.set((IStatus)rph.executeImpl(null));
}
});
@@ -157,17 +156,15 @@ public class ExportProjectHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
+ public Object executeImpl(ExecutionEvent event) {
if (Plugin.getDefault().anyDirtyStar()) {
- if (Plugin.getDefault().
- showSaveEditorDialog()) {
-
+ if (Plugin.getDefault().showSaveEditorDialog()) {
showExportDialog();
}
Plugin.stopLongRunning();
return null;
}
- showExportDialog();
+ showExportDialog();
Plugin.stopLongRunning();
return null;
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ImportProjectHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ImportProjectHandler.java
new file mode 100644
index 000000000..2d68713ac
--- /dev/null
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ImportProjectHandler.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BREDEX 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.ui.handlers.project;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jubula.client.core.persistence.GeneralStorage;
+import org.eclipse.jubula.client.ui.Plugin;
+import org.eclipse.jubula.client.ui.businessprocess.ImportFileBP;
+import org.eclipse.jubula.client.ui.businessprocess.ImportFileBP.IProjectImportInfoProvider;
+import org.eclipse.jubula.client.ui.dialogs.ImportProjectDialog;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author BREDEX GmbH
+ * @created 08.11.2004
+ */
+public class ImportProjectHandler extends AbstractProjectHandler {
+ /**
+ * {@inheritDoc}
+ */
+ public Object executeImpl(ExecutionEvent event) {
+ if (GeneralStorage.getInstance().getProject() != null
+ && Plugin.getDefault().anyDirtyStar()) {
+ if (Plugin.getDefault().showSaveEditorDialog()) {
+ showImportDialog();
+ }
+ Plugin.stopLongRunning();
+ return null;
+ }
+ showImportDialog();
+ return null;
+ }
+
+ /**
+ * brings up the ImportDiaog
+ */
+ void showImportDialog() {
+ ImportProjectDialog importProjectWizard = new ImportProjectDialog();
+ WizardDialog dialog = new WizardDialog(Plugin.getShell(),
+ importProjectWizard) {
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ Button finishButton = getButton(IDialogConstants.FINISH_ID);
+ finishButton.setText(IDialogConstants.OK_LABEL);
+ }
+ };
+ importProjectWizard
+ .setWindowTitle(org.eclipse.jubula.client.ui.i18n.
+ Messages.ImportProjectDialogTitle);
+ dialog.setHelpAvailable(true);
+
+ int val = dialog.open();
+ if (val == Window.OK) {
+ importProjects(importProjectWizard.getImportInfoProvider());
+ }
+ }
+
+ /**
+ * Performs an import using the information provided by the argument.
+ *
+ * @param importInfo
+ * Provides information relevant to the import.
+ */
+ public void importProjects(IProjectImportInfoProvider importInfo) {
+ String[] fileNames = importInfo.getFiles();
+ boolean openProject = importInfo.getIsOpenProject();
+ ImportFileBP.getInstance().importProject(0, fileNames, openProject);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/NewProjectHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/NewProjectHandler.java
index 043fe9e3d..cea1b821c 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/NewProjectHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/NewProjectHandler.java
@@ -8,22 +8,19 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jubula.client.core.model.IProjectPO;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
-import org.eclipse.jubula.client.core.persistence.Hibernator;
import org.eclipse.jubula.client.ui.Plugin;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.dialogs.NagDialog;
-import org.eclipse.jubula.client.ui.utils.JBThread;
import org.eclipse.jubula.client.ui.widgets.JavaAutConfigComponent;
import org.eclipse.jubula.client.ui.wizards.ProjectWizard;
import org.eclipse.jubula.tools.constants.CommandConstants;
@@ -35,7 +32,7 @@ import org.eclipse.ui.PlatformUI;
* @author BREDEX GmbH
* @created 07.02.2005
*/
-public class NewProjectHandler extends AbstractHandler {
+public class NewProjectHandler extends AbstractProjectHandler {
/** was the nag dialog for the executable field already shown? */
private boolean m_alreadyNagged = false;
@@ -145,37 +142,16 @@ public class NewProjectHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
+ public Object executeImpl(ExecutionEvent event) {
m_alreadyNagged = false;
- Plugin.startLongRunning();
- JBThread t = new JBThread() {
- public void run() {
- if (!Hibernator.init()) {
- Plugin.stopLongRunning();
- return;
- }
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- if (GeneralStorage.getInstance().getProject()
- != null
- && Plugin.getDefault().anyDirtyStar()) {
-
- if (!Plugin.getDefault()
- .showSaveEditorDialog()) {
+ if (GeneralStorage.getInstance().getProject() != null
+ && Plugin.getDefault().anyDirtyStar()) {
- return;
- }
- }
- openNewProjectWizard();
- }
- });
- }
-
- protected void errorOccured() {
- Plugin.stopLongRunning();
- }
- };
- t.start();
+ if (!Plugin.getDefault().showSaveEditorDialog()) {
+ return null;
+ }
+ }
+ openNewProjectWizard();
return null;
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/OpenProjectHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/OpenProjectHandler.java
index 51b00b635..dfd9796a1 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/OpenProjectHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/OpenProjectHandler.java
@@ -8,7 +8,7 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -21,7 +21,6 @@ import java.util.TreeMap;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -56,7 +55,6 @@ import org.eclipse.jubula.client.ui.dialogs.NagDialog;
import org.eclipse.jubula.client.ui.dialogs.ProjectDialog;
import org.eclipse.jubula.client.ui.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
-import org.eclipse.jubula.client.ui.utils.JBThread;
import org.eclipse.jubula.client.ui.utils.Utils;
import org.eclipse.jubula.toolkit.common.businessprocess.ToolkitSupportBP;
import org.eclipse.jubula.toolkit.common.exception.ToolkitPluginException;
@@ -70,12 +68,11 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
-
/**
* @author BREDEX GmbH
* @created 18.04.2005
*/
-public class OpenProjectHandler extends AbstractHandler {
+public class OpenProjectHandler extends AbstractProjectHandler {
/**
* @author BREDEX GmbH
* @created Jan 2, 2008
@@ -85,12 +82,13 @@ public class OpenProjectHandler extends AbstractHandler {
* <code>TESTRESULT_DETAIL_JOB_CLEANUP_DELAY</code> is 10 minutes
*/
private static final int TESTRESULT_DETAIL_JOB_CLEANUP_DELAY = 600000;
-
+
/** The project to open */
private IProjectPO m_selectedProject;
/**
- * @param selectedProject The project that is being opened.
+ * @param selectedProject
+ * The project that is being opened.
*/
public OpenProjectOperation(IProjectPO selectedProject) {
m_selectedProject = selectedProject;
@@ -99,20 +97,19 @@ public class OpenProjectHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public void run(IProgressMonitor monitor)
- throws InterruptedException {
+ public void run(IProgressMonitor monitor) throws InterruptedException {
Utils.clearClient();
int totalWork = getTotalWork();
ProgressMonitorTracker.getInstance().setProgressMonitor(monitor);
-
- monitor.beginTask(
- NLS.bind(Messages.OpenProjectOperationOpeningProject,
- new Object[] {m_selectedProject.getName(),
- m_selectedProject.getMajorProjectVersion(),
- m_selectedProject.getMinorProjectVersion()}),
- totalWork);
+
+ monitor.beginTask(NLS.bind(
+ Messages.OpenProjectOperationOpeningProject,
+ new Object[] { m_selectedProject.getName(),
+ m_selectedProject.getMajorProjectVersion(),
+ m_selectedProject.getMinorProjectVersion() }),
+ totalWork);
try {
if (!checkProjectToolkits(m_selectedProject)) {
throw new InterruptedException();
@@ -120,11 +117,12 @@ public class OpenProjectHandler extends AbstractHandler {
checkToolkitAvailable(m_selectedProject.getToolkit());
try {
EntityManager s = Hibernator.instance().openSession();
- EntityTransaction tx =
- Hibernator.instance().getTransaction(s);
- IProjectPO proj = (IProjectPO)s.find(NodeMaker
- .getProjectPOClass(), m_selectedProject.getId());
-
+ EntityTransaction tx = Hibernator.instance()
+ .getTransaction(s);
+ IProjectPO proj = (IProjectPO)s.find(
+ NodeMaker.getProjectPOClass(),
+ m_selectedProject.getId());
+
ProjectPM.initAttributeDescriptions(s, proj);
ProjectPM.initAttributes(proj);
@@ -161,11 +159,10 @@ public class OpenProjectHandler extends AbstractHandler {
ProgressMonitorTracker.getInstance().setProgressMonitor(null);
NodePM.getInstance().setUseCache(false);
monitor.done();
- DataEventDispatcher.getInstance().
- fireProjectOpenedListener();
+ DataEventDispatcher.getInstance().fireProjectOpenedListener();
}
}
-
+
/**
* set persisted values for cleaning testresults in database
*
@@ -201,16 +198,17 @@ public class OpenProjectHandler extends AbstractHandler {
*/
private void checkToolkitAvailable(String toolkitId) {
try {
- if (!ComponentBuilder.getInstance()
- .getLevelToolkitIds().contains(toolkitId)
- && ToolkitConstants.LEVEL_TOOLKIT.equals(
- ToolkitSupportBP.getToolkitLevel(toolkitId))) {
- Utils.createMessageDialog(
- MessageIDs.W_PROJECT_TOOLKIT_NOT_AVAILABLE);
+ if (!ComponentBuilder.getInstance().getLevelToolkitIds()
+ .contains(toolkitId)
+ && ToolkitConstants.LEVEL_TOOLKIT
+ .equals(ToolkitSupportBP
+ .getToolkitLevel(toolkitId))) {
+ Utils.createMessageDialog(MessageIDs.
+ W_PROJECT_TOOLKIT_NOT_AVAILABLE);
}
} catch (ToolkitPluginException e) {
- Utils.createMessageDialog(
- MessageIDs.W_PROJECT_TOOLKIT_NOT_AVAILABLE);
+ Utils.createMessageDialog(MessageIDs.
+ W_PROJECT_TOOLKIT_NOT_AVAILABLE);
}
}
@@ -220,45 +218,40 @@ public class OpenProjectHandler extends AbstractHandler {
*/
private int getTotalWork() {
int totalWork = 0;
- EntityManager masterSession =
- GeneralStorage.getInstance().getMasterSession();
+ EntityManager masterSession = GeneralStorage.getInstance()
+ .getMasterSession();
long selectedProjectId = m_selectedProject.getId();
-
+
// (node=1)
- totalWork += NodePM.getNumNodes(selectedProjectId,
- masterSession);
+ totalWork += NodePM.getNumNodes(selectedProjectId, masterSession);
// (tdMan=1)
- totalWork += NodePM.getNumTestDataManagers(
- selectedProjectId,
+ totalWork += NodePM.getNumTestDataManagers(selectedProjectId,
masterSession);
-
+
// (execTC=1 [each corresponding specTC needs to be fetched])
- totalWork += NodePM.getNumExecTestCases(
- selectedProjectId,
+ totalWork += NodePM.getNumExecTestCases(selectedProjectId,
masterSession);
-
- for (IReusedProjectPO reused
- : m_selectedProject.getUsedProjects()) {
-
+
+ for (IReusedProjectPO reused : m_selectedProject.
+ getUsedProjects()) {
try {
- IProjectPO reusedProject =
- ProjectPM.loadReusedProject(reused);
+ IProjectPO reusedProject = ProjectPM
+ .loadReusedProject(reused);
if (reusedProject != null) {
long reusedId = reusedProject.getId();
-
+
// (node=1)
- totalWork += NodePM.getNumNodes(reusedId,
- masterSession);
+ totalWork += NodePM
+ .getNumNodes(reusedId, masterSession);
// (tdMan=1)
- totalWork += NodePM.getNumTestDataManagers(
- reusedId,
+ totalWork += NodePM.getNumTestDataManagers(reusedId,
masterSession);
- // (execTC=1 [each corresponding specTC needs to be fetched])
- totalWork += NodePM.getNumExecTestCases(
- reusedId,
+ // (execTC=1 [each corresponding specTC needs to be
+ // fetched])
+ totalWork += NodePM.getNumExecTestCases(reusedId,
masterSession);
}
} catch (JBException e) {
@@ -267,16 +260,18 @@ public class OpenProjectHandler extends AbstractHandler {
}
return totalWork;
}
-
+
/**
*
- * @param proj the project to open.
- * @param monitor The progress monitor for this operation.
- * @throws InterruptedException if the operation was canceled.
+ * @param proj
+ * the project to open.
+ * @param monitor
+ * The progress monitor for this operation.
+ * @throws InterruptedException
+ * if the operation was canceled.
*/
- private void load(IProjectPO proj, IProgressMonitor monitor)
+ private void load(IProjectPO proj, IProgressMonitor monitor)
throws InterruptedException {
-
if (proj == null) {
Plugin.stopLongRunning();
showErrorDialog(Messages.OpenProjectActionInternalError);
@@ -292,13 +287,13 @@ public class OpenProjectHandler extends AbstractHandler {
IProjectPO prevProj = GeneralStorage.getInstance().getProject();
ProjectPM.loadProjectInROSession(proj);
try {
- final IProjectPO project =
- GeneralStorage.getInstance().getProject();
+ final IProjectPO project = GeneralStorage.getInstance()
+ .getProject();
try {
UsedToolkitBP.getInstance().refreshToolkitInfo(project);
} catch (PMException e1) {
- PMExceptionHandler.handlePMExceptionForMasterSession(
- e1);
+ PMExceptionHandler
+ .handlePMExceptionForMasterSession(e1);
} catch (ProjectDeletedException e1) {
PMExceptionHandler.handleGDProjectDeletedException();
}
@@ -311,7 +306,7 @@ public class OpenProjectHandler extends AbstractHandler {
} else {
ProjectPM.loadProjectInROSession(prevProj);
}
-
+
throw ce;
}
} catch (PMReadException e) {
@@ -322,59 +317,60 @@ public class OpenProjectHandler extends AbstractHandler {
Plugin.stopLongRunning();
}
}
-
+
/**
* Handles an exception thrown while opening a project.
*/
public void handleOperationException() {
// Clear all current project data
- IProjectPO clearedProject =
- GeneralStorage.getInstance().getProject();
+ IProjectPO clearedProject = GeneralStorage.getInstance()
+ .getProject();
if (clearedProject != null) {
Utils.clearClient();
GeneralStorage.getInstance().setProject(null);
- DataEventDispatcher.getInstance()
- .fireDataChangedListener(clearedProject, DataState.Deleted,
- UpdateState.all);
+ DataEventDispatcher.getInstance().fireDataChangedListener(
+ clearedProject, DataState.Deleted, UpdateState.all);
}
}
/**
- * Checks that the toolkits and toolkit versions are correct enough to
+ * Checks that the toolkits and toolkit versions are correct enough to
* be able to load the project.
*
- * @param proj the project for which to check the toolkits
- * @return <code>true</code> if project can be loaded. Otherwise
+ * @param proj
+ * the project for which to check the toolkits
+ * @return <code>true</code> if project can be loaded. Otherwise
* <code>false</code>.
*/
- private boolean checkProjectToolkits(IProjectPO proj)
+ private boolean checkProjectToolkits(IProjectPO proj)
throws PMException {
-
- final Set<IUsedToolkitPO> usedToolkits =
- UsedToolkitBP.getInstance().readUsedToolkitsFromDB(proj);
+ final Set<IUsedToolkitPO> usedToolkits = UsedToolkitBP
+ .getInstance().readUsedToolkitsFromDB(proj);
return ToolkitBP.getInstance().checkXMLVersion(usedToolkits);
}
/**
* Create an appropriate error dialog.
*
- * @param ce The exception that prevented the loading of
- * project.
+ * @param ce
+ * The exception that prevented the loading of project.
*/
private void handleCapDataNotFound(GDConfigXmlException ce) {
Utils.createMessageDialog(
- MessageIDs.E_LOAD_PROJECT_CONFIG_CONFLICT, null,
- new String[] {ce.getMessage()});
+ MessageIDs.E_LOAD_PROJECT_CONFIG_CONFLICT, null,
+ new String[] { ce.getMessage() });
}
-
+
/**
* Opens an error dialog.
- * @param message the messag eto show in the dialog.
+ *
+ * @param message
+ * the messag eto show in the dialog.
*/
private void showErrorDialog(String message) {
- Utils.createMessageDialog(new JBException(message,
- MessageIDs.E_UNEXPECTED_EXCEPTION), null, new String[]{
- message});
+ Utils.createMessageDialog(new JBException(message,
+ MessageIDs.E_UNEXPECTED_EXCEPTION), null,
+ new String[] { message });
}
/**
@@ -387,180 +383,139 @@ public class OpenProjectHandler extends AbstractHandler {
}
/**
- * Runnable to load Projects from DB
- * @author BREDEX GmbH
- *
+ * Opens a dialog to select a project to open.
*/
- private static class Loader extends JBThread {
-
- /**
- * run method
- */
- public void run() {
- Plugin.startLongRunning();
- if (Hibernator.init()) {
- Display.getDefault().syncExec(new Runnable() {
+ void selectProjects() {
+ if (GeneralStorage.getInstance().getProject() != null
+ && Plugin.getDefault().anyDirtyStar()
+ && !Plugin.getDefault().showSaveEditorDialog()) {
+
+ Plugin.stopLongRunning();
+ return;
+ }
+ List<IProjectPO> projList = null;
+ try {
+ projList = ProjectPM.findAllProjects();
+ if (projList.isEmpty()) {
+ Display.getDefault().asyncExec(new Runnable() {
public void run() {
- try {
- selectProjects();
- } finally {
- Plugin.stopLongRunning();
- }
+ Utils.createMessageDialog(
+ MessageIDs.I_NO_PROJECT_IN_DB);
}
});
- } else {
Plugin.stopLongRunning();
+ return;
}
- }
-
- /**
- * Opens a dialog to select a project to open.
- */
- void selectProjects() {
- if (GeneralStorage.getInstance().getProject() != null
- && Plugin.getDefault().anyDirtyStar()
- && !Plugin.getDefault().showSaveEditorDialog()) {
+ SortedMap<String, List<String>> projNameToVersionMap =
+ new TreeMap<String, List<String>>();
+ for (IProjectPO proj : projList) {
+ String projName = proj.getName();
+ String projVersion = proj.getVersionString();
+ if (!projNameToVersionMap.containsKey(projName)) {
+ projNameToVersionMap.put(projName, new ArrayList<String>());
+ }
+ projNameToVersionMap.get(projName).add(projVersion);
+ }
+ ProjectDialog dialog = openProjectSelectionDialog(projList);
+ if (dialog.getReturnCode() == Window.CANCEL) {
Plugin.stopLongRunning();
return;
}
- List <IProjectPO> projList = null;
- try {
- projList = ProjectPM.findAllProjects();
- if (projList.isEmpty()) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- Utils.createMessageDialog(
- MessageIDs.I_NO_PROJECT_IN_DB);
- }
- });
- Plugin.stopLongRunning();
- return;
- }
-
- SortedMap<String, List<String>> projNameToVersionMap =
- new TreeMap<String, List<String>>();
- for (IProjectPO proj : projList) {
- String projName = proj.getName();
- String projVersion = proj.getVersionString();
- if (!projNameToVersionMap.containsKey(projName)) {
- projNameToVersionMap.put(
- projName, new ArrayList<String>());
- }
- projNameToVersionMap.get(projName).add(projVersion);
- }
- ProjectDialog dialog =
- openProjectSelectionDialog(
- projList);
- if (dialog.getReturnCode() == Window.CANCEL) {
- Plugin.stopLongRunning();
- return;
- }
- final IProjectPO selectedProject = dialog.getSelection();
+ final IProjectPO selectedProject = dialog.getSelection();
- OpenProjectOperation openOperation =
- new OpenProjectOperation(selectedProject);
- try {
- PlatformUI.getWorkbench().getProgressService()
+ OpenProjectOperation openOperation = new OpenProjectOperation(
+ selectedProject);
+ try {
+ PlatformUI.getWorkbench().getProgressService()
.busyCursorWhile(openOperation);
- Plugin.getDisplay().syncExec(new Runnable() {
- public void run() {
- Plugin.setProjectNameInTitlebar(
- selectedProject.getName(),
- selectedProject.getMajorProjectVersion(),
- selectedProject.getMinorProjectVersion());
- }
- });
- checkAndNagForMissingProjects();
- } catch (InvocationTargetException ite) {
- openOperation.handleOperationException();
- } catch (InterruptedException ie) {
- openOperation.handleOperationException();
- }
-
- } catch (final JBException e) {
- Display.getDefault().asyncExec(new Runnable() {
+ Plugin.getDisplay().syncExec(new Runnable() {
public void run() {
- Utils.createMessageDialog(e, null, null);
+ Plugin.setProjectNameInTitlebar(
+ selectedProject.getName(),
+ selectedProject.getMajorProjectVersion(),
+ selectedProject.getMinorProjectVersion());
}
});
- return;
+ checkAndNagForMissingProjects();
+ } catch (InvocationTargetException ite) {
+ openOperation.handleOperationException();
+ } catch (InterruptedException ie) {
+ openOperation.handleOperationException();
}
+ } catch (final JBException e) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ Utils.createMessageDialog(e, null, null);
+ }
+ });
+ return;
}
+ }
- /**
- * checks for missing reused projects after project loading
- */
- private void checkAndNagForMissingProjects() {
- List<String> missingProjects = new LinkedList<String>();
- final IProjectPO project = GeneralStorage
- .getInstance().getProject();
- if (project != null) {
- final Set<IReusedProjectPO> usedProjects = project
- .getUsedProjects();
- if (usedProjects != null) {
- for (IReusedProjectPO rProjects : usedProjects) {
- if (!ProjectPM.doesProjectVersionExist(rProjects
- .getProjectGuid(), rProjects.getMajorNumber(),
- rProjects.getMinorNumber())) {
- missingProjects.add(rProjects.getProjectGuid());
- }
+ /**
+ * checks for missing reused projects after project loading
+ */
+ private void checkAndNagForMissingProjects() {
+ List<String> missingProjects = new LinkedList<String>();
+ final IProjectPO project = GeneralStorage.getInstance().getProject();
+ if (project != null) {
+ final Set<IReusedProjectPO> usedProjects = project
+ .getUsedProjects();
+ if (usedProjects != null) {
+ for (IReusedProjectPO rProjects : usedProjects) {
+ if (!ProjectPM.doesProjectVersionExist(
+ rProjects.getProjectGuid(),
+ rProjects.getMajorNumber(),
+ rProjects.getMinorNumber())) {
+ missingProjects.add(rProjects.getProjectGuid());
}
}
}
- if (!missingProjects.isEmpty()) {
- NagDialog.runNagDialog(Plugin.getShell(),
- "InfoNagger.ImportAllRequiredProjects", //$NON-NLS-1$
- ContextHelpIds.IMPORT_ALL_REQUIRED_PROJECTS);
- }
}
-
- /**
- * @param projList the list of projects in the database
- * @return the dialog
- */
- private ProjectDialog
- openProjectSelectionDialog(List<IProjectPO> projList) {
-
- final ProjectDialog dialog =
- new ProjectDialog(
- Plugin.getShell(), projList,
- Messages.OpenProjectActionMessage,
- Messages.OpenProjectActionTitle,
- IconConstants.OPEN_PROJECT_DIALOG_IMAGE,
- Messages.OpenProjectActionCaption, false);
- // set up help for dialog, with link
- dialog.setHelpAvailable(true);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.OPEN_PROJECT);
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- Plugin.startLongRunning(
- Messages.OpenProjectActionLoadProjectWaitMessage);
- dialog.open();
- }
- });
- return dialog;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void errorOccured() {
- Plugin.stopLongRunning();
+ if (!missingProjects.isEmpty()) {
+ NagDialog.runNagDialog(Plugin.getShell(),
+ "InfoNagger.ImportAllRequiredProjects", //$NON-NLS-1$
+ ContextHelpIds.IMPORT_ALL_REQUIRED_PROJECTS);
}
-
}
/**
+ * @param projList
+ * the list of projects in the database
+ * @return the dialog
+ */
+ private ProjectDialog openProjectSelectionDialog(
+ List<IProjectPO> projList) {
+ final ProjectDialog dialog = new ProjectDialog(Plugin.getShell(),
+ projList, Messages.OpenProjectActionMessage,
+ Messages.OpenProjectActionTitle,
+ IconConstants.OPEN_PROJECT_DIALOG_IMAGE,
+ Messages.OpenProjectActionCaption, false);
+ // set up help for dialog, with link
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.OPEN_PROJECT);
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ Plugin.startLongRunning(Messages.
+ OpenProjectActionLoadProjectWaitMessage);
+ dialog.open();
+ }
+ });
+ return dialog;
+ }
+
+
+ /**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
- new Loader().start();
+ public Object executeImpl(ExecutionEvent event) {
+ selectProjects();
return null;
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ProjectPropertiesHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ProjectPropertiesHandler.java
index f24ed5852..303b25b4f 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ProjectPropertiesHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/ProjectPropertiesHandler.java
@@ -8,11 +8,9 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.preference.PreferenceNode;
@@ -47,7 +45,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
* @author BREDEX GmbH
* @created Apr 30, 2009
*/
-public class ProjectPropertiesHandler extends AbstractHandler {
+public class ProjectPropertiesHandler extends AbstractProjectHandler {
/**
* ID of command parameter for the section of the Project Properties
@@ -59,7 +57,7 @@ public class ProjectPropertiesHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ public Object executeImpl(ExecutionEvent event) {
IWorkbenchWindow activeWindow =
HandlerUtil.getActiveWorkbenchWindow(event);
Shell shell = activeWindow != null ? activeWindow.getShell() : null;
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshProjectHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/RefreshProjectHandler.java
index f35b10b85..69f615877 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/RefreshProjectHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/RefreshProjectHandler.java
@@ -8,13 +8,12 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
import java.lang.reflect.InvocationTargetException;
import javax.persistence.EntityManager;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -38,9 +37,9 @@ import org.eclipse.ui.PlatformUI;
* @author BREDEX GmbH
* @created 01.06.2006
*/
-public class RefreshProjectHandler extends AbstractHandler {
+public class RefreshProjectHandler extends AbstractProjectHandler {
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) {
+ public Object executeImpl(ExecutionEvent event) {
return refreshProject();
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/SaveProjectAsHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/SaveProjectAsHandler.java
index 4c463b20d..55bff5a45 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/SaveProjectAsHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/SaveProjectAsHandler.java
@@ -8,7 +8,7 @@
* Contributors:
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
-package org.eclipse.jubula.client.ui.handlers;
+package org.eclipse.jubula.client.ui.handlers.project;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -16,7 +16,6 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -65,8 +64,7 @@ import org.eclipse.ui.PlatformUI;
* @created 11.05.2005
*/
@SuppressWarnings("synthetic-access")
-public class SaveProjectAsHandler extends AbstractHandler {
-
+public class SaveProjectAsHandler extends AbstractProjectHandler {
/** standard logging */
private static Log log = LogFactory.getLog(SaveProjectAsHandler.class);
@@ -341,8 +339,7 @@ public class SaveProjectAsHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
- Plugin.startLongRunning(Messages.SaveProjectAsActionWaitWhileSaving);
+ public Object executeImpl(ExecutionEvent event) {
InputDialog dialog = openInputDialog();
if (dialog.getReturnCode() == Window.OK) {
final String newProjectName = dialog.getName();
@@ -361,8 +358,6 @@ public class SaveProjectAsHandler extends AbstractHandler {
// rolled back.
Utils.clearClient();
}
- } else {
- Plugin.stopLongRunning();
}
return null;
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/SelectDatabaseHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/SelectDatabaseHandler.java
new file mode 100644
index 000000000..82d1fd294
--- /dev/null
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/SelectDatabaseHandler.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BREDEX 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.ui.handlers.project;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jubula.client.core.persistence.CompNamePM;
+import org.eclipse.jubula.client.core.persistence.DatabaseConnectionInfo;
+import org.eclipse.jubula.client.core.persistence.GeneralStorage;
+import org.eclipse.jubula.client.core.persistence.Hibernator;
+import org.eclipse.jubula.client.core.persistence.locking.LockManager;
+import org.eclipse.jubula.client.core.preferences.database.DatabaseConnection;
+import org.eclipse.jubula.client.core.preferences.database.DatabaseConnectionConverter;
+import org.eclipse.jubula.client.core.preferences.database.H2ConnectionInfo;
+import org.eclipse.jubula.client.ui.Plugin;
+import org.eclipse.jubula.client.ui.dialogs.DBLoginDialog;
+import org.eclipse.jubula.client.ui.i18n.Messages;
+import org.eclipse.jubula.client.ui.utils.DialogUtils;
+import org.eclipse.jubula.client.ui.utils.Utils;
+import org.eclipse.jubula.tools.constants.StringConstants;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author BREDEX GmbH
+ * @created 18.04.2005
+ */
+public class SelectDatabaseHandler extends AbstractHandler {
+ /** the logger */
+ private static Log log = LogFactory.getLog(SelectDatabaseHandler.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object execute(ExecutionEvent event) {
+ IStatus returnStatus = Status.CANCEL_STATUS;
+ boolean performLogin = false;
+ String userName = StringConstants.EMPTY;
+ String pwd = StringConstants.EMPTY;
+ DatabaseConnectionInfo dbInfo = null;
+
+ List<DatabaseConnection> availableConnections =
+ DatabaseConnectionConverter
+ .computeAvailableConnections();
+ if (availableConnections.size() == 1
+ && availableConnections.get(0).getConnectionInfo()
+ instanceof H2ConnectionInfo) {
+ dbInfo = availableConnections.get(0).getConnectionInfo();
+ userName = dbInfo.getProperty(PersistenceUnitProperties.JDBC_USER);
+ pwd = dbInfo.getProperty(PersistenceUnitProperties.JDBC_PASSWORD);
+ performLogin = true;
+ } else {
+ DBLoginDialog dialog = new DBLoginDialog(Plugin.getShell());
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ dialog.open();
+ if (dialog.getReturnCode() == Window.OK) {
+ userName = dialog.getUser();
+ pwd = dialog.getPwd();
+ dbInfo = dialog.getDatabaseConnection().getConnectionInfo();
+ performLogin = true;
+ }
+ }
+
+ if (performLogin) {
+ try {
+ returnStatus = connectToDatabase(userName, pwd, dbInfo);
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ }
+
+ Hibernator.setUser(null);
+ Hibernator.setPw(null);
+ return returnStatus;
+ }
+
+ /**
+ *
+ * @param username
+ * the username to use
+ * @param pwd
+ * the password to use
+ * @param info
+ * the database connection info
+ * @return a status
+ */
+ private IStatus connectToDatabase(final String username, final String pwd,
+ final DatabaseConnectionInfo info) throws InterruptedException {
+ final AtomicReference<IStatus> returnStatus =
+ new AtomicReference<IStatus>(Status.CANCEL_STATUS);
+ try {
+ PlatformUI.getWorkbench().getProgressService()
+ .run(true, false, new IRunnableWithProgress() {
+ /** {@inheritDoc} */
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(Messages.PluginConnectProgress,
+ IProgressMonitor.UNKNOWN);
+ Utils.clearClient();
+ Hibernator.setUser(username);
+ Hibernator.setPw(pwd);
+ Hibernator.setDbConnectionName(info);
+
+ if (Hibernator.instance() != null) {
+ CompNamePM.dispose();
+ GeneralStorage.getInstance().dispose();
+ if (LockManager.isRunning()) {
+ LockManager.instance().dispose();
+ }
+ Hibernator.instance().dispose();
+ }
+ if (Hibernator.init()) {
+ LockManager.instance();
+ Plugin.getDefault().writeLineToConsole(
+ Messages.
+ SelectDatabaseConnectSuccessful,
+ true);
+ returnStatus.set(Status.OK_STATUS);
+ } else {
+ Plugin.getDefault().writeLineToConsole(
+ Messages.SelectDatabaseConnectFailed,
+ true);
+ }
+ }
+ });
+ } catch (InvocationTargetException ite) {
+ // Exception occurred during operation
+ log.error(ite.getCause(), ite.getCause());
+ } catch (InterruptedException ie) {
+ throw ie;
+ }
+
+ return returnStatus.get();
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
index ad651202c..dbe03aac1 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
@@ -797,8 +797,8 @@ public class Messages extends NLS {
public static String SaveProjectAsOperationSavingProject;
public static String SearchingIn;
public static String SearchResultPageResultPageLabel;
- public static String SelectDatabaseActionInfoConnectFailed;
- public static String SelectDatabaseActionInfoConnectSuccessful;
+ public static String SelectDatabaseConnectFailed;
+ public static String SelectDatabaseConnectSuccessful;
public static String SelectedElementIsNotTestResultSummary;
public static String ServerLogViewerName;
public static String ServerName;
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
index 2734933aa..31b4c72bf 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
@@ -72,8 +72,8 @@ SaveProjectAsActionLabel=New Project &name\:
SaveProjectAsActionInvalidName=Project name is not valid. A Project name must not start or end with a blank.
SaveProjectAsActionDoubleOrInvalidName=Project name already exists or contains invalid characters.
SaveProjectAsActionShellTitle=Save Project as...
-SelectDatabaseActionInfoConnectSuccessful=Connection to Database successful.
-SelectDatabaseActionInfoConnectFailed=Connection to Database failed.
+SelectDatabaseConnectSuccessful=Connection to Database successful.
+SelectDatabaseConnectFailed=Connection to Database failed.
PluginConnectProgress=Please wait while connecting to Database...
AUTPropertyPageAdd=A&dd
AUTPropertyPageEdit=&Edit
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/sourceprovider/ActiveProjectSourceProvider.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/sourceprovider/ActiveProjectSourceProvider.java
index 8c8d8c7d3..6458295be 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/sourceprovider/ActiveProjectSourceProvider.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/sourceprovider/ActiveProjectSourceProvider.java
@@ -22,9 +22,9 @@ import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.IProjectPO;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
import org.eclipse.jubula.client.core.persistence.Hibernator;
-import org.eclipse.jubula.client.core.utils.IProgressListener;
-import org.eclipse.jubula.client.core.utils.ProgressEvent;
-import org.eclipse.jubula.client.core.utils.ProgressEventDispatcher;
+import org.eclipse.jubula.client.core.utils.IDatabaseStateListener;
+import org.eclipse.jubula.client.core.utils.DatabaseStateEvent;
+import org.eclipse.jubula.client.core.utils.DatabaseStateDispatcher;
import org.eclipse.ui.ISources;
@@ -36,8 +36,7 @@ import org.eclipse.ui.ISources;
*/
public class ActiveProjectSourceProvider extends AbstractJBSourceProvider
implements IProjectLoadedListener, IDataChangedListener,
- IProgressListener {
-
+ IDatabaseStateListener {
/**
* ID of variable that indicates whether a Project is currently active/open.
*/
@@ -62,7 +61,7 @@ public class ActiveProjectSourceProvider extends AbstractJBSourceProvider
public ActiveProjectSourceProvider() {
DataEventDispatcher.getInstance().addProjectLoadedListener(this, true);
DataEventDispatcher.getInstance().addDataChangedListener(this, true);
- ProgressEventDispatcher.addProgressListener(this);
+ DatabaseStateDispatcher.addDatabaseStateListener(this);
}
/**
@@ -72,7 +71,7 @@ public class ActiveProjectSourceProvider extends AbstractJBSourceProvider
public void dispose() {
DataEventDispatcher.getInstance().removeProjectLoadedListener(this);
DataEventDispatcher.getInstance().removeDataChangedListener(this);
- ProgressEventDispatcher.removeProgressListener(this);
+ DatabaseStateDispatcher.removeDatabaseStateListener(this);
}
/**
@@ -140,7 +139,7 @@ public class ActiveProjectSourceProvider extends AbstractJBSourceProvider
/**
* {@inheritDoc}
*/
- public void reactOnProgressEvent(ProgressEvent e) {
+ public void reactOnProgressEvent(DatabaseStateEvent e) {
fireSourceChanged();
}
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/JBThread.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/JBThread.java
index e41e71d01..874ae6989 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/JBThread.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/JBThread.java
@@ -26,27 +26,6 @@ public abstract class JBThread extends Thread {
}
/**
- * @param target
- * Runnable
- * @param name
- * String
- */
- public JBThread(Runnable target, String name) {
- super(target, name);
- addErrorHandler();
-
- }
-
- /**
- * @param target
- * Runnable
- */
- public JBThread(Runnable target) {
- super(target);
- addErrorHandler();
- }
-
- /**
* @param name
* String
*/
@@ -56,58 +35,6 @@ public abstract class JBThread extends Thread {
}
/**
- * @param group
- * ThreadGroup
- * @param target
- * Runnable
- * @param name
- * Runnable
- * @param stackSize
- * long
- */
- public JBThread(ThreadGroup group, Runnable target,
- String name, long stackSize) {
- super(group, target, name, stackSize);
- addErrorHandler();
- }
-
- /**
- * @param group
- * ThreadGroup
- * @param target
- * Runnable
- * @param name
- * String
- */
- public JBThread(ThreadGroup group, Runnable target, String name) {
- super(group, target, name);
- addErrorHandler();
- }
-
- /**
- * @param group
- * ThreadGroup
- * @param target
- * String
- */
- public JBThread(ThreadGroup group, Runnable target) {
- super(group, target);
- addErrorHandler();
- }
-
- /**
- *
- * @param group
- * ThreadGroup
- * @param name
- * String
- */
- public JBThread(ThreadGroup group, String name) {
- super(group, name);
- addErrorHandler();
- }
-
- /**
* {@inheritDoc}
*/
public void start() {
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java
index 8066f083a..1e9181a3f 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java
@@ -857,7 +857,7 @@ public class TestresultSummaryView extends ViewPart
* refresh view
*/
public void refreshView() {
- m_tableViewer.getControl().getDisplay().syncExec(new Runnable() {
+ m_tableViewer.getControl().getDisplay().asyncExec(new Runnable() {
public void run() {
List<ITestResultSummaryPO> metaList;
try {
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/problemview/JBMarkerResolutionGenerator.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/problemview/JBMarkerResolutionGenerator.java
index ca3667db8..b4ddc5e7d 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/problemview/JBMarkerResolutionGenerator.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/problemview/JBMarkerResolutionGenerator.java
@@ -42,8 +42,8 @@ import org.eclipse.jubula.client.ui.constants.CommandIDs;
import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.editors.ObjectMappingMultiPageEditor;
import org.eclipse.jubula.client.ui.editors.TestCaseEditor;
-import org.eclipse.jubula.client.ui.handlers.ProjectPropertiesHandler;
import org.eclipse.jubula.client.ui.handlers.open.AbstractOpenHandler;
+import org.eclipse.jubula.client.ui.handlers.project.ProjectPropertiesHandler;
import org.eclipse.jubula.client.ui.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.CommandHelper;
import org.eclipse.jubula.client.ui.utils.DialogUtils;

Back to the top