Project

General

Profile

« Previous | Next » 

Revision b3b61969

Added by Andreas Müller almost 4 years ago

cleanup

View differences:

eu.etaxonomy.taxeditor.printpublisher/src/main/java/eu/etaxonomy/taxeditor/printpublisher/wizard/AbstractPublishWizard.java
1 1
/**
2
 * 
2
 *
3 3
 */
4 4
package eu.etaxonomy.taxeditor.printpublisher.wizard;
5 5

  
......
29 29
 *
30 30
 * @author n.hoffmann
31 31
 * @created Apr 1, 2010
32
 * @version 1.0
33 32
 */
34 33
public abstract class AbstractPublishWizard extends Wizard implements IExportWizard, IHasPersistableSettings{
35
			
34

  
36 35
	/** Constant <code>PAGE_SERVICE="PAGE_SERVICE"</code> */
37 36
	public static final String PAGE_SERVICE = "PAGE_SERVICE";
38 37
	/** Constant <code>PAGE_TAXA="PAGE_TAXA"</code> */
......
47 46
	public static final String PAGE_FEATURETREE = "PAGE_FEATURETREE";
48 47
	/** Constant <code>PAGE_STYLESHEET="PAGE_STYLESHEET"</code> */
49 48
	public static final String PAGE_STYLESHEET = "PAGE_STYLESHEET";
50
		
49

  
51 50
	protected SelectServiceWizardPage pageService;
52 51
	protected SelectTaxaWizardPage pageTaxa;
53 52
	protected SelectOptionsWizardPage pageOptions;
......
59 58

  
60 59
	private IPublishOutputModule outputModule;
61 60

  
62
	/**
63
	 * <p>Constructor for AbstractPublishWizard.</p>
64
	 */
65
	public AbstractPublishWizard(){		
61
	public AbstractPublishWizard(){
66 62
		setNeedsProgressMonitor(true);
67 63
		setDialogSettings(PrintpublisherPlugin.getDefault().getDialogSettings());
68 64
	}
69
	
70
	/* (non-Javadoc)
71
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
72
	 */
73
	/** {@inheritDoc} */
65

  
74 66
	@Override
75 67
	public boolean performFinish() {
76
		
68

  
77 69
		Job job = new Job("Running Print Publisher") {
78 70

  
79 71
			@Override
80 72
			protected IStatus run(IProgressMonitor monitor) {
81 73
				monitor.beginTask("Print Publisher", getConfigurator().calculateNumberOfNodes() + 1);
82 74
				ConversationHolder conversation = null;
83
				try{					
75
				try{
84 76
					getConfigurator().setProgressMonitor(CdmProgressMonitorAdapter.CreateMonitor(monitor));
85
					
77

  
86 78
					if(getConfigurator().isLocal()){
87 79
						conversation = CdmStore.createConversation();
88
						// we want to enforce that the session is closed and nothing is 
89
						// instantiated beneath the regular cdmlib-remote object boundaries 
80
						// we want to enforce that the session is closed and nothing is
81
						// instantiated beneath the regular cdmlib-remote object boundaries
90 82
						conversation.commit(false);
91 83
					}
92
					
84

  
93 85
					Publisher.publish(getConfigurator());
94
					
86

  
95 87
				}finally{
96 88
					monitor.done();
97
					if(conversation != null) conversation.close();
89
					if(conversation != null) {
90
                        conversation.close();
91
                    }
98 92
					Display.getDefault().asyncExec(new Runnable() {
99 93
						@Override
100 94
						public void run() {
......
104 98
				}
105 99
				return Status.OK_STATUS;
106 100
			}
107
			
101

  
108 102
		};
109
		
103

  
110 104
		job.setPriority(Job.BUILD);
111 105
		job.schedule();
112
		
106

  
113 107
		return true;
114 108
	}
115 109

  
116
	/** {@inheritDoc} */
117 110
	@Override
118 111
	public void addPages() {
119 112
		super.addPages();
120
		
113

  
121 114
		pageService = new SelectServiceWizardPage(PAGE_SERVICE);
122 115
		addPage(pageService);
123
				
116

  
124 117
		pageOptions = new SelectOptionsWizardPage(PAGE_OPTIONS);
125 118
		addPage(pageOptions);
126
		
119

  
127 120
		pageFeatureTree = new SelectFeatureTreeWizardPage(PAGE_FEATURETREE);
128 121
		addPage(pageFeatureTree);
129
		
122

  
130 123
		pageStylesheet = new SelectStylesheetWizardPage(PAGE_STYLESHEET);
131 124
		addPage(pageStylesheet);
132 125

  
133 126
		pageFolder = new SelectDirectoryWizardPage(PAGE_FOLDER);
134 127
		addPage(pageFolder);
135
		
136 128
	}
137
	
129

  
138 130
	@Override
139 131
	public void loadSettings() {
140 132
		for(IWizardPage page : getPages()){
141 133
			if(page instanceof IHasPersistableSettings){
142 134
				((IHasPersistableSettings) page).loadSettings();
143 135
			}
144
		}		
136
		}
145 137
	}
146
	
147
	/* (non-Javadoc)
148
	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
149
	 */
150
	/** {@inheritDoc} */
151
	public void init(IWorkbench workbench, IStructuredSelection selection) {
138

  
139
	@Override
140
    public void init(IWorkbench workbench, IStructuredSelection selection) {
152 141
		MessagingUtils.info("Instantiating wizard: " + this.getClass().getSimpleName());
153 142
	}
154
	
155 143

  
156
	
157
	/** {@inheritDoc} */
158 144
	@Override
159 145
	public boolean canFinish() {
160 146
		boolean canFinish = true;
161
		
162
		canFinish &= pageService.isPageComplete(); 
163
		
147

  
148
		canFinish &= pageService.isPageComplete();
149

  
164 150
		// persistable settings pages
165 151
		canFinish &= pageFeatureTree.isPageComplete();
166 152
		canFinish &= pageFolder.isPageComplete();
167 153
		canFinish &= pageStylesheet.isPageComplete();
168
		
154

  
169 155
		return canFinish;
170 156
	}
171
	
172
	/**
173
	 * <p>Getter for the field <code>configurator</code>.</p>
174
	 *
175
	 * @return a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
176
	 */
157

  
177 158
	protected PublishConfigurator getConfigurator() {
178 159
		return configurator;
179 160
	}
180
	
181
	/**
182
	 * <p>Setter for the field <code>configurator</code>.</p>
183
	 *
184
	 * @param configurator a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
185
	 */
186 161
	protected void setConfigurator(PublishConfigurator configurator){
187 162
		this.configurator = configurator;
188 163
	}
189
	
190
	/**
191
	 * <p>Setter for the field <code>outputModule</code>.</p>
192
	 *
193
	 * @param outputModule a {@link eu.etaxonomy.cdm.print.out.IPublishOutputModule} object.
194
	 */
164

  
195 165
	protected void setOutputModule(IPublishOutputModule outputModule){
196 166
		this.outputModule = outputModule;
197 167
	}
198
	
199
	/**
200
	 * <p>Getter for the field <code>outputModule</code>.</p>
201
	 *
202
	 * @return a {@link eu.etaxonomy.cdm.print.out.IPublishOutputModule} object.
203
	 */
204 168
	public IPublishOutputModule getOutputModule(){
205 169
		return outputModule;
206 170
	}

Also available in: Unified diff