View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: FileParamsSelectionPageComposite.java
13   * Created: 2009-03-19
14   * Author: bmilos
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.importer.wizard.page;
19  
20  import java.nio.charset.Charset;
21  import java.util.LinkedList;
22  import java.util.List;
23  import java.util.Map;
24  
25  import org.eclipse.jface.viewers.TableViewer;
26  import org.eclipse.swt.SWT;
27  import org.eclipse.swt.events.SelectionAdapter;
28  import org.eclipse.swt.events.SelectionEvent;
29  import org.eclipse.swt.layout.GridData;
30  import org.eclipse.swt.layout.GridLayout;
31  import org.eclipse.swt.widgets.Button;
32  import org.eclipse.swt.widgets.Combo;
33  import org.eclipse.swt.widgets.Composite;
34  import org.eclipse.swt.widgets.Group;
35  import org.eclipse.swt.widgets.Label;
36  import org.eclipse.swt.widgets.Table;
37  import org.eclipse.swt.widgets.TableColumn;
38  
39  import pl.edu.agh.cast.importer.base.data.RawTabularData;
40  import pl.edu.agh.cast.importer.base.tokenizer.ITokenizerOption;
41  import pl.edu.agh.cast.importer.wizard.dialog.AdvancedEncodingDialog;
42  import pl.edu.agh.cast.importer.wizard.util.ConversionRulesPageInfo;
43  import pl.edu.agh.cast.importer.wizard.util.Messages;
44  import pl.edu.agh.cast.importer.wizard.utils.AbstractWizardPageHelper;
45  import pl.edu.agh.cast.importer.wizard.utils.SimpleCharset;
46  import pl.edu.agh.cast.importer.wizard.utils.TableViewerHelper;
47  
48  /**
49   * The main composite of the {@link FileParamsSelectionPage}.
50   * 
51   * @author AGH CAST Team
52   */
53  public class FileParamsSelectionPageComposite extends Composite {
54  
55  	private FileParamsSelectionPage mediator;
56  
57  	private Combo domainModelCombo;
58  
59  	private Combo fileFormatCombo;
60  
61  	private Group domainModelGroup;
62  
63  	private Label conversionPageLabel;
64  
65  	// private Composite modelInfoComposite;
66  
67  	private Composite dataFileParams2;
68  
69  	private Group fileFormatGroup;
70  
71  	private Label fileFormatDescriptionLbl;
72  
73  	private TableViewer previewTableViewer;
74  
75  	private Button detectEncodingBtn;
76  
77  	private Group fileEncodingGroup;
78  
79  	private Button advancedEncodingBtn;
80  
81  	private Label fileEncodingDescriptionLbl;
82  
83  	private Group filePreviewGroup;
84  
85  	private Combo fileEncodingCombo;
86  
87  	private RawTabularData previewData;
88  
89  	private ConversionRulesPageInfo currConversionPageInfo;
90  
91  	/**
92  	 * The default constructor.
93  	 * 
94  	 * @param parent
95  	 *            the parent composite
96  	 * @param style
97  	 *            the style of widget to construct
98  	 * @param mediator
99  	 *            the mediating wizard page
100 	 */
101 	public FileParamsSelectionPageComposite(Composite parent, int style, FileParamsSelectionPage mediator) {
102 		super(parent, style);
103 		this.mediator = mediator;
104 		initGUI();
105 	}
106 
107 	private void initGUI() {
108 		GridLayout thisLayout = new GridLayout();
109 		thisLayout.verticalSpacing = 10;
110 		this.setLayout(thisLayout);
111 		this.setSize(800, 600);
112 
113 		dataFileParams2 = new Composite(this, SWT.NONE);
114 		GridLayout dataFileParams2Layout = new GridLayout();
115 		dataFileParams2Layout.makeColumnsEqualWidth = true;
116 		dataFileParams2Layout.numColumns = 2;
117 		GridData dataFileParams2LData = new GridData(SWT.FILL, SWT.FILL, true, true);
118 		dataFileParams2.setLayoutData(dataFileParams2LData);
119 		dataFileParams2.setLayout(dataFileParams2Layout);
120 
121 		fileFormatGroup = new Group(dataFileParams2, SWT.NONE);
122 		fileFormatGroup.setText(Messages.InitImportPageComposite_FileFormat);
123 		GridLayout fileFormatGroupLayout = new GridLayout();
124 		GridData fileFormatGroupLData = new GridData(SWT.FILL, SWT.FILL, true, true);
125 		fileFormatGroup.setLayoutData(fileFormatGroupLData);
126 		fileFormatGroup.setLayout(fileFormatGroupLayout);
127 
128 		domainModelGroup = new Group(dataFileParams2, SWT.NONE);
129 		GridLayout domainModelGroupLayout = new GridLayout();
130 		domainModelGroupLayout.makeColumnsEqualWidth = true;
131 		GridData domainModelGroupLData = new GridData(SWT.FILL, SWT.FILL, true, true);
132 		domainModelGroupLData.verticalSpan = 3;
133 		domainModelGroup.setText(Messages.InitImportPageComposite_DomainModel);
134 		domainModelGroup.setLayoutData(domainModelGroupLData);
135 		domainModelGroup.setLayout(domainModelGroupLayout);
136 
137 		domainModelCombo = new Combo(domainModelGroup, SWT.READ_ONLY);
138 		GridData domainModelComboLData = new GridData();
139 		domainModelComboLData.grabExcessHorizontalSpace = true;
140 		domainModelComboLData.horizontalAlignment = GridData.FILL;
141 		domainModelCombo.setLayoutData(domainModelComboLData);
142 
143 		conversionPageLabel = new Label(domainModelGroup, SWT.WRAP);
144 		GridData conversionPageLabelLData = new GridData();
145 		conversionPageLabelLData.grabExcessHorizontalSpace = true;
146 		conversionPageLabelLData.grabExcessVerticalSpace = true;
147 		conversionPageLabelLData.horizontalAlignment = GridData.FILL;
148 		conversionPageLabelLData.verticalAlignment = GridData.FILL;
149 		conversionPageLabel.setLayoutData(conversionPageLabelLData);
150 
151 		domainModelCombo.addSelectionListener(new SelectionAdapter() {
152 			@Override
153 			public void widgetSelected(SelectionEvent event) {
154 				handleDomainModelComboSelection();
155 			}
156 		});
157 		if (mediator != null) {
158 			mediator.setDomainModelComboData(domainModelCombo);
159 		}
160 
161 		/*
162 		 * modelInfoComposite = new Composite(domainModelGroup, SWT.NONE); GridData modelInfoGroupLData = new
163 		 * GridData(SWT.FILL, SWT.FILL, true, true); modelInfoGroupLData.minimumHeight = 100;
164 		 * modelInfoComposite.setLayoutData(modelInfoGroupLData); modelInfoComposite.layout(true);
165 		 */
166 		fileEncodingGroup = new Group(dataFileParams2, SWT.NONE);
167 		GridLayout fileEncodingGroupLayout = new GridLayout();
168 		fileEncodingGroupLayout.numColumns = 3;
169 		fileEncodingGroup.setLayout(fileEncodingGroupLayout);
170 		GridData fileEncodingGroupLData = new GridData(SWT.FILL, SWT.FILL, true, true);
171 		fileEncodingGroup.setLayoutData(fileEncodingGroupLData);
172 		fileEncodingGroup.setText(Messages.FileTypeSelectionPageComposite_FileEncoding);
173 
174 		fileEncodingCombo = new Combo(fileEncodingGroup, SWT.READ_ONLY);
175 		GridData fileEncodingComboLData = new GridData();
176 		fileEncodingComboLData.horizontalAlignment = GridData.FILL;
177 		fileEncodingComboLData.grabExcessHorizontalSpace = true;
178 		fileEncodingComboLData.verticalAlignment = GridData.BEGINNING;
179 		fileEncodingCombo.setLayoutData(fileEncodingComboLData);
180 
181 		fileEncodingCombo.setItems(getAvailableCharsets());
182 		fileEncodingCombo.addSelectionListener(new SelectionAdapter() {
183 			@Override
184 			public void widgetSelected(SelectionEvent event) {
185 				handleFileEncodingComboSelection();
186 			}
187 		});
188 
189 		detectEncodingBtn = new Button(fileEncodingGroup, SWT.PUSH | SWT.CENTER);
190 		GridData detectEncodingLData = new GridData();
191 		detectEncodingLData.minimumWidth = 80;
192 		detectEncodingLData.minimumHeight = 25;
193 		detectEncodingLData.horizontalAlignment = GridData.END;
194 		detectEncodingLData.verticalAlignment = GridData.BEGINNING;
195 		detectEncodingBtn.setLayoutData(detectEncodingLData);
196 		detectEncodingBtn.setText(Messages.FileParamsSelectionComposite_DetectAutomatically);
197 
198 		detectEncodingBtn.setEnabled(false);
199 		detectEncodingBtn.addSelectionListener(new SelectionAdapter() {
200 			@Override
201 			public void widgetSelected(SelectionEvent event) {
202 				handleDetectFileEncoding();
203 			}
204 		});
205 
206 		advancedEncodingBtn = new Button(fileEncodingGroup, SWT.PUSH | SWT.CENTER);
207 		GridData advancedEncodingBtnLData = new GridData();
208 		advancedEncodingBtnLData.minimumWidth = 80;
209 		advancedEncodingBtnLData.minimumHeight = 25;
210 		advancedEncodingBtnLData.horizontalAlignment = GridData.END;
211 		advancedEncodingBtnLData.verticalAlignment = GridData.BEGINNING;
212 		advancedEncodingBtn.setLayoutData(advancedEncodingBtnLData);
213 		advancedEncodingBtn.setText(Messages.FileParamsSelectionComposite_Advanced);
214 
215 		advancedEncodingBtn.setEnabled(false);
216 		advancedEncodingBtn.addSelectionListener(new SelectionAdapter() {
217 			@Override
218 			public void widgetSelected(SelectionEvent event) {
219 				handleAdvancedFileEncoding();
220 			}
221 		});
222 
223 		fileEncodingDescriptionLbl = new Label(fileEncodingGroup, SWT.WRAP);
224 		GridData fileEncodingDescriptionLblLData = new GridData(SWT.FILL, SWT.FILL, true, true);
225 		fileEncodingDescriptionLblLData.horizontalSpan = 3;
226 		fileEncodingDescriptionLbl.setLayoutData(fileEncodingDescriptionLblLData);
227 		fileEncodingDescriptionLbl.setText(Messages.FileParamsSelectionPageComposite_NoFileEncodingDescription);
228 
229 		fileFormatCombo = new Combo(fileFormatGroup, SWT.READ_ONLY);
230 		GridData fileFormatComboLData = new GridData();
231 		fileFormatComboLData.grabExcessHorizontalSpace = true;
232 		fileFormatComboLData.horizontalAlignment = GridData.FILL;
233 		fileFormatCombo.setLayoutData(fileFormatComboLData);
234 		fileFormatCombo.addSelectionListener(new SelectionAdapter() {
235 			@Override
236 			public void widgetSelected(SelectionEvent event) {
237 				handleFileFormatComboSelection();
238 			}
239 		});
240 		if (mediator != null) {
241 			mediator.setFormatComboData(fileFormatCombo);
242 		}
243 
244 		fileFormatDescriptionLbl = new Label(fileFormatGroup, SWT.WRAP);
245 		GridData fileFormatDescriptionLblLData = new GridData(SWT.FILL, SWT.FILL, true, true);
246 		fileFormatDescriptionLbl.setLayoutData(fileFormatDescriptionLblLData);
247 
248 		filePreviewGroup = new Group(this, SWT.NONE);
249 		GridLayout filePreviewGroupLayout = new GridLayout();
250 		filePreviewGroup.setLayout(filePreviewGroupLayout);
251 		GridData filePreviewGroupLData = new GridData(SWT.FILL, SWT.FILL, true, true);
252 		filePreviewGroupLData.minimumWidth = 550;
253 		filePreviewGroupLData.minimumHeight = 150;
254 		filePreviewGroup.setLayoutData(filePreviewGroupLData);
255 		filePreviewGroup.setText(Messages.InitImportPageComposite_FilePreview);
256 
257 		previewTableViewer = new TableViewer(filePreviewGroup, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL
258 		        | SWT.H_SCROLL);
259 		GridData previewTableViewerLData = new GridData(SWT.FILL, SWT.FILL, true, true);
260 		previewTableViewerLData.minimumWidth = 500;
261 		previewTableViewerLData.heightHint = 100;
262 		previewTableViewer.getControl().setLayoutData(previewTableViewerLData);
263 	}
264 
265 	/*
266 	 * -----------------------------------------------------------------------------------------------------------
267 	 * --------------------------ACTION METHODS------------------------------------------------------------
268 	 * -----------------------------------------------------------------------------------------------------------
269 	 */
270 
271 	private void handleFileFormatComboSelection() {
272 		detectEncodingBtn.setEnabled(true);
273 		advancedEncodingBtn.setEnabled(true);
274 
275 		if (mediator == null) {
276 			return;
277 		}
278 
279 		String formatId = getSelectedFormatId();
280 		// retrieve description
281 		String formatDescription = mediator.getTokenizerDescription(formatId);
282 		if (formatDescription != null && formatDescription.length() > 0) {
283 			fileFormatDescriptionLbl.setText(formatDescription);
284 		} else {
285 			fileFormatDescriptionLbl.setText(Messages.InitImportPageComposite_NoFileFormatDescription);
286 		}
287 
288 		// handle encoding - detect is automatically if it wasn't selected before
289 		if (!isEncodingSelected()) {
290 			handleDetectFileEncoding();
291 		} else {
292 			// file preview is refreshed only when encoding is NOT selected (as the refresh is also called inside the
293 			// handleDetectFileEncoding() method)
294 			refreshFilePreview(null);
295 		}
296 		mediator.widgetModified();
297 	}
298 
299 	private void handleDomainModelComboSelection() {
300 		ConversionRulesPageInfo conversionPageInfo = getSelectedConversionRulesSelectionPageInfo();
301 		if (conversionPageInfo.equals(currConversionPageInfo)) {
302 			return;
303 		}
304 		currConversionPageInfo = conversionPageInfo;
305 
306 		/*
307 		 * if (modelInfoComposite != null) { modelInfoComposite.dispose(); } modelInfoComposite = new
308 		 * Composite(domainModelGroup, SWT.FILL);
309 		 */
310 		if (conversionPageInfo == null) {
311 			conversionPageLabel.setText(""); //$NON-NLS-1$
312 		} else {
313 			conversionPageLabel.setText(conversionPageInfo.getDescription());
314 		}
315 
316 		// fillModelInfoGroup(modelId);
317 		// domainModelGroup.layout(true);
318 
319 		if (mediator != null) {
320 			mediator.widgetModified();
321 		}
322 	}
323 
324 	private void handleFileEncodingComboSelection() {
325 		if (isFormatSelected()) {
326 			detectEncodingBtn.setEnabled(true);
327 			advancedEncodingBtn.setEnabled(true);
328 		}
329 
330 		Charset charset = getSelectedEncoding();
331 		SimpleCharset[] simpleCharsets = SimpleCharset.values();
332 		boolean simpleEncodingSelected = false;
333 
334 		for (SimpleCharset simpleCharset : simpleCharsets) {
335 			if (simpleCharset.getCharset().equals(charset)) {
336 				fileEncodingDescriptionLbl.setText(simpleCharset.getDescription());
337 				simpleEncodingSelected = true;
338 				break;
339 			}
340 		}
341 
342 		if (!simpleEncodingSelected) {
343 			fileEncodingDescriptionLbl.setText(Messages.FileParamsSelectionPageComposite_NoFileEncodingDescription);
344 		}
345 
346 		refreshFilePreview(null);
347 	}
348 
349 	private void handleDetectFileEncoding() {
350 		Charset charset = mediator.getFileCharset();
351 		setSelectedEncoding(charset);
352 
353 		if (mediator != null) {
354 			mediator.widgetModified();
355 		}
356 	}
357 
358 	private void handleAdvancedFileEncoding() {
359 		AdvancedEncodingDialog dialog = new AdvancedEncodingDialog(this.getShell(), mediator, getSelectedEncoding(),
360 		        previewData);
361 		dialog.open();
362 	}
363 
364 	/*----------------------------------------------------------------------------------------------------------*/
365 
366 	/*
367 	 * -----------------------------------------------------------------------------------------------------------
368 	 * --------------------------HELPER METHODS------------------------------------------------------------
369 	 * -----------------------------------------------------------------------------------------------------------
370 	 */
371 
372 	private String[] getAvailableCharsets() {
373 		List<String> availableCharsets = new LinkedList<String>();
374 		SimpleCharset[] simpleCharsets = SimpleCharset.values();
375 
376 		for (SimpleCharset simpleCharset : simpleCharsets) {
377 			availableCharsets.add(simpleCharset.getCharset().displayName());
378 		}
379 
380 		String[] simpleCharsetsArray = new String[availableCharsets.size()];
381 		return availableCharsets.toArray(simpleCharsetsArray);
382 	}
383 
384 	/**
385 	 * Method called by the mediating wizard page to refresh the Composite's view.
386 	 * 
387 	 * @param selectedFilePath
388 	 *            the selected file path
389 	 */
390 	public void refreshPage(String selectedFilePath) {
391 		refreshFilePreviewGroupLabel(selectedFilePath);
392 		setFileFormatSelection(selectedFilePath);
393 	}
394 
395 	/**
396 	 * Refreshes the file preview group label by adding to it the selected data file path name.
397 	 * 
398 	 * @param filePath
399 	 *            the selected file path
400 	 */
401 	private void refreshFilePreviewGroupLabel(String filePath) {
402 		if (filePath != null && filePath.length() > 0) {
403 			StringBuilder sb = new StringBuilder();
404 			sb.append(Messages.InitImportPageComposite_FilePreview);
405 			sb.append(": "); //$NON-NLS-1$
406 			sb.append(filePath);
407 			filePreviewGroup.setText(sb.toString());
408 		}
409 	}
410 
411 	/**
412 	 * Detects the selected file's extension and sets the file format combo to an appropriate item (if such exists).
413 	 * 
414 	 * @param filePath
415 	 *            the selected file path
416 	 */
417 	private void setFileFormatSelection(String filePath) {
418 		if (filePath != null && filePath.length() > 0) {
419 			Map<String, String> supportedExtensions = mediator.getAllSupportedFileExtensions();
420 
421 			int extensionStart = filePath.lastIndexOf('.');
422 			String extension = filePath.substring(extensionStart + 1);
423 
424 			if (extension != null) {
425 				for (String fileExt : supportedExtensions.keySet()) {
426 					if (extension.equalsIgnoreCase(fileExt)) {
427 						String tokenizerId = supportedExtensions.get(fileExt);
428 						String[] tokenizerIds = (String[])fileFormatCombo.getData();
429 
430 						for (int i = 0; i < tokenizerIds.length; i++) {
431 							if (tokenizerIds[i].equals(tokenizerId)) {
432 								fileFormatCombo.select(i);
433 								handleFileFormatComboSelection();
434 								return;
435 							}
436 						}
437 					}
438 				}
439 			}
440 
441 			fileFormatCombo.clearSelection();
442 			fileFormatCombo.deselectAll();
443 			fileEncodingCombo.clearSelection();
444 			fileEncodingCombo.deselectAll();
445 			refreshFilePreview(null);
446 		}
447 	}
448 
449 	/**
450 	 * Refreshes the file preview.
451 	 * 
452 	 * @param options
453 	 *            the options for the tokenzier
454 	 */
455 	private void refreshFilePreview(List<ITokenizerOption> options) {
456 		if (mediator == null) {
457 			return;
458 		}
459 
460 		previewData = mediator.loadPreview(getSelectedEncoding(), options,
461 		        AbstractWizardPageHelper.PREVIEW_ROWS_LIMIT_PARTIAL);
462 
463 		if (previewData != null) {
464 			// create preview table
465 			previewTableViewer.getTable().setEnabled(true);
466 
467 			TableViewerHelper.initTable(previewTableViewer, previewData);
468 
469 			previewTableViewer.getTable().setLinesVisible(true);
470 			TableViewerHelper.adjustColumnWidth(previewTableViewer);
471 
472 		} else {
473 
474 			previewTableViewer.getTable().setEnabled(false);
475 			previewTableViewer.getTable().setLinesVisible(false);
476 			previewTableViewer.getTable().clearAll();
477 		}
478 	}
479 
480 	/**
481 	 * Fills in the <code>modelInfoGroup</code> composite, with the information about the model.
482 	 * 
483 	 * XXX Temporary unused
484 	 * 
485 	 * @param modelInfo
486 	 *            the modelInfo
487 	 */
488 	@SuppressWarnings("unused")
489 	private void fillModelInfoGroup(String modelId) {
490 		/*
491 		 * GridLayout modelInfoLayout = new GridLayout(); modelInfoLayout.verticalSpacing = 5;
492 		 * modelInfoComposite.setLayout(modelInfoLayout);
493 		 * 
494 		 * GridData modelInfoGroupLData = new GridData(SWT.FILL, SWT.FILL, true, true);
495 		 * modelInfoComposite.setLayoutData(modelInfoGroupLData);
496 		 * 
497 		 * Label modelInfoTitleLbl = new Label(modelInfoComposite, SWT.NONE);
498 		 * modelInfoTitleLbl.setText(Messages.ModelInfo_DomainModelDetails);
499 		 * 
500 		 * Table modelColumnsTable = new Table(modelInfoComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
501 		 * GridData modelColumnsTableLData = new GridData(SWT.FILL, SWT.FILL, true, true);
502 		 * modelColumnsTable.setLayoutData(modelColumnsTableLData);
503 		 * 
504 		 * // set table layout so that all columns are of equal size TableLayout tableLayout = new TableLayout();
505 		 * tableLayout.addColumnData(new ColumnWeightData(33, 75, false)); tableLayout.addColumnData(new
506 		 * ColumnWeightData(33, 75, false)); tableLayout.addColumnData(new ColumnWeightData(33, 75, false));
507 		 * modelColumnsTable.setLayout(tableLayout);
508 		 * 
509 		 * fillModelColumnsTable(modelColumnsTable, modelId);
510 		 * 
511 		 * modelColumnsTable.setHeaderVisible(true); modelColumnsTable.setLinesVisible(true);
512 		 */
513 	}
514 
515 	/**
516 	 * XXX Temporary unused
517 	 * 
518 	 */
519 	@SuppressWarnings("unused")
520 	private void fillModelColumnsTable(Table table, String modelId) {
521 		TableColumn[] tableColumns = table.getColumns();
522 		for (TableColumn column : tableColumns) {
523 			column.dispose();
524 		}
525 
526 		TableColumn tableColumn = new TableColumn(table, SWT.NONE);
527 		tableColumn.setText(Messages.ModelInfo_Name);
528 		tableColumn = new TableColumn(table, SWT.NONE);
529 		tableColumn.setText(Messages.ModelInfo_Type);
530 		tableColumn = new TableColumn(table, SWT.NONE);
531 		tableColumn.setText(Messages.ModelInfo_Use);
532 		/*
533 		 * ModelColumn[] columns = mediator.getModelColumns(modelId);
534 		 * 
535 		 * TableItem item = null; if (columns != null) { for (ModelColumn modelColumn : columns) { item = new
536 		 * TableItem(table, SWT.NONE); item.setText(new String[] { modelColumn.getName(),
537 		 * translateDataType(modelColumn.getType()), translateUseValue(modelColumn.isRequired()) }); } }
538 		 */
539 	}
540 
541 	/**
542 	 * XXX Temporary unused
543 	 * 
544 	 */
545 	@SuppressWarnings("unused")
546 	private String translateUseValue(boolean required) {
547 		if (required) {
548 			return Messages.ModelInfo_Required;
549 		} else {
550 			return Messages.ModelInfo_Optional;
551 		}
552 	}
553 
554 	/**
555 	 * Localizes the data types, so that they can be displayed in different languages.
556 	 * 
557 	 * @param type
558 	 *            the type to localize
559 	 * @return the localized type
560 	 */
561 	private String translateDataType(String type) {
562 		if (type == null || type.length() == 0) {
563 			return ""; //$NON-NLS-1$
564 		}
565 
566 		String result = type;
567 		/*
568 		 * if (type.equals(BasePlugin.COLUMN_TYPE_DATE)) { result = Messages.ModelInfo_Date; } else if
569 		 * (type.equals(BasePlugin.COLUMN_TYPE_LONG)) { result = Messages.ModelInfo_Long; } else if
570 		 * (type.equals(BasePlugin.COLUMN_TYPE_STRING)) { result = Messages.ModelInfo_String; } else if
571 		 * (type.equals(BasePlugin.COLUMN_TYPE_BOOLEAN)) { result = Messages.ModelInfo_Boolean; } else if
572 		 * (type.equals(BasePlugin.COLUMN_TYPE_DOUBLE)) { result = Messages.ModelInfo_Double; }
573 		 */
574 		return result;
575 	}
576 
577 	/*----------------------------------------------------------------------------------------------------------*/
578 
579 	/*
580 	 * -----------------------------------------------------------------------------------------------------------
581 	 * --------------------------GETTERS AND SETTERS------------------------------------------------------
582 	 * -----------------------------------------------------------------------------------------------------------
583 	 */
584 
585 	/**
586 	 * Sets the selected encoding.
587 	 * 
588 	 * @param charset
589 	 *            the selected encoding
590 	 */
591 	public void setSelectedEncoding(Charset charset) {
592 		if (charset != null) {
593 			String[] availableEncodings = fileEncodingCombo.getItems();
594 
595 			boolean charsetPresent = false;
596 			for (int encodingIndex = 0; encodingIndex < availableEncodings.length; encodingIndex++) {
597 				if (charset.displayName().equals(availableEncodings[encodingIndex])) {
598 					fileEncodingCombo.select(encodingIndex);
599 					charsetPresent = true;
600 					break;
601 				}
602 			}
603 
604 			if (!charsetPresent) {
605 				fileEncodingCombo.add(charset.displayName());
606 				fileEncodingCombo.select(fileEncodingCombo.getItems().length - 1);
607 			}
608 		}
609 
610 		handleFileEncodingComboSelection();
611 	}
612 
613 	/**
614 	 * Retrieves the selected conversion rules selection page info.
615 	 * 
616 	 * @return selected items
617 	 */
618 	public ConversionRulesPageInfo getSelectedConversionRulesSelectionPageInfo() {
619 		ConversionRulesPageInfo[] conversionPages = (ConversionRulesPageInfo[])domainModelCombo.getData();
620 		int selectedIndex = domainModelCombo.getSelectionIndex();
621 		if (selectedIndex == -1) {
622 			return null;
623 		}
624 		return conversionPages[domainModelCombo.getSelectionIndex()];
625 	}
626 
627 	/**
628 	 * Retrieves the selected domain model name.
629 	 * 
630 	 * @return selected model name
631 	 */
632 	public String getSelectedModelName() {
633 		return domainModelCombo.getItem(domainModelCombo.getSelectionIndex());
634 	}
635 
636 	/**
637 	 * Retrieves the selected file format (tokenizer) identifier.
638 	 * 
639 	 * @return selected format id
640 	 */
641 	public String getSelectedFormatId() {
642 		String[] tokenizerIds = (String[])fileFormatCombo.getData();
643 		int selectedIndex = fileFormatCombo.getSelectionIndex();
644 		if (selectedIndex == -1) {
645 			return null;
646 		}
647 		return tokenizerIds[fileFormatCombo.getSelectionIndex()];
648 	}
649 
650 	/**
651 	 * Retrieves the selected charset.
652 	 * 
653 	 * @return selected charset
654 	 */
655 	public Charset getSelectedEncoding() {
656 		String[] availableEncodings = fileEncodingCombo.getItems();
657 		int selectedIndex = fileEncodingCombo.getSelectionIndex();
658 		if (selectedIndex == -1) {
659 			return null;
660 		}
661 		String selectedCharsetName = fileEncodingCombo.getItem(selectedIndex);
662 
663 		for (String encoding : availableEncodings) {
664 			if (selectedCharsetName.equals(encoding)) {
665 				return Charset.availableCharsets().get(selectedCharsetName);
666 			}
667 		}
668 		return null;
669 	}
670 
671 	public boolean isFormatSelected() {
672 		return (fileFormatCombo.getSelectionIndex() == -1) ? false : true;
673 	}
674 
675 	public boolean isDomainModelSelected() {
676 		return (domainModelCombo.getSelectionIndex() == -1) ? false : true;
677 	}
678 
679 	private boolean isEncodingSelected() {
680 		return (fileEncodingCombo.getSelectionIndex() == -1) ? false : true;
681 	}
682 
683 	/*----------------------------------------------------------------------------------------------------------*/
684 
685 }