use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.
the class WizardJetFilesChoosePage method creatResourceLangGrp.
private void creatResourceLangGrp(Composite groupsComposite) {
Group resourceLangGrp = new Group(groupsComposite, SWT.NONE);
//$NON-NLS-1$
resourceLangGrp.setText("Select language dependent file");
// GridDataFactory.fillDefaults().span(1, 1).grab(true, false).applyTo(
// filesSelectionGrp);
resourceLangGrp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout groupLayout = new GridLayout(3, false);
resourceLangGrp.setLayout(groupLayout);
useDefaultResourceButton = new Button(resourceLangGrp, SWT.CHECK | SWT.RIGHT);
useDefaultResourceButton.setText(PluginConstant.DEFAULTLANG_RESOURCE);
useZHResourceButton = new Button(resourceLangGrp, SWT.CHECK | SWT.RIGHT);
useZHResourceButton.setText(PluginConstant.ZHLANG_RESOURCE);
useFRResourceButton = new Button(resourceLangGrp, SWT.CHECK | SWT.RIGHT);
useFRResourceButton.setText(PluginConstant.FRLANG_RESOURCE);
SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setPageComplete(validatePage());
Button button = ((Button) e.getSource());
if (button.getSelection()) {
componentPref.getResourceLanguageTypes().add(ResourceLanguageType.find(button.getText()));
} else {
componentPref.getResourceLanguageTypes().remove(ResourceLanguageType.find(button.getText()));
}
// propertyChangeBean.firePropertyChange(PluginConstant.RESOURCETYPE_PROPERTY, null, resourceTypes);
}
};
useDefaultResourceButton.addSelectionListener(listener);
useZHResourceButton.addSelectionListener(listener);
useFRResourceButton.addSelectionListener(listener);
}
use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.
the class AbstractXMLConfigPage method initialize.
/*
* (non-Javadoc)
*
* @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractComponentPage#initialize()
*/
protected void initialize() {
availableXmlTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (availableXmlTree.getMenu() != null) {
availableXmlTree.getMenu().dispose();
}
final TreeItem[] treeItem = ((Tree) event.getSource()).getSelection();
Menu popMenu = new Menu(availableXmlTree);
MenuItem itemNew = new MenuItem(popMenu, SWT.CASCADE);
//$NON-NLS-1$
itemNew.setText(Messages.getString("AbstractXMLConfigPage.New"));
MenuItem itemDel = new MenuItem(popMenu, SWT.CASCADE);
//$NON-NLS-1$
itemDel.setText(Messages.getString("AbstractXMLConfigPage.Delete"));
itemDel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeNodeData currentNodeData = (TreeNodeData) treeItem[0].getParentItem().getData();
currentNodeData.getXMLNode().removeChild(((TreeNodeData) treeItem[0].getData()).getXMLNode());
treeItem[0].dispose();
}
});
final TreeNodeData treeNodeData = ((TreeNodeData) treeItem[0].getData());
if (treeNodeData.isHasChildTreeNode()) {
Menu subNewMenu = new Menu(itemNew);
itemNew.setMenu(subNewMenu);
Object[] subNodeNames = treeNodeData.getChildNodeNames();
for (Object nodeName : subNodeNames) {
final MenuItem nodeMenuItem = new MenuItem(subNewMenu, SWT.CASCADE);
final String itemName = (String) nodeName;
nodeMenuItem.setText(itemName);
nodeMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeItem newItem = new TreeItem(treeItem[0], 0);
newItem.setText(itemName);
TreeNodeData newNodeData = null;
newNodeData = new TreeNodeData();
Node parentNode = treeNodeData.getXMLNode();
newNodeData.setXMLNode(parentNode.appendChild(parentNode.getOwnerDocument().createElement(itemName)));
//$NON-NLS-1$
newNodeData.setTreePath(treeNodeData.getTreePath() + "/" + itemName);
newNodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(newNodeData.getTreePath()));
newItem.setData(newNodeData);
}
});
}
} else {
itemNew.setEnabled(false);
}
availableXmlTree.setMenu(popMenu);
if (nodeAttrCompsite != null) {
nodeAttrCompsite.dispose();
}
rebuildAttrComposite(treeNodeData);
setComponentMinSize(treeNodeData.getTreeNode().getLabel());
rightComposite.layout();
}
});
}
use of org.eclipse.swt.events.SelectionAdapter in project translationstudio8 by heartsome.
the class ConversionWizardPage method createConversionOptionsGroup.
/**
* 转换选项组
* @param contents
* ;
*/
private void createConversionOptionsGroup(Composite contents) {
Group options = new Group(contents, SWT.NONE);
//$NON-NLS-1$
options.setText(Messages.getString("wizard.ConversionWizardPage.options"));
options.setLayout(new GridLayout(1, false));
options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
/* 如果已经存在,是否要替换 */
final Button btnReplaceTarget = new Button(options, SWT.CHECK);
//$NON-NLS-1$
btnReplaceTarget.setText(Messages.getString("wizard.ConversionWizardPage.btnReplaceTarget"));
btnReplaceTarget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnReplaceTarget.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
isReplaceTarget = btnReplaceTarget.getSelection();
for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
conversionConfigBean.setReplaceTarget(btnReplaceTarget.getSelection());
}
validate();
}
});
final Button btnOpenPreTrans = new Button(options, SWT.CHECK);
btnOpenPreTrans.setText(Messages.getString("wizard.ConversionWizardPage.btnOpenPreTrans"));
btnOpenPreTrans.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnOpenPreTrans.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
isOpenPreTrans = btnOpenPreTrans.getSelection();
}
});
Composite composite = new Composite(options, SWT.NONE);
GridLayout gd = new GridLayout(1, false);
gd.marginWidth = 0;
gd.marginHeight = 0;
composite.setLayout(gd);
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
Label tgtLangLbl = new Label(composite, SWT.NONE);
tgtLangLbl.setText(Messages.getString("wizard.ConversionWizardPage.tgtLangLbl"));
tgtLangViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
Table tgtLangTable = tgtLangViewer.getTable();
GridData gdTgtLangTable = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gdTgtLangTable.heightHint = 80;
tgtLangTable.setLayoutData(gdTgtLangTable);
tgtLangViewer.setLabelProvider(new LanguageLabelProvider());
tgtLangViewer.setContentProvider(new ArrayContentProvider());
tgtLangViewer.setInput(conversionConfigBeans.get(0).getTgtLangList());
tgtLangViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
@SuppressWarnings("unchecked") List<Language> selectedList = sel.toList();
for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
conversionConfigBean.setHasSelTgtLangList(selectedList);
}
validate();
}
});
tgtLangViewer.getTable().select(0);
IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
btnReplaceTarget.setSelection(dialogSettings.getBoolean(REPLACE_TARGET));
btnOpenPreTrans.setSelection(dialogSettings.getBoolean(OPEN_PRE_TRANS));
this.isOpenPreTrans = btnOpenPreTrans.getSelection();
isReplaceTarget = btnReplaceTarget.getSelection();
for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
conversionConfigBean.setReplaceTarget(isReplaceTarget);
}
validate();
}
use of org.eclipse.swt.events.SelectionAdapter in project translationstudio8 by heartsome.
the class ReverseConversionWizardPage method createFilesGroup.
/**
* 创建文件列表区域
* @param contents
* ;
*/
private Composite createFilesGroup(Composite contents) {
Composite filesComposite = new Composite(contents, SWT.NONE);
filesComposite.setLayout(new GridLayout(1, false));
filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
tableData.heightHint = 100;
filesTable.setLayoutData(tableData);
filesTable.setLinesVisible(true);
filesTable.setHeaderVisible(true);
filesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] selected = filesTable.getSelection();
if (selected.length == 0) {
return;
}
//$NON-NLS-1$
String strTgtEnc = "";
for (int i = 0; i < selected.length; i++) {
String curTgtEnc = selected[i].getText(2);
if (i == 0) {
strTgtEnc = curTgtEnc;
} else {
if (!strTgtEnc.equals(curTgtEnc)) {
//$NON-NLS-1$
strTgtEnc = "";
break;
}
}
}
if (!"".equals(strTgtEnc)) {
//$NON-NLS-1$
tgtEncCombo.setText(strTgtEnc);
} else {
tgtEncCombo.deselectAll();
}
}
});
tableViewer = new TableViewer(filesTable);
lineNumberColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
lineNumberColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.lineNumberColumn"));
xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
//$NON-NLS-1$
xliffColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.xliffColumn"));
tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
//$NON-NLS-1$
tgtEncColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncColumn"));
targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
//$NON-NLS-1$
targetColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.targetColumn"));
IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] { "index", "source", "targetEncoding", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"target" });
ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class), valueProperties);
filesComposite.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent arg0) {
int width = filesTable.getClientArea().width;
lineNumberColumn.setWidth(width * 1 / 10);
targetColumn.setWidth(width * 4 / 10);
tgtEncColumn.setWidth(width * 1 / 10);
xliffColumn.setWidth(width * 4 / 10);
}
});
return filesComposite;
}
use of org.eclipse.swt.events.SelectionAdapter in project ACS by ACS-Community.
the class TableViewBase method createPartControl.
@Override
public void createPartControl(Composite parent) {
tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
Table table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
// Set the column
for (int t = 0; t < colNames.length; t++) {
int style = t == 0 ? SWT.LEFT : SWT.CENTER;
final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, style);
final TableColumn column = viewerColumn.getColumn();
column.setText(colNames[t]);
final int index = t;
// Setting the right sorter
column.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sorter.setColumn(index);
int dir = tableViewer.getTable().getSortDirection();
if (tableViewer.getTable().getSortColumn() == column) {
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
dir = SWT.DOWN;
}
tableViewer.getTable().setSortDirection(dir);
tableViewer.getTable().setSortColumn(column);
tableViewer.refresh();
}
});
column.pack();
column.setWidth(colWidths[t]);
}
tableViewer.setContentProvider(new ViewContentProvider());
}
Aggregations