package eu.etaxonomy.taxeditor.printpublisher.wizard;
+import java.net.URL;
+import java.nio.channels.IllegalSelectorException;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.wizard.WizardPage;
import eu.etaxonomy.cdm.print.PublishConfigurator;
import eu.etaxonomy.cdm.print.out.IPublishOutputModule;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* <p>Abstract AbstractPublishWizardPage class.</p>
throw new IllegalStateException("OutputModule may not be null at this moment");
return outputModule;
}
+
+ public void putDialogSettingValue(String key, String value){
+ getDialogSettingSection().put(key, value);
+ }
+
+ public String getDialogSettingValue(String key){
+ return getDialogSettingSection().get(key);
+ }
+
+ public boolean getDialogSettingBooleanValue(String key){
+ return getDialogSettingSection().getBoolean(key);
+ }
+
+ private IDialogSettings getDialogSettingSection(){
+ IDialogSettings wizardDialogSetting = getWizard().getDialogSettings();
+ if(wizardDialogSetting == null){
+ throw new IllegalStateException("Wizards dialog setting may not be null");
+ }
+
+ IDialogSettings specificWizardDialogSection = getOrCreateSettingSection(wizardDialogSetting, getWizard().getClass().getName());
+
+ String dataSource = null;
+ if(getConfigurator().isLocal()){
+ dataSource = CdmStore.getDataSource().getName();
+ }else if(getConfigurator().isRemote()){
+ URL serviceUrl = getConfigurator().getWebserviceUrl();
+ dataSource = serviceUrl.toExternalForm();
+ }else{
+ throw new IllegalStateException("Print publisher configurator should be either local or remote");
+ }
+
+ IDialogSettings specificDataSourceDialogSection = getOrCreateSettingSection(specificWizardDialogSection, dataSource);
+
+ return specificDataSourceDialogSection;
+ }
+
+ private IDialogSettings getOrCreateSettingSection(IDialogSettings setting, String sectionName){
+ IDialogSettings section = setting.getSection(sectionName);
+
+ if(section == null){
+ section = setting.addNewSection(sectionName);
+ }
+
+ return section;
+ }
}