Improved PrintPublisher Wizard; Integrated SpecimenCdmExcel import
[taxeditor.git] / eu.etaxonomy.taxeditor.printpublisher / src / main / java / eu / etaxonomy / taxeditor / printpublisher / wizard / AbstractPublishWizardPage.java
index 49c9a0a2db85344903497e3f5c184abf8a8ce80b..5d9359dcc3b8ed6fe99f87adb4f91776c2933be1 100644 (file)
 
 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>
@@ -62,4 +67,49 @@ public abstract class AbstractPublishWizardPage extends WizardPage {
                        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;
+       }
 }