Revision 924ba372
Added by Ben Stöver over 6 years ago
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java | ||
---|---|---|
68 | 68 |
parameters.put(ReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORY, translatorFactory); |
69 | 69 |
|
70 | 70 |
// Create writer and document adapters: |
71 |
JPhyloIOEventWriter writer = factory.getWriter(wizard.getSelectedFormat()); |
|
71 |
JPhyloIOEventWriter writer = factory.getWriter(wizard.getSelectedFormat().getFormatID());
|
|
72 | 72 |
ListBasedDocumentDataAdapter document = new ListBasedDocumentDataAdapter(); |
73 | 73 |
document.getMatrices().add(new CDMSequenceMatrixAdapter(sequence, wizard.getConsensusSequenceLabel())); |
74 | 74 |
|
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizard.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.molecular.io.wizard; |
11 | 11 |
|
12 | 12 |
|
13 |
import info.bioinfweb.jphyloio.formatinfo.JPhyloIOFormatInfo; |
|
14 |
|
|
13 | 15 |
import java.io.File; |
14 | 16 |
|
15 | 17 |
import org.eclipse.jface.wizard.Wizard; |
... | ... | |
25 | 27 |
public class ExportSingleReadAlignmentWizard extends Wizard { |
26 | 28 |
private ExportSingleReadAlignmentWizardPage page; |
27 | 29 |
|
28 |
private String selectedFormat = null;
|
|
30 |
private JPhyloIOFormatInfo selectedFormat = null;
|
|
29 | 31 |
private File selectedFile = null; |
30 | 32 |
private String consensusSequenceLabel = null; |
31 | 33 |
|
... | ... | |
56 | 58 |
} |
57 | 59 |
|
58 | 60 |
|
59 |
public String getSelectedFormat() {
|
|
61 |
public JPhyloIOFormatInfo getSelectedFormat() {
|
|
60 | 62 |
return selectedFormat; |
61 | 63 |
} |
62 | 64 |
|
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizardPage.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.molecular.io.wizard; |
11 | 11 |
|
12 | 12 |
|
13 |
import info.bioinfweb.commons.io.ContentExtensionFileFilter; |
|
13 | 14 |
import info.bioinfweb.jphyloio.events.type.EventContentType; |
14 | 15 |
import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory; |
15 | 16 |
import info.bioinfweb.jphyloio.formatinfo.JPhyloIOFormatInfo; |
... | ... | |
29 | 30 |
import org.eclipse.swt.widgets.Button; |
30 | 31 |
import org.eclipse.swt.widgets.Combo; |
31 | 32 |
import org.eclipse.swt.widgets.Composite; |
33 |
import org.eclipse.swt.widgets.FileDialog; |
|
32 | 34 |
import org.eclipse.swt.widgets.Label; |
33 | 35 |
import org.eclipse.swt.widgets.Text; |
34 | 36 |
|
... | ... | |
151 | 153 |
fileTextField.setLayoutData(fd_text); |
152 | 154 |
|
153 | 155 |
Button btnBrowse = new Button(container, SWT.NONE); |
156 |
btnBrowse.addSelectionListener(new SelectionAdapter() { |
|
157 |
@Override |
|
158 |
public void widgetSelected(SelectionEvent e) { |
|
159 |
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); |
|
160 |
dialog.setText("Export to"); //TODO Make multi language |
|
161 |
//fd.setFilterPath("C:/"); |
|
162 |
ContentExtensionFileFilter filter = getSelectedFormat().createFileFilter(); |
|
163 |
dialog.setFilterExtensions(new String[]{filter.getExtensionsAsString()}); |
|
164 |
dialog.setFilterNames(new String[]{filter.getDescription()}); |
|
165 |
String selectedFile = dialog.open(); |
|
166 |
if (selectedFile != null) { // Otherwise selecting was canceled. |
|
167 |
fileTextField.setText(selectedFile); |
|
168 |
} |
|
169 |
//TODO Add default extension, if necessary. |
|
170 |
} |
|
171 |
}); |
|
154 | 172 |
fd_text.right = new FormAttachment(100, -134); |
155 | 173 |
FormData fd_btnBrowse = new FormData(); |
156 | 174 |
fd_btnBrowse.left = new FormAttachment(fileTextField, 6); |
... | ... | |
174 | 192 |
|
175 | 193 |
|
176 | 194 |
/** |
177 |
* Returns the <i>JPhyloIO</i> format ID to be used for exporting.
|
|
195 |
* Returns the <i>JPhyloIO</i> format info object to be used for exporting.
|
|
178 | 196 |
* |
179 |
* @return the format ID or {@code null}, if none was yet selected
|
|
197 |
* @return the format info or {@code null}, if none was yet selected
|
|
180 | 198 |
*/ |
181 |
public String getSelectedFormat() {
|
|
199 |
public JPhyloIOFormatInfo getSelectedFormat() {
|
|
182 | 200 |
if (formatComboBox != null) { |
183 | 201 |
int index = formatComboBox.getSelectionIndex(); |
184 | 202 |
if (index > -1) { |
185 |
return FORMATS.get(index).getFormatID();
|
|
203 |
return FORMATS.get(index); |
|
186 | 204 |
} |
187 | 205 |
} |
188 | 206 |
return null; |
Also available in: Unified diff
ExportSingleReadAlignmentWizard now exposes whole format info object.
FileDialog added to ExportSingleReadAlignmentWizardPage.