Search in sources :

Example 41 with DisposeListener

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);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Program(org.eclipse.swt.program.Program) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ImageData(org.eclipse.swt.graphics.ImageData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu)

Example 42 with DisposeListener

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 );
*/
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Action(org.eclipse.jface.action.Action) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuManager(org.eclipse.jface.action.MenuManager) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Separator(org.eclipse.jface.action.Separator)

Example 43 with DisposeListener

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();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SQLEditor(org.jkiss.dbeaver.ui.editors.sql.SQLEditor) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) FontData(org.eclipse.swt.graphics.FontData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData)

Example 44 with DisposeListener

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;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Button(org.eclipse.swt.widgets.Button) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 45 with DisposeListener

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;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) PropertyChangeListener(java.beans.PropertyChangeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) Image(org.eclipse.swt.graphics.Image) DisposeEvent(org.eclipse.swt.events.DisposeEvent) LinkedList(java.util.LinkedList) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

DisposeListener (org.eclipse.swt.events.DisposeListener)118 DisposeEvent (org.eclipse.swt.events.DisposeEvent)117 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 GridData (org.eclipse.swt.layout.GridData)38 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)33 Image (org.eclipse.swt.graphics.Image)29 Cursor (org.eclipse.swt.graphics.Cursor)26 ToolBar (org.eclipse.swt.widgets.ToolBar)25 ToolItem (org.eclipse.swt.widgets.ToolItem)23 Composite (org.eclipse.swt.widgets.Composite)19 Color (org.eclipse.swt.graphics.Color)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 Point (org.eclipse.swt.graphics.Point)16 ControlEvent (org.eclipse.swt.events.ControlEvent)11 SelectionListener (org.eclipse.swt.events.SelectionListener)10 Control (org.eclipse.swt.widgets.Control)10 TextLayout (org.eclipse.swt.graphics.TextLayout)9 Listener (org.eclipse.swt.widgets.Listener)9 ControlListener (org.eclipse.swt.events.ControlListener)8 MouseEvent (org.eclipse.swt.events.MouseEvent)8