~ubuntu-branches/ubuntu/utopic/eclipse-eclox/utopic

« back to all changes in this revision

Viewing changes to eclox.ui/src/eclox/ui/editor/editors/TextListEditor.java

  • Committer: Package Import Robot
  • Author(s): Graham Inggs
  • Date: 2013-07-07 20:33:10 UTC
  • Revision ID: package-import@ubuntu.com-20130707203310-a44yw80gqtc2s9ob
Tags: upstream-0.10.0
ImportĀ upstreamĀ versionĀ 0.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (C) 2003-2006, 2013, Guillaume Brocker
 
3
 * 
 
4
 * All rights reserved. This program and the accompanying materials
 
5
 * are made available under the terms of the Eclipse Public License v1.0
 
6
 * which accompanies this distribution, and is available at
 
7
 * http://www.eclipse.org/legal/epl-v10.html
 
8
 *
 
9
 * Contributors:
 
10
 *     Guillaume Brocker - Initial API and implementation
 
11
 *
 
12
 ******************************************************************************/ 
 
13
 
 
14
package eclox.ui.editor.editors;
 
15
 
 
16
import org.eclipse.jface.dialogs.IInputValidator;
 
17
import org.eclipse.jface.dialogs.InputDialog;
 
18
import org.eclipse.swt.widgets.Shell;
 
19
 
 
20
import eclox.core.doxyfiles.Setting;
 
21
 
 
22
/**
 
23
 * Implements a list editor that handle value compounds as simple text
 
24
 * 
 
25
 * @author gbrocker
 
26
 */
 
27
public class TextListEditor extends ListEditor {
 
28
        
 
29
        /**
 
30
         * Implements an input validator for the input dialog used to edit value compunds.
 
31
         */
 
32
        private class MyInputValidator implements IInputValidator {
 
33
 
 
34
                public String isValid(String newText) {
 
35
                        if( newText.length() == 0 ) {
 
36
                                return "Empty value is not allowed.";
 
37
                        }
 
38
                        else {
 
39
                                return null;
 
40
                        }
 
41
                }
 
42
                
 
43
        }
 
44
        
 
45
        protected String editValueCompound(Shell parent, Setting setting, String compound) {
 
46
                // Creates the edition dialog.
 
47
                InputDialog     dialog = new InputDialog(
 
48
                                parent,
 
49
                                "Value Edition",
 
50
                                "Enter the new text for the value.",
 
51
                                Convenience.unescapeValue( compound ),
 
52
                                new MyInputValidator() );
 
53
                
 
54
                // Lauches the value edition
 
55
                if( dialog.open() == InputDialog.OK ) {                 
 
56
                        return Convenience.escapeValue( dialog.getValue() );
 
57
                }
 
58
                else {
 
59
                        return null;
 
60
                }
 
61
        }
 
62
 
 
63
}