Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Krauth2017-10-24 06:11:48 -0400
committerMarvin Mueller2017-12-11 06:17:04 -0500
commitd4d816e10c64ea516bca114059a2835206c3eedc (patch)
tree4fc5bd40af7c3aba64eeaf991a3705a92c5a9341
parent9fb961954a1c70ac537d00e2141234915bfceddb (diff)
downloadorg.eclipse.jubula.core-d4d816e10c64ea516bca114059a2835206c3eedc.tar.gz
org.eclipse.jubula.core-d4d816e10c64ea516bca114059a2835206c3eedc.tar.xz
org.eclipse.jubula.core-d4d816e10c64ea516bca114059a2835206c3eedc.zip
Fixing NullPointerException when moving to external prjects while none are referenced
Change-Id: I508d9eaf76933291cb46f3925492dddaa1ee6811 Signed-off-by: Marcel Krauth <Marcel.Krauth@bredex.de>
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MoveTestCaseHandler.java92
-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
3 files changed, 69 insertions, 27 deletions
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MoveTestCaseHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MoveTestCaseHandler.java
index 1313057bb..5789934e5 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MoveTestCaseHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MoveTestCaseHandler.java
@@ -23,6 +23,7 @@ import javax.persistence.EntityTransaction;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
@@ -209,34 +210,13 @@ public class MoveTestCaseHandler extends AbstractHandler {
for (IReusedProjectPO project : reusedProjects) {
projectNamesList.add(project.getName());
}
-
- String [] projectNames =
- projectNamesList.toArray(new String [projectNamesList.size()]);
- ReusedProjectSelectionDialog dialog;
- if (hasRefDataCube(selectionList)) {
- dialog =
- new ReusedProjectSelectionDialog(
- getActiveShell(), projectNames,
- Messages.MoveTestCaseDialogShellTitle,
- Messages.MoveTestCaseDialogCTDHint,
- true,
- IconConstants.MOVE_TC_DIALOG_STRING,
- Messages.MoveTestCaseDialogShellTitle);
- } else {
- dialog =
- new ReusedProjectSelectionDialog(
- getActiveShell(), projectNames,
- Messages.MoveTestCaseDialogShellTitle,
- Messages.MoveTestCaseDialogMessage,
- IconConstants.MOVE_TC_DIALOG_STRING,
- Messages.MoveTestCaseDialogShellTitle);
+ boolean emptyList = checkForEmptyProjectList(projectNamesList);
+ if (emptyList) {
+ return null;
}
- dialog.setHelpAvailable(true);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.TESTCASE_MOVE_EXTERNAL);
- dialog.open();
+
+ ReusedProjectSelectionDialog dialog =
+ openDialog(selectionList, projectNamesList);
if (dialog.getReturnCode() == Window.OK) {
// Check which project was selected
String selectedName = dialog.getSelectedName();
@@ -255,7 +235,65 @@ public class MoveTestCaseHandler extends AbstractHandler {
return null;
}
+
+ /**
+ * @param selectionList List of selcted Nodes
+ * @param projectNamesList List of referenced
+ * @return the dialog window
+ */
+ private ReusedProjectSelectionDialog openDialog(
+ List<INodePO> selectionList, List<String> projectNamesList) {
+ String [] projectNames =
+ projectNamesList.toArray(new String [projectNamesList.size()]);
+ ReusedProjectSelectionDialog dialog;
+ if (hasRefDataCube(selectionList)) {
+ dialog =
+ new ReusedProjectSelectionDialog(
+ getActiveShell(), projectNames,
+ Messages.MoveTestCaseDialogShellTitle,
+ Messages.MoveTestCaseDialogCTDHint,
+ true,
+ IconConstants.MOVE_TC_DIALOG_STRING,
+ Messages.MoveTestCaseDialogShellTitle);
+ } else {
+ dialog =
+ new ReusedProjectSelectionDialog(
+ getActiveShell(), projectNames,
+ Messages.MoveTestCaseDialogShellTitle,
+ Messages.MoveTestCaseDialogMessage,
+ IconConstants.MOVE_TC_DIALOG_STRING,
+ Messages.MoveTestCaseDialogShellTitle);
+ }
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.TESTCASE_MOVE_EXTERNAL);
+ dialog.open();
+ return dialog;
+ }
+ /**
+ * @param projectNamesList the list of referenced projects
+ * @return wether the list is empty or not
+ */
+ private boolean checkForEmptyProjectList(List<String> projectNamesList) {
+
+ if (projectNamesList.size() == 0) {
+ MessageDialog dialog = new MessageDialog(getActiveShell(),
+ Messages.MoveTestCaseDialogShellTitle,
+ Window.getDefaultImage(),
+ Messages.NoReferencedProject,
+ MessageDialog.INFORMATION,
+ new String[] {
+ Messages.UtilsOk},
+ 0);
+ dialog.open();
+ return true;
+ }
+ return false;
+ }
+
/** {@inheritDoc} */
public void setEnabled(boolean enabled) {
IProjectPO currentProject = GeneralStorage.getInstance().getProject();
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 f1769ca78..b99ec37a5 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
@@ -471,6 +471,7 @@ public class Messages extends NLS {
public static String NoAUTConfigPageForToolkit;
public static String NoComponentNames;
public static String NoNullConnectionAllowed;
+ public static String NoReferencedProject;
public static String NoServer;
public static String NotOfCorrectType;
public static String NotSupported;
@@ -971,6 +972,7 @@ public class Messages extends NLS {
public static String UtilsLocalhost2;
public static String UtilsLocalhost3;
public static String UtilsNo;
+ public static String UtilsOk;
public static String UtilsQuestion;
public static String UtilsRemember;
public static String UtilsSpecPerspective;
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 a62b000f8..3303841ee 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
@@ -456,6 +456,7 @@ NoActiveTCEditorPleaseFixTheMethod=no active TC editor, please fix the method
NoAUTConfigPageForToolkit=No AUT-Config-Page for Toolkit
NoComponentNames=no component names
NoNullConnectionAllowed=no null connection allowed
+NoReferencedProject=There are no referenced projects
NoServer=NOSERVER
NotOfCorrectType=not of correct type
NotUseReferenceParameterTitle=Parameter references found
@@ -956,6 +957,7 @@ UtilsLocalhost1=localhost
UtilsLocalhost2=127.0.0.1
UtilsLocalhost3=LOCALHOST
UtilsNo=No
+UtilsOk=Ok
UtilsQuestion=Do you want to change to the "{0}" perspective ?
UtilsRemember=Remember my decision.
UtilsSpecPerspective=Functional Test Specification

Back to the top