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
{
34 private String openUrlServiceAccessPoint
;
35 private String openUrlImageMaxWidth
;
36 private String openUrlImageMaxHeight
;
42 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
45 public void init(IWorkbench workbench
) {
46 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
53 * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse
54 * .swt.widgets.Composite)
57 protected Control
createContents(Composite parent
) {
58 Composite container
= new Composite(parent
, SWT
.NULL
);
59 final GridLayout gridLayout
= new GridLayout();
60 container
.setLayout(gridLayout
);
62 creatOpenUrlServiceAccessPoint(container
);
64 createOpenUrlImageSize(container
);
72 private void createOpenUrlImageSize(Composite container
) {
73 openUrlImageMaxWidth
= getPreferenceStore().getString(
74 IPreferenceKeys
.OPENURL_IMAGE_MAX_WIDTH
);
75 openUrlImageMaxHeight
= getPreferenceStore().getString(
76 IPreferenceKeys
.OPENURL_IMAGE_MAX_HEIGHT
);
78 Composite composite
= new Composite(container
, SWT
.NULL
);
79 final GridLayout gridLayout
= new GridLayout(2, false);
80 composite
.setLayout(gridLayout
);
82 final CLabel labelWidth
= new CLabel(composite
, SWT
.NULL
);
83 labelWidth
.setText("Image Maximum Width: ");
85 final Text textWidth
= new Text(composite
, SWT
.BORDER
);
86 textWidth
.setText(openUrlImageMaxWidth
);
87 textWidth
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
89 textWidth
.addModifyListener(new ModifyListener() {
91 public void modifyText(ModifyEvent e
) {
92 openUrlImageMaxWidth
= textWidth
.getText();
96 final CLabel labelHeight
= new CLabel(composite
, SWT
.NULL
);
97 labelHeight
.setText("Image Maximum Height: ");
99 final Text textHeight
= new Text(composite
, SWT
.BORDER
);
100 textHeight
.setText(openUrlImageMaxHeight
);
101 textHeight
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
103 textHeight
.addModifyListener(new ModifyListener() {
105 public void modifyText(ModifyEvent e
) {
106 openUrlImageMaxHeight
= textHeight
.getText();
111 private void creatOpenUrlServiceAccessPoint(Composite composite
) {
112 openUrlServiceAccessPoint
= getPreferenceStore().getString(
113 IPreferenceKeys
.OPENURL_ACCESS_POINT
);
115 final CLabel label
= new CLabel(composite
, SWT
.NULL
);
116 label
.setText("Mobot Open Url Service Access Point:");
118 final Text text
= new Text(composite
, SWT
.BORDER
);
119 text
.setText(openUrlServiceAccessPoint
);
120 text
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
122 text
.addModifyListener(new ModifyListener() {
124 public void modifyText(ModifyEvent e
) {
125 openUrlServiceAccessPoint
= text
.getText();
133 * @see org.eclipse.jface.preference.PreferencePage#performOk()
136 public boolean performOk() {
137 getPreferenceStore().setValue(IPreferenceKeys
.OPENURL_ACCESS_POINT
,
138 openUrlServiceAccessPoint
);
139 getPreferenceStore().setValue(IPreferenceKeys
.OPENURL_IMAGE_MAX_WIDTH
,
140 openUrlImageMaxWidth
);
141 getPreferenceStore().setValue(IPreferenceKeys
.OPENURL_IMAGE_MAX_HEIGHT
,
142 openUrlImageMaxHeight
);
144 return super.performOk();