use of org.eclipse.jface.viewers.ComboViewer in project translationstudio8 by heartsome.
the class ExportTbxDialog method createDialogArea.
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new GridLayout(1, false));
Group dbListGroup = new Group(container, SWT.NONE);
GridLayout glDbListGroup = new GridLayout(2, false);
glDbListGroup.horizontalSpacing = 0;
glDbListGroup.marginHeight = 0;
glDbListGroup.marginWidth = 0;
dbListGroup.setLayout(glDbListGroup);
dbListGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
dbListGroup.setText(Messages.getString("dialog.ExportTbxDialog.dbListGroup"));
Composite leftComposite = new Composite(dbListGroup, SWT.NONE);
GridLayout glLeftComposite = new GridLayout(1, false);
glLeftComposite.verticalSpacing = 0;
glLeftComposite.marginHeight = 0;
leftComposite.setLayout(glLeftComposite);
leftComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
// 列表和语言设置
Composite dbListComposite = new Composite(leftComposite, SWT.NONE);
GridLayout glTopLeftComposite = new GridLayout(1, false);
glTopLeftComposite.marginHeight = 0;
glTopLeftComposite.marginWidth = 0;
dbListComposite.setLayout(glTopLeftComposite);
dbListComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
dbListViewer = new TableViewer(dbListComposite, SWT.BORDER | SWT.FULL_SELECTION);
Table table = dbListViewer.getTable();
GridData gd_table = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_table.heightHint = 100;
table.setLayoutData(gd_table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
dbListViewer.setContentProvider(new ArrayContentProvider());
dbListViewer.setInput(dbList);
createColumn(dbListViewer);
dbListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
currentDatabase = (ExportDatabaseBean) selection.getFirstElement();
loadData();
}
});
Composite langSetComposite = new Composite(leftComposite, SWT.NONE);
GridLayout gl_langSetComposite = new GridLayout(2, false);
gl_langSetComposite.marginWidth = 0;
langSetComposite.setLayout(gl_langSetComposite);
langSetComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
Label langSelLabel = new Label(langSetComposite, SWT.NONE);
langSelLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
langSelLabel.setText(Messages.getString("dialog.ExportTbxDialog.langSelLabel"));
hasSelLangListViewer = new ListViewer(langSetComposite, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
org.eclipse.swt.widgets.List list = hasSelLangListViewer.getList();
GridData glLangList = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
glLangList.heightHint = 76;
list.setLayoutData(glLangList);
hasSelLangListViewer.setContentProvider(new ArrayContentProvider());
hasSelLangListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@SuppressWarnings("unchecked")
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.isEmpty()) {
return;
}
if (currentDatabase != null) {
currentDatabase.getHasSelectedLangs().clear();
currentDatabase.getHasSelectedLangs().addAll(sel.toList());
List<String> canSelSrcLangs = new ArrayList<String>();
canSelSrcLangs.addAll(sel.toList());
currentDatabase.setCanSelSrcLangs(canSelSrcLangs);
srcLangcomboViewer.setInput(canSelSrcLangs);
if (canSelSrcLangs.contains(currentDatabase.getSrcLang())) {
String srcLang = currentDatabase.getSrcLang();
if (srcLang != null && !srcLang.equals("")) {
for (int i = 0; i < canSelSrcLangs.size(); i++) {
if (canSelSrcLangs.get(i).equals(srcLang)) {
srcLangcomboViewer.getCombo().select(i);
break;
}
}
}
} else {
srcLangcomboViewer.getCombo().select(0);
}
}
}
});
Label srcLangSelLabel = new Label(langSetComposite, SWT.NONE);
srcLangSelLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
srcLangSelLabel.setBounds(0, 0, 79, 19);
srcLangSelLabel.setText(Messages.getString("dialog.ExportTbxDialog.srcLangSelLabel"));
srcLangcomboViewer = new ComboViewer(langSetComposite, SWT.NONE | SWT.READ_ONLY);
Combo combo = srcLangcomboViewer.getCombo();
GridData gd_combo = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
gd_combo.widthHint = 197;
combo.setLayoutData(gd_combo);
srcLangcomboViewer.setContentProvider(new ArrayContentProvider());
srcLangcomboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.isEmpty()) {
return;
}
if (currentDatabase != null) {
currentDatabase.setSrcLang((String) sel.getFirstElement());
}
}
});
// 操作库列的按钮区域
Composite rightComposite = new Composite(dbListGroup, SWT.NONE);
GridLayout gl_rightComposite = new GridLayout(1, false);
gl_rightComposite.marginRight = 5;
gl_rightComposite.marginHeight = 0;
gl_rightComposite.marginWidth = 0;
rightComposite.setLayout(gl_rightComposite);
rightComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
HSDropDownButton addBtn = new HSDropDownButton(rightComposite, SWT.NONE);
addBtn.setText(Messages.getString("dialog.ExportTbxDialog.AddDbBtn"));
Menu addMenu = addBtn.getMenu();
MenuItem item = new MenuItem(addMenu, SWT.PUSH);
item.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddFileTb"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialg = new FileDialog(getShell());
fileDialg.setFilterExtensions(new String[] { "*.hstb", "*.*" });
String result = fileDialg.open();
if (result == null) {
return;
}
File f = new File(result);
if (!f.exists()) {
return;
}
Map<DatabaseModelBean, String> r = null;
try {
r = Utils.convertFile2TbModel(f, true);
} catch (Exception e1) {
MessageDialog.openError(getShell(), Messages.getString("tb.dialog.addFileTb.errorTitle"), e1.getMessage());
}
if (r == null) {
return;
}
Iterator<DatabaseModelBean> it = r.keySet().iterator();
if (it.hasNext()) {
DatabaseModelBean selectedVal = it.next();
ExportDatabaseBean bean = new ExportDatabaseBean(selectedVal.toDbMetaData(), r.get(selectedVal));
if (!dbList.contains(bean)) {
// 实现: 重写equals方法
dbList.add(bean);
bean.setIndex(dbList.size() + "");
}
dbListViewer.getTable().removeAll();
dbListViewer.setInput(dbList);
if (dbList.size() != 0) {
deleteDbBtn.setEnabled(true);
browserBtn.setEnabled(true);
selectCurrentDb(currentDatabase);
} else {
deleteDbBtn.setEnabled(false);
browserBtn.setEnabled(false);
}
}
}
});
MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
serverItem.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddServerTb"));
serverItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TermDbManagerDialog dialog = new TermDbManagerDialog(getShell());
dialog.setDialogUseFor(TermDbManagerDialog.TYPE_DBSELECTED);
if (dialog.open() == Window.OK) {
Map<DatabaseModelBean, String> selDb = dialog.getHasSelectedDatabase();
Iterator<Entry<DatabaseModelBean, String>> entryIt = selDb.entrySet().iterator();
while (entryIt.hasNext()) {
Entry<DatabaseModelBean, String> entry = entryIt.next();
ExportDatabaseBean bean = new ExportDatabaseBean(entry.getKey().toDbMetaData(), entry.getValue());
if (!dbList.contains(bean)) {
// 实现: 重写equals方法
dbList.add(bean);
bean.setIndex(dbList.size() + "");
}
}
dbListViewer.getTable().removeAll();
dbListViewer.setInput(dbList);
}
if (dbList.size() != 0) {
deleteDbBtn.setEnabled(true);
browserBtn.setEnabled(true);
selectCurrentDb(currentDatabase);
} else {
deleteDbBtn.setEnabled(false);
browserBtn.setEnabled(false);
}
}
});
deleteDbBtn = new Button(rightComposite, SWT.NONE);
deleteDbBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
deleteDbBtn.setBounds(0, 0, 104, 31);
deleteDbBtn.setText(Messages.getString("dialog.ExportTbxDialog.deleteDbBtn"));
deleteDbBtn.setEnabled(false);
deleteDbBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) dbListViewer.getSelection();
if (sel.isEmpty()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg1"));
return;
}
dbList.removeAll(sel.toList());
dbListViewer.remove(sel.toArray());
if (dbList.size() != 0) {
deleteDbBtn.setEnabled(true);
browserBtn.setEnabled(true);
selectCurrentDb(currentDatabase);
} else {
currentDatabase = null;
deleteDbBtn.setEnabled(false);
browserBtn.setEnabled(false);
}
}
});
Composite tbxTemplateComp = new Composite(container, SWT.NONE);
GridLayout glTbxTemplateComp = new GridLayout(1, false);
glTbxTemplateComp.marginWidth = 0;
glTbxTemplateComp.marginHeight = 0;
tbxTemplateComp.setLayout(glTbxTemplateComp);
Composite encodingComposite = new Composite(container, SWT.NONE);
GridLayout glEncodingComposite = new GridLayout(2, false);
glEncodingComposite.marginWidth = 0;
glEncodingComposite.marginHeight = 0;
encodingComposite.setLayout(glEncodingComposite);
encodingComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
hasChangedCodingCbtn = new Button(encodingComposite, SWT.CHECK);
hasChangedCodingCbtn.setText(Messages.getString("dialog.ExportTbxDialog.hasChangedCodingCbtn"));
hasChangedCodingCbtn.setSelection(false);
hasChangedCodingCbtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
encodingComboViewer.getCombo().setEnabled(hasChangedCodingCbtn.getSelection());
}
});
encodingComboViewer = new ComboViewer(encodingComposite, SWT.NONE | SWT.READ_ONLY);
Combo encodingCombo = encodingComboViewer.getCombo();
GridData gdEncodingCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gdEncodingCombo.widthHint = 279;
encodingCombo.setLayoutData(gdEncodingCombo);
encodingCombo.setEnabled(hasChangedCodingCbtn.getSelection());
encodingComboViewer.setContentProvider(new ArrayContentProvider());
encodingComboViewer.setInput(pageCodes);
Composite filterComposite = new Composite(container, SWT.NONE);
filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
GridLayout glFilterComposite = new GridLayout(4, false);
glFilterComposite.marginWidth = 0;
glFilterComposite.marginHeight = 0;
filterComposite.setLayout(glFilterComposite);
hasFilterChangedBtn = new Button(filterComposite, SWT.CHECK);
hasFilterChangedBtn.setText(Messages.getString("dialog.ExportTbxDialog.button"));
hasFilterChangedBtn.setSelection(false);
hasFilterChangedBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
filterComboViewer.getCombo().setEnabled(hasFilterChangedBtn.getSelection());
filterSettingBtn.setEnabled(hasFilterChangedBtn.getSelection());
filterDeleteBtn.setEnabled(hasFilterChangedBtn.getSelection());
}
});
filterComboViewer = new ComboViewer(filterComposite, SWT.NONE);
Combo filterCombo = filterComboViewer.getCombo();
filterCombo.setEnabled(false);
filterCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
filterComboViewer.setContentProvider(new ArrayContentProvider());
filterComboViewer.setLabelProvider(new FilterLabelProvider());
filterComboViewer.setInput(filterList);
// 有一个空的过滤器
filterCombo.select(0);
filterSettingBtn = new Button(filterComposite, SWT.NONE);
filterSettingBtn.setText(Messages.getString("dialog.ExportTbxDialog.filterSettingBtn"));
filterSettingBtn.setEnabled(false);
filterSettingBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) filterComboViewer.getSelection();
ExportFilterBean bean = (ExportFilterBean) sel.getFirstElement();
if (bean.equals(filterList.get(0))) {
// 0位置的始终存在 Empty
// 新建
filterSetting(null);
} else {
// 编辑
filterSetting(bean);
}
}
});
filterDeleteBtn = new Button(filterComposite, SWT.NONE);
filterDeleteBtn.setText(Messages.getString("dialog.ExportTbxDialog.filterDeleteBtn"));
filterDeleteBtn.setEnabled(false);
filterDeleteBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) filterComboViewer.getSelection();
ExportFilterBean bean = (ExportFilterBean) sel.getFirstElement();
if (bean.equals(filterList.get(0))) {
// 总是存在一个空的filter,显示为"无"
return;
}
if (MessageDialog.openConfirm(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg2"))) {
filterStore.deleteFilterRuleByName(bean.getFilterName(), "TBX");
int i = filterList.indexOf(bean);
filterList.remove(i);
filterComboViewer.setInput(filterList);
filterComboViewer.getCombo().select(0);
}
}
});
Composite tbxFileSetComposite = new Composite(container, SWT.NONE);
GridLayout glTbxFileSetComposite = new GridLayout(3, false);
glTbxFileSetComposite.marginWidth = 0;
glTbxFileSetComposite.marginHeight = 0;
tbxFileSetComposite.setLayout(glTbxFileSetComposite);
tbxFileSetComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label tbxFileLabel = new Label(tbxFileSetComposite, SWT.NONE);
tbxFileLabel.setText(Messages.getString("dialog.ExportTbxDialog.tbxFileLabel"));
tbxFileText = new Text(tbxFileSetComposite, SWT.BORDER);
tbxFileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
tbxFileText.setEnabled(false);
browserBtn = new Button(tbxFileSetComposite, SWT.NONE);
browserBtn.setText(Messages.getString("dialog.ExportTbxDialog.browserBtn"));
browserBtn.setEnabled(false);
browserBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (dbList.size() > 1) {
DirectoryDialog dlg = new DirectoryDialog(getParentShell());
String filePath = dlg.open();
if (filePath != null) {
tbxFileText.setText(filePath);
}
} else {
FileDialog dlg = new FileDialog(getShell(), SWT.SAVE);
String[] filterExt = { "*.tbx" };
dlg.setFilterExtensions(filterExt);
String filePath = dlg.open();
if (filePath != null) {
tbxFileText.setText(filePath);
}
}
}
});
return container;
}
use of org.eclipse.jface.viewers.ComboViewer in project translationstudio8 by heartsome.
the class NewTermDbBaseInfoPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
setControl(container);
int labelWidth = 100;
GridData gdLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gdLabel.widthHint = labelWidth;
Group dbGroup1 = new Group(container, SWT.NONE);
dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
dbGroup1.setLayout(new GridLayout(2, false));
dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
dbGroup1.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbGroup1"));
Label label = new Label(dbGroup1, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.lblType"));
dbTypeComboViewer = new ComboViewer(dbGroup1, SWT.READ_ONLY);
Combo combo = dbTypeComboViewer.getCombo();
combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
// //
label = new Label(dbGroup1, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbNameText"));
dbNameText = new Text(dbGroup1, SWT.BORDER);
dbNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(dbGroup1, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.instanceText"));
instanceText = new Text(dbGroup1, SWT.BORDER);
instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
dbTypeComboViewer.setContentProvider(new ArrayContentProvider());
dbTypeComboViewer.setInput(dbTypeList);
dbTypeComboViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
SystemDBOperator dbOp = (SystemDBOperator) element;
String dbType = dbOp.getDBConfig().getDefaultType();
if (dbType.equals(Constants.DBTYPE_MYSQL)) {
dbType = Constants.DBTYPE_MYSQL_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_MSSQL2005)) {
dbType = Constants.DBTYPE_MSSQL2005_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_SQLITE)) {
dbType = Messages.getString("tb.dbtype.sqlite");
}
return dbType;
}
});
dbTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection != null && selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
Object selObj = sel.getFirstElement();
if (selObj != null && selObj instanceof SystemDBOperator) {
SystemDBOperator selDbOp = (SystemDBOperator) selObj;
dbTypeChangeEvent(selDbOp);
}
}
}
});
Group dbGroup = new Group(container, SWT.NONE);
dbGroup.setLayout(new GridLayout(5, false));
dbGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
dbGroup.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbGroup"));
label = new Label(dbGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.hostText"));
hostText = new Text(dbGroup, SWT.BORDER);
hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(dbGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.portText"));
portText = new Text(dbGroup, SWT.BORDER);
new Label(dbGroup, SWT.NONE);
label = new Label(dbGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.locationText"));
locationText = new Text(dbGroup, SWT.BORDER);
locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
locationText.setEnabled(false);
borwserBtn = new Button(dbGroup, SWT.NONE);
borwserBtn.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.borwserBtn"));
borwserBtn.setEnabled(false);
borwserBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
String path = dlg.open();
if (path != null) {
locationText.setText(path);
}
}
});
Group authorityGroup = new Group(container, SWT.NONE);
authorityGroup.setLayout(new GridLayout(2, false));
authorityGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
authorityGroup.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.authorityGroup"));
label = new Label(authorityGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.usernameText"));
usernameText = new Text(authorityGroup, SWT.BORDER);
usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(authorityGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.passwordText"));
passwordText = new Text(authorityGroup, SWT.BORDER | SWT.PASSWORD);
passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
initDataBindings();
if (this.dbOp != null) {
dbTypeComboViewer.setSelection(new StructuredSelection(this.dbOp));
} else {
dbTypeComboViewer.setSelection(new StructuredSelection(dbTypeList.get(0)));
}
IStatus state = validator();
if (!state.isOK()) {
setErrorMessage(state.getMessage());
setPageComplete(false);
}
}
use of org.eclipse.jface.viewers.ComboViewer in project translationstudio8 by heartsome.
the class NewTmDbBaseInfoPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
setControl(container);
int labelWidth = 100;
GridData gdLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gdLabel.widthHint = labelWidth;
Group dbGroup1 = new Group(container, SWT.NONE);
dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
dbGroup1.setLayout(new GridLayout(2, false));
dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
dbGroup1.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.dbGroup1"));
Label label = new Label(dbGroup1, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.lblType"));
dbTypeComboViewer = new ComboViewer(dbGroup1, SWT.READ_ONLY);
Combo combo = dbTypeComboViewer.getCombo();
combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
// //
label = new Label(dbGroup1, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.dbNameText"));
dbNameText = new Text(dbGroup1, SWT.BORDER);
dbNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(dbGroup1, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.instanceText"));
instanceText = new Text(dbGroup1, SWT.BORDER);
instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
dbTypeComboViewer.setContentProvider(new ArrayContentProvider());
dbTypeComboViewer.setInput(dbTypeList);
dbTypeComboViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
SystemDBOperator dbOp = (SystemDBOperator) element;
String dbType = dbOp.getDBConfig().getDefaultType();
if (dbType.equals(Constants.DBTYPE_MYSQL)) {
dbType = Constants.DBTYPE_MYSQL_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_MSSQL2005)) {
dbType = Constants.DBTYPE_MSSQL2005_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_SQLITE)) {
dbType = Messages.getString("tm.dbtype.sqlite");
}
return dbType;
}
});
dbTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection != null && selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
Object selObj = sel.getFirstElement();
if (selObj != null && selObj instanceof SystemDBOperator) {
SystemDBOperator selDbOp = (SystemDBOperator) selObj;
dbTypeChangeEvent(selDbOp);
}
}
}
});
Group dbGroup = new Group(container, SWT.NONE);
dbGroup.setLayout(new GridLayout(5, false));
dbGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
dbGroup.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.dbGroup"));
label = new Label(dbGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.hostText"));
hostText = new Text(dbGroup, SWT.BORDER);
hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(dbGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.portText"));
portText = new Text(dbGroup, SWT.BORDER);
new Label(dbGroup, SWT.NONE);
label = new Label(dbGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.locationText"));
locationText = new Text(dbGroup, SWT.BORDER);
locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
locationText.setEnabled(false);
borwserBtn = new Button(dbGroup, SWT.NONE);
borwserBtn.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.borwserBtn"));
borwserBtn.setEnabled(false);
borwserBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
String path = dlg.open();
if (path != null) {
locationText.setText(path);
}
}
});
Group authorityGroup = new Group(container, SWT.NONE);
authorityGroup.setLayout(new GridLayout(2, false));
authorityGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
authorityGroup.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.authorityGroup"));
label = new Label(authorityGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.usernameText"));
usernameText = new Text(authorityGroup, SWT.BORDER);
usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(authorityGroup, SWT.RIGHT);
label.setLayoutData(gdLabel);
label.setText(Messages.getString("wizard.NewTmDbBaseInfoPage.passwordText"));
passwordText = new Text(authorityGroup, SWT.BORDER | SWT.PASSWORD);
passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
initDataBindings();
if (this.dbOp != null) {
dbTypeComboViewer.setSelection(new StructuredSelection(this.dbOp));
} else {
dbTypeComboViewer.setSelection(new StructuredSelection(dbTypeList.get(0)));
}
IStatus state = validator();
if (!state.isOK()) {
setErrorMessage(state.getMessage());
setPageComplete(false);
}
}
use of org.eclipse.jface.viewers.ComboViewer in project azure-tools-for-java by Microsoft.
the class AzureNewDockerConfigPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite mainContainer = new Composite(parent, SWT.NONE);
setControl(mainContainer);
mainContainer.setLayout(new GridLayout(3, false));
Label lblName = new Label(mainContainer, SWT.NONE);
GridData gd_lblName = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblName.horizontalIndent = 5;
lblName.setLayoutData(gd_lblName);
lblName.setText("Name:");
dockerHostNameTextField = new Text(mainContainer, SWT.BORDER);
GridData gd_dockerHostNameTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
gd_dockerHostNameTextField.horizontalIndent = 3;
gd_dockerHostNameTextField.widthHint = 200;
dockerHostNameTextField.setLayoutData(gd_dockerHostNameTextField);
Label lblNewLabel = new Label(mainContainer, SWT.NONE);
GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblNewLabel.horizontalIndent = 5;
lblNewLabel.setLayoutData(gd_lblNewLabel);
lblNewLabel.setText("Subscription:");
dockerSubscriptionComboViewer = new ComboViewer(mainContainer, SWT.READ_ONLY);
dockerSubscriptionCombo = dockerSubscriptionComboViewer.getCombo();
dockerSubscriptionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(mainContainer, SWT.NONE);
Label lblId = new Label(mainContainer, SWT.NONE);
GridData gd_lblId = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblId.horizontalIndent = 5;
lblId.setLayoutData(gd_lblId);
lblId.setText("Id:");
dockerSubscriptionIdTextField = new Text(mainContainer, SWT.NONE);
GridData gd_dockerSubscriptionIdTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerSubscriptionIdTextField.horizontalIndent = 3;
gd_dockerSubscriptionIdTextField.widthHint = 300;
dockerSubscriptionIdTextField.setLayoutData(gd_dockerSubscriptionIdTextField);
dockerSubscriptionIdTextField.setEditable(false);
dockerSubscriptionIdTextField.setBackground(mainContainer.getBackground());
new Label(mainContainer, SWT.NONE);
Label lblRegion = new Label(mainContainer, SWT.NONE);
GridData gd_lblRegion = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblRegion.horizontalIndent = 5;
lblRegion.setLayoutData(gd_lblRegion);
lblRegion.setText("Region:");
dockerLocationComboBox = new Combo(mainContainer, SWT.READ_ONLY);
GridData gd_dockerLocationComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerLocationComboBox.widthHint = 200;
dockerLocationComboBox.setLayoutData(gd_dockerLocationComboBox);
new Label(mainContainer, SWT.NONE);
hostDetailsTabFolder = new TabFolder(mainContainer, SWT.NONE);
GridData gd_hostDetailsTabFolder = new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1);
gd_hostDetailsTabFolder.heightHint = 128;
hostDetailsTabFolder.setLayoutData(gd_hostDetailsTabFolder);
vmKindTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
vmKindTableItem.setText("OS and Size");
vmKindComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
vmKindTableItem.setControl(vmKindComposite);
vmKindComposite.setLayout(new GridLayout(3, false));
Label lblNewLabel_1 = new Label(vmKindComposite, SWT.NONE);
lblNewLabel_1.setText("Host OS:");
dockerHostOSTypeComboBox = new Combo(vmKindComposite, SWT.READ_ONLY);
GridData gd_dockerHostOSTypeComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerHostOSTypeComboBox.widthHint = 200;
dockerHostOSTypeComboBox.setLayoutData(gd_dockerHostOSTypeComboBox);
new Label(vmKindComposite, SWT.NONE);
Label lblSize = new Label(vmKindComposite, SWT.NONE);
lblSize.setText("Size:");
dockerHostVMSizeComboBox = new Combo(vmKindComposite, SWT.READ_ONLY);
GridData gd_dockerHostVMSizeComboBox = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
gd_dockerHostVMSizeComboBox.widthHint = 200;
dockerHostVMSizeComboBox.setLayoutData(gd_dockerHostVMSizeComboBox);
Link dockerPricingHyperlink = new Link(vmKindComposite, SWT.NONE);
dockerPricingHyperlink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL("https://azure.microsoft.com/en-us/pricing/details/virtual-machines/linux/"));
} catch (Exception ex) {
DefaultLoader.getUIHelper().logError(ex.getMessage(), ex);
}
}
});
dockerPricingHyperlink.setText("<a>Pricing</a>");
GridData gd_dockerPricingHyperlink = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 2);
dockerPricingHyperlink.setLayoutData(gd_dockerPricingHyperlink);
dockerHostVMPreferredSizesCheckBox = new Button(vmKindComposite, SWT.CHECK);
dockerHostVMPreferredSizesCheckBox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
dockerHostVMPreferredSizesCheckBox.setText("Show preferred sizes only");
rgTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
rgTableItem.setText("Resource Group");
Composite rgComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
rgTableItem.setControl(rgComposite);
rgComposite.setLayout(new GridLayout(2, false));
dockerHostNewRGRadioButton = new Button(rgComposite, SWT.RADIO);
dockerHostNewRGRadioButton.setText("New resource group:");
dockerHostRGTextField = new Text(rgComposite, SWT.BORDER);
GridData gd_dockerHostRGTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerHostRGTextField.horizontalIndent = 3;
gd_dockerHostRGTextField.widthHint = 200;
dockerHostRGTextField.setLayoutData(gd_dockerHostRGTextField);
dockerHostSelectRGRadioButton = new Button(rgComposite, SWT.RADIO);
dockerHostSelectRGRadioButton.setText("Existing resource group:");
dockerHostSelectRGComboBox = new Combo(rgComposite, SWT.READ_ONLY);
GridData gd_dockerHostSelectRGComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerHostSelectRGComboBox.widthHint = 220;
dockerHostSelectRGComboBox.setLayoutData(gd_dockerHostSelectRGComboBox);
networkTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
networkTableItem.setText("Network");
Composite networkComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
networkTableItem.setControl(networkComposite);
networkComposite.setLayout(new GridLayout(2, false));
dockerHostNewVNetRadioButton = new Button(networkComposite, SWT.RADIO);
dockerHostNewVNetRadioButton.setText("New virtual network");
dockerHostNewVNetNameTextField = new Text(networkComposite, SWT.BORDER);
GridData gd_dockerHostNewVNetNameTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerHostNewVNetNameTextField.horizontalIndent = 3;
gd_dockerHostNewVNetNameTextField.widthHint = 200;
dockerHostNewVNetNameTextField.setLayoutData(gd_dockerHostNewVNetNameTextField);
Label lblAddressSpacecdir = new Label(networkComposite, SWT.NONE);
GridData gd_lblAddressSpacecdir = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblAddressSpacecdir.horizontalIndent = 18;
lblAddressSpacecdir.setLayoutData(gd_lblAddressSpacecdir);
lblAddressSpacecdir.setText("Address space (CDIR):");
dockerHostNewVNetAddrSpaceTextField = new Text(networkComposite, SWT.BORDER);
GridData gd_dockerHostNewVNetAddrSpaceTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerHostNewVNetAddrSpaceTextField.horizontalIndent = 3;
gd_dockerHostNewVNetAddrSpaceTextField.widthHint = 200;
dockerHostNewVNetAddrSpaceTextField.setLayoutData(gd_dockerHostNewVNetAddrSpaceTextField);
dockerHostSelectVNetRadioButton = new Button(networkComposite, SWT.RADIO);
dockerHostSelectVNetRadioButton.setText("Existing virtual network:");
dockerHostSelectVnetComboBox = new Combo(networkComposite, SWT.READ_ONLY);
GridData gd_dockerHostSelectVnetComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerHostSelectVnetComboBox.widthHint = 220;
dockerHostSelectVnetComboBox.setLayoutData(gd_dockerHostSelectVnetComboBox);
Label lblSubnet = new Label(networkComposite, SWT.NONE);
GridData gd_lblSubnet = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblSubnet.horizontalIndent = 18;
lblSubnet.setLayoutData(gd_lblSubnet);
lblSubnet.setText("Subnet:");
dockerHostSelectSubnetComboBox = new Combo(networkComposite, SWT.READ_ONLY);
GridData gd_dockerHostSelectSubnetComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerHostSelectSubnetComboBox.widthHint = 220;
dockerHostSelectSubnetComboBox.setLayoutData(gd_dockerHostSelectSubnetComboBox);
storageTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
storageTableItem.setText("Storage");
Composite storageComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
storageTableItem.setControl(storageComposite);
storageComposite.setLayout(new GridLayout(2, false));
dockerHostNewStorageRadioButton = new Button(storageComposite, SWT.RADIO);
dockerHostNewStorageRadioButton.setText("New storage account:");
dockerNewStorageTextField = new Text(storageComposite, SWT.BORDER);
GridData gd_dockerNewStorageTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerNewStorageTextField.horizontalIndent = 3;
gd_dockerNewStorageTextField.widthHint = 200;
dockerNewStorageTextField.setLayoutData(gd_dockerNewStorageTextField);
dockerHostSelectStorageRadioButton = new Button(storageComposite, SWT.RADIO);
dockerHostSelectStorageRadioButton.setText("Existing storage account:");
dockerSelectStorageComboBox = new Combo(storageComposite, SWT.READ_ONLY);
GridData gd_dockerSelectStorageComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_dockerSelectStorageComboBox.widthHint = 220;
dockerSelectStorageComboBox.setLayoutData(gd_dockerSelectStorageComboBox);
FormToolkit toolkit = new FormToolkit(mainContainer.getDisplay());
toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER);
managedForm = new ManagedForm(mainContainer);
errMsgForm = managedForm.getForm();
errMsgForm.setVisible(false);
// errMsgForm.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
// errMsgForm.setBackground(mainContainer.getBackground());
errDispatcher = managedForm.getMessageManager();
initUIMainContainer(mainContainer);
}
use of org.eclipse.jface.viewers.ComboViewer in project tdi-studio-se by Talend.
the class AlfrescoModelDialog method createDialogArea.
/*
* (non-Javadoc) Method declared on Dialog.
*/
protected Control createDialogArea(Composite parent) {
// create composite
alfrescoModelComposite = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout(3, false);
layout.marginWidth = 12;
alfrescoModelComposite.setLayout(layout);
Label typeLabel = new Label(alfrescoModelComposite, SWT.NULL);
GridData typeLabelGridData = new GridData(GridData.FILL_BOTH);
typeLabelGridData.horizontalSpan = 3;
typeLabel.setLayoutData(typeLabelGridData);
//$NON-NLS-1$
typeLabel.setText(Messages.getString("AlfrescoModelDialog.type"));
typeCombo = new Combo(alfrescoModelComposite, SWT.NULL);
GridData typeComboGridData = new GridData(GridData.FILL_BOTH);
typeComboGridData.horizontalSpan = 3;
typeCombo.setLayoutData(typeComboGridData);
typeComboViewer = new ComboViewer(typeCombo);
typeComboViewer.setContentProvider(new AlfrescoModelContentProvider() {
public void alfrescoModelElementAdded(Element alfrescoModelElement) {
typeComboViewer.add(alfrescoModelElement);
}
public void alfrescoModelElementRemoved(Element alfrescoModelElement) {
typeComboViewer.remove(alfrescoModelElement);
}
});
typeComboViewer.setLabelProvider(new AlfrescoModelLabelProvider());
typeComboViewer.setInput(modelManager.getAvailableTypes());
typeCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
ISelection selection = typeComboViewer.getSelection();
if (selection instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) selection).getFirstElement();
if (selected instanceof Element) {
Element newType = (Element) selected;
if (modelManager.getType() == null || !newType.attributeValue("name").equals(modelManager.getType().attributeValue("name"))) {
//$NON-NLS-1$ //$NON-NLS-2$
modelManager.setType(newType);
AlfrescoModelDialog.this.updateMetadata();
}
} else if (modelManager.getType() != null) {
modelManager.setType(null);
AlfrescoModelDialog.this.updateMetadata();
}
}
}
});
Label aspectsLabel = new Label(alfrescoModelComposite, SWT.NULL);
//$NON-NLS-1$
aspectsLabel.setText(Messages.getString("AlfrescoModelDialog.aspects"));
// filler
new Composite(alfrescoModelComposite, SWT.NULL);
Label availableAspectsLabel = new Label(alfrescoModelComposite, SWT.NULL);
//$NON-NLS-1$
availableAspectsLabel.setText(Messages.getString("AlfrescoModelDialog.availableAspects"));
// create table
aspectsTable = createAlfrescoModelElementTable(alfrescoModelComposite, modelManager.getAspects());
GridData aspectsTableGridData = new GridData(GridData.FILL_BOTH);
// aspectsTableGridData.grabExcessVerticalSpace = true;
// aspectsTableGridData.grabExcessHorizontalSpace = true;
aspectsTableGridData.heightHint = 300;
aspectsTable.setLayoutData(aspectsTableGridData);
Composite aspectButtonsComposite = new Composite(alfrescoModelComposite, SWT.NULL);
GridLayout aspectButtonsLayout = new GridLayout();
aspectButtonsLayout.marginWidth = 12;
aspectButtonsComposite.setLayout(aspectButtonsLayout);
Button addAspectButton = new Button(aspectButtonsComposite, SWT.NULL);
//$NON-NLS-1$
addAspectButton.setText("+");
addAspectButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
TableItem[] selectedItems = availableAspectsTable.getSelection();
for (int i = 0; i < selectedItems.length; i++) {
Object selectedData = selectedItems[i].getData();
if (selectedData instanceof Element) {
Element alfrescoModelElement = (Element) selectedData;
modelManager.addAspect(alfrescoModelElement);
}
}
AlfrescoModelDialog.this.updateMetadata();
}
});
Button removeAspectButton = new Button(aspectButtonsComposite, SWT.NULL);
//$NON-NLS-1$
removeAspectButton.setText("-");
removeAspectButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
TableItem[] selectedItems = aspectsTable.getSelection();
for (int i = 0; i < selectedItems.length; i++) {
Object selectedData = selectedItems[i].getData();
if (selectedData instanceof Element) {
Element alfrescoModelElement = (Element) selectedData;
modelManager.removeAspect(alfrescoModelElement);
}
}
AlfrescoModelDialog.this.updateMetadata();
}
});
// create table
availableAspectsTable = createAlfrescoModelElementTable(alfrescoModelComposite, modelManager.getAvailableAspects());
// RowData availableAspectsTableRowData = new RowData();
// availableAspectsTableRowData.height = 200;
// availableAspectsTable.setLayoutData(availableAspectsTableRowData);
GridData availableAspectsTableGridData = new GridData(GridData.FILL_BOTH);
// availableAspectsTableGridData.grabExcessVerticalSpace = true;
// availableAspectsTableGridData.grabExcessHorizontalSpace = true;
availableAspectsTableGridData.heightHint = 300;
availableAspectsTable.setLayoutData(availableAspectsTableGridData);
Label availableModelsLabel = new Label(alfrescoModelComposite, SWT.NULL);
GridData availableModelsLabelGridData = new GridData(GridData.FILL_BOTH);
availableModelsLabelGridData.horizontalSpan = 3;
availableModelsLabel.setLayoutData(availableModelsLabelGridData);
//$NON-NLS-1$
availableModelsLabel.setText("Available Models");
availableModelsList = new org.eclipse.swt.widgets.List(alfrescoModelComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
GridData availableModelsListGridData = new GridData(GridData.FILL_BOTH);
// availableModelsListGridData.grabExcessVerticalSpace = true;
// availableModelsListGridData.grabExcessHorizontalSpace = true;
availableModelsListGridData.horizontalSpan = 3;
availableModelsListGridData.heightHint = 200;
availableModelsList.setLayoutData(availableModelsListGridData);
// init
availableModelsList.setItems(new String[0]);
Button addAvailableModelButton = new Button(alfrescoModelComposite, SWT.NULL);
//$NON-NLS-1$
addAvailableModelButton.setText(Messages.getString("AlfrescoModelDialog.add"));
addAvailableModelButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
// opens a dialog to select the model file
// shell
FileDialog dialog = new FileDialog(alfrescoModelComposite.getShell(), SWT.OPEN);
dialog.setFileName(AlfrescoModelDialog.this.chosenModelFilePath);
//$NON-NLS-1$ //$NON-NLS-2$
dialog.setFilterExtensions(new String[] { "*.xml", "*.*" });
AlfrescoModelDialog.this.chosenModelFilePath = dialog.open();
if (AlfrescoModelDialog.this.chosenModelFilePath == null) {
return;
}
try {
modelManager.addModel(AlfrescoModelDialog.this.chosenModelFilePath);
} catch (AlfrescoOutputException aoex) {
MessageDialog.openError(new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL), Messages.getString("AlfrescoModelDialog.addModelFailed"), //$NON-NLS-1$
aoex.getMessage());
return;
}
// let's refresh the list :
availableModelsList.setItems(modelManager.getAvailableModels().toArray(new String[0]));
AlfrescoModelDialog.this.updateMetadata();
}
});
Button removeAvailableModelButton = new Button(alfrescoModelComposite, SWT.NULL);
//$NON-NLS-1$
removeAvailableModelButton.setText(Messages.getString("AlfrescoModelDialog.remove"));
removeAvailableModelButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String[] selectedItems = availableModelsList.getSelection();
for (String selectedItem : selectedItems) {
try {
modelManager.removeModel(selectedItem);
} catch (AlfrescoOutputException aoex) {
MessageDialog.openError(new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL), Messages.getString("AlfrescoModelDialog.removeModelFailed"), //$NON-NLS-1$
aoex.getMessage());
return;
}
// let's refresh the list :
availableModelsList.setItems(modelManager.getAvailableModels().toArray(new String[0]));
}
AlfrescoModelDialog.this.updateMetadata();
}
});
// complete init (all other views are in sync with the model) :
// type
Element type = modelManager.getType();
if (type != null) {
this.typeComboViewer.setSelection(new StructuredSelection(type));
} else {
this.typeComboViewer.setSelection(new StructuredSelection());
}
// available models
availableModelsList.setItems(modelManager.getAvailableModels().toArray(new String[0]));
// chosen model filepath
if (!this.modelManager.getAvailableModels().isEmpty()) {
this.chosenModelFilePath = this.modelManager.getAvailableModels().get(this.modelManager.getAvailableModels().size() - 1);
}
applyDialogFont(alfrescoModelComposite);
return alfrescoModelComposite;
}
Aggregations