r.add(element);
return r;
}
private static CompositeEditor createJDBCPage(final Binding bndr) {
CompositeEditor r = new CompositeEditor(bndr);
OneLineTextElement<String> element = new OneLineTextElement<String>(
bndr.getBinding("jdbcConnection"));
/*
* element.setSelector(new IFactory() {
*
* public Object getValue(Object context) { // TODO Auto-generated
* method stub return null; }
*
* public String getName() { return "Browse..."; }
*
* public String getDescription() { return ""; } });
*/
OneLineTextElement<String> element1 = new OneLineTextElement<String>(
bndr.getBinding("jdbcDriverClassName"));
OneLineTextElement<String> elementL = new OneLineTextElement<String>(
bndr.getBinding("databaseLogin"));
OneLineTextElement<String> elementP = new OneLineTextElement<String>(
bndr.getBinding("databasePasswd"));
elementP.setIsPassword(true);
r.add(element);
r.add(element1);
r.add(elementL);
r.add(elementP);
Container element2 = new Container(Container.GROUP);
element2.getLayoutHints().setGrabHorizontal(true);
element2.setLayoutManager(new HorizontalLayouter());
element2.setText("Class Path");
final ListEnumeratedValueSelector<String> classpath = new ListEnumeratedValueSelector<String>(
bndr.getBinding("jdbcDriverClassPath")) {
protected void updateSize(TableViewer newCheckList) {
// TODO Auto-generated method stub
TableColumn tableColumn = (TableColumn) columnWidget;
tableColumn.pack();
// int width = tableColumn.getWidth();
// int width2 = newCheckList.getTable().getBounds().width;
// if (width < width2) {
// ((TableColumn) columnWidget).setWidth(width2 - 5);
// }
}
};
ButtonSelector addButton = new ButtonSelector();
addButton.setText("add jar");
GridData addDat = new GridData(GridData.FILL_HORIZONTAL);
addButton.setLayoutData(addDat);
addButton.addListener(SWT.Selection, new SWTEventListener<Button>() {
public void handleEvent(AbstractUIElement<Button> element,
Event event) {
FileDialog dialog = new FileDialog(Display.getCurrent()
.getActiveShell(), SWT.MULTI | SWT.SELECTED);
dialog.setFilterExtensions(new String[] { "*.jar" });
dialog.setFilterNames(new String[] { "*.jar" });
dialog.setOverwrite(false);
dialog.open();
String[] names = dialog.getFileNames();
String path = dialog.getFilterPath();
for (String name : names) {
String result = path + File.separator + name;
classpath.addValue(result);
((TableViewer) classpath.getViewer()).getTable()
.getParent().layout();
}
}
});
ButtonSelector removeButton = new ButtonSelector();
removeButton.setText("remove jar");
GridData removeDat = new GridData(GridData.FILL_HORIZONTAL);
removeButton.setLayoutData(removeDat);
removeButton.addListener(SWT.Selection, new SWTEventListener<Button>() {
public void handleEvent(AbstractUIElement<Button> element,
Event event) {
for (Iterator i = classpath.getSelection().iterator(); i
.hasNext();) {
String str = (String) i.next();
classpath.removeValue(str);
}
}
});
Container buttonContainer = new Container();
buttonContainer.setLayout(new GridLayout(1, true));
buttonContainer.getLayoutHints().setGrabHorizontal(false);
buttonContainer.setBordered(false);
buttonContainer.add(addButton);
buttonContainer.add(removeButton);
element2.add(classpath);
element2.add(buttonContainer);
r.add(element2);
// r.add(classpath);
return r;
}