2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.printpublisher
.wizard
;
13 import java
.nio
.channels
.IllegalSelectorException
;
15 import org
.eclipse
.jface
.dialogs
.IDialogSettings
;
16 import org
.eclipse
.jface
.wizard
.WizardPage
;
18 import eu
.etaxonomy
.cdm
.print
.PublishConfigurator
;
19 import eu
.etaxonomy
.cdm
.print
.out
.IPublishOutputModule
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 * <p>Abstract AbstractPublishWizardPage class.</p>
26 * @created Apr 27, 2010
29 public abstract class AbstractPublishWizardPage
extends WizardPage
{
32 * <p>Constructor for AbstractPublishWizardPage.</p>
34 * @param pageName a {@link java.lang.String} object.
36 protected AbstractPublishWizardPage(String pageName
) {
41 * <p>getConfigurator</p>
43 * @return a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
45 public PublishConfigurator
getConfigurator(){
46 return ((AbstractPublishWizard
) getWizard()).getConfigurator();
50 * <p>setConfigurator</p>
52 * @param configurator a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
54 public void setConfigurator(PublishConfigurator configurator
){
55 ((AbstractPublishWizard
) getWizard()).setConfigurator(configurator
);
59 * <p>getOutputModule</p>
61 * @return a {@link eu.etaxonomy.cdm.print.out.IPublishOutputModule} object.
63 public IPublishOutputModule
getOutputModule(){
64 IPublishOutputModule outputModule
= ((AbstractPublishWizard
) getWizard()).getOutputModule();
65 if(outputModule
== null)
66 throw new IllegalStateException("OutputModule may not be null at this moment");
70 public void putDialogSettingValue(String key
, String value
){
71 getDialogSettingSection().put(key
, value
);
74 public String
getDialogSettingValue(String key
){
75 return getDialogSettingSection().get(key
);
78 public boolean getDialogSettingBooleanValue(String key
){
79 return getDialogSettingSection().getBoolean(key
);
82 private IDialogSettings
getDialogSettingSection(){
83 IDialogSettings wizardDialogSetting
= getWizard().getDialogSettings();
84 if(wizardDialogSetting
== null){
85 throw new IllegalStateException("Wizards dialog setting may not be null");
88 IDialogSettings specificWizardDialogSection
= getOrCreateSettingSection(wizardDialogSetting
, getWizard().getClass().getName());
90 String dataSource
= null;
91 if(getConfigurator().isLocal()){
92 dataSource
= CdmStore
.getActiveCdmSource().getName();
93 }else if(getConfigurator().isRemote()){
94 URL serviceUrl
= getConfigurator().getWebserviceUrl();
95 dataSource
= serviceUrl
.toExternalForm();
97 throw new IllegalStateException("Print publisher configurator should be either local or remote");
100 IDialogSettings specificDataSourceDialogSection
= getOrCreateSettingSection(specificWizardDialogSection
, dataSource
);
102 return specificDataSourceDialogSection
;
105 private IDialogSettings
getOrCreateSettingSection(IDialogSettings setting
, String sectionName
){
106 IDialogSettings section
= setting
.getSection(sectionName
);
109 section
= setting
.addNewSection(sectionName
);