3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
;
12 import java
.io
.IOException
;
14 import org
.eclipse
.jface
.dialogs
.IMessageProvider
;
15 import org
.eclipse
.jface
.dialogs
.TitleAreaDialog
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.custom
.CCombo
;
18 import org
.eclipse
.swt
.custom
.CLabel
;
19 import org
.eclipse
.swt
.events
.SelectionEvent
;
20 import org
.eclipse
.swt
.events
.SelectionListener
;
21 import org
.eclipse
.swt
.layout
.GridData
;
22 import org
.eclipse
.swt
.layout
.GridLayout
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Control
;
25 import org
.eclipse
.swt
.widgets
.Shell
;
27 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
35 public class DefaultLanguageDialog
extends TitleAreaDialog
{
39 final PreferencesUtil preferencesUtil
= new PreferencesUtil();
44 public DefaultLanguageDialog(Shell parentShell
) {
49 protected void configureShell(Shell shell
) {
50 super.configureShell(shell
);
54 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
57 protected Control
createDialogArea(Composite parent
) {
58 // TODO Auto-generated method stub
59 setTitle("Select your default Language");
60 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
);
61 Composite composite
= (Composite
)super.createDialogArea(parent
);
62 Composite container
= new Composite(parent
, SWT
.NONE
);
63 container
.setLayoutData(new GridData(SWT
.TOP
));
65 GridLayout layout
= new GridLayout(1, false);
66 container
.setLayoutData(new GridData(SWT
.CENTER
, SWT
.TOP
, true, true));
67 container
.setLayout(layout
);
69 final CLabel titleLabel
= new CLabel(container
, SWT
.NONE
);
70 titleLabel
.setText("After this the editor will restart, " +
71 "with your selection loaded. ");
74 createComboElement(container
);
83 private void createComboElement(Composite parent
) {
84 Composite container1
= new Composite(parent
, SWT
.NONE
);
85 container1
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
87 GridLayout layout1
= new GridLayout(2, false);
88 container1
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.RIGHT
, true, true));
89 container1
.setLayout(layout1
);
92 final CLabel comboLabel
= new CLabel(container1
, SWT
.NONE
);
93 comboLabel
.setText("Please choose your default language: ");
95 GridData oneLine
= new GridData();
96 oneLine
.grabExcessHorizontalSpace
= true;
97 oneLine
.horizontalAlignment
= GridData
.FILL
;
99 combo
= new CCombo(container1
, SWT
.NONE
);
100 combo
.setLayoutData(oneLine
);
102 combo
.add(Language
.GERMAN
.getLabel(), 0);
103 combo
.add(Language
.ENGLISH
.getLabel(), 1);
105 combo
.addSelectionListener(new SelectionListener() {
108 public void widgetSelected(SelectionEvent e
) {
110 preferencesUtil
.writePropertyToConfigFile(combo
.getSelectionIndex());
111 } catch (IOException e1
) {
112 e1
.printStackTrace();
117 public void widgetDefaultSelected(SelectionEvent e
) {
123 protected void okPressed() {
125 preferencesUtil
.writePropertyToConfigFile(combo
.getSelectionIndex());
126 } catch (IOException e
) {
132 private enum Language
{
134 GERMAN("Deutsch"), ENGLISH("English");
135 private String label
;
136 private Language(String label
){
143 public String
getLabel() {