~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/preferences/TaskTagsPreferencePage.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 *    Red Hat - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.rpm.ui.editor.preferences;
 
12
 
 
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;
 
21
 
 
22
public class TaskTagsPreferencePage extends FieldEditorPreferencePage implements
 
23
                IWorkbenchPreferencePage {
 
24
 
 
25
        public TaskTagsPreferencePage() {
 
26
                super(GRID);
 
27
                setPreferenceStore(Activator.getDefault().getPreferenceStore());
 
28
        }
 
29
 
 
30
        public void init(IWorkbench workbench) {
 
31
        }
 
32
 
 
33
        @Override
 
34
        protected void createFieldEditors() {
 
35
                addField(new TasksListEditor(PreferenceConstants.P_TASK_TAGS,
 
36
                                Messages.TaskTagsPreferencePage_0,
 
37
                                getFieldEditorParent()));
 
38
        }
 
39
 
 
40
        class TasksListEditor extends ListEditor {
 
41
 
 
42
                public TasksListEditor(String name, String labelText, Composite parent) {
 
43
                        super(name, labelText, parent);
 
44
                }
 
45
 
 
46
                @Override
 
47
                protected String createList(String[] items) {
 
48
                        StringBuilder itemsString = new StringBuilder();
 
49
                        for (String item : items) {
 
50
                                itemsString.append(item + ';');
 
51
                        }
 
52
                        return itemsString.toString();
 
53
                }
 
54
 
 
55
                @Override
 
56
                protected String getNewInputObject() {
 
57
                        String result = null;
 
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();
 
62
 
 
63
                        if (returnCode == Window.OK) {
 
64
                                result = inputDialog.getValue();
 
65
                        }
 
66
 
 
67
                        return result;
 
68
 
 
69
                }
 
70
 
 
71
                @Override
 
72
                protected String[] parseString(String stringList) {
 
73
                        return stringList.split(";"); //$NON-NLS-1$
 
74
                }
 
75
 
 
76
        }
 
77
 
 
78
}