2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.ui
.dialog
;
11 import java
.io
.IOException
;
13 import org
.eclipse
.jface
.dialogs
.IMessageProvider
;
14 import org
.eclipse
.jface
.dialogs
.TitleAreaDialog
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.custom
.CCombo
;
17 import org
.eclipse
.swt
.custom
.CLabel
;
18 import org
.eclipse
.swt
.events
.SelectionEvent
;
19 import org
.eclipse
.swt
.events
.SelectionListener
;
20 import org
.eclipse
.swt
.layout
.GridData
;
21 import org
.eclipse
.swt
.layout
.GridLayout
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.swt
.widgets
.Control
;
24 import org
.eclipse
.swt
.widgets
.Shell
;
26 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
34 public class DefaultLanguageDialog
extends TitleAreaDialog
{
38 final PreferencesUtil preferencesUtil
= new PreferencesUtil();
43 public DefaultLanguageDialog(Shell parentShell
) {
48 protected void configureShell(Shell shell
) {
49 super.configureShell(shell
);
53 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
56 protected Control
createDialogArea(Composite parent
) {
57 // TODO Auto-generated method stub
58 setTitle("Select your default Language");
59 setMessage("This is will set your default langauge once.\n You will be able to change this in the prefrence menue at any time.", IMessageProvider
.INFORMATION
);
60 Composite composite
= (Composite
)super.createDialogArea(parent
);
61 Composite container
= new Composite(parent
, SWT
.NONE
);
62 container
.setLayoutData(new GridData(SWT
.TOP
));
64 GridLayout layout
= new GridLayout(1, false);
65 container
.setLayoutData(new GridData(SWT
.CENTER
, SWT
.TOP
, true, true));
66 container
.setLayout(layout
);
68 final CLabel titleLabel
= new CLabel(container
, SWT
.NONE
);
69 titleLabel
.setText("After this the editor will restart, " +
70 "with your selection loaded. ");
73 createComboElement(container
);
82 private void createComboElement(Composite parent
) {
83 Composite container1
= new Composite(parent
, SWT
.NONE
);
84 container1
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
86 GridLayout layout1
= new GridLayout(2, false);
87 container1
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.RIGHT
, true, true));
88 container1
.setLayout(layout1
);
91 final CLabel comboLabel
= new CLabel(container1
, SWT
.NONE
);
92 comboLabel
.setText("Please choose your default language: ");
94 GridData oneLine
= new GridData();
95 oneLine
.grabExcessHorizontalSpace
= true;
96 oneLine
.horizontalAlignment
= GridData
.FILL
;
98 combo
= new CCombo(container1
, SWT
.NONE
);
99 combo
.setLayoutData(oneLine
);
101 combo
.add(Language
.GERMAN
.getLabel(), 0);
102 combo
.add(Language
.ENGLISH
.getLabel(), 1);
104 combo
.addSelectionListener(new SelectionListener() {
107 public void widgetSelected(SelectionEvent e
) {
109 preferencesUtil
.writePropertyToConfigFile(combo
.getSelectionIndex());
110 } catch (IOException e1
) {
111 e1
.printStackTrace();
116 public void widgetDefaultSelected(SelectionEvent e
) {
122 protected void okPressed() {
124 preferencesUtil
.writePropertyToConfigFile(combo
.getSelectionIndex());
125 } catch (IOException e
) {
131 private enum Language
{
133 GERMAN("Deutsch"), ENGLISH("English");
134 private String label
;
135 private Language(String label
){
142 public String
getLabel() {