3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.printpublisher
.wizard
;
14 import java
.nio
.channels
.IllegalSelectorException
;
16 import org
.eclipse
.jface
.dialogs
.IDialogSettings
;
17 import org
.eclipse
.jface
.wizard
.WizardPage
;
19 import eu
.etaxonomy
.cdm
.print
.PublishConfigurator
;
20 import eu
.etaxonomy
.cdm
.print
.out
.IPublishOutputModule
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
24 * <p>Abstract AbstractPublishWizardPage class.</p>
27 * @created Apr 27, 2010
30 public abstract class AbstractPublishWizardPage
extends WizardPage
{
33 * <p>Constructor for AbstractPublishWizardPage.</p>
35 * @param pageName a {@link java.lang.String} object.
37 protected AbstractPublishWizardPage(String pageName
) {
42 * <p>getConfigurator</p>
44 * @return a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
46 public PublishConfigurator
getConfigurator(){
47 return ((AbstractPublishWizard
) getWizard()).getConfigurator();
51 * <p>setConfigurator</p>
53 * @param configurator a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
55 public void setConfigurator(PublishConfigurator configurator
){
56 ((AbstractPublishWizard
) getWizard()).setConfigurator(configurator
);
60 * <p>getOutputModule</p>
62 * @return a {@link eu.etaxonomy.cdm.print.out.IPublishOutputModule} object.
64 public IPublishOutputModule
getOutputModule(){
65 IPublishOutputModule outputModule
= ((AbstractPublishWizard
) getWizard()).getOutputModule();
66 if(outputModule
== null)
67 throw new IllegalStateException("OutputModule may not be null at this moment");
71 public void putDialogSettingValue(String key
, String value
){
72 getDialogSettingSection().put(key
, value
);
75 public String
getDialogSettingValue(String key
){
76 return getDialogSettingSection().get(key
);
79 public boolean getDialogSettingBooleanValue(String key
){
80 return getDialogSettingSection().getBoolean(key
);
83 private IDialogSettings
getDialogSettingSection(){
84 IDialogSettings wizardDialogSetting
= getWizard().getDialogSettings();
85 if(wizardDialogSetting
== null){
86 throw new IllegalStateException("Wizards dialog setting may not be null");
89 IDialogSettings specificWizardDialogSection
= getOrCreateSettingSection(wizardDialogSetting
, getWizard().getClass().getName());
91 String dataSource
= null;
92 if(getConfigurator().isLocal()){
93 dataSource
= CdmStore
.getDataSource().getName();
94 }else if(getConfigurator().isRemote()){
95 URL serviceUrl
= getConfigurator().getWebserviceUrl();
96 dataSource
= serviceUrl
.toExternalForm();
98 throw new IllegalStateException("Print publisher configurator should be either local or remote");
101 IDialogSettings specificDataSourceDialogSection
= getOrCreateSettingSection(specificWizardDialogSection
, dataSource
);
103 return specificDataSourceDialogSection
;
106 private IDialogSettings
getOrCreateSettingSection(IDialogSettings setting
, String sectionName
){
107 IDialogSettings section
= setting
.getSection(sectionName
);
110 section
= setting
.addNewSection(sectionName
);