]>
git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.akb.ui/src/main/java/org/argeo/slc/akb/ui/dialogs/AddItemDialog.java
1 package org
.argeo
.slc
.akb
.ui
.dialogs
;
4 import javax
.jcr
.Property
;
5 import javax
.jcr
.RepositoryException
;
7 import org
.argeo
.slc
.akb
.AkbException
;
8 import org
.argeo
.slc
.akb
.AkbTypes
;
9 import org
.eclipse
.jface
.dialogs
.TrayDialog
;
10 import org
.eclipse
.swt
.SWT
;
11 import org
.eclipse
.swt
.graphics
.Point
;
12 import org
.eclipse
.swt
.layout
.GridData
;
13 import org
.eclipse
.swt
.layout
.GridLayout
;
14 import org
.eclipse
.swt
.widgets
.Combo
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.swt
.widgets
.Control
;
17 import org
.eclipse
.swt
.widgets
.Label
;
18 import org
.eclipse
.swt
.widgets
.Shell
;
19 import org
.eclipse
.swt
.widgets
.Text
;
22 * Dialog to create a new Item Template
24 public class AddItemDialog
extends TrayDialog
{
26 // this page widgets and UI objects
27 private final String title
;
29 private String
[] itemTypesLbl
= new String
[] { "SSH File", "SSH Command",
31 private String
[] itemTypes
= new String
[] { AkbTypes
.AKB_SSH_FILE
,
32 AkbTypes
.AKB_SSH_COMMAND
, AkbTypes
.AKB_JDBC_QUERY
};
35 private Node parentNode
;
39 private Combo typeCmb
;
40 private Text titleTxt
;
42 public AddItemDialog(Shell parentShell
, String title
, Node parentNode
) {
45 this.parentNode
= parentNode
;
48 protected Point
getInitialSize() {
49 return new Point(400, 300);
52 protected Control
createDialogArea(Composite parent
) {
53 Composite dialogArea
= (Composite
) super.createDialogArea(parent
);
54 dialogArea
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
56 dialogArea
.setLayout(new GridLayout(2, false));
58 Label lbl
= new Label(dialogArea
, SWT
.NONE
);
59 lbl
.setText("Item type");
60 typeCmb
= new Combo(dialogArea
, SWT
.READ_ONLY
);
61 typeCmb
.setItems(itemTypesLbl
);
63 titleTxt
= createLT(dialogArea
, "Item Name");
70 protected void okPressed() {
72 newNode
= parentNode
.addNode(titleTxt
.getText(),
73 itemTypes
[typeCmb
.getSelectionIndex()]);
74 newNode
.setProperty(Property
.JCR_TITLE
, titleTxt
.getText());
75 } catch (RepositoryException e
) {
76 throw new AkbException("unable to create Item", e
);
81 public Node
getNewNode() {
85 /** Creates label and text. */
86 protected Text
createLT(Composite parent
, String label
) {
87 new Label(parent
, SWT
.NONE
).setText(label
);
88 Text text
= new Text(parent
, SWT
.SINGLE
| SWT
.LEAD
| SWT
.BORDER
);
89 text
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
93 protected void configureShell(Shell shell
) {
94 super.configureShell(shell
);