3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.preference
;
13 import org
.eclipse
.jface
.preference
.PreferencePage
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.custom
.CLabel
;
16 import org
.eclipse
.swt
.events
.ModifyEvent
;
17 import org
.eclipse
.swt
.events
.ModifyListener
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.layout
.GridLayout
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.swt
.widgets
.Control
;
22 import org
.eclipse
.swt
.widgets
.Text
;
23 import org
.eclipse
.ui
.IWorkbench
;
24 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
28 * @created Feb 4, 2011
31 public class MobotOpenUrlPreferences
extends PreferencePage
implements
32 IWorkbenchPreferencePage
{
35 private String openUrlServiceAccessPoint
;
36 private String openUrlImageMaxWidth
;
37 private String openUrlImageMaxHeight
;
40 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
43 public void init(IWorkbench workbench
) {
44 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
48 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
51 protected Control
createContents(Composite parent
) {
52 Composite container
= new Composite(parent
, SWT
.NULL
);
53 final GridLayout gridLayout
= new GridLayout();
54 container
.setLayout(gridLayout
);
56 creatOpenUrlServiceAccessPoint(container
);
58 createOpenUrlImageSize(container
);
66 private void createOpenUrlImageSize(Composite container
) {
67 openUrlImageMaxWidth
= getPreferenceStore().getString(IPreferenceKeys
.OPENURL_IMAGE_MAX_WIDTH
);
68 openUrlImageMaxHeight
= getPreferenceStore().getString(IPreferenceKeys
.OPENURL_IMAGE_MAX_HEIGHT
);
70 Composite composite
= new Composite(container
, SWT
.NULL
);
71 final GridLayout gridLayout
= new GridLayout(2, false);
72 composite
.setLayout(gridLayout
);
74 final CLabel labelWidth
= new CLabel(composite
, SWT
.NULL
);
75 labelWidth
.setText("Image Maximum Width: ");
77 final Text textWidth
= new Text(composite
, SWT
.BORDER
);
78 textWidth
.setText(openUrlImageMaxWidth
);
79 textWidth
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
81 textWidth
.addModifyListener(new ModifyListener() {
83 public void modifyText(ModifyEvent e
) {
84 openUrlImageMaxWidth
= textWidth
.getText();
88 final CLabel labelHeight
= new CLabel(composite
, SWT
.NULL
);
89 labelHeight
.setText("Image Maximum Height: ");
91 final Text textHeight
= new Text(composite
, SWT
.BORDER
);
92 textHeight
.setText(openUrlImageMaxHeight
);
93 textHeight
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
95 textHeight
.addModifyListener(new ModifyListener() {
97 public void modifyText(ModifyEvent e
) {
98 openUrlImageMaxHeight
= textHeight
.getText();
103 private void creatOpenUrlServiceAccessPoint(Composite composite
) {
104 openUrlServiceAccessPoint
= getPreferenceStore().getString(IPreferenceKeys
.OPENURL_ACCESS_POINT
);
106 final CLabel label
= new CLabel(composite
, SWT
.NULL
);
107 label
.setText("Mobot Open Url Service Access Point:");
109 final Text text
= new Text(composite
, SWT
.BORDER
);
110 text
.setText(openUrlServiceAccessPoint
);
111 text
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
113 text
.addModifyListener(new ModifyListener() {
115 public void modifyText(ModifyEvent e
) {
116 openUrlServiceAccessPoint
= text
.getText();
122 * @see org.eclipse.jface.preference.PreferencePage#performOk()
125 public boolean performOk() {
126 getPreferenceStore().setValue(IPreferenceKeys
.OPENURL_ACCESS_POINT
, openUrlServiceAccessPoint
);
127 getPreferenceStore().setValue(IPreferenceKeys
.OPENURL_IMAGE_MAX_WIDTH
, openUrlImageMaxWidth
);
128 getPreferenceStore().setValue(IPreferenceKeys
.OPENURL_IMAGE_MAX_HEIGHT
, openUrlImageMaxHeight
);
130 return super.performOk();