Project

General

Profile

« Previous | Next » 

Revision 02e8904c

Added by Ben Stöver over 7 years ago

Fixes in ExportSingleReadAlignmentWizardPage layout.
Default values added to ExportSingleReadAlignmentWizardModel.
Updating values after model binding in ExportSingleReadAlignmentWizardPage implemented.

View differences:

eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizardPage.java
80 80
        container.setLayout(new FormLayout());
81 81

  
82 82
        exportSingleReadsCB = new Button(container, SWT.CHECK);
83
        exportSingleReadsCB.setSelection(true);
84 83
        FormData fd_exportSingleReadsCB = new FormData();
85 84
        fd_exportSingleReadsCB.left = new FormAttachment(0, 10);
86 85
        exportSingleReadsCB.setLayoutData(fd_exportSingleReadsCB);
87 86
        exportSingleReadsCB.setText("Export single reads");
88 87
        final ISWTObservableValue exportSingleReadsObservable = SWTObservables.observeSelection(exportSingleReadsCB);
89 88
        dbc.bindValue(exportSingleReadsObservable, getWizard().getModel().getExportSingleReadsObservable());
89
        exportSingleReadsCB.setSelection(false);
90
        exportSingleReadsCB.setSelection(true);  // Must happen after the component has been bound to the model.
91

  
90 92

  
91 93
        exportConsensusSequenceCB = new Button(container, SWT.CHECK);
92
        exportConsensusSequenceCB.setSelection(true);
93 94
        exportConsensusSequenceCB.addSelectionListener(new SelectionAdapter() {
94 95
            @Override
95 96
            public void widgetSelected(SelectionEvent e) {
......
103 104
        exportConsensusSequenceCB.setText("Export consensus sequence");
104 105
        final ISWTObservableValue exportConsensusSequenceObservable = SWTObservables.observeSelection(exportConsensusSequenceCB);
105 106
        dbc.bindValue(exportConsensusSequenceObservable, getWizard().getModel().getExportConsensusSequenceObservable());
107
        exportConsensusSequenceCB.setSelection(false);
108
        exportConsensusSequenceCB.setSelection(true);  // Must happen after the component has been bound to the model.
106 109

  
107 110
        consensusSequenceLabelTextField = new Text(container, SWT.BORDER);
108
        consensusSequenceLabelTextField.setText("ConsensusSequence");
109 111
        FormData fd_consensusSequenceNameTextField = new FormData();
112
        fd_consensusSequenceNameTextField.bottom = new FormAttachment(exportConsensusSequenceCB, 32, SWT.BOTTOM);
110 113
        fd_consensusSequenceNameTextField.left = new FormAttachment(0, 32);
111 114
        fd_consensusSequenceNameTextField.right = new FormAttachment(100, -10);
112 115
        fd_consensusSequenceNameTextField.top = new FormAttachment(exportConsensusSequenceCB, 6);
113
        fd_consensusSequenceNameTextField.bottom = new FormAttachment(30, 26);
114 116
        consensusSequenceLabelTextField.setLayoutData(fd_consensusSequenceNameTextField);
115 117
        final ISWTObservableValue consensusSequenceLabelObservable = SWTObservables.observeText(consensusSequenceLabelTextField, SWT.Modify);
116 118
        dbc.bindValue(consensusSequenceLabelObservable, getWizard().getModel().getConsensusSequenceLabelObservable());
119
        consensusSequenceLabelTextField.setText("ConsensusSequence");  // Must happen after the component has been bound to the model.
117 120

  
118 121
        Label lblFormat = new Label(container, SWT.NONE);
119 122
        FormData fd_lblFormat = new FormData();
120
        fd_lblFormat.top = new FormAttachment(consensusSequenceLabelTextField, 25);
123
        fd_lblFormat.top = new FormAttachment(consensusSequenceLabelTextField, 36);
121 124
        fd_lblFormat.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
122 125
        lblFormat.setLayoutData(fd_lblFormat);
123 126
        lblFormat.setText("Select the export format:");  //TODO multi language
......
146 149

  
147 150
        fileTextField = new Text(container, SWT.BORDER);
148 151
        FormData fd_text = new FormData();
149
        fd_text.right = new FormAttachment(consensusSequenceLabelTextField, 0, SWT.RIGHT);
150
        fd_text.top = new FormAttachment(lblSelectTheExport, 6);
152
        fd_text.right = new FormAttachment(100, -10);
151 153
        fd_text.left = new FormAttachment(lblAlignmentFile, 6);
154
        fd_text.top = new FormAttachment(lblSelectTheExport, 6);
152 155
        fileTextField.setLayoutData(fd_text);
153 156
        final ISWTObservableValue fileNameObservable = SWTObservables.observeText(fileTextField, SWT.Modify);
154 157
        dbc.bindValue(fileNameObservable, getWizard().getModel().getFileNameObservable());
......
159 162
            public void widgetSelected(SelectionEvent e) {
160 163
                FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
161 164
                dialog.setText("Export to");  //TODO multi language
162
                ContentExtensionFileFilter filter = getWizard().getModel().getFormatInfo().createFileFilter(TestStrategy.EXTENSION);
165
                ContentExtensionFileFilter filter = getSelectedFormat().createFileFilter(TestStrategy.EXTENSION);
163 166
                dialog.setFilterExtensions(new String[]{filter.getExtensionsAsString()});
164 167
                dialog.setFilterNames(new String[]{filter.getDescription()});
165 168
                String selectedFile = dialog.open();
......
169 172
            }
170 173
        });
171 174
        FormData fd_btnBrowse = new FormData();
172
        fd_btnBrowse.bottom = new FormAttachment(100, -10);
175
        fd_btnBrowse.left = new FormAttachment(100, -128);
176
        fd_btnBrowse.bottom = new FormAttachment(fileTextField, 43, SWT.BOTTOM);
177
        fd_btnBrowse.top = new FormAttachment(fileTextField, 13);
173 178
        fd_btnBrowse.right = new FormAttachment(100, -10);
174 179
        btnBrowse.setLayoutData(fd_btnBrowse);
175 180
        btnBrowse.setText("Browse...");
......
179 184
            formatComboBox.add(formatInfo.getFormatName());
180 185
        }
181 186
        FormData fd_formatComboBox = new FormData();
182
        fd_formatComboBox.right = new FormAttachment(consensusSequenceLabelTextField, 0, SWT.RIGHT);
187
        fd_formatComboBox.left = new FormAttachment(0, 10);
188
        fd_formatComboBox.right = new FormAttachment(100, -10);
183 189
        fd_formatComboBox.top = new FormAttachment(lblFormat, 6);
184
        fd_formatComboBox.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
185 190
        formatComboBox.setLayoutData(fd_formatComboBox);
186
        formatComboBox.select(0);
187 191
        final ISWTObservableValue formatObservable = SWTObservables.observeSelection(formatComboBox);  // ViewerProperties.singleSelection().observe(formatComboBox); falls ein ComboViewer verwendet wird. (Dann kann direkt FormatInfo verwendet werden.)
192
        dbc.bindValue(formatObservable, getWizard().getModel().getFormatInfoObservable());
193
        formatComboBox.select(0);  // Must happen after the component has been bound to the model.
188 194

  
189 195
        Button appendExtensionButton = new Button(container, SWT.NONE);
190 196
        appendExtensionButton.addSelectionListener(new SelectionAdapter() {
191 197
            @Override
192 198
            public void widgetSelected(SelectionEvent e) {
193 199
                fileTextField.setText(fileTextField.getText() + ExtensionFileFilter.EXTENSION_SEPARATOR +
194
                        ExportSingleReadAlignmentWizardModel.FORMAT_NAMES_TO_INFO_MAP.get(
195
                                formatComboBox.getText()).createFileFilter(TestStrategy.EXTENSION).getDefaultExtension());
200
                        getSelectedFormat().createFileFilter(TestStrategy.EXTENSION).getDefaultExtension());
196 201
            }
197 202
        });
198
        fd_btnBrowse.left = new FormAttachment(0, 446);
199 203
        FormData fd_btnNewButton = new FormData();
200 204
        fd_btnNewButton.left = new FormAttachment(btnBrowse, -217, SWT.LEFT);
201
        fd_btnNewButton.bottom = new FormAttachment(100, -10);
202 205
        fd_btnNewButton.right = new FormAttachment(btnBrowse, -6);
206
        fd_btnNewButton.bottom = new FormAttachment(fileTextField, 43, SWT.BOTTOM);
207
        fd_btnNewButton.top = new FormAttachment(fileTextField, 13);
203 208
        appendExtensionButton.setLayoutData(fd_btnNewButton);
204 209
        appendExtensionButton.setText("Append default extension");  //TODO multi language
205
        dbc.bindValue(formatObservable, getWizard().getModel().getFormatInfoObservable());
206 210

  
207 211
        dbc.addValidationStatusProvider(new MultiValidator() {
208 212
            @Override
......
222 226
                if ((fileName == null) || fileName.isEmpty()) {
223 227
                    return ValidationStatus.error("The file name must not be empty.");  //TODO multi language
224 228
                }
225
                else if (!ExportSingleReadAlignmentWizardModel.FORMAT_NAMES_TO_INFO_MAP.get(
226
                        formatObservable.getValue()).createFileFilter(TestStrategy.EXTENSION).accept(new File(fileName))) {
227

  
229
                else if (!getSelectedFormat().createFileFilter(TestStrategy.EXTENSION).accept(new File(fileName))) {
228 230
                    return ValidationStatus.warning("The file name does have a valid extension for the selected format.");  //TODO multi language
229 231
                }
232
                else if (fileName.charAt(0) == ExtensionFileFilter.EXTENSION_SEPARATOR) {
233
                    return ValidationStatus.warning("File starting with '" + ExtensionFileFilter.EXTENSION_SEPARATOR +
234
                            "' are not supported on all operating systems.");  //TODO multi language
235
                }
230 236
                else {
231 237
                    return ValidationStatus.ok();
232 238
                }
......
235 241
    }
236 242

  
237 243

  
244
    private JPhyloIOFormatInfo getSelectedFormat() {
245
        return ExportSingleReadAlignmentWizardModel.FORMAT_NAMES_TO_INFO_MAP.get(formatComboBox.getText());
246
    }
247

  
248

  
238 249
    /**
239 250
     * {@inheritDoc}
240 251
     */

Also available in: Unified diff