use of org.eclipse.jface.viewers.ISelectionChangedListener in project translationstudio8 by heartsome.
the class LanguageCodesPreferencePage method addListener.
// 对需要添加监听的控件添加相应的监听器
private void addListener() {
// 添加语言列表选择事件监听
fFilteredTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
return;
}
// 暂时注释
// if (selection instanceof IStructuredSelection) {
// refreshFormatControls((IStructuredSelection) selection);
// }
}
});
// 注册添加按钮的选择监听器
addBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
addLanguage();
}
});
// 注册编辑按钮的选择监听器
editBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
verifyCurrentSelected(EDIT);
}
});
// 注册删除按钮的选择监听器
removeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
verifyCurrentSelected(REMOVE);
}
});
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project translationstudio8 by heartsome.
the class NewProjectWizardLanguagePage 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));
// source language control
Group sourceLanguageGrp = new Group(container, SWT.NONE);
sourceLanguageGrp.setLayout(new GridLayout(1, false));
sourceLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
sourceLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.sourceLanguageGrp"));
srcLangComboViewer = new TableComboViewer(sourceLanguageGrp, SWT.READ_ONLY | SWT.BORDER);
TableCombo tableCombo = srcLangComboViewer.getTableCombo();
// set options.
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(20);
srcLangComboViewer.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
srcLangComboViewer.setLabelProvider(new LanguageLabelProvider());
srcLangComboViewer.setContentProvider(new ArrayContentProvider());
srcLangComboViewer.setInput(languages);
srcLangComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
srcLanguage = (Language) selection.getFirstElement();
validator.update();
}
});
// initialization remember value
String rmSrcLangCode = ps.getString(IPreferenceConstants.NEW_PROJECT_SRC_LANG);
if (rmSrcLangCode != null && !rmSrcLangCode.equals("")) {
for (Language srcLang : languages) {
if (srcLang.getCode().equals(rmSrcLangCode)) {
srcLangComboViewer.setSelection(new StructuredSelection(srcLang));
break;
}
}
}
// end source language
// target language control
Group targetLanguageGrp = new Group(container, SWT.NONE);
targetLanguageGrp.setLayout(new GridLayout(3, false));
targetLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
targetLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.targetLanguageGrp"));
targetLangControl.createControl(targetLanguageGrp);
// end Target language
setControl(container);
validator.update();
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project translationstudio8 by heartsome.
the class NonTranslationQAPage method initListener.
/**
* 一些事件的添加
*/
public void initListener() {
// 非译元素的添加事件
addBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
addNonTransElement();
}
public void widgetDefaultSelected(SelectionEvent e) {
addNonTransElement();
}
});
editBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
editNontransElement();
}
public void widgetDefaultSelected(SelectionEvent arg0) {
editNontransElement();
}
});
// 删除按钮的点击操作
deleteBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
deleteElement();
}
public void widgetDefaultSelected(SelectionEvent e) {
deleteElement();
}
});
// 给comboViewer添加事件,同时传入内置元素
comboViewer.getCombo().addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
addInternalElement();
comboViewer.getCombo().setText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
}
public void widgetDefaultSelected(SelectionEvent e) {
addInternalElement();
comboViewer.getCombo().setText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
}
});
// 非译元素列表的点击事件
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = tableViewer.getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
if (structuredSelection.getFirstElement() instanceof NontransElementBean) {
if (structuredSelection.size() == 1 && !validIsInternalElementNonTip((NontransElementBean) structuredSelection.getFirstElement())) {
editBtn.setEnabled(true);
} else {
editBtn.setEnabled(false);
}
deleteBtn.setEnabled(true);
} else {
setAddModel();
}
} else {
setAddModel();
}
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent arg0) {
editNontransElement();
}
});
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project translationstudio8 by heartsome.
the class SelectionProviderAdapter method setSelection.
/**
* 设置被选中对象,并用安全线程通知监听器。
* @param selection
* the selection
* @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
*/
public void setSelection(ISelection selection) {
theSelection = selection;
final SelectionChangedEvent e = new SelectionChangedEvent(this, selection);
Object[] listenersArray = listeners.toArray();
for (int i = 0; i < listenersArray.length; i++) {
final ISelectionChangedListener l = (ISelectionChangedListener) listenersArray[i];
SafeRunner.run(new SafeRunnable() {
public void run() {
l.selectionChanged(e);
}
});
}
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project translationstudio8 by heartsome.
the class RowSelectionProvider method handleLayerEvent.
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof ISelectionEvent) {
int[] rowPositions = selectionLayer.getFullySelectedRowPositions();
if (fullySelectedRowsOnly && rowPositions.length == 0) {
ActiveCellRegion.setActiveCellRegion(null);
return;
}
Arrays.sort(rowPositions);
int rowPosition = rowPositions[rowPositions.length - 1];
if (rowPosition == currentRowPosition) {
return;
}
currentRowPosition = rowPosition;
int rowIndex = selectionLayer.getRowIndexByPosition(rowPosition);
ISelection selection = new StructuredSelection(rowIndex);
SelectionChangedEvent e = new SelectionChangedEvent(this, selection);
for (ISelectionChangedListener listener : listeners) {
listener.selectionChanged(e);
}
}
}
Aggregations