use of org.eclipse.swt.events.FocusEvent in project dbeaver by serge-rider.
the class CustomCheckboxCellEditor method createControl.
@Override
protected Control createControl(Composite parent) {
checkBox = new Button(parent, SWT.CHECK);
checkBox.setFont(parent.getFont());
checkBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
applyEditorValue();
// This is needed for MacOS
fireApplyEditorValue();
}
});
checkBox.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
CustomCheckboxCellEditor.this.focusLost();
}
});
return checkBox;
}
use of org.eclipse.swt.events.FocusEvent in project dbeaver by serge-rider.
the class BaseValueEditor method initInlineControl.
protected void initInlineControl(final Control inlineControl) {
boolean isInline = (valueController.getEditType() == IValueController.EditType.INLINE);
if (isInline && UIUtils.isInDialog(inlineControl)) {
//isInline = false;
}
UIUtils.enableHostEditorKeyBindingsSupport(valueController.getValueSite(), inlineControl);
// if (!isInline) {
// inlineControl.setBackground(valueController.getEditPlaceholder().getBackground());
// }
final IContextService contextService = valueController.getValueSite().getService(IContextService.class);
inlineControl.addFocusListener(new FocusListener() {
private IContextActivation activationEditor;
@Override
public void focusGained(FocusEvent e) {
if (contextService != null) {
activationEditor = contextService.activateContext(RESULTS_EDIT_CONTEXT_ID);
}
}
@Override
public void focusLost(FocusEvent e) {
contextService.deactivateContext(activationEditor);
activationEditor = null;
}
});
if (isInline) {
inlineControl.setFont(valueController.getEditPlaceholder().getFont());
inlineControl.setFocus();
if (valueController instanceof IMultiController) {
// In dialog it also should handle all standard stuff because we have params dialog
inlineControl.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
saveValue();
((IMultiController) valueController).closeInlineEditor();
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
((IMultiController) valueController).closeInlineEditor();
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
} else if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
saveValue();
((IMultiController) valueController).nextInlineEditor(e.detail == SWT.TRAVERSE_TAB_NEXT);
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
}
}
});
if (!UIUtils.isInDialog(inlineControl)) {
addAutoSaveSupport(inlineControl);
}
}
}
final ControlModifyListener modifyListener = new ControlModifyListener();
control.addListener(SWT.Modify, modifyListener);
control.addListener(SWT.Selection, modifyListener);
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class EditMultiHostStatisticItemDialog method createDialogArea.
/**
* Creates and returns the contents of the upper part of this dialog (above
* the button bar).
*
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
final Composite parentComp = (Composite) super.createDialogArea(parent);
final int DEFAULT_WIDTH = 80;
Composite compHost = new Composite(parentComp, SWT.RESIZE);
compHost.setLayout(new FillLayout());
compHost.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
hostTableViewer = new TableViewer(compHost, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
hostTableViewer.getTable().setHeaderVisible(true);
hostTableViewer.getTable().setLinesVisible(true);
hostTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
TableItem[] tableItems = hostTableViewer.getTable().getSelection();
StatisticChartHost hostItem = (StatisticChartHost) tableItems[0].getData();
openAddStatisticHostDialog(hostItem, hostList.size() == 1, false);
}
});
//Host Name
final TableViewerColumn nameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
nameColumn.getColumn().setWidth(DEFAULT_WIDTH);
nameColumn.getColumn().setText(Messages.lblHostName);
//IP
final TableViewerColumn ipColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
ipColumn.getColumn().setWidth(DEFAULT_WIDTH);
ipColumn.getColumn().setText(Messages.lblIp);
//Port
final TableViewerColumn portColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
portColumn.getColumn().setWidth(50);
portColumn.getColumn().setText(Messages.lblPort);
//Data Type
final TableViewerColumn dataTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
dataTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
dataTypeColumn.getColumn().setText(Messages.lblDataType);
//Time Type
final TableViewerColumn timeTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
timeTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
timeTypeColumn.getColumn().setText(Messages.lblTimeType);
//Database Name
final TableViewerColumn dbNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
dbNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
dbNameColumn.getColumn().setText(Messages.lblDbName);
//Database Volume Name
final TableViewerColumn volNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
volNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
volNameColumn.getColumn().setText(Messages.lblVolName);
//Broker Name
final TableViewerColumn brokerColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
brokerColumn.getColumn().setWidth(DEFAULT_WIDTH);
brokerColumn.getColumn().setText(Messages.lblBrokerName);
//Metric
final TableViewerColumn metricColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
metricColumn.getColumn().setWidth(DEFAULT_WIDTH);
metricColumn.getColumn().setText(Messages.lblMetric);
hostTableViewer.setContentProvider(new HostTableViewerContentProvider());
hostTableViewer.setLabelProvider(new HostTableViewerLabelProvider());
hostTableViewer.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(hostTableViewer.getTable());
}
});
hostTableViewer.getTable().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] items = hostTableViewer.getTable().getSelection();
btnEditHost.setEnabled(items.length > 0);
btnDeleteHost.setEnabled(items.length > 0);
}
});
Composite compBtn = new Composite(parentComp, SWT.RESIZE);
GridLayout layoutCompBtn = new GridLayout(6, false);
layoutCompBtn.marginRight = 0;
// layoutCompBtn.numColumns = 6;
layoutCompBtn.marginWidth = 0;
compBtn.setLayout(layoutCompBtn);
compBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
btnAddHost = new Button(compBtn, SWT.NONE);
btnAddHost.setText(Messages.btnAddHost);
btnAddHost.addSelectionListener(new ButtonAddHostAdapter());
btnEditHost = new Button(compBtn, SWT.NONE);
btnEditHost.setText(Messages.btnEditHost);
btnEditHost.addSelectionListener(new ButtonEditHostAdapter());
btnEditHost.setEnabled(false);
btnDeleteHost = new Button(compBtn, SWT.NONE);
btnDeleteHost.setText(Messages.btnDelHost);
btnDeleteHost.addSelectionListener(new ButtonDeleteHostAdapter());
btnDeleteHost.setEnabled(false);
if (!isNew && statisticChartItem != null) {
MultiHostChartItem multiHostChartItem = (MultiHostChartItem) statisticChartItem;
type = multiHostChartItem.getType();
timeType = TimeType.getEnumByType(multiHostChartItem.getDType());
hostList = multiHostChartItem.getHostList();
hostTableViewer.setInput(hostList);
} else {
hostList = new ArrayList<StatisticChartHost>();
}
return parentComp;
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class CUBRIDTextEditor method createPartControl.
/**
* Create Part Controls.
*
* @param parent composite.
*/
public void createPartControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
initTextViewer(composite);
undoManager.connect(textViewer);
createActions();
updateActions();
//create context menu
MenuManager contextMenuManager = new MenuManager("#PopupMenu", "CUBRIDTExtEditorContextMenu");
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
createContextMenu(manager);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(textViewer.getTextWidget());
textViewer.getTextWidget().setMenu(contextMenu);
IWorkbenchPartSite site = getSite();
site.registerContextMenu(contextMenuManager, textViewer);
site.setSelectionProvider(textViewer);
textViewer.getTextWidget().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
hookRetargetActions();
}
public void focusLost(FocusEvent event) {
unHookRetargetActions();
}
});
}
use of org.eclipse.swt.events.FocusEvent in project eclipse.platform.text by eclipse.
the class CompletionProposalPopup method addCommandSupport.
/**
* Adds command support to the given control.
*
* @param control the control to watch for focus
* @since 3.2
*/
private void addCommandSupport(final Control control) {
final KeySequence commandSequence = fContentAssistant.getRepeatedInvocationKeySequence();
if (commandSequence != null && !commandSequence.isEmpty() && fContentAssistant.isRepeatedInvocationMode()) {
control.addFocusListener(new FocusListener() {
private CommandKeyListener fCommandKeyListener;
@Override
public void focusGained(FocusEvent e) {
if (Helper.okToUse(control)) {
if (fCommandKeyListener == null) {
fCommandKeyListener = new CommandKeyListener(commandSequence);
fProposalTable.addKeyListener(fCommandKeyListener);
}
}
}
@Override
public void focusLost(FocusEvent e) {
if (fCommandKeyListener != null) {
control.removeKeyListener(fCommandKeyListener);
fCommandKeyListener = null;
}
}
});
}
if (fAdditionalInfoController != null) {
control.addFocusListener(new FocusListener() {
private TraverseListener fTraverseListener;
@Override
public void focusGained(FocusEvent e) {
if (Helper.okToUse(control)) {
if (fTraverseListener == null) {
fTraverseListener = new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent event) {
if (event.detail == SWT.TRAVERSE_TAB_NEXT) {
IInformationControl iControl = fAdditionalInfoController.getCurrentInformationControl2();
if (fAdditionalInfoController.getInternalAccessor().canReplace(iControl)) {
fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true);
event.doit = false;
}
}
}
};
fProposalTable.addTraverseListener(fTraverseListener);
}
}
}
@Override
public void focusLost(FocusEvent e) {
if (fTraverseListener != null) {
control.removeTraverseListener(fTraverseListener);
fTraverseListener = null;
}
}
});
}
}
Aggregations