Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2012-07-04 14:04:46 +0000
committerMarkus Tiede2012-07-04 14:04:46 +0000
commit559182c714f03e6dc3f1cee77f35fdf144b4afe3 (patch)
tree7f8ef97e26dd23e34b21ff95bd9b60040a34bcc2
parentc1743bc647ab2c54a33500849c93e61fae4ea7fc (diff)
downloadorg.eclipse.jubula.core-559182c714f03e6dc3f1cee77f35fdf144b4afe3.tar.gz
org.eclipse.jubula.core-559182c714f03e6dc3f1cee77f35fdf144b4afe3.tar.xz
org.eclipse.jubula.core-559182c714f03e6dc3f1cee77f35fdf144b4afe3.zip
Sprint task - added new option to perform auto-load of project from database for the UI client.
-rw-r--r--org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProjectUIBP.java139
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java143
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/DeleteProjectHandler.java21
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/OpenProjectHandler.java123
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java2
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties2
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/preferences/PrefPageBasic.java23
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java14
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java30
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/preferences/PreferenceInitializer.java2
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/DialogUtils.java36
12 files changed, 433 insertions, 105 deletions
diff --git a/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF
index dd7fd4eed..a009af42f 100644
--- a/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF
+++ b/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF
@@ -70,7 +70,8 @@ Require-Bundle: org.eclipse.jubula.tools;bundle-version="[1.2.0,1.3.0)",
org.eclipse.jubula.client.archive;bundle-version="[1.2.0,1.3.0)",
org.eclipse.core.databinding;bundle-version="[1.3.0,2.0.0)",
org.eclipse.core.databinding.beans;bundle-version="[1.2.100,2.0.0)",
- org.eclipse.core.databinding.property;bundle-version="1.3.0"
+ org.eclipse.core.databinding.property;bundle-version="1.3.0",
+ org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-BundleShape: jar
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProjectUIBP.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProjectUIBP.java
new file mode 100644
index 000000000..3b0f09801
--- /dev/null
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProjectUIBP.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 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.rcp.businessprocess;
+
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.equinox.security.storage.StorageException;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jubula.client.ui.constants.Constants;
+import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.dialogs.ProjectDialog.ProjectData;
+import org.eclipse.jubula.tools.constants.DebugConstants;
+import org.eclipse.jubula.tools.constants.StringConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ *
+ * @author BREDEX GmbH
+ * @created 12.06.2012
+ *
+ */
+public class ProjectUIBP {
+ /** the singleton instance */
+ private static ProjectUIBP instance;
+
+ /** the logger */
+ private static final Logger LOG = LoggerFactory.
+ getLogger(ProjectUIBP.class);
+
+ /** the preference store */
+ private final IPreferenceStore m_prefStore;
+
+ /**
+ * hidden constructor
+ */
+ private ProjectUIBP() {
+ m_prefStore = Plugin.getDefault().getPreferenceStore();
+ }
+
+ /**
+ * creates the instance of this class or ...
+ * @return returns the instance
+ */
+ public static ProjectUIBP getInstance() {
+ if (instance == null) {
+ instance = new ProjectUIBP();
+ }
+ return instance;
+ }
+
+ /**
+ * checks whether a project is saved in preference store
+ * @return true when project data exists,
+ * false otherwise
+ */
+ public boolean shouldPerformAutoProjectLoad() {
+ return m_prefStore.getBoolean(Constants.PERFORM_AUTO_PROJECT_LOAD_KEY);
+ }
+
+ /**
+ * gets the project data from secure preference store
+ * @return the project data
+ */
+ public static ProjectData getMostRecentProjectData() {
+ ISecurePreferences node = getSecurePreferenceNode();
+ ProjectData projectData = new ProjectData(StringConstants.EMPTY,
+ StringConstants.EMPTY);
+ if (node != null) {
+ try {
+ projectData.setGUID(node.get(
+ Constants.MOST_RECENT_PROJECTDATA_GUID_KEY,
+ StringConstants.EMPTY));
+ projectData.setVersionString(node.get(
+ Constants.MOST_RECENT_PROJECTDATA_VERSION_KEY,
+ StringConstants.EMPTY));
+
+ } catch (StorageException e) {
+ LOG.error(DebugConstants.ERROR, e);
+ }
+ }
+ return projectData;
+ }
+
+ /**
+ * saves the project data in secure preference store
+ * @param projectData the project data
+ */
+ public void saveMostRecentProjectData(
+ ProjectData projectData) {
+ m_prefStore.setValue(Constants.PERFORM_AUTO_PROJECT_LOAD_KEY, true);
+ ISecurePreferences node = getSecurePreferenceNode();
+ if (node != null) {
+ try {
+ node.put(Constants.MOST_RECENT_PROJECTDATA_GUID_KEY,
+ projectData.getGUID(), true);
+ node.put(Constants.MOST_RECENT_PROJECTDATA_VERSION_KEY,
+ projectData.getVersionString(), true);
+ } catch (StorageException e1) {
+ LOG.error(DebugConstants.ERROR, e1);
+ }
+ } else {
+ LOG.error(DebugConstants.ERROR);
+ }
+ }
+
+ /**
+ * removes the project data from secure preference store
+ */
+ public void removeMostRecentProjectData() {
+ ISecurePreferences node = getSecurePreferenceNode();
+ m_prefStore.setValue(Constants.PERFORM_AUTO_PROJECT_LOAD_KEY, false);
+ if (node != null) {
+ node.removeNode();
+ }
+ }
+
+ /**
+ * creates the secure preference node and returns it
+ * @return the secure preference node
+ */
+ private static ISecurePreferences getSecurePreferenceNode() {
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ ISecurePreferences node = root;
+ if (root != null) {
+ node = root.node(
+ Constants.ORG_ECLIPSE_JUBULA_MOST_RECENT_PROJECTDATA_KEY);
+ }
+ return node;
+ }
+
+}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java
index 116b5ddb2..4ac08ec2c 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java
@@ -20,9 +20,15 @@ import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.layout.RowLayoutFactory;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jubula.client.core.model.IProjectPO;
+import org.eclipse.jubula.client.ui.constants.Constants;
+import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.businessprocess.ProjectUIBP;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.rcp.provider.ControlDecorator;
+import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.jubula.client.ui.utils.LayoutUtil;
import org.eclipse.jubula.client.ui.widgets.DirectCombo;
import org.eclipse.jubula.tools.constants.StringConstants;
@@ -82,15 +88,18 @@ public class ProjectDialog extends TitleAreaDialog {
private DirectCombo<String> m_versionComboBox;
/**
- * Mapping from project name to project versions
+ * Mapping from project GUIDs to project versions
*/
- private Map<String, List<String>> m_nameToVersionMap;
+ private Map<String, List<String>> m_guidToVersionMap;
/**
* Mapping from project data to project
*/
private Map<ProjectData, IProjectPO> m_projectMap;
+ /** List of project GUIDs */
+ private List<String> m_guidList;
+
/** List of project names */
private List<String> m_nameList;
@@ -98,8 +107,8 @@ public class ProjectDialog extends TitleAreaDialog {
private List<String> m_versionList;
/** result of dialog, null if nothing was selected */
- private IProjectPO m_selection = null;
-
+ private ProjectData m_selection;
+
/**
* label of name combo
*/
@@ -126,6 +135,11 @@ public class ProjectDialog extends TitleAreaDialog {
private String m_shellTitle;
/**
+ * check box to select a default project and project version
+ */
+ private Button m_defaultProject;
+
+ /**
* <code>m_isDeleteAction</code> true if dialog is "delete project"-dialog
*/
private boolean m_isDeleteAction = false;
@@ -145,19 +159,19 @@ public class ProjectDialog extends TitleAreaDialog {
* @author BREDEX GmbH
* @created Jun 21, 2007
*/
- private class ProjectData {
- /** project name */
- private String m_name;
+ public static class ProjectData {
+ /** project guid */
+ private String m_guid;
/** project version */
private String m_versionString;
/**
* Constructor
- * @param name project name
+ * @param guid project's GUID
* @param versionString project version string
*/
- public ProjectData(String name, String versionString) {
- m_name = name;
+ public ProjectData(String guid, String versionString) {
+ m_guid = guid;
m_versionString = versionString;
}
@@ -165,16 +179,32 @@ public class ProjectDialog extends TitleAreaDialog {
*
* @return version string
*/
- private String getVersionString() {
+ public String getVersionString() {
return m_versionString;
}
+
+ /**
+ * sets the project version
+ * @param version the project version
+ */
+ public void setVersionString(String version) {
+ m_versionString = version;
+ }
/**
*
- * @return name
+ * @return GUID
+ */
+ public String getGUID() {
+ return m_guid;
+ }
+
+ /**
+ * sets the project name
+ * @param guid the projects GUID
*/
- private String getName() {
- return m_name;
+ public void setGUID(String guid) {
+ m_guid = guid;
}
/**
@@ -190,7 +220,7 @@ public class ProjectDialog extends TitleAreaDialog {
}
ProjectData otherData = (ProjectData)obj;
- return new EqualsBuilder().append(getName(), otherData.getName())
+ return new EqualsBuilder().append(getGUID(), otherData.getGUID())
.append(getVersionString(), otherData.getVersionString())
.isEquals();
}
@@ -200,11 +230,10 @@ public class ProjectDialog extends TitleAreaDialog {
* {@inheritDoc}
*/
public int hashCode() {
- return new HashCodeBuilder().append(getName())
+ return new HashCodeBuilder().append(getGUID())
.append(getVersionString())
.toHashCode();
}
-
}
/**
@@ -222,24 +251,26 @@ public class ProjectDialog extends TitleAreaDialog {
super(parentShell);
- m_nameToVersionMap =
+ m_guidToVersionMap =
new HashMap<String, List<String>>();
m_projectMap = new HashMap<ProjectData, IProjectPO>();
+ m_guidList = new ArrayList<String>();
m_nameList = new ArrayList<String>();
m_versionList = new ArrayList<String>();
for (IProjectPO proj : projectList) {
- String projName = proj.getName();
+ String projGUID = proj.getGuid();
String projVersion = proj.getVersionString();
- if ((projName != null) && (projVersion != null)) { // protect
+ if ((projGUID != null) && (projVersion != null)) { // protect
// against racing
// conditions in
// DB
- if (!m_nameToVersionMap.containsKey(projName)) {
- m_nameList.add(projName);
- m_nameToVersionMap.put(projName, new ArrayList<String>());
+ if (!m_guidToVersionMap.containsKey(projGUID)) {
+ m_nameList.add(proj.getName());
+ m_guidList.add(projGUID);
+ m_guidToVersionMap.put(projGUID, new ArrayList<String>());
}
- m_nameToVersionMap.get(projName).add(projVersion);
- m_projectMap.put(new ProjectData(projName, projVersion), proj);
+ m_guidToVersionMap.get(projGUID).add(projVersion);
+ m_projectMap.put(new ProjectData(projGUID, projVersion), proj);
} else {
log.warn(Messages.ProjectWithGUID + StringConstants.SPACE
+ proj.getGuid() + StringConstants.SPACE
@@ -286,6 +317,7 @@ public class ProjectDialog extends TitleAreaDialog {
area.setLayoutData(gridData);
createComboBoxes(area);
+ createDefaultProjectCheckbox(area);
if (m_isDeleteAction) {
createDeleteTestresultsCheckbox(area);
@@ -316,17 +348,16 @@ public class ProjectDialog extends TitleAreaDialog {
* The parent composite.
*/
private void createComboBoxes(Composite parent) {
- new Label(parent, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.CENTER, false, false, HORIZONTAL_SPAN + 1, 1));
+ createEmptyLabel(parent);
new Label(parent, SWT.NONE).setText(m_label);
m_nameComboBox = new DirectCombo<String>(parent, SWT.SINGLE | SWT.BORDER
- | SWT.READ_ONLY, m_nameList, m_nameList, false, true);
+ | SWT.READ_ONLY, m_guidList, m_nameList, false, true);
GridData gridData = newGridData();
LayoutUtil.addToolTipAndMaxWidth(gridData, m_nameComboBox);
m_nameComboBox.setLayoutData(gridData);
m_nameComboBox.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- m_versionList = m_nameToVersionMap.get(
+ m_versionList = m_guidToVersionMap.get(
m_nameComboBox.getSelectedObject());
m_versionComboBox.setItems(m_versionList, m_versionList);
m_versionComboBox.select(m_versionComboBox.getItemCount() - 1);
@@ -339,10 +370,9 @@ public class ProjectDialog extends TitleAreaDialog {
if (m_nameComboBox.getItemCount() > 0) {
m_nameComboBox.select(0);
}
- m_versionList = m_nameToVersionMap.get(
+ m_versionList = m_guidToVersionMap.get(
m_nameComboBox.getSelectedObject());
- new Label(parent, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.CENTER, false, false, HORIZONTAL_SPAN + 1, 1));
+ createEmptyLabel(parent);
new Label(parent, SWT.NONE).setText(m_label2);
m_versionComboBox =
new DirectCombo<String>(parent, SWT.SINGLE | SWT.BORDER
@@ -374,6 +404,40 @@ public class ProjectDialog extends TitleAreaDialog {
}
/**
+ * Creates the check box to select a default project and project version
+ *
+ * @param composite the parent composite
+ */
+ private void createDefaultProjectCheckbox(Composite composite) {
+ if (!m_isDeleteAction) {
+ createEmptyLabel(composite);
+ new Label(composite, SWT.NONE).setLayoutData(new GridData(
+ GridData.FILL, GridData.CENTER, false, false,
+ HORIZONTAL_SPAN, 1));
+ IPreferenceStore prefs = Plugin.getDefault().getPreferenceStore();
+ Composite checkLinkComposite = new Composite(composite, SWT.NONE);
+ checkLinkComposite.setLayout(RowLayoutFactory.fillDefaults()
+ .spacing(0).create());
+ m_defaultProject = new Button(checkLinkComposite, SWT.CHECK);
+ m_defaultProject.setSelection(prefs.getBoolean(
+ Constants.PERFORM_AUTO_PROJECT_LOAD_KEY));
+ DialogUtils.createLinkToSecureStoragePreferencePage(
+ checkLinkComposite,
+ Messages.OpenProjectDialogDefaultProjectCheckbox);
+ }
+ }
+
+ /**
+ * @param composite
+ * the parent composite to use
+ */
+ private void createEmptyLabel(Composite composite) {
+ new Label(composite, SWT.NONE).setLayoutData(new GridData(
+ GridData.FILL, GridData.CENTER, false, false,
+ HORIZONTAL_SPAN + 1, 1));
+ }
+
+ /**
* enables the OK button
*/
public void enableOKButton() {
@@ -387,12 +451,15 @@ public class ProjectDialog extends TitleAreaDialog {
* This method is called, when the OK button was pressed
*/
protected void okPressed() {
- m_selection = m_projectMap.get(
- new ProjectData(m_nameComboBox.getSelectedObject(),
- m_versionComboBox.getSelectedObject()));
+ m_selection = new ProjectData(m_nameComboBox.getSelectedObject(),
+ m_versionComboBox.getSelectedObject());
+
+ final ProjectUIBP defaultProject = ProjectUIBP.getInstance();
if (m_isDeleteAction) {
- m_keepTestresultSummary =
- m_keepTestresultSummaryButton.getSelection();
+ m_keepTestresultSummary = m_keepTestresultSummaryButton
+ .getSelection();
+ } else if (m_defaultProject.getSelection()) {
+ defaultProject.saveMostRecentProjectData(m_selection);
}
setReturnCode(OK);
close();
@@ -413,7 +480,7 @@ public class ProjectDialog extends TitleAreaDialog {
/**
* @return Returns the selection.
*/
- public IProjectPO getSelection() {
+ public ProjectData getSelection() {
return m_selection;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/DeleteProjectHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/DeleteProjectHandler.java
index 0a6af992e..ad800b1bb 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/DeleteProjectHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/DeleteProjectHandler.java
@@ -216,8 +216,17 @@ public class DeleteProjectHandler extends AbstractProjectHandler {
if (dialog.getReturnCode() == Window.CANCEL) {
return;
}
- IProjectPO project = dialog.getSelection();
- if (project == null) {
+ ProjectDialog.ProjectData project = dialog.getSelection();
+ IProjectPO projectToDelete = null;
+ for (IProjectPO projToDelete : projList) {
+ if (projToDelete.getGuid().equals(
+ project.getGUID())
+ && projToDelete.getVersionString().equals(
+ project.getVersionString())) {
+ projectToDelete = projToDelete;
+ }
+ }
+ if (projectToDelete == null) {
Plugin.stopLongRunning();
return;
}
@@ -225,12 +234,13 @@ public class DeleteProjectHandler extends AbstractProjectHandler {
Integer questionID = null;
Object[] param = null;
IProjectPO actProj = GeneralStorage.getInstance().getProject();
- if (actProj != null && actProj.getId().equals(project.getId())) {
+ if (actProj != null && actProj.getId().equals(
+ projectToDelete.getId())) {
questionID = MessageIDs.Q_DELETE_ACTUAL_PROJECT;
deleteCurrentProject = true;
} else {
questionID = MessageIDs.Q_DELETE_PROJECT;
- param = new Object[]{project.getName()};
+ param = new Object[]{projectToDelete.getName()};
}
Plugin.startLongRunning(
Messages.DeleteProjectActionWaitWhileDeleting);
@@ -240,7 +250,8 @@ public class DeleteProjectHandler extends AbstractProjectHandler {
try {
PlatformUI.getWorkbench().getProgressService()
.busyCursorWhile(new DeleteProjectOperation(
- project, deleteCurrentProject, keepTestresults));
+ projectToDelete, deleteCurrentProject,
+ keepTestresults));
} catch (InvocationTargetException e) {
// Exception occurred during the operation.
// The exception was already handled by the operation.
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/OpenProjectHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/OpenProjectHandler.java
index 8c2e79b4c..9aac84baa 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/OpenProjectHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/project/OpenProjectHandler.java
@@ -47,6 +47,7 @@ import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.handlers.project.AbstractProjectHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.businessprocess.ProjectUIBP;
import org.eclipse.jubula.client.ui.rcp.businessprocess.ToolkitBP;
import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.rcp.dialogs.NagDialog;
@@ -350,7 +351,7 @@ public class OpenProjectHandler extends AbstractProjectHandler {
* Opens an error dialog.
*
* @param message
- * the messag eto show in the dialog.
+ * the message to show in the dialog.
*/
private void showErrorDialog(String message) {
ErrorHandlingUtil.createMessageDialog(new JBException(message,
@@ -366,18 +367,13 @@ public class OpenProjectHandler extends AbstractProjectHandler {
}
}
-
+
/**
- * Opens a dialog to select a project to open.
+ * Checks all available projects
+ *
+ * @return list of all projects
*/
- void selectProjects() {
- if (GeneralStorage.getInstance().getProject() != null
- && Plugin.getDefault().anyDirtyStar()
- && !Plugin.getDefault().showSaveEditorDialog()) {
-
- Plugin.stopLongRunning();
- return;
- }
+ private List<IProjectPO> checkAllAvailableProjects() {
List<IProjectPO> projList = null;
try {
projList = ProjectPM.findAllProjects();
@@ -385,32 +381,76 @@ public class OpenProjectHandler extends AbstractProjectHandler {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
ErrorHandlingUtil.createMessageDialog(
- MessageIDs.I_NO_PROJECT_IN_DB);
+ 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>());
+ } else {
+ 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);
}
- projNameToVersionMap.get(projName).add(projVersion);
}
- ProjectDialog dialog = openProjectSelectionDialog(projList);
+ } catch (final JBException e) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ ErrorHandlingUtil.createMessageDialog(e, null, null);
+ }
+ });
+ }
+ return projList;
+ }
+
+ /**
+ * opens the project open dialog
+ * @param projList the project list
+ * @return the open project dialog
+ */
+ public ProjectDialog openProjectOpenDialog(List<IProjectPO> projList) {
+ ProjectDialog dialog = null;
+ if (GeneralStorage.getInstance().getProject() != null
+ && Plugin.getDefault().anyDirtyStar()
+ && !Plugin.getDefault().showSaveEditorDialog()) {
+
+ Plugin.stopLongRunning();
+ } else {
+ dialog = openProjectSelectionDialog(projList);
if (dialog.getReturnCode() == Window.CANCEL) {
Plugin.stopLongRunning();
- return;
}
- final IProjectPO selectedProject = dialog.getSelection();
-
+ }
+ return dialog;
+ }
+
+ /**
+ * open the selected or the default project
+ *
+ * @param projectData the project data
+ * @param projList list which contains all available projects
+ */
+ public void loadProject(ProjectDialog.ProjectData projectData,
+ List<IProjectPO> projList) {
+ IProjectPO projectToOpen = null;
+ for (IProjectPO project : projList) {
+ if (project.getGuid().equals(projectData.getGUID())
+ && project.getVersionString().equals(
+ projectData.getVersionString())) {
+ projectToOpen = project;
+ break;
+ }
+ }
+ if (projectToOpen == null) {
+ openProjectOpenDialog(projList);
+ } else {
OpenProjectOperation openOperation = new OpenProjectOperation(
- selectedProject);
+ projectToOpen);
try {
PlatformUI.getWorkbench().getProgressService()
.busyCursorWhile(openOperation);
@@ -421,14 +461,6 @@ public class OpenProjectHandler extends AbstractProjectHandler {
} catch (InterruptedException ie) {
openOperation.handleOperationException();
}
-
- } catch (final JBException e) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- ErrorHandlingUtil.createMessageDialog(e, null, null);
- }
- });
- return;
}
}
@@ -492,7 +524,24 @@ public class OpenProjectHandler extends AbstractProjectHandler {
* {@inheritDoc}
*/
public Object executeImpl(ExecutionEvent event) {
- selectProjects();
+ ProjectDialog.ProjectData project = null;
+ boolean cancelPressed = false;
+ ProjectDialog dialog = null;
+ List<IProjectPO> projList = checkAllAvailableProjects();
+
+ if (ProjectUIBP.getInstance().shouldPerformAutoProjectLoad()) {
+ project = ProjectUIBP.getMostRecentProjectData();
+ } else {
+ dialog = openProjectOpenDialog(projList);
+ if (dialog.getReturnCode() == Window.CANCEL) {
+ cancelPressed = true;
+ } else {
+ project = dialog.getSelection();
+ }
+ }
+ if (!cancelPressed) {
+ loadProject(project, projList);
+ }
return null;
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java
index 16fc4c5a8..1b988c654 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java
@@ -430,6 +430,7 @@ public class Messages extends NLS {
public static String InternalGefError;
public static String InternalRcpError;
public static String IsAlreadyInUseInDifferentEditor;
+ public static String LoadDefaultProject;
public static String LogicalNameErrorEmpty;
public static String LogicalNameErrorExists;
public static String LogicalNameErrorInvalidChar;
@@ -588,6 +589,7 @@ public class Messages extends NLS {
public static String OpenProjectActionToolkitVersionConflict4b;
public static String OpenProjectActionToolkitVersionConflict4c;
public static String OpenProjectActionToolkitVersionConflict5;
+ public static String OpenProjectDialogDefaultProjectCheckbox;
public static String OpenProjectOperationOpeningProject;
public static String OpenTestCaseTableDialogAddButtonText;
public static String OpenTestCaseTableDialogMessage;
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties
index e7fad9605..d46490d02 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties
@@ -416,6 +416,7 @@ JubulaPrefPageBasicScroll=A&uto-scroll and -expand trees while using drag-and-dr
JubulaPrefPageBasicShowOrig=&Show original Test Case name for renamed Test Case References.*
JubulaPropertiesViewProperty=Property
JubulaPropertiesViewValue=Value
+LoadDefaultProject=Perform auto load of project from database.
LogicalNameErrorEmpty=Component name is empty.
LogicalNameErrorExists=Component name already exists. Please choose another one.
LogicalNameErrorInvalidChar=Only digits, a-z, A-Z and underscore allowed in component names.
@@ -574,6 +575,7 @@ OpenProjectActionToolkitVersionConflict4a=different Major Version Number
OpenProjectActionToolkitVersionConflict4b=higher Minor Version Number
OpenProjectActionToolkitVersionConflict4c=lower Minor Version Number
OpenProjectActionToolkitVersionConflict5=\ than the installed Toolkit Plugin.
+OpenProjectDialogDefaultProjectCheckbox=<a>Secure store</a> and auto load this project data.
OpenProjectOperationOpeningProject=Opening "{0}" Project in version "{1}.{2}"...
OpenTestCaseTableDialogAddButtonText=Open
OpenTestCaseTableDialogMessage=Open a Test Case from the active project.
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/preferences/PrefPageBasic.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/preferences/PrefPageBasic.java
index c1c867d6d..49cc8bcea 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/preferences/PrefPageBasic.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/preferences/PrefPageBasic.java
@@ -83,6 +83,8 @@ public class PrefPageBasic extends PreferencePage implements
private Button m_capInfoCheckbox;
/** checkbox to decide if CAP infos should be displayed after CAP-name in testCaseEditor */
private Button m_showTransientChildrenCheckBox;
+ /** checkbox to decide if load most recent project is active or not */
+ private Button m_loadDefaultProjectCheckBox;
/** widgets used in preference page to define preference values private */
private Button m_perspChange0Button;
/** widgets used in preference page to define preference values private */
@@ -166,6 +168,7 @@ public class PrefPageBasic extends PreferencePage implements
createShowOrigTestCaseName(composite);
createShowCAPInfosCheckbox(composite);
createShowTransientChildrensCheckbox(composite);
+ createDefaultProjectCheckbox(composite);
createSeparator(composite, 3);
createRememberGroup(composite);
createSeparator(composite, 3);
@@ -226,6 +229,19 @@ public class PrefPageBasic extends PreferencePage implements
ControlDecorator.decorateInfo(m_showTransientChildrenCheckBox,
"GDControlDecorator.showTransientChildrenCheckBox", false); //$NON-NLS-1$
}
+
+ /**
+ * creates the check box so set load most recent project as active or inactive
+ * @param composite the parent composite
+ */
+ private void createDefaultProjectCheckbox(Composite composite) {
+ m_loadDefaultProjectCheckBox = new Button(composite, SWT.CHECK);
+ m_loadDefaultProjectCheckBox.setText(
+ Messages.LoadDefaultProject);
+ m_loadDefaultProjectCheckBox.setSelection(Plugin.getDefault()
+ .getPreferenceStore().getBoolean(
+ Constants.PERFORM_AUTO_PROJECT_LOAD_KEY));
+ }
/**
* create a grid layout with a selectable number of columns
@@ -233,7 +249,7 @@ public class PrefPageBasic extends PreferencePage implements
* @param numColumns number of columns in the grid
*/
private void setGridLayout(final Composite composite, int numColumns) {
- /** Define laout rules for widget placement */
+ /** Define layout rules for widget placement */
GridLayout compositeLayout = new GridLayout();
compositeLayout.numColumns = numColumns;
compositeLayout.horizontalSpacing = HORIZONTAL_SPACING_10;
@@ -479,6 +495,9 @@ public class PrefPageBasic extends PreferencePage implements
.getDefaultBoolean(Constants.SHOWCAPINFO_KEY));
m_showTransientChildrenCheckBox.setSelection(m_store
.getDefaultBoolean(Constants.SHOW_TRANSIENT_CHILDREN_KEY));
+ m_loadDefaultProjectCheckBox.setSelection(m_store
+ .getDefaultBoolean(
+ Constants.PERFORM_AUTO_PROJECT_LOAD_KEY));
m_perspChangeValue = m_store.getDefaultInt(Constants.PERSP_CHANGE_KEY);
m_rememberValue = m_store.getDefaultBoolean(Constants.REMEMBER_KEY);
setRadioSelection();
@@ -517,6 +536,8 @@ public class PrefPageBasic extends PreferencePage implements
m_capInfoCheckbox.getSelection());
getPreferenceStore().setValue(Constants.SHOW_TRANSIENT_CHILDREN_KEY,
m_showTransientChildrenCheckBox.getSelection());
+ getPreferenceStore().setValue(Constants.PERFORM_AUTO_PROJECT_LOAD_KEY,
+ m_loadDefaultProjectCheckBox.getSelection());
removeListener();
return super.performOk();
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java
index c1668876f..9c9a2356a 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java
@@ -169,6 +169,15 @@ public interface Constants {
/** Key for m_text value to be stored as a resource property */
public static final String MAX_NUMBER_OF_DAYS_KEY = "MAX_NUMBER_OF_DAYS_KEY"; //$NON-NLS-1$
+ /** Key for secure storage category */
+ public static final String ORG_ECLIPSE_JUBULA_MOST_RECENT_PROJECTDATA_KEY = "org.eclipse.jubula.MostRecentProjectdata"; //$NON-NLS-1$
+
+ /** Key for the most recent project name */
+ public static final String MOST_RECENT_PROJECTDATA_GUID_KEY = "project.guid"; //$NON-NLS-1$
+
+ /** Key for the most recent project version */
+ public static final String MOST_RECENT_PROJECTDATA_VERSION_KEY = "project.version"; //$NON-NLS-1$
+
/** Key for m_text value to be stored as a resource property */
public static final String GENERATEREPORT_KEY = "GENERATEREPORT_KEY"; //$NON-NLS-1$
@@ -278,6 +287,9 @@ public interface Constants {
public static final String LINK_WITH_EDITOR_TCVIEW_KEY = "LINK_WITH_EDITOR_TCVIEW_KEY"; //$NON-NLS-1$
/** Key for the mode of the AUT Config dialog */
public static final String AUT_CONFIG_DIALOG_MODE = "AUT_CONFIG_DIALOG_MODE"; //$NON-NLS-1$
+ /** Key for loading the default project automatically */
+ public static final String PERFORM_AUTO_PROJECT_LOAD_KEY = "PERFORM_AUTO_PROJECT_LOAD_KEY"; //$NON-NLS-1$
+
@@ -424,6 +436,8 @@ public interface Constants {
public static final boolean SHOWCAPINFO_KEY_DEFAULT = true;
/** default value for showing transient childrens */
public static final boolean SHOW_TRANSIENT_CHILDREN_KEY_DEFAULT = true;
+ /** default value for loading the default project */
+ public static final boolean LOAD_DEFAULT_PROJECT_KEY_DEFAULT = false;
// --------------------------------------------------------------------
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 9b8a2b5ee..eba4f4bd8 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
@@ -34,6 +34,7 @@ import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.i18n.Messages;
+import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.jubula.client.ui.utils.LayoutUtil;
import org.eclipse.jubula.tools.constants.StringConstants;
import org.eclipse.jubula.tools.constants.SwtAUTHierarchyConstants;
@@ -54,7 +55,6 @@ import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PreferencesUtil;
/**
@@ -96,8 +96,6 @@ public class DBLoginDialog extends TitleAreaDialog {
private Label m_pwdLabel;
/** the connection combobox viewer */
private ComboViewer m_connectionComboViewer;
- /** save database profile composite*/
- private Composite m_saveProfileComp;
/** save database profile check box */
private Button m_profileSave;
/** automatic database connection check box */
@@ -340,10 +338,10 @@ public class DBLoginDialog extends TitleAreaDialog {
SWT.CENTER, false, false,
HORIZONTAL_SPAN + 1, 1));
new Label(area, SWT.NONE).setText(StringConstants.EMPTY);
- m_saveProfileComp = new Composite(area, SWT.NONE);
- m_saveProfileComp.setLayout(RowLayoutFactory.fillDefaults()
+ Composite saveProfileComp = new Composite(area, SWT.NONE);
+ saveProfileComp.setLayout(RowLayoutFactory.fillDefaults()
.spacing(0).create());
- m_profileSave = new Button(m_saveProfileComp, SWT.CHECK);
+ m_profileSave = new Button(saveProfileComp, SWT.CHECK);
m_profileSave.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
m_automConn.setEnabled(m_profileSave.getSelection());
@@ -352,23 +350,9 @@ public class DBLoginDialog extends TitleAreaDialog {
// do nothing
}
});
- m_secureStorageLink = new Link(m_saveProfileComp, SWT.NONE);
- m_secureStorageLink.setText(Messages.DBLoginDialogSaveDBPassword);
- m_secureStorageLink.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- final String prefPageID =
- Constants.SECURE_STORAGE_PLUGIN_ID;
- PreferencesUtil.createPreferenceDialogOn(
- Plugin.getDefault().getWorkbench().getDisplay()
- .getActiveShell(), prefPageID,
- new String[] { prefPageID }, null,
- PreferencesUtil.OPTION_FILTER_LOCKED).open();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- /** do nothing */
- }
- });
+ m_secureStorageLink = DialogUtils
+ .createLinkToSecureStoragePreferencePage(saveProfileComp,
+ Messages.DBLoginDialogSaveDBPassword);
}
/**
* Fills the username and the password field
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/preferences/PreferenceInitializer.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/preferences/PreferenceInitializer.java
index 7d36c2570..a866eaac7 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/preferences/PreferenceInitializer.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/preferences/PreferenceInitializer.java
@@ -84,6 +84,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
Constants.SHOWCAPINFO_KEY_DEFAULT);
prefStore.setDefault(Constants.SHOW_TRANSIENT_CHILDREN_KEY,
Constants.SHOW_TRANSIENT_CHILDREN_KEY_DEFAULT);
+ prefStore.setDefault(Constants.PERFORM_AUTO_PROJECT_LOAD_KEY,
+ Constants.LOAD_DEFAULT_PROJECT_KEY_DEFAULT);
prefStore.setDefault(Constants.REMEMBER_KEY,
Constants.REMEMBER_KEY_DEFAULT);
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/DialogUtils.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/DialogUtils.java
index 315a47c74..d4efb85cb 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/DialogUtils.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/utils/DialogUtils.java
@@ -11,13 +11,20 @@
package org.eclipse.jubula.client.ui.utils;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jubula.client.ui.Plugin;
+import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.tools.constants.SwtAUTHierarchyConstants;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
/**
@@ -189,4 +196,33 @@ public final class DialogUtils {
break;
}
}
+
+ /**
+ * @param parent
+ * the parent to use
+ * @param linkText
+ * the link text
+ * @return a new link instance
+ */
+ public static Link createLinkToSecureStoragePreferencePage(
+ Composite parent, String linkText) {
+ Link l = new Link(parent, SWT.NONE);
+ l.setText(linkText);
+ l.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ final String prefPageID =
+ Constants.SECURE_STORAGE_PLUGIN_ID;
+ PreferencesUtil.createPreferenceDialogOn(
+ Plugin.getDefault().getWorkbench().getDisplay()
+ .getActiveShell(), prefPageID,
+ new String[] { prefPageID }, null,
+ PreferencesUtil.OPTION_FILTER_LOCKED).open();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ /** do nothing */
+ }
+ });
+ return l;
+ }
}

Back to the top