use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.
the class GotoResourceAction method run.
/**
* Collect all resources in the workbench open a dialog asking the user to
* select a resource and change the selection in the navigator.
*/
public void run() {
GotoResourceDialog dialog = new GotoResourceDialog(shell, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE | IResource.FOLDER | IResource.PROJECT);
dialog.open();
Object[] result = dialog.getResult();
if (result == null || result.length == 0 || result[0] instanceof IResource == false) {
return;
}
IResource selection = (IResource) result[0];
viewer.setSelection(new StructuredSelection(selection), true);
}
use of org.eclipse.jface.viewers.StructuredSelection 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.StructuredSelection in project translationstudio8 by heartsome.
the class TermDbManagerDialog method selectSaveItem.
/**
* 选择当前选中的内容 ;
*/
private void selectSaveItem() {
if (getCurrDbType() != null) {
boolean expanded = getTreeViewer().getExpandedState(getCurrDbType());
if (!expanded) {
getTreeViewer().setExpandedState(getCurrDbType(), !expanded);
}
DatabaseModelBean lastSelectItem = findServerBean(getCurrDbType(), getLastSelectedServer());
if (lastSelectItem != null) {
getTreeViewer().setSelection(new StructuredSelection(lastSelectItem), true);
getTreeViewer().getControl().setFocus();
} else {
getTreeViewer().setSelection(new StructuredSelection(getCurrDbType()), true);
getTreeViewer().getControl().setFocus();
}
}
}
use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.
the class ExportTmxDialog method loadData.
/**
* 加载语言数据 ;
*/
private void loadData() {
if (currentDatabase == null) {
// 清理数据
hasSelLangListViewer.getList().removeAll();
srcLangcomboViewer.getCombo().removeAll();
encodingComboViewer.getCombo().setText("");
return;
}
// 加载所有语言
hasSelLangListViewer.setInput(currentDatabase.getExistLangs().split(","));
hasSelLangListViewer.setSelection(new StructuredSelection(currentDatabase.getHasSelectedLangs()));
// 加载源语言;
srcLangcomboViewer.setInput(currentDatabase.getCanSelSrcLangs());
srcLangcomboViewer.setSelection(new StructuredSelection(currentDatabase.getSrcLang()));
// 加载编码列表,默认为UTF-8
encodingComboViewer.setSelection(new StructuredSelection("UTF-8"));
}
use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.
the class RowSelectionPreserver method handleLayerEvent.
/**
* On a change in the underlying data:
* <ol>
* <li>Clears the selection
* <li>Re-select the row objects selected earlier.
* </ol>
*/
public void handleLayerEvent(IVisualChangeEvent event) {
if (ObjectUtils.isEmpty(selectedRowObjects)) {
return;
}
if (event instanceof RowStructuralRefreshEvent || event instanceof RowStructuralChangeEvent || event instanceof SortColumnEvent) {
selectionLayer.clear();
selectionProvider.setSelection(new StructuredSelection(getValidSelections()));
}
}
Aggregations