Project

General

Profile

« Previous | Next » 

Revision 0608d733

Added by Ben Stöver over 7 years ago

ExportSingleReadAlignmentWizardPage now allows to select output file and
format.

View differences:

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.jphyloio.events.type.EventContentType;
14
import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
15
import info.bioinfweb.jphyloio.formatinfo.JPhyloIOFormatInfo;
16

  
17
import java.util.ArrayList;
18
import java.util.Collections;
19
import java.util.List;
20

  
13 21
import org.eclipse.jface.wizard.WizardPage;
14 22
import org.eclipse.swt.SWT;
15 23
import org.eclipse.swt.events.SelectionAdapter;
......
18 26
import org.eclipse.swt.layout.FormData;
19 27
import org.eclipse.swt.layout.FormLayout;
20 28
import org.eclipse.swt.widgets.Button;
29
import org.eclipse.swt.widgets.Combo;
21 30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Label;
22 32
import org.eclipse.swt.widgets.Text;
23 33

  
24 34

  
......
30 40
 * @date 18.04.2016
31 41
 */
32 42
public class ExportSingleReadAlignmentWizardPage extends WizardPage {
43
    private static JPhyloIOReaderWriterFactory factory = new JPhyloIOReaderWriterFactory();
44
    private static List<JPhyloIOFormatInfo> formats = createFormatInfoList();
45

  
33 46
    private Text consensusSequenceNameTextField;
34 47
    private Button exportConsensusSequenceCB;
35 48
    private Button exportSingleReadsCB;
49
    private Text fileTextField;
50
    private Combo formatComboBox;
36 51

  
37 52

  
38 53
    /**
......
45 60
    }
46 61

  
47 62

  
63
    private static List<JPhyloIOFormatInfo> createFormatInfoList() {
64
        List<JPhyloIOFormatInfo> result = new ArrayList<JPhyloIOFormatInfo>();
65
        for (String formatID : factory.getFormatIDsSet()) {
66
            JPhyloIOFormatInfo info = factory.getFormatInfo(formatID);
67
            if (info.isElementModeled(EventContentType.ALIGNMENT, false)) {  // Check if the current format allows to write alignments.
68
                result.add(info);
69
            }
70
        }
71
        return Collections.unmodifiableList(result);
72
    }
73

  
74

  
48 75
    /**
49 76
     * Create contents of the wizard.
50 77
     *
......
60 87
        exportSingleReadsCB = new Button(container, SWT.CHECK);
61 88
        exportSingleReadsCB.setSelection(true);
62 89
        FormData fd_exportSingleReadsCB = new FormData();
63
        fd_exportSingleReadsCB.top = new FormAttachment(0, 10);
64 90
        fd_exportSingleReadsCB.left = new FormAttachment(0, 10);
65 91
        exportSingleReadsCB.setLayoutData(fd_exportSingleReadsCB);
66 92
        exportSingleReadsCB.setText("Export single reads");
......
75 101
        });
76 102
        FormData fd_exportConsensusSequenceCB = new FormData();
77 103
        fd_exportConsensusSequenceCB.top = new FormAttachment(exportSingleReadsCB, 6);
78
        fd_exportConsensusSequenceCB.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
104
        fd_exportConsensusSequenceCB.left = new FormAttachment(0, 10);
79 105
        exportConsensusSequenceCB.setLayoutData(fd_exportConsensusSequenceCB);
80 106
        exportConsensusSequenceCB.setText("Export consensus sequence");
81 107

  
82 108
        consensusSequenceNameTextField = new Text(container, SWT.BORDER);
83 109
        consensusSequenceNameTextField.setText("ConsensusSequence");
84 110
        FormData fd_consensusSequenceNameTextField = new FormData();
85
        fd_consensusSequenceNameTextField.bottom = new FormAttachment(30);
86
        fd_consensusSequenceNameTextField.right = new FormAttachment(28);
87
        fd_consensusSequenceNameTextField.top = new FormAttachment(0, 62);
88 111
        fd_consensusSequenceNameTextField.left = new FormAttachment(0, 32);
112
        fd_consensusSequenceNameTextField.right = new FormAttachment(100, -10);
113
        fd_consensusSequenceNameTextField.top = new FormAttachment(exportConsensusSequenceCB, 6);
114
        fd_consensusSequenceNameTextField.bottom = new FormAttachment(30, 26);
89 115
        consensusSequenceNameTextField.setLayoutData(fd_consensusSequenceNameTextField);
116

  
117
        Label lblFormat = new Label(container, SWT.NONE);
118
        FormData fd_lblFormat = new FormData();
119
        fd_lblFormat.top = new FormAttachment(consensusSequenceNameTextField, 25);
120
        fd_lblFormat.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
121
        lblFormat.setLayoutData(fd_lblFormat);
122
        lblFormat.setText("Select the export format:");
123

  
124
        Label lblSelectTheData = new Label(container, SWT.NONE);
125
        fd_exportSingleReadsCB.top = new FormAttachment(lblSelectTheData, 6);
126
        FormData fd_lblSelectTheData = new FormData();
127
        fd_lblSelectTheData.left = new FormAttachment(0, 10);
128
        fd_lblSelectTheData.top = new FormAttachment(0, 10);
129
        lblSelectTheData.setLayoutData(fd_lblSelectTheData);
130
        lblSelectTheData.setText("Select the data to export:");
131

  
132
        Label lblSelectTheExport = new Label(container, SWT.NONE);
133
        FormData fd_lblSelectTheExport = new FormData();
134
        fd_lblSelectTheExport.top = new FormAttachment(lblFormat, 57);
135
        fd_lblSelectTheExport.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
136
        lblSelectTheExport.setLayoutData(fd_lblSelectTheExport);
137
        lblSelectTheExport.setText("Select the export destination:");
138

  
139
        Label lblAlignmentFile = new Label(container, SWT.NONE);
140
        FormData fd_lblAlignmentFile = new FormData();
141
        fd_lblAlignmentFile.top = new FormAttachment(lblSelectTheExport, 9);
142
        fd_lblAlignmentFile.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
143
        lblAlignmentFile.setLayoutData(fd_lblAlignmentFile);
144
        lblAlignmentFile.setText("Alignment file:");
145

  
146
        fileTextField = new Text(container, SWT.BORDER);
147
        FormData fd_text = new FormData();
148
        fd_text.left = new FormAttachment(lblAlignmentFile, 6);
149
        fd_text.top = new FormAttachment(lblSelectTheExport, 6);
150
        fileTextField.setLayoutData(fd_text);
151

  
152
        Button btnBrowse = new Button(container, SWT.NONE);
153
        fd_text.right = new FormAttachment(100, -134);
154
        FormData fd_btnBrowse = new FormData();
155
        fd_btnBrowse.left = new FormAttachment(fileTextField, 6);
156
        fd_btnBrowse.top = new FormAttachment(lblAlignmentFile, -5, SWT.TOP);
157
        fd_btnBrowse.right = new FormAttachment(100, -10);
158
        btnBrowse.setLayoutData(fd_btnBrowse);
159
        btnBrowse.setText("Browse...");
160

  
161
        formatComboBox = new Combo(container, SWT.NONE);
162
        for (JPhyloIOFormatInfo formatInfo : formats) {
163
            formatComboBox.add(formatInfo.getFormatName());
164
        }
165

  
166
        FormData fd_formatComboBox = new FormData();
167
        fd_formatComboBox.right = new FormAttachment(consensusSequenceNameTextField, 0, SWT.RIGHT);
168
        fd_formatComboBox.top = new FormAttachment(lblFormat, 6);
169
        fd_formatComboBox.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
170
        formatComboBox.setLayoutData(fd_formatComboBox);
171
    }
172

  
173

  
174
    /**
175
     * Returns the <i>JPhyloIO</i> format ID to be used for exporting.
176
     *
177
     * @return the format ID or {@code null}, if none was yet selected
178
     */
179
    public String getSelectedFormat() {
180
        if (formatComboBox != null) {
181
            int index = formatComboBox.getSelectionIndex();
182
            if (index > -1) {
183
                formats.get(index).getFormatID();
184
            }
185
        }
186
        return null;
90 187
    }
91 188
}

Also available in: Unified diff