in ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/TextRulerViewComposite.java [202:576]
private void initGUI() {
try {
this.setLayout(new FormLayout());
this.setSize(600, 380);
configurators = new ArrayList<LearnerConfigurator>();
label1 = new Label(this, SWT.NONE);
FormData label1LData = new FormData();
label1LData.left = new FormAttachment(0, 1000, 12);
label1LData.top = new FormAttachment(0, 1000, 20);
label1LData.width = 109;
label1.setLayoutData(label1LData);
label1.setText("Training Data:");
inputDirectoryText = new Text(this, SWT.SINGLE | SWT.BORDER);
FormData inputDirectoryTexLData = new FormData();
inputDirectoryTexLData.width = 300;
inputDirectoryTexLData.left = new FormAttachment(0, 1000, 126);
inputDirectoryTexLData.top = new FormAttachment(0, 1000, 20);
inputDirectoryTexLData.right = new FormAttachment(1000, 1000, -110);
inputDirectoryText.setLayoutData(inputDirectoryTexLData);
inputDirectoryText.setText("");
inputDirectoryText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
// without that listener, the text fields forget the
// last change when leaving with tab! don't know why!
// we also MUST call getText() otherwise the changes in
// the field are lost (what is this???!!)
Text t = (Text) e.widget;
t.getText();
}
});
dirButton = new Button(this, SWT.PUSH | SWT.CENTER);
FormData dirButtoLData = new FormData();
dirButtoLData.width = 25;
dirButtoLData.height = 25;
dirButtoLData.top = new FormAttachment(0, 1000, 18);
dirButtoLData.right = new FormAttachment(1000, 1000, -80);
dirButton.setLayoutData(dirButtoLData);
Image folderIcon = getImage("folder");
dirButton.setImage(folderIcon);
dirButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
dlg.setFilterPath(inputDirectoryText.getText());
dlg.setText("Input Directory");
dlg.setMessage("Select a directory with input XMI files for the learning algorithms.");
String dir = dlg.open();
if (dir != null) {
inputDirectoryText.setText(dir);
}
}
});
label4 = new Label(this, SWT.NONE);
FormData label4LData = new FormData();
label4LData.left = new FormAttachment(0, 1000, 12);
label4LData.top = new FormAttachment(0, 1000, 44);
label4LData.width = 109;
label4.setLayoutData(label4LData);
label4.setText("Additional Data:");
additionalDirectoryText = new Text(this, SWT.SINGLE | SWT.BORDER);
FormData additionalDirectoryTexLData = new FormData();
additionalDirectoryTexLData.width = 300;
additionalDirectoryTexLData.left = new FormAttachment(0, 1000, 126);
additionalDirectoryTexLData.top = new FormAttachment(0, 1000, 44);
additionalDirectoryTexLData.right = new FormAttachment(1000, 1000, -110);
additionalDirectoryText.setLayoutData(additionalDirectoryTexLData);
additionalDirectoryText.setText("");
additionalDirectoryText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
// without that listener, the text fields forget the
// last change when leaving with tab! don't know why!
// we also MUST call getText() otherwise the changes in
// the field are lost (what is this???!!)
Text t = (Text) e.widget;
t.getText();
}
});
additionalButton = new Button(this, SWT.PUSH | SWT.CENTER);
FormData additionalButtoLData = new FormData();
additionalButtoLData.width = 25;
additionalButtoLData.height = 25;
additionalButtoLData.top = new FormAttachment(0, 1000, 42);
additionalButtoLData.right = new FormAttachment(1000, 1000, -80);
additionalButton.setLayoutData(additionalButtoLData);
folderIcon = getImage("folder");
additionalButton.setImage(folderIcon);
additionalButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
dlg.setFilterPath(inputDirectoryText.getText());
dlg.setText("Additional Directory");
dlg.setMessage("Select a directory with input additional XMI files for the learning algorithms.");
String dir = dlg.open();
if (dir != null) {
additionalDirectoryText.setText(dir);
}
}
});
label5 = new Label(this, SWT.NONE);
FormData label5LData = new FormData();
label5LData.left = new FormAttachment(0, 1000, 12);
label5LData.top = new FormAttachment(0, 1000, 44 + 24);
label5LData.width = 109;
label5.setLayoutData(label5LData);
label5.setText("Test Data:");
testDirectoryText = new Text(this, SWT.SINGLE | SWT.BORDER);
FormData testDirectoryTexLData = new FormData();
testDirectoryTexLData.width = 300;
testDirectoryTexLData.left = new FormAttachment(0, 1000, 126);
testDirectoryTexLData.top = new FormAttachment(0, 1000, 44 + 24);
testDirectoryTexLData.right = new FormAttachment(1000, 1000, -110);
testDirectoryText.setLayoutData(testDirectoryTexLData);
testDirectoryText.setText("");
testDirectoryText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
// without that listener, the text fields forget the
// last change when leaving with tab! don't know why!
// we also MUST call getText() otherwise the changes in
// the field are lost (what is this???!!)
Text t = (Text) e.widget;
t.getText();
}
});
testDirectoryText.setEnabled(false);
testButton = new Button(this, SWT.PUSH | SWT.CENTER);
FormData testButtoLData = new FormData();
testButtoLData.width = 25;
testButtoLData.height = 25;
testButtoLData.top = new FormAttachment(0, 1000, 42 + 24);
testButtoLData.right = new FormAttachment(1000, 1000, -80);
testButton.setLayoutData(testButtoLData);
folderIcon = getImage("folder");
testButton.setImage(folderIcon);
testButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
dlg.setFilterPath(inputDirectoryText.getText());
dlg.setText("Test Directory");
dlg.setMessage("Select a directory with input test XMI files.");
String dir = dlg.open();
if (dir != null) {
testDirectoryText.setText(dir);
}
}
});
testButton.setEnabled(false);
showTestsButton = new Button(this, SWT.CHECK | SWT.LEFT);
FormData showTestsButtoLData = new FormData();
showTestsButtoLData.width = 50;
showTestsButtoLData.height = 18;
showTestsButtoLData.top = new FormAttachment(0, 1000, 42 + 24);
showTestsButtoLData.right = new FormAttachment(1000, 1000, -25);
showTestsButton.setLayoutData(showTestsButtoLData);
showTestsButton.setText("eval");
showTestsButton.setEnabled(false);
label3 = new Label(this, SWT.NONE);
FormData label3LData = new FormData();
label3LData.width = 103;
label3LData.left = new FormAttachment(0, 1000, 12);
label3LData.top = new FormAttachment(0, 1000, 68 + 24);
label3.setLayoutData(label3LData);
label3.setText("Preprocess Script:");
preFileText = new Text(this, SWT.SINGLE | SWT.BORDER);
FormData preFileTexLData = new FormData();
preFileTexLData.width = 495;
preFileTexLData.left = new FormAttachment(0, 1000, 126);
preFileTexLData.top = new FormAttachment(0, 1000, 68 + 24);
preFileTexLData.right = new FormAttachment(1000, 1000, -110);
preFileText.setLayoutData(preFileTexLData);
preFileText.setText("");
preFileText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
// without that listener, the text fields forget the
// last change when leaving with tab! don't know why!
// we also MUST call getText() otherwise the changes in
// the field are lost (what is this???!!)
Text t = (Text) e.widget;
t.getText();
}
});
fileChooseButton = new Button(this, SWT.PUSH | SWT.CENTER);
FormData fileChooseButtoLData = new FormData();
fileChooseButtoLData.width = 25;
fileChooseButtoLData.height = 25;
fileChooseButtoLData.top = new FormAttachment(0, 1000, 66 + 24);
fileChooseButtoLData.right = new FormAttachment(1000, 1000, -80);
fileChooseButton.setLayoutData(fileChooseButtoLData);
Image icon = getImage("prepFolder");
fileChooseButton.setImage(icon);
fileChooseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
fd.setText("Choose Ruta Source File");
String[] filterExt = { "*" + RutaEngine.SCRIPT_FILE_EXTENSION, "*.*" };
fd.setFilterExtensions(filterExt);
String file = fd.open();
if (file != null) {
preFileText.setText(file);
}
}
});
skipPreButton = new Button(this, SWT.CHECK | SWT.LEFT);
FormData skipPreButtonLData = new FormData();
skipPreButtonLData.width = 50;
skipPreButtonLData.height = 18;
skipPreButtonLData.top = new FormAttachment(0, 1000, 68 + 24);
skipPreButtonLData.right = new FormAttachment(1000, 1000, -25);
skipPreButton.setLayoutData(skipPreButtonLData);
skipPreButton.setText("skip");
label2 = new Label(this, SWT.NONE);
FormData label2LData = new FormData();
label2LData.left = new FormAttachment(0, 1000, 12);
label2LData.top = new FormAttachment(0, 1000, 44 + 24 + 24 + 24);
label2LData.width = 109;
label2.setLayoutData(label2LData);
label2.setText("Information Types:");
slotTypes = new AddRemoveList("SlotTypes", images, this, true);
FormData slotTypesLData = new FormData();
slotTypesLData.width = 300;
slotTypesLData.height = 144;
slotTypesLData.top = new FormAttachment(0, 1000, 85 + 24 + 24);
slotTypesLData.left = new FormAttachment(0, 1000, 12);
slotTypes.setLayoutData(slotTypesLData);
addDropTarget(slotTypes);
filtersLabel = new Label(this, SWT.NONE);
FormData filtersLabeLData = new FormData();
filtersLabeLData.width = 120;
filtersLabeLData.left = new FormAttachment(0, 1000, 320);
filtersLabeLData.top = new FormAttachment(0, 1000, 44 + 24 + 24 + 24);
filtersLabel.setLayoutData(filtersLabeLData);
filtersLabel.setText("Filtered Feature Types:");
filterTypes = new AddRemoveList("FilterTypes", images, this, false);
FormData filterTypesLData = new FormData();
filterTypesLData.width = 300;
filterTypesLData.height = 144;
filterTypesLData.top = new FormAttachment(0, 1000, 85 + 24 + 24);
filterTypesLData.left = new FormAttachment(0, 1000, 320);
filterTypes.setLayoutData(filterTypesLData);
addDropTarget(filterTypes);
FormData globalStatusLabeLData = new FormData();
globalStatusLabeLData.width = 400;
globalStatusLabeLData.left = new FormAttachment(0, 1000, 70);
globalStatusLabeLData.top = new FormAttachment(0, 1000, 228 + 24 + 24);
globalStatusLabeLData.right = new FormAttachment(1000, 1000, -19);
globalStatusLabel = new Label(this, SWT.NONE);
globalStatusLabel.setLayoutData(globalStatusLabeLData);
methodsLabel = new Label(this, SWT.NONE);
FormData algsLabeLData = new FormData();
algsLabeLData.width = 120;
algsLabeLData.left = new FormAttachment(0, 1000, 12);
algsLabeLData.top = new FormAttachment(0, 1000, 228 + 24 + 24);
methodsLabel.setLayoutData(algsLabeLData);
methodsLabel.setText("Methods:");
FormData algListViewerLData = new FormData();
// algListViewerLData.width = 400;
// algListViewerLData.height = 115;
algListViewerLData.left = new FormAttachment(0, 1000, 10);
algListViewerLData.top = new FormAttachment(0, 1000, 248 + 24 + 24);
algListViewerLData.right = new FormAttachment(1000, 1000, -10);
algListViewerLData.bottom = new FormAttachment(1000, 1000, -10);
algListViewer = CheckboxTableViewer.newCheckList(this, SWT.BORDER | SWT.H_SCROLL
| SWT.V_SCROLL);
algListViewer.getControl().setLayoutData(algListViewerLData);
algListViewer.setContentProvider(new ListContentProvider());
algListViewer.setLabelProvider(new DefaultLabelProvider("learner"));
algListViewer.setSorter(new NameSorter());
if (textRulerView != null)
algListViewer.setInput(textRulerView.getViewSite());
this.layout();
} catch (Exception e) {
TextRulerPlugin.error(e);
}
DropTarget dt = new DropTarget(inputDirectoryText, DND.DROP_DEFAULT | DND.DROP_MOVE);
dt.setTransfer(new Transfer[] { FileTransfer.getInstance() });
dt.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
String fileList[] = null;
FileTransfer ft = FileTransfer.getInstance();
if (ft.isSupportedType(event.currentDataType)) {
fileList = (String[]) event.data;
}
if (fileList.length > 0)
inputDirectoryText.setText(fileList[0]);
}
});
DropTarget dt3 = new DropTarget(additionalDirectoryText, DND.DROP_DEFAULT | DND.DROP_MOVE);
dt3.setTransfer(new Transfer[] { FileTransfer.getInstance() });
dt3.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
String fileList[] = null;
FileTransfer ft = FileTransfer.getInstance();
if (ft.isSupportedType(event.currentDataType)) {
fileList = (String[]) event.data;
}
if (fileList.length > 0)
additionalDirectoryText.setText(fileList[0]);
}
});
DropTarget dt4 = new DropTarget(testDirectoryText, DND.DROP_DEFAULT | DND.DROP_MOVE);
dt4.setTransfer(new Transfer[] { FileTransfer.getInstance() });
dt4.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
String fileList[] = null;
FileTransfer ft = FileTransfer.getInstance();
if (ft.isSupportedType(event.currentDataType)) {
fileList = (String[]) event.data;
}
if (fileList.length > 0)
testDirectoryText.setText(fileList[0]);
}
});
DropTarget dt2 = new DropTarget(preFileText, DND.DROP_DEFAULT | DND.DROP_MOVE);
dt2.setTransfer(new Transfer[] { FileTransfer.getInstance() });
dt2.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
String fileList[] = null;
FileTransfer ft = FileTransfer.getInstance();
if (ft.isSupportedType(event.currentDataType)) {
fileList = (String[]) event.data;
}
if (fileList.length > 0)
preFileText.setText(fileList[0]);
}
});
createAlgorithmConfigurators();
// algListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
// public void selectionChanged(SelectionChangedEvent event) {
// StructuredSelection s = (StructuredSelection) event.getSelection();
// String id = null;
// if (!s.isEmpty())
// id = ((TextRulerLearnerController) s.getFirstElement()).getID();
// showConfiguratorForAlgorithm(id);
// }
// });
}