Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2014-09-10 13:53:10 +0000
committerMarvin Mueller2014-09-11 06:04:13 +0000
commit69972ebf2d5939399cfe656e0100269d93cb6268 (patch)
tree83e7d6a2e3cd889290fef9e160475fb11a9df8ee /org.eclipse.jubula.client.wiki.ui
parente239ee47f125bbe0d4c090d1b1790419bde486ac (diff)
downloadorg.eclipse.jubula.core-69972ebf2d5939399cfe656e0100269d93cb6268.tar.gz
org.eclipse.jubula.core-69972ebf2d5939399cfe656e0100269d93cb6268.tar.xz
org.eclipse.jubula.core-69972ebf2d5939399cfe656e0100269d93cb6268.zip
Sprint task - adding question dialog if the user wants to open the descriptionView
Diffstat (limited to 'org.eclipse.jubula.client.wiki.ui')
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java90
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/Messages.java2
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/messages.properties4
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java3
4 files changed, 98 insertions, 1 deletions
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java
index 56b87cf80..62678d2c5 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java
@@ -12,25 +12,38 @@ package org.eclipse.jubula.client.wiki.ui.handlers;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.IPersistentObject;
+import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
+import org.eclipse.jubula.client.wiki.ui.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.jubula.client.wiki.ui.dialogs.DescriptionEditDialog;
import org.eclipse.jubula.client.wiki.ui.utils.DescriptionUtil;
+import org.eclipse.jubula.client.wiki.ui.views.DescriptionView;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
/**
*
* @author BREDEX GmbH
*/
public class EditDescriptionHandler extends AbstractSelectionBasedHandler {
+
+ /** key for the preference store*/
+ private static final String OPEN_VIEW_PREF_KEY = "AUTOMATIC_DESCRIPTIONVIEW"; //$NON-NLS-1$
/** {@inheritDoc} */
protected Object executeImpl(ExecutionEvent event) {
@@ -54,13 +67,90 @@ public class EditDescriptionHandler extends AbstractSelectionBasedHandler {
if (dialog.open() == Window.OK) {
performChanges(editor, workNode, dialog);
}
+ checkAndAskForDescriptionView();
}
+
});
}
return null;
}
+ /** checks if the description view is open and ask if the user wants to pen it
+ * it uses the preferenceStore to save it, if the user wants to remember it */
+ private void checkAndAskForDescriptionView() {
+ IWorkbenchPage workbench = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ final IPreferenceStore preferenceStore = Plugin.getDefault()
+ .getPreferenceStore();
+ int value = preferenceStore.getInt(OPEN_VIEW_PREF_KEY);
+
+ if (workbench.findView(DescriptionView.VIEW_ID) == null) {
+ if (value != Constants.OPEN_DESCRIPTION_VIEW_NO
+ && value != Constants.OPEN_DESCRIPTION_VIEW_YES) {
+ MessageDialogWithToggle dialog =
+ createQuestionDialog(preferenceStore);
+ if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
+ openDescriptionView();
+ }
+ } else if (value == Constants.OPEN_DESCRIPTION_VIEW_YES) {
+ openDescriptionView();
+ }
+ }
+ }
+
+ /**
+ * creates the question dialog if you want to open the {@link DescriptionView}
+ * @param preferenceStore the preference store in which you want to store
+ * the settings if it should be remembered
+ * @return the message dialog
+ */
+ private MessageDialogWithToggle createQuestionDialog(
+ final IPreferenceStore preferenceStore) {
+ MessageDialogWithToggle dialog = new MessageDialogWithToggle(
+ getActiveShell(),
+ Messages.OpenDescriptionViewTitle, null,
+ Messages.OpenDescriptionViewQuestion,
+ MessageDialog.QUESTION,
+ new String[] {
+ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL },
+ 0,
+ org.eclipse.jubula.client.ui.rcp.i18n.Messages.UtilsRemember,
+ false) {
+ /**
+ * {@inheritDoc}
+ */
+ protected void buttonPressed(int buttonId) {
+ super.buttonPressed(buttonId);
+
+ int val = Constants.OPEN_DESCRIPTION_VIEW_PROMPT;
+ if (getToggleState()
+ && getReturnCode() == IDialogConstants.NO_ID) {
+ val = Constants.OPEN_DESCRIPTION_VIEW_NO;
+ } else if (getToggleState()
+ && getReturnCode() == IDialogConstants.YES_ID) {
+ val = Constants.OPEN_DESCRIPTION_VIEW_YES;
+ }
+ preferenceStore.setValue(OPEN_VIEW_PREF_KEY, val);
+ }
+ };
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ dialog.open();
+ return dialog;
+ }
+
+ /**
+ * try's to open the {@link DescriptionView}
+ */
+ private void openDescriptionView() {
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().showView(DescriptionView.VIEW_ID);
+ } catch (PartInitException e) {
+ // silently ignore
+ }
+ }
/**
* Performs the changes done in the {@link DescriptionEditDialog}
* @param editor an editor like {@link TestCaseEditor} or {@link TestSuiteEditor}
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/Messages.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/Messages.java
index 9d913708b..f935d3e3d 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/Messages.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/Messages.java
@@ -23,6 +23,8 @@ public class Messages extends NLS {
public static String EditDescriptionDialogSourceViewer;
public static String EditDescriptionDialogTitle;
public static String NoDescriptionAvailable;
+ public static String OpenDescriptionViewTitle;
+ public static String OpenDescriptionViewQuestion;
static {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/messages.properties b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/messages.properties
index 98d68395a..bab578c62 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/messages.properties
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/i18n/messages.properties
@@ -9,4 +9,6 @@ NoDescriptionAvailable=No description available...
EditDescriptionDialogTitle=Edit description
EditDescriptionDialogDescription=Edit the description of the Node
EditDescriptionDialogSourceViewer= Source Editor
-EditDescriptionDialogPreview=Preview \ No newline at end of file
+EditDescriptionDialogPreview=Preview
+OpenDescriptionViewTitle=Open View
+OpenDescriptionViewQuestion=Do you want to open the Description View ? \ No newline at end of file
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
index d529119bd..489b5f205 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
@@ -40,6 +40,9 @@ import org.eclipse.ui.part.ViewPart;
* @author BREDEX GmbH
*/
public class DescriptionView extends ViewPart implements IDataChangedListener {
+ /** the view id (should be same as in plugin.xml) */
+ public static final String VIEW_ID = "org.eclipse.jubula.client.wiki.ui.views.DescriptionView"; //$NON-NLS-1$
+
/** the viewer to display the documentation */
private Browser m_browser;
/** the markup parser to use */

Back to the top