use of org.eclipse.jface.viewers.SelectionChangedEvent 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.jface.viewers.SelectionChangedEvent in project azure-tools-for-java by Microsoft.
the class AzureNewDockerConfigPage method updateDockerSubscriptionComboBox.
private void updateDockerSubscriptionComboBox(Composite mainContainer) {
dockerSubscriptionComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() > 0) {
AzureDockerSubscription currentSubscription = (AzureDockerSubscription) selection.getFirstElement();
dockerSubscriptionIdTextField.setText(currentSubscription != null ? currentSubscription.id : "");
wizard.setSubscription(currentSubscription);
errDispatcher.removeMessage("dockerSubscriptionCombo", dockerSubscriptionCombo);
updateDockerLocationComboBox(mainContainer, currentSubscription);
updateDockerHostSelectRGComboBox(mainContainer, currentSubscription);
String region = (String) dockerLocationComboBox.getText();
Region regionObj = Region.findByLabelOrName(region);
updateDockerSelectVnetComboBox(mainContainer, currentSubscription, regionObj != null ? regionObj.name() : region);
updateDockerSelectStorageComboBox(mainContainer, currentSubscription);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerSubscriptionCombo", "No active subscriptions found", null, IMessageProvider.ERROR, dockerSubscriptionCombo);
setPageComplete(false);
}
}
});
dockerSubscriptionComboViewer.setContentProvider(ArrayContentProvider.getInstance());
dockerSubscriptionComboViewer.setInput(dockerManager.getSubscriptionsList());
if (dockerManager.getSubscriptionsList() != null && dockerManager.getSubscriptionsList().size() > 0) {
dockerSubscriptionCombo.select(0);
dockerSubscriptionIdTextField.setText(((AzureDockerSubscription) ((StructuredSelection) dockerSubscriptionComboViewer.getSelection()).getFirstElement()).id);
wizard.setSubscription((AzureDockerSubscription) ((StructuredSelection) dockerSubscriptionComboViewer.getSelection()).getFirstElement());
}
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project cubrid-manager by CUBRID.
the class RecentlyUsedSQLComposite method createHistoryTable.
/**
* createHistoryTable
* @param bottomSash
*/
public void createHistoryTable(SashForm bottomSash) {
sqlHistoryTable = new TableViewer(bottomSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
sqlHistoryTable.getTable().setHeaderVisible(true);
sqlHistoryTable.getTable().setLinesVisible(true);
// final TableViewerColumn columnNO = new TableViewerColumn(
// sqlHistoryTable, SWT.CENTER);
// columnNO.getColumn().setWidth(40);
// columnNO.getColumn().setText("NO");
final TableViewerColumn columnRunTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnRunTime.getColumn().setWidth(155);
columnRunTime.getColumn().setText(Messages.recentlyUsedSQLColumnRunTime);
columnRunTime.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.EXECUTETIME_ASC : Sorter.EXECUTETIME_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnSQL = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnSQL.getColumn().setWidth(250);
columnSQL.getColumn().setText(Messages.recentlyUsedSQLColumn);
columnSQL.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.SQL_ASC : Sorter.SQL_DEC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnElapseTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnElapseTime.getColumn().setWidth(100);
columnElapseTime.getColumn().setText(Messages.recentlyUsedSQLColumnElapseTime);
columnElapseTime.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.ELAPSETIME_ASC : Sorter.ELAPSETIME_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnInfo = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnInfo.getColumn().setWidth(300);
columnInfo.getColumn().setText(Messages.recentlyUsedSQLColumnLOG);
columnInfo.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.LOG_ASC : Sorter.LOG_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
sqlHistoryTable.setContentProvider(new HistorySQLContentProvider());
provider = new HistorySQLLabelProvider();
sqlHistoryTable.setLabelProvider(provider);
sqlHistoryTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
SQLHistoryDetail history = (SQLHistoryDetail) sqlHistoryTable.getElementAt(sqlHistoryTable.getTable().getSelectionIndex());
if (history != null) {
logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + history.getSql());
}
}
});
sqlHistoryTable.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
SQLHistoryDetail history = (SQLHistoryDetail) selection.getFirstElement();
logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + StringUtil.NEWLINE + history.getSql());
int start = editor.getAllQueries().length();
editor.setQuery(StringUtil.NEWLINE + history.getSql(), true, false, false);
int end = start + history.getSql().length();
// "/n" take a postion ,so both start and end should + 1
editor.setSelection(start + 1, end + 1);
}
});
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project cubrid-manager by CUBRID.
the class LayoutManager method fireSelectionChanged.
/**
*
* Fire selection change event
*
* @param selection the ISelection object
*/
public void fireSelectionChanged(ISelection selection) {
SelectionChangedEvent event = new SelectionChangedEvent(getSelectionProvider(), selection);
selectionChanged(event);
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project dbeaver by serge-rider.
the class ViewValuePanel method createContents.
@Override
public Control createContents(IResultSetPresentation presentation, Composite parent) {
this.presentation = presentation;
viewPlaceholder = new Composite(parent, SWT.NONE);
viewPlaceholder.setLayout(new FillLayout());
viewPlaceholder.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (viewPlaceholder.getChildren().length == 0) {
String hidePanelCmd = ActionUtils.findCommandDescription(ResultSetCommandHandler.CMD_TOGGLE_PANELS, ViewValuePanel.this.presentation.getController().getSite(), true);
UIUtils.drawMessageOverControl(viewPlaceholder, e, "Select a cell to view/edit value", 0);
UIUtils.drawMessageOverControl(viewPlaceholder, e, "Press " + hidePanelCmd + " to hide this panel", 20);
}
}
});
if (this.presentation instanceof ISelectionProvider) {
final ISelectionProvider selectionProvider = (ISelectionProvider) this.presentation;
final ISelectionChangedListener selectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (ViewValuePanel.this.presentation.getController().getVisiblePanel() == ViewValuePanel.this) {
refreshValue(false);
}
}
};
selectionProvider.addSelectionChangedListener(selectionListener);
viewPlaceholder.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
selectionProvider.removeSelectionChangedListener(selectionListener);
}
});
}
return viewPlaceholder;
}
Aggregations