use of org.eclipse.swt.events.ControlEvent in project dbeaver by dbeaver.
the class PrefPageConnectionTypes method performDefaults.
@Override
protected void performDefaults() {
typeTable.removeAll();
// colorPicker.loadStandardColors();
for (DBPConnectionType source : DataSourceProviderRegistry.getInstance().getConnectionTypes()) {
addTypeToTable(source, new DBPConnectionType(source));
}
typeTable.select(0);
if (selectedType != null) {
for (int i = 0; i < typeTable.getItemCount(); i++) {
if (typeTable.getItem(i).getData().equals(selectedType)) {
typeTable.select(i);
break;
}
}
}
showSelectedType(getSelectedType());
typeTable.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
UIUtils.packColumns(typeTable, true);
}
});
super.performDefaults();
}
use of org.eclipse.swt.events.ControlEvent in project pentaho-kettle by pentaho.
the class JobMetricsDelegate method setupContent.
public void setupContent() {
if (metricsComposite.isDisposed()) {
return;
}
//
for (Control control : metricsComposite.getChildren()) {
if (!control.isDisposed()) {
control.dispose();
}
}
emptyGraph = false;
canvas = new Canvas(metricsComposite, SWT.NONE);
spoon.props.setLook(canvas);
FormData fdCanvas = new FormData();
fdCanvas.left = new FormAttachment(0, 0);
fdCanvas.right = new FormAttachment(100, 0);
fdCanvas.top = new FormAttachment(0, 0);
fdCanvas.bottom = new FormAttachment(100, 0);
canvas.setLayoutData(fdCanvas);
metricsComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
updateGraph();
}
});
metricsComposite.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
if (image != null) {
image.dispose();
}
}
});
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
if (jobGraph.job != null && (jobGraph.job.isFinished() || jobGraph.job.isStopped())) {
refreshImage(event.gc);
if (!Const.isRunningOnWebspoonMode()) {
if (image != null && !image.isDisposed()) {
event.gc.drawImage(image, 0, 0);
}
}
} else {
Rectangle bounds = canvas.getBounds();
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
event.gc.setForeground(GUIResource.getInstance().getColorWhite());
event.gc.setBackground(GUIResource.getInstance().getColorWhite());
event.gc.fillRectangle(new Rectangle(0, 0, bounds.width, bounds.height));
event.gc.setForeground(GUIResource.getInstance().getColorBlack());
String metricsMessage = BaseMessages.getString(PKG, "JobMetricsDelegate.JobIsNotRunning.Message");
org.eclipse.swt.graphics.Point extent = event.gc.textExtent(metricsMessage);
event.gc.drawText(metricsMessage, (bounds.width - extent.x) / 2, (bounds.height - extent.y) / 2);
}
}
});
// Refresh automatically every 5 seconds as well.
//
final Timer timer = new Timer("JobMetricsDelegate Timer");
timer.schedule(new TimerTask() {
public void run() {
updateGraph();
}
}, 0, 5000);
// When the tab is closed, we remove the update timer
//
jobMetricsTab.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
timer.cancel();
}
});
if (Const.isRunningOnWebspoonMode()) {
// When the browser tab/window is closed, we remove the update timer
jobMetricsTab.getDisplay().disposeExec(new Runnable() {
@Override
public void run() {
timer.cancel();
}
});
}
// Show tool tips with details...
//
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent event) {
if (drawAreas == null) {
return;
}
for (int i = drawAreas.size() - 1; i >= 0; i--) {
MetricsDrawArea drawArea = drawAreas.get(i);
if (drawArea.getArea().contains(event.x, event.y)) {
MetricsDuration duration = drawArea.getDuration();
if (duration == null) {
continue;
}
System.out.println(duration.toString());
LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject(duration.getLogChannelId());
if (loggingObject == null) {
return;
}
System.out.println(loggingObject.getObjectType() + " : " + loggingObject.getObjectName());
}
}
}
});
canvas.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent arg0) {
// force a refresh
lastRefreshTime = 0;
}
});
}
use of org.eclipse.swt.events.ControlEvent in project archi by archimatetool.
the class DirectEditManager method hookListeners.
protected void hookListeners() {
ancestorListener = new AncestorListener.Stub() {
@Override
public void ancestorMoved(IFigure ancestor) {
placeCellEditor();
}
};
getEditPart().getFigure().addAncestorListener(ancestorListener);
Control control = getControl();
controlListener = new ControlAdapter() {
@Override
public void controlMoved(ControlEvent e) {
// This must be handled async because during scrolling, the
// CellEditor moves
// first, but then afterwards the viewport Scrolls, which would
// cause the
// shadow to move twice
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
placeCellEditorFrame();
}
});
}
@Override
public void controlResized(ControlEvent e) {
placeCellEditorFrame();
}
};
control.addControlListener(controlListener);
cellEditorListener = new ICellEditorListener() {
@Override
public void applyEditorValue() {
commit();
}
@Override
public void cancelEditor() {
bringDown();
}
@Override
public void editorValueChanged(boolean old, boolean newState) {
handleValueChanged();
}
};
getCellEditor().addListener(cellEditorListener);
editPartListener = new EditPartListener.Stub() {
@Override
public void partDeactivated(EditPart editpart) {
bringDown();
}
};
getEditPart().addEditPartListener(editPartListener);
}
use of org.eclipse.swt.events.ControlEvent in project archi by archimatetool.
the class SaveCanvasAsTemplateWizardPage method createControl.
@Override
public void createControl(Composite parent) {
GridData gd;
Label label;
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout());
setControl(container);
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, HELP_ID);
Group fileComposite = new Group(container, SWT.NULL);
fileComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout layout = new GridLayout(3, false);
fileComposite.setLayout(layout);
label = new Label(fileComposite, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_2);
fFileTextField = UIUtils.createSingleTextControl(fileComposite, SWT.BORDER, false);
fFileTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
String defaultFileName = Messages.SaveCanvasAsTemplateWizardPage_3 + CanvasTemplateManager.CANVAS_TEMPLATE_FILE_EXTENSION;
// Get last folder used
String lastFolderName = CanvasEditorPlugin.INSTANCE.getPreferenceStore().getString(PREFS_LAST_FOLDER);
File lastFolder = new File(lastFolderName);
if (lastFolder.exists() && lastFolder.isDirectory()) {
fFileTextField.setText(new File(lastFolder, defaultFileName).getPath());
} else {
// $NON-NLS-1$
fFileTextField.setText(new File(System.getProperty("user.home"), defaultFileName).getPath());
}
fFileTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validateFields();
}
});
Button fileButton = new Button(fileComposite, SWT.PUSH);
fileButton.setText(Messages.SaveCanvasAsTemplateWizardPage_4);
fileButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
File file = chooseFile();
if (file != null) {
fFileTextField.setText(file.getPath());
}
}
});
Group fieldGroup = new Group(container, SWT.NULL);
fieldGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
layout = new GridLayout(2, false);
fieldGroup.setLayout(layout);
label = new Label(fieldGroup, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_5);
fNameTextField = UIUtils.createSingleTextControl(fieldGroup, SWT.BORDER, false);
fNameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (StringUtils.isSet(fCanvasModel.getName())) {
fNameTextField.setText(fCanvasModel.getName());
}
fNameTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validateFields();
}
});
label = new Label(fieldGroup, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_6);
gd = new GridData(SWT.NULL, SWT.TOP, false, false);
label.setLayoutData(gd);
fDescriptionTextField = new Text(fieldGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 120;
// Stop overstretch
gd.widthHint = 550;
fDescriptionTextField.setLayoutData(gd);
if (StringUtils.isSet(fCanvasModel.getDocumentation())) {
fDescriptionTextField.setText(fCanvasModel.getDocumentation());
}
// Thumbnail
Group thumbsGroup = new Group(container, SWT.NULL);
thumbsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
layout = new GridLayout(2, false);
thumbsGroup.setLayout(layout);
fButtonIncludeThumbnail = new Button(thumbsGroup, SWT.CHECK);
fButtonIncludeThumbnail.setText(Messages.SaveCanvasAsTemplateWizardPage_7);
fButtonIncludeThumbnail.setSelection(true);
fButtonIncludeThumbnail.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fPreviewLabel.setEnabled(fButtonIncludeThumbnail.getSelection());
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fButtonIncludeThumbnail.setLayoutData(gd);
label = new Label(thumbsGroup, SWT.NULL);
// $NON-NLS-1$
label.setText(Messages.SaveCanvasAsTemplateWizardPage_8 + " ");
gd = new GridData(SWT.NULL, SWT.TOP, false, false);
label.setLayoutData(gd);
fPreviewLabel = new Label(thumbsGroup, SWT.BORDER);
fPreviewLabel.setAlignment(SWT.CENTER);
fPreviewLabel.setBackground(new Color(255, 255, 255));
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 120;
gd.widthHint = 150;
fPreviewLabel.setLayoutData(gd);
// Dispose of the image here not in the main dispose() method because if the help system is showing then
// the TrayDialog is resized and this label is asked to relayout.
fPreviewLabel.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
disposePreviewImage();
}
});
// This will be called initially as well as on resize
fPreviewLabel.addControlListener(new ControlAdapter() {
int oldTime;
@Override
public void controlResized(ControlEvent e) {
if (e.time - oldTime > 50) {
TemplateUtils.createThumbnailPreviewImage(fCanvasModel, fPreviewLabel);
}
oldTime = e.time;
}
});
validateFields();
}
use of org.eclipse.swt.events.ControlEvent in project iobserve-analysis by research-iobserve.
the class cloudprofileEditor method createPages.
/**
* This is the method used by the framework to install your own controls.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void createPages() {
// Creates the model from the editor input
//
createModel();
//
if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
// Create a page for the selection tree view.
//
{
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), cloudprofileEditor.this) {
@Override
public Viewer createViewer(Composite composite) {
Tree tree = new Tree(composite, SWT.MULTI);
TreeViewer newTreeViewer = new TreeViewer(tree);
return newTreeViewer;
}
@Override
public void requestActivation() {
super.requestActivation();
setCurrentViewerPane(this);
}
};
viewerPane.createControl(getContainer());
selectionViewer = (TreeViewer) viewerPane.getViewer();
selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
selectionViewer.setInput(editingDomain.getResourceSet());
selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
viewerPane.setTitle(editingDomain.getResourceSet());
new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
createContextMenuFor(selectionViewer);
int pageIndex = addPage(viewerPane.getControl());
setPageText(pageIndex, getString("_UI_SelectionPage_label"));
}
// Create a page for the parent tree view.
//
{
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), cloudprofileEditor.this) {
@Override
public Viewer createViewer(Composite composite) {
Tree tree = new Tree(composite, SWT.MULTI);
TreeViewer newTreeViewer = new TreeViewer(tree);
return newTreeViewer;
}
@Override
public void requestActivation() {
super.requestActivation();
setCurrentViewerPane(this);
}
};
viewerPane.createControl(getContainer());
parentViewer = (TreeViewer) viewerPane.getViewer();
parentViewer.setAutoExpandLevel(30);
parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
createContextMenuFor(parentViewer);
int pageIndex = addPage(viewerPane.getControl());
setPageText(pageIndex, getString("_UI_ParentPage_label"));
}
// This is the page for the list viewer
//
{
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), cloudprofileEditor.this) {
@Override
public Viewer createViewer(Composite composite) {
return new ListViewer(composite);
}
@Override
public void requestActivation() {
super.requestActivation();
setCurrentViewerPane(this);
}
};
viewerPane.createControl(getContainer());
listViewer = (ListViewer) viewerPane.getViewer();
listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
createContextMenuFor(listViewer);
int pageIndex = addPage(viewerPane.getControl());
setPageText(pageIndex, getString("_UI_ListPage_label"));
}
// This is the page for the tree viewer
//
{
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), cloudprofileEditor.this) {
@Override
public Viewer createViewer(Composite composite) {
return new TreeViewer(composite);
}
@Override
public void requestActivation() {
super.requestActivation();
setCurrentViewerPane(this);
}
};
viewerPane.createControl(getContainer());
treeViewer = (TreeViewer) viewerPane.getViewer();
treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
createContextMenuFor(treeViewer);
int pageIndex = addPage(viewerPane.getControl());
setPageText(pageIndex, getString("_UI_TreePage_label"));
}
// This is the page for the table viewer.
//
{
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), cloudprofileEditor.this) {
@Override
public Viewer createViewer(Composite composite) {
return new TableViewer(composite);
}
@Override
public void requestActivation() {
super.requestActivation();
setCurrentViewerPane(this);
}
};
viewerPane.createControl(getContainer());
tableViewer = (TableViewer) viewerPane.getViewer();
Table table = tableViewer.getTable();
TableLayout layout = new TableLayout();
table.setLayout(layout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn objectColumn = new TableColumn(table, SWT.NONE);
layout.addColumnData(new ColumnWeightData(3, 100, true));
objectColumn.setText(getString("_UI_ObjectColumn_label"));
objectColumn.setResizable(true);
TableColumn selfColumn = new TableColumn(table, SWT.NONE);
layout.addColumnData(new ColumnWeightData(2, 100, true));
selfColumn.setText(getString("_UI_SelfColumn_label"));
selfColumn.setResizable(true);
tableViewer.setColumnProperties(new String[] { "a", "b" });
tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
createContextMenuFor(tableViewer);
int pageIndex = addPage(viewerPane.getControl());
setPageText(pageIndex, getString("_UI_TablePage_label"));
}
// This is the page for the table tree viewer.
//
{
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), cloudprofileEditor.this) {
@Override
public Viewer createViewer(Composite composite) {
return new TreeViewer(composite);
}
@Override
public void requestActivation() {
super.requestActivation();
setCurrentViewerPane(this);
}
};
viewerPane.createControl(getContainer());
treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();
Tree tree = treeViewerWithColumns.getTree();
tree.setLayoutData(new FillLayout());
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
objectColumn.setText(getString("_UI_ObjectColumn_label"));
objectColumn.setResizable(true);
objectColumn.setWidth(250);
TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
selfColumn.setText(getString("_UI_SelfColumn_label"));
selfColumn.setResizable(true);
selfColumn.setWidth(200);
treeViewerWithColumns.setColumnProperties(new String[] { "a", "b" });
treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
createContextMenuFor(treeViewerWithColumns);
int pageIndex = addPage(viewerPane.getControl());
setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
}
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
setActivePage(0);
}
});
}
// Ensures that this editor will only display the page's tab
// area if there are more than one page
//
getContainer().addControlListener(new ControlAdapter() {
boolean guard = false;
@Override
public void controlResized(ControlEvent event) {
if (!guard) {
guard = true;
hideTabs();
guard = false;
}
}
});
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
updateProblemIndication();
}
});
}
Aggregations