blob: cb3c44f05d8e6ae04e56cef72a7bc394daf0efc6 (
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
|
/*****************************************************************************
* Copyright (c) 2011 Nicolas Deblock & Manuel Giles.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nicolas Deblock nico.deblock@gmail.com - Initial API and implementation
* Manuel Giles giles.manu@live.fr - Initial API and implementation
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Idea of the java generator project & help for the conception
*
*****************************************************************************/
package org.eclipse.papyrus.java.generator.ui.preference;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.jdt.internal.ui.preferences.TypeFilterInputDialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.preference.ListEditor;
import org.eclipse.swt.widgets.Composite;
/**
*
* Used to select packages from the dialog.
*
* @author DEBLOCK Nicolas and GILES Manuel
*/
public class PackageListEditor extends ListEditor {
/**
* Constructor.
*
* @param name
* @param labelText
* @param parent
*/
PackageListEditor(String name, String labelText, Composite parent) {
super(name, labelText, parent);
}
@Override
/**
* Functionality for New button.
* Shows a browser dialog to select a file and returns that file.
*/
protected String getNewInputObject() {
//Dialog p = new JDialog();
List<String> l = new LinkedList<String>();
TypeFilterInputDialog d = new TypeFilterInputDialog(getShell(), l);
d.open();
Object pack = d.getResult();
// Return null if user clicked on "cancel" button, to not add ampty package on the list
if(d.getReturnCode() == InputDialog.CANCEL) {
return null;
}
return pack.toString();
}
@Override
protected String createList(String[] items) {
StringBuffer str = new StringBuffer();
for(String item : items)
str.append(item + ";");
return str.toString();
}
/*
* (non-Javadoc)
* initialize list of items
*
* @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
*/
@Override
protected String[] parseString(String stringList) {
return stringList.split(";");
}
}
|