Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 92a2524138b1c9a07d631ac2c14ced43f782c639 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/****************************************************************************
 * Copyright (c) 2004 Composent, Inc. and others.
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * Contributors:
 *    Composent, Inc. - initial API and implementation
 *
 * SPDX-License-Identifier: EPL-2.0
 *****************************************************************************/

package org.eclipse.ecf.internal.example.collab.ui;

import org.eclipse.ecf.internal.example.collab.ClientPlugin;
import org.eclipse.ecf.internal.example.collab.Messages;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FontFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

public class ClientPreferencePage extends FieldEditorPreferencePage implements
		IWorkbenchPreferencePage {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
	 */
	protected void performDefaults() {
		super.performDefaults();

		this.getPreferenceStore().setDefault(ClientPlugin.PREF_USE_CHAT_WINDOW,
				false);
		this.getPreferenceStore().setDefault(
				ClientPlugin.PREF_DISPLAY_TIMESTAMP, true);

		// this.getPreferenceStore().setDefault(ClientPlugin.PREF_CHAT_FONT,
		// "");

		this.getPreferenceStore().setDefault(
				ClientPlugin.PREF_CONFIRM_FILE_SEND, true);
		// this.getPreferenceStore().setDefault(ClientPlugin.PREF_CONFIRM_FILE_RECEIVE,
		// true);
		this.getPreferenceStore().setDefault(
				ClientPlugin.PREF_CONFIRM_REMOTE_VIEW, true);

		this.getPreferenceStore().setDefault(ClientPlugin.PREF_START_SERVER,
				false);
		this.getPreferenceStore().setDefault(ClientPlugin.PREF_REGISTER_SERVER,
				false);
		this.getPreferenceStore().setDefault(
				ClientPlugin.PREF_SHAREDEDITOR_PLAY_EVENTS_IMMEDIATELY, true);
		this.getPreferenceStore().setDefault(
				ClientPlugin.PREF_SHAREDEDITOR_ASK_RECEIVER, true);
	}

	public ClientPreferencePage() {
		super(GRID);
		setPreferenceStore(ClientPlugin.getDefault().getPreferenceStore());
	}

	BooleanFieldEditor playImmediate = null;
	BooleanFieldEditor ask = null;
	Composite askParent = null;

	public void createFieldEditors() {
		addField(new BooleanFieldEditor(ClientPlugin.PREF_USE_CHAT_WINDOW,
				Messages.ClientPreferencePage_USE_CHAT_WINDOW_FIELD_TEXT,
				getFieldEditorParent()));
		addField(new BooleanFieldEditor(ClientPlugin.PREF_DISPLAY_TIMESTAMP,
				Messages.ClientPreferencePage_SHOW_TIME_FOR_CHAT_FIELD, getFieldEditorParent()));
		addField(new FontFieldEditor(ClientPlugin.PREF_CHAT_FONT,
				Messages.ClientPreferencePage_CHAT_WINDOW_FONT_FIELD, getFieldEditorParent()));
		// addField(new
		// BooleanFieldEditor(ClientPlugin.PREF_CONFIRM_FILE_RECEIVE, "Confirm
		// before receiving file.", getFieldEditorParent()));
		// addField(new SpacerFieldEditor(
		// getFieldEditorParent()));
		addField(new ColorFieldEditor(ClientPlugin.PREF_ME_TEXT_COLOR,
				Messages.ClientPreferencePage_CHAT_COLOR_FOR_ME_FIELD, getFieldEditorParent()));
		addField(new ColorFieldEditor(ClientPlugin.PREF_OTHER_TEXT_COLOR,
				Messages.ClientPreferencePage_CHAT_TEXT_COLOR_FOR_OTHER_FIELD, getFieldEditorParent()));
		addField(new ColorFieldEditor(ClientPlugin.PREF_SYSTEM_TEXT_COLOR,
				Messages.ClientPreferencePage_CHAT_COLOR_FOR_SYSTEM_FIELD, getFieldEditorParent()));
		addField(new SpacerFieldEditor(getFieldEditorParent()));

		playImmediate = new BooleanFieldEditor(
				ClientPlugin.PREF_SHAREDEDITOR_PLAY_EVENTS_IMMEDIATELY,
				Messages.ClientPreferencePage_PLAY_EDITOR_EVENTS_IMMEDIATELY, getFieldEditorParent());
		addField(playImmediate);
		askParent = getFieldEditorParent();
		ask = new BooleanFieldEditor(
				ClientPlugin.PREF_SHAREDEDITOR_ASK_RECEIVER,
				Messages.ClientPreferencePage_ASK_RECEIVER_FOR_PERMISSION,
				askParent);
		addField(ask);

		boolean val = getPreferenceStore().getBoolean(
				ClientPlugin.PREF_SHAREDEDITOR_PLAY_EVENTS_IMMEDIATELY);
		ask.setEnabled(val, askParent);

	}

	public void propertyChange(PropertyChangeEvent event) {
		Object field = event.getSource();
		if (field.equals(playImmediate)) {
			Boolean oldValue = (Boolean) event.getNewValue();
			ask.setEnabled(oldValue.booleanValue(), askParent);
		} else {
			super.propertyChange(event);
		}
	}

	public void init(IWorkbench workbench) {
	}
}

Back to the top