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
;
13 import java
.lang
.reflect
.InvocationTargetException
;
14 import java
.net
.MalformedURLException
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.events
.ModifyEvent
;
20 import org
.eclipse
.swt
.events
.ModifyListener
;
21 import org
.eclipse
.swt
.events
.SelectionAdapter
;
22 import org
.eclipse
.swt
.events
.SelectionEvent
;
23 import org
.eclipse
.swt
.layout
.GridData
;
24 import org
.eclipse
.swt
.layout
.GridLayout
;
25 import org
.eclipse
.swt
.widgets
.Button
;
26 import org
.eclipse
.swt
.widgets
.Composite
;
27 import org
.eclipse
.swt
.widgets
.Label
;
28 import org
.eclipse
.swt
.widgets
.Text
;
30 import eu
.etaxonomy
.cdm
.print
.PublishConfigurator
;
31 import eu
.etaxonomy
.taxeditor
.model
.CdmProgressMonitorAdapter
;
32 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
36 * <p>SelectServiceWizardPage class.</p>
39 * @created Apr 6, 2010
42 public class SelectServiceWizardPage
extends AbstractPublishWizardPage
{
44 private Composite composite
;
45 private Button button_local
;
46 private Button button_remote
;
47 private Label label_serviceUrl
;
48 private Text text_serviceUrl
;
51 * <p>Constructor for SelectServiceWizardPage.</p>
53 * @param pageName a {@link java.lang.String} object.
55 protected SelectServiceWizardPage(String pageName
) {
57 setTitle("Select a Service");
61 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
64 public void createControl(Composite parent
) {
66 composite
= new Composite(parent
, SWT
.NULL
);
67 composite
.setLayout(new GridLayout());
69 RadioSelectionListener listener
= new RadioSelectionListener();
71 button_local
= new Button(composite
, SWT
.RADIO
);
72 button_local
.setText("Local (By selecting this option the database you are currently " +
73 "connected to will be used to gather data.)");
75 button_local
.addSelectionListener(listener
);
79 button_remote
= new Button(composite
, SWT
.RADIO
);
80 button_remote
.setText("Remote");
81 button_remote
.addSelectionListener(listener
);
84 label_serviceUrl
= new Label(composite
, SWT
.NULL
);
85 label_serviceUrl
.setText("Service URL");
87 text_serviceUrl
= new Text(composite
, SWT
.BORDER
);
88 text_serviceUrl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
89 text_serviceUrl
.setText("http://");
90 text_serviceUrl
.addModifyListener(new ModifyListener() {
92 public void modifyText(ModifyEvent e
) {
93 String text
= text_serviceUrl
.getText();
96 getConfigurator().setWebserviceUrl(text
);
97 } catch (MalformedURLException e1
) {
98 StoreUtil
.warn(this.getClass(), "Malformed Url");
101 if(isPageComplete()){
102 SelectServiceWizardPage
.this.setErrorMessage(null);
103 setPageComplete(true);
105 SelectServiceWizardPage
.this.setErrorMessage("Webservice URL has to end with \"/\"");
106 setPageComplete(false);
111 if(CdmStore
.isActive()){
115 button_local
.setEnabled(false);
118 setControl(composite
);
122 private class RadioSelectionListener
extends SelectionAdapter
{
124 public void widgetSelected(SelectionEvent e
) {
125 if(e
.widget
== button_local
){
133 private void enableRemote() {
134 button_local
.setSelection(false);
135 button_remote
.setSelection(true);
137 label_serviceUrl
.setEnabled(true);
138 text_serviceUrl
.setEnabled(true);
140 setConfigurator(PublishConfigurator
.NewRemoteInstance());
141 getConfigurator().addOutputModule(getOutputModule());
144 private void enableLocal() {
145 button_remote
.setSelection(false);
146 button_local
.setSelection(true);
148 label_serviceUrl
.setEnabled(false);
149 text_serviceUrl
.setEnabled(false);
151 setConfigurator(PublishConfigurator
.NewLocalInstance(CdmStore
.getCurrentApplicationController()));
152 getConfigurator().addOutputModule(getOutputModule());
157 * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
161 public boolean canFlipToNextPage() {
162 if(isPageComplete()){
164 getContainer().run(false, false, new IRunnableWithProgress() {
167 public void run(IProgressMonitor monitor
) throws InvocationTargetException
,
168 InterruptedException
{
169 getConfigurator().setProgressMonitor(CdmProgressMonitorAdapter
.CreateMonitor(monitor
));
171 SelectTaxaWizardPage selectTaxaPage
= (SelectTaxaWizardPage
) getWizard().getPage(AbstractPublishWizard
.PAGE_TAXA
);
172 selectTaxaPage
.refresh();
174 SelectFeatureTreeWizardPage selectFeatureTreePage
= (SelectFeatureTreeWizardPage
) getWizard().getPage(AbstractPublishWizard
.PAGE_FEATURETREE
);
175 selectFeatureTreePage
.refresh();
179 } catch (InvocationTargetException e
) {
180 PrintUtil
.error(getClass(), e
);
181 } catch (InterruptedException e
) {
182 PrintUtil
.error(getClass(), e
);
192 * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
196 public boolean isPageComplete() {
197 if(getConfigurator().isLocal()){
199 }else if(getConfigurator().isRemote()
200 && getConfigurator().getWebserviceUrl() != null
201 && getConfigurator().getWebserviceUrl().toString().endsWith("/")){