use of org.eclipse.swt.events.DisposeListener in project cubrid-manager by CUBRID.
the class BLOBCellPopupDialog method loadProgramMenu.
/**
*
* Load the program menus
*
*/
private void loadProgramMenu() {
if (programMenu != null) {
programMenu.dispose();
}
programMenu = new Menu(getShell(), SWT.POP_UP);
String fileType = getFileType();
// Load the default application
if (fileType != null && fileType.trim().length() > 0) {
final Program program = Program.findProgram(fileType);
if (program != null && program.getName() != null && program.getName().trim().length() > 0) {
programMenuItem = new MenuItem(programMenu, SWT.NONE);
programMenuItem.setText(program.getName());
ImageData imageData = program.getImageData();
if (imageData != null) {
final Image image = new Image(getShell().getDisplay(), imageData);
programMenuItem.setImage(image);
programMenu.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
image.dispose();
}
});
}
programMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
openByExternalProgram(program);
}
});
new MenuItem(programMenu, SWT.SEPARATOR);
}
}
// Load the other applications
Program[] programs = Program.getPrograms();
if (programs != null) {
for (final Program program : programs) {
String name = program.getName();
if (name == null || name.trim().length() == 0) {
continue;
}
if (programMenuItem != null && programMenuItem.getText().equals(name.trim())) {
continue;
}
final MenuItem selectProgramMenuItem = new MenuItem(programMenu, SWT.NONE);
selectProgramMenuItem.setText(name);
ImageData imageData = program.getImageData();
if (imageData != null) {
final Image image = new Image(getShell().getDisplay(), imageData);
selectProgramMenuItem.setImage(image);
selectProgramMenuItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
image.dispose();
}
});
}
selectProgramMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
openByExternalProgram(program);
}
});
}
}
Rectangle rect = openByExternalBtn.getBounds();
Point pt = new Point(rect.x, rect.y + rect.height);
pt = openByExternalBtn.getParent().toDisplay(pt);
programMenu.setLocation(pt);
programMenu.setVisible(true);
}
use of org.eclipse.swt.events.DisposeListener in project MonjaDB by Kanatoko.
the class MSavedActionsView method init2.
//--------------------------------------------------------------------------------
public void init2() {
parent.setLayout(new FormLayout());
tree = new Tree(parent, SWT.BORDER);
tree.addListener(SWT.KeyDown, this);
tree.addListener(SWT.MouseDoubleClick, this);
/*
tree.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
onKeyPressed( e );
}
});
*/
tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
onTreeSelect();
}
});
tree.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
saveSavedActions();
}
});
tree.setHeaderVisible(true);
FormData fd_tree_1 = new FormData();
fd_tree_1.bottom = new FormAttachment(100, 0);
fd_tree_1.right = new FormAttachment(100, -1);
fd_tree_1.top = new FormAttachment(0, 0);
fd_tree_1.left = new FormAttachment(0, 0);
tree.setLayoutData(fd_tree_1);
loadSavedActions();
menuManager = new MenuManager();
Menu contextMenu = menuManager.createContextMenu(tree);
tree.setMenu(contextMenu);
executeAction = new Action() {
public void run() {
//-----------
onExecute();
}
};
//-----------
executeAction.setToolTipText("Execute Saved Actions");
executeAction.setText("Execute\tShift+Enter");
initAction(executeAction, "cog_go.png", menuManager);
editAction = new Action() {
public void run() {
//-----------
onEdit();
}
};
//-----------
editAction.setToolTipText("Edit Saved Actions");
editAction.setText("Edit");
initAction(editAction, "cog_edit.png", menuManager);
menuManager.add(new Separator());
newAction = new Action() {
public void run() {
//-----------
onNewSavedAction();
}
};
//-----------
newAction.setToolTipText("New");
newAction.setText("New");
initAction(newAction, "cog_add.png", menuManager);
newFolderAction = new Action() {
public void run() {
//-----------
onNewFolder();
}
};
//-----------
newFolderAction.setToolTipText("Create A New Folder");
newFolderAction.setText("New Folder");
initAction(newFolderAction, "folder_add.png", menuManager);
menuManager.add(new Separator());
removeAction = new Action() {
public void run() {
//-----------
onRemove();
}
};
//-----------
removeAction.setToolTipText("Remove Selected Item");
removeAction.setText("Remove");
initAction(removeAction, "cog_delete.png", menuManager);
executeAction.setEnabled(false);
editAction.setEnabled(false);
newAction.setEnabled(false);
newFolderAction.setEnabled(false);
removeAction.setEnabled(false);
display = shell.getDisplay();
setupDnd();
if (tree.getItemCount() > 0) {
tree.setSelection(tree.getItems()[0]);
onTreeSelect();
}
/*
tree = new Tree( parent, SWT.BORDER );
tree.setHeaderVisible( true );
FormData d1 = new FormData();
d1.top = new FormAttachment( 0, 1 );
d1.left = new FormAttachment( 0, 1 );
d1.right = new FormAttachment( 100, -1 );
d1.bottom = new FormAttachment( 100, -1 );
tree.setLayoutData( d1 );
*/
/*
tree = new Tree( sashForm, SWT.BORDER );
*/
}
use of org.eclipse.swt.events.DisposeListener in project dbeaver by serge-rider.
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);
UIUtils.drawMessageOverControl(placeholder, e, "No Data", -10);
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, "Execute query (" + execQuery + ") or script (" + execScript + ") to see results", 20);
}
}
});
trackPresentationControl();
}
use of org.eclipse.swt.events.DisposeListener in project cubrid-manager by CUBRID.
the class FontGroup method createChangeControl.
/**
* create change color button
*
* @param parent the parent container
* @return button the instance of Button
*/
private Button createChangeControl(Composite parent) {
if (changeFontButton == null) {
changeFontButton = new Button(parent, SWT.PUSH);
}
if (changeButtonText != null) {
changeFontButton.setText(changeButtonText);
}
changeFontButton.addSelectionListener(new ChangeSelectListen());
changeFontButton.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
changeFontButton = null;
}
});
changeFontButton.setFont(parent.getFont());
return changeFontButton;
}
use of org.eclipse.swt.events.DisposeListener in project bndtools by bndtools.
the class AdvancedSearchDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Advanced Search");
setMessage("Perform a search for resource capabilities in the Repositories. Select the\ncapability namespace using the tab bar.");
Composite area = (Composite) super.createDialogArea(parent);
tabFolder = new TabFolder(area, SWT.TOP);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
PropertyChangeListener changeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateFromPanel();
}
};
final List<Image> images = new LinkedList<Image>();
for (Entry<String, SearchPanel> panelEntry : panelMap.entrySet()) {
String title = panelEntry.getKey();
SearchPanel panel = panelEntry.getValue();
Composite container = new Composite(tabFolder, SWT.NONE);
container.setLayout(new GridLayout(1, false));
Control control = panel.createControl(container);
GridData controlLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, true);
controlLayoutData.widthHint = 200;
control.setLayoutData(controlLayoutData);
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText(title);
item.setControl(container);
item.setData(panel);
Image image = panel.createImage(tabFolder.getDisplay());
if (image != null) {
images.add(image);
item.setImage(image);
}
panel.addPropertyChangeListener(changeListener);
}
tabFolder.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
for (Image image : images) {
if (!image.isDisposed())
image.dispose();
}
}
});
tabFolder.setSelection(activeTabIndex);
SearchPanel currentPanel = (SearchPanel) tabFolder.getItem(activeTabIndex).getData();
currentPanel.setFocus();
requirement = currentPanel.getRequirement();
tabFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeTabIndex = tabFolder.getSelectionIndex();
updateFromPanel();
getSelectedPanel().setFocus();
}
});
return area;
}
Aggregations