Configure WebPrintAction
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/actions/SpecificationWebPrintAction.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/actions/SpecificationWebPrintAction.java index 415baa6..daf74c8 100644 --- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/actions/SpecificationWebPrintAction.java +++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/actions/SpecificationWebPrintAction.java
@@ -18,8 +18,11 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.window.Window; import org.eclipse.rmf.reqif10.Specification; +import org.eclipse.rmf.reqif10.pror.editor.preferences.PreferenceConstants; +import org.eclipse.rmf.reqif10.pror.editor.presentation.Reqif10EditorPlugin; import org.eclipse.rmf.reqif10.pror.editor.presentation.ReqifSpecificationEditorInput; import org.eclipse.rmf.reqif10.pror.editor.util.HTMLPrinter; import org.eclipse.swt.SWT; @@ -61,16 +64,34 @@ Specification spec = ((ReqifSpecificationEditorInput)input).getSpec(); - HTMLExportDialog dialog = new HTMLExportDialog(spec); - if (dialog.open() != Window.OK){ - return; + + boolean exportOutgoingLinks; + boolean exportIncomingLinks; + + boolean askUser = Reqif10EditorPlugin.getPlugin().getPreferenceStore().getBoolean(PreferenceConstants.P_WEB_EXPORT_ALWAYS_ASK_FOR_SPEC_RELATIONS); + if (askUser){ + HTMLExportDialog dialog = new HTMLExportDialog(spec); + if (dialog.open() != Window.OK){ + return; + } + exportOutgoingLinks = dialog.isExportOutgoingSpecRelations(); + exportIncomingLinks = dialog.isExportIncomingSpecRelations(); + }else{ + // we get the configuration directly from the preference store + exportOutgoingLinks = Reqif10EditorPlugin.getPlugin().getPreferenceStore() + .getBoolean(PreferenceConstants.P_WEB_EXPORT_INLUDE_OUTGOING_SPEC_RELATIONS); + + exportIncomingLinks = Reqif10EditorPlugin.getPlugin().getPreferenceStore() + .getBoolean(PreferenceConstants.P_WEB_EXPORT_INLUDE_INCOMING_SPEC_RELATIONS); } + + try { HTMLPrinter htmlPrinter = new HTMLPrinter(spec, editingDomain, adapterFactory); - htmlPrinter.setExportOutgoingSpecRelations(dialog.isExportOutgoingSpecRelations()); - htmlPrinter.setExportIncomingSpecRelations(dialog.isExportIncomingSpecRelations()); + htmlPrinter.setExportOutgoingSpecRelations(exportOutgoingLinks); + htmlPrinter.setExportIncomingSpecRelations(exportIncomingLinks); File htmlSpec = htmlPrinter.print(); Program.launch(htmlSpec.getAbsolutePath()); @@ -93,10 +114,22 @@ private boolean exportIncomingSpecRelations; + private boolean askForSpecRelations; + private Button rememberSettingButton; + public HTMLExportDialog(Specification spec) { super(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); this.spec = spec; + + exportOutgoingSpecRelations = Reqif10EditorPlugin.getPlugin().getPreferenceStore() + .getBoolean(PreferenceConstants.P_WEB_EXPORT_INLUDE_OUTGOING_SPEC_RELATIONS); + + exportIncomingSpecRelations = Reqif10EditorPlugin.getPlugin().getPreferenceStore() + .getBoolean(PreferenceConstants.P_WEB_EXPORT_INLUDE_INCOMING_SPEC_RELATIONS); + + askForSpecRelations = Reqif10EditorPlugin.getPlugin().getPreferenceStore() + .getBoolean(PreferenceConstants.P_WEB_EXPORT_ALWAYS_ASK_FOR_SPEC_RELATIONS); } @@ -117,15 +150,21 @@ container.setLayout(layout); exportOutgoingSpecRelationsButton = new Button(container, SWT.CHECK); + exportOutgoingSpecRelationsButton.setSelection(exportOutgoingSpecRelations); new Label(container, SWT.NONE).setText("Print outgoing Links"); exportIncomingSpecRelationsButton = new Button(container, SWT.CHECK); + exportIncomingSpecRelationsButton.setSelection(exportIncomingSpecRelations); new Label(container, SWT.NONE).setText("Print incoming Links"); new Label(container, SWT.NONE).setText(""); new Label(container, SWT.NONE).setText(""); - + rememberSettingButton = new Button(container, SWT.CHECK); + new Label(container, SWT.NONE).setText("Remember my descision and dont ask again."); + new Label(container, SWT.NONE).setText(""); + new Label(container, SWT.NONE).setText("(Settings can be changed through ReqIF Settings.)"); + return dialogArea; } @@ -135,6 +174,15 @@ protected void okPressed() { this.exportOutgoingSpecRelations = exportOutgoingSpecRelationsButton.getSelection(); this.exportIncomingSpecRelations = exportIncomingSpecRelationsButton.getSelection(); + + //update preferences: + if (rememberSettingButton.getSelection()){ + IPreferenceStore store = Reqif10EditorPlugin.getPlugin().getPreferenceStore(); + store.setValue(PreferenceConstants.P_WEB_EXPORT_ALWAYS_ASK_FOR_SPEC_RELATIONS, false); + store.setValue(PreferenceConstants.P_WEB_EXPORT_INLUDE_OUTGOING_SPEC_RELATIONS, exportOutgoingSpecRelations); + store.setValue(PreferenceConstants.P_WEB_EXPORT_INLUDE_INCOMING_SPEC_RELATIONS, exportIncomingSpecRelations); + } + super.okPressed(); }
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/PreferenceConstants.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/PreferenceConstants.java index ae4851a..500dc11 100644 --- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/PreferenceConstants.java +++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/PreferenceConstants.java
@@ -50,11 +50,10 @@ .getSimpleName(); public static final String P_DEFAULT_PRESENTATION_REAL = DatatypeDefinitionReal.class .getSimpleName(); - - + // Constants for SpecificationWebPrintAction - public static final String P_WEB_EXPORT_INLUDE_OUTGOING_SPEC_RELATIONS = "Print outgoing Links"; - public static final String P_WEB_EXPORT_INLUDE_INCOMING_SPEC_RELATIONS = "Print incoming Links"; - public static final String P_WEB_EXPORT_ALWAYS_ASK_FOR_SPEC_RELATIONS = "Always ask for if links should be printed"; - + public static final String P_WEB_EXPORT_INLUDE_OUTGOING_SPEC_RELATIONS = "p_web_export_print_outgoing_links"; + public static final String P_WEB_EXPORT_INLUDE_INCOMING_SPEC_RELATIONS = "p_web_export_print_incoming_inks"; + public static final String P_WEB_EXPORT_ALWAYS_ASK_FOR_SPEC_RELATIONS = "p_web_export_always_ask_for_if_links_should_be_printed"; + }
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/ProRSpecificationWebPrintPreferencePage.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/ProRSpecificationWebPrintPreferencePage.java index cca03f3..0d3a564 100644 --- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/ProRSpecificationWebPrintPreferencePage.java +++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/preferences/ProRSpecificationWebPrintPreferencePage.java
@@ -26,21 +26,23 @@ // Set preference store setPreferenceStore(Reqif10EditorPlugin.getPlugin().getPreferenceStore()); setDescription("ReqIF Print / Web Export Settings"); + + Reqif10EditorPlugin.getPlugin().getPreferenceStore().setDefault(PreferenceConstants.P_WEB_EXPORT_ALWAYS_ASK_FOR_SPEC_RELATIONS, true); } @Override protected void createFieldEditors() { addField(new BooleanFieldEditor( PreferenceConstants.P_WEB_EXPORT_INLUDE_OUTGOING_SPEC_RELATIONS, - "Print outgoing links.", + "Print outgoing links by default.", getFieldEditorParent())); - + addField(new BooleanFieldEditor(PreferenceConstants.P_WEB_EXPORT_INLUDE_INCOMING_SPEC_RELATIONS, - "Print incoming Links.", getFieldEditorParent())); + "Print incoming Links ba default.", getFieldEditorParent())); addField(new BooleanFieldEditor( PreferenceConstants.P_WEB_EXPORT_ALWAYS_ASK_FOR_SPEC_RELATIONS, - "Always ask which if links should be printed.", + "Always ask if links should be printed.", getFieldEditorParent())); }