1
/*******************************************************************************
2
* Copyright (c) 2008, 2009 Red Hat, Inc.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Red Hat - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.linuxtools.internal.rpm.ui.editor.preferences;
13
import org.eclipse.jface.dialogs.InputDialog;
14
import org.eclipse.jface.preference.FieldEditorPreferencePage;
15
import org.eclipse.jface.preference.ListEditor;
16
import org.eclipse.jface.window.Window;
17
import org.eclipse.linuxtools.internal.rpm.ui.editor.Activator;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.ui.IWorkbench;
20
import org.eclipse.ui.IWorkbenchPreferencePage;
22
public class TaskTagsPreferencePage extends FieldEditorPreferencePage implements
23
IWorkbenchPreferencePage {
25
public TaskTagsPreferencePage() {
27
setPreferenceStore(Activator.getDefault().getPreferenceStore());
30
public void init(IWorkbench workbench) {
34
protected void createFieldEditors() {
35
addField(new TasksListEditor(PreferenceConstants.P_TASK_TAGS,
36
Messages.TaskTagsPreferencePage_0,
37
getFieldEditorParent()));
40
class TasksListEditor extends ListEditor {
42
public TasksListEditor(String name, String labelText, Composite parent) {
43
super(name, labelText, parent);
47
protected String createList(String[] items) {
48
StringBuilder itemsString = new StringBuilder();
49
for (String item : items) {
50
itemsString.append(item + ';');
52
return itemsString.toString();
56
protected String getNewInputObject() {
58
// open an input dialog so that the user can enter a new task tag
59
InputDialog inputDialog = new InputDialog(getShell(),
60
Messages.TaskTagsPreferencePage_1, Messages.TaskTagsPreferencePage_2, "", null); //$NON-NLS-1$
61
int returnCode = inputDialog.open();
63
if (returnCode == Window.OK) {
64
result = inputDialog.getValue();
72
protected String[] parseString(String stringList) {
73
return stringList.split(";"); //$NON-NLS-1$