use of org.eclipse.swt.events.DisposeEvent in project dbeaver by dbeaver.
the class TabbedFolderPageEditor method createControl.
@Override
public void createControl(Composite parent) {
editor = editorDescriptor.createEditor();
final IWorkbenchPartSite ownerSite = this.mainEditor.getSite();
if (ownerSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart ownerMultiPageEditor = ((MultiPageEditorSite) ownerSite).getMultiPageEditor();
nestedEditorSite = new TabbedFolderPageEditorSite(ownerMultiPageEditor, editor);
// We need it to tell owner editor about dirty state change
if (ownerMultiPageEditor instanceof IPropertyChangeReflector) {
editor.addPropertyListener(new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
((IPropertyChangeReflector) ownerMultiPageEditor).handlePropertyChange(propId);
}
});
}
} else {
nestedEditorSite = new SubEditorSite(mainEditor.getEditorSite());
}
try {
editor.init(nestedEditorSite, editorDescriptor.getNestedEditorInput(mainEditor.getEditorInput()));
} catch (PartInitException e) {
DBUserInterface.getInstance().showError("Create SQL viewer", null, e);
}
editor.createPartControl(parent);
if (editor instanceof ISingleControlEditor) {
// Use focus to active selection provider and contributed actions
Control editorControl = ((ISingleControlEditor) editor).getEditorControl();
assert editorControl != null;
editorControl.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
mainEditor.getSite().setSelectionProvider(selectionProvider);
if (actionContributor != null) {
actionContributor.setActiveEditor(editor);
}
activateNestedSite(true);
}
@Override
public void focusLost(FocusEvent e) {
activateNestedSite(false);
if (actionContributor != null) {
actionContributor.setActiveEditor(null);
}
}
});
}
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (editor != null) {
editor.dispose();
editor = null;
}
}
});
}
use of org.eclipse.swt.events.DisposeEvent in project dbeaver by dbeaver.
the class MetaDataPanel method createContents.
@Override
public Control createContents(final IResultSetPresentation presentation, Composite parent) {
this.presentation = presentation;
this.colorDisabled = presentation.getControl().getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
this.attributeList = new MetaDataTable(parent);
this.attributeList.setFitWidth(false);
this.attributeList.getItemsViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
DBDAttributeBinding attr = getSelectedAttribute();
if (attr != null && !updateSelection) {
if (isAttributeVisible(attr)) {
updateSelection = true;
try {
presentation.setCurrentAttribute(attr);
} finally {
updateSelection = false;
}
}
}
}
});
if (this.presentation instanceof ISelectionProvider) {
final ISelectionChangedListener listener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (!updateSelection && MetaDataPanel.this.presentation.getController().getVisiblePanel() == MetaDataPanel.this) {
DBDAttributeBinding attr = presentation.getCurrentAttribute();
if (attr != null && attr != getSelectedAttribute()) {
updateSelection = true;
try {
attributeList.getItemsViewer().setSelection(new StructuredSelection(attr));
} finally {
updateSelection = false;
}
}
}
}
};
((ISelectionProvider) this.presentation).addSelectionChangedListener(listener);
attributeList.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
((ISelectionProvider) presentation).removeSelectionChangedListener(listener);
}
});
}
return this.attributeList;
}
use of org.eclipse.swt.events.DisposeEvent in project dbeaver by dbeaver.
the class EmptyPresentation method createPresentation.
@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
super.createPresentation(controller, parent);
UIUtils.createHorizontalLine(parent);
placeholder = new Canvas(parent, SWT.NONE);
placeholder.setLayoutData(new GridData(GridData.FILL_BOTH));
placeholder.setBackground(controller.getDefaultBackground());
final Font normalFont = parent.getFont();
FontData[] fontData = normalFont.getFontData();
fontData[0].setStyle(fontData[0].getStyle() | SWT.BOLD);
fontData[0].setHeight(18);
final Font largeFont = new Font(normalFont.getDevice(), fontData[0]);
placeholder.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
UIUtils.dispose(largeFont);
}
});
placeholder.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (controller.isRefreshInProgress()) {
return;
}
e.gc.setFont(largeFont);
int fontSize = largeFont.getFontData()[0].getHeight();
UIUtils.drawMessageOverControl(placeholder, e, CoreMessages.sql_editor_resultset_filter_panel_control_no_data, -(fontSize / 2));
e.gc.setFont(normalFont);
if (controller.getDataContainer() instanceof SQLEditor.QueryResultsContainer) {
String execQuery = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_STATEMENT, controller.getSite(), true);
String execScript = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_SCRIPT, controller.getSite(), true);
UIUtils.drawMessageOverControl(placeholder, e, NLS.bind(CoreMessages.sql_editor_resultset_filter_panel_control_execute_to_see_reslut, execQuery, execScript), fontSize + fontSize / 3);
}
}
});
trackPresentationControl();
}
use of org.eclipse.swt.events.DisposeEvent in project yamcs-studio by yamcs.
the class OverviewOutlinePage method createControl.
@Override
public void createControl(Composite parent) {
overview = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(overview);
thumbnail = new ScrollableThumbnail((Viewport) rootEP.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(rootEP.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
disposeListener = new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (thumbnail != null) {
thumbnail.deactivate();
thumbnail = null;
}
}
};
rootEP.getViewer().getControl().addDisposeListener(disposeListener);
}
use of org.eclipse.swt.events.DisposeEvent in project tmdm-studio-se by Talend.
the class ValidationRuleDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
parent.getShell().setText(this.title);
Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout(2, false));
Label label = new Label(composite, SWT.NONE);
label.setText(Messages.ValidationRuleDialog_);
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
columns = new ComplexTableViewerColumn[] { new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"Type", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
ComplexTableViewerColumn.COMBO_STYLE, IConstants.SCHEMATRON_TYPES, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"Context XPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", ComplexTableViewerColumn.XPATH_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"Expression", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
ComplexTableViewerColumn.VALIDATIONRULE_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"Message", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
ComplexTableViewerColumn.MULTIMESSAGE_STYLE, new String[] {}, 0) };
columns[0].setColumnWidth(70);
columns[1].setColumnWidth(130);
columns[2].setColumnWidth(300);
columns[3].setColumnWidth(300);
viewer = getNewTisTableViewer(Arrays.asList(columns), WidgetFactory.getWidgetFactory(), composite);
Map<ComplexTableViewerColumn, IXPathValidator> validators = new HashMap<ComplexTableViewerColumn, IXPathValidator>();
// set to "Context XPath" column the xpath validator
validators.put(columns[1], new DefaultXPathValidator());
viewer.setValidators(validators);
// Modified by hhb,to fix bug 21784
TreeParent treeParent = (TreeParent) page.getAdapter(TreeParent.class);
viewer.setTreeParent(treeParent);
// The ending| bug:21784
viewer.setXpath(true);
// viewer.setMainPage(page);
String modelName = page.getDataModel().getName();
viewer.setDatamodelName(modelName);
viewer.setConceptName(conceptName);
viewer.setContext(true);
viewer.create();
viewer.getViewer().setInput(parseRules());
viewer.setHeight(110);
viewer.setWidth(800);
viewer.getMainComposite().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 3));
parent.getShell().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
XpathSelectDialog.setContext(null);
}
});
return composite;
}
Aggregations