Search in sources :

Example 16 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project azure-tools-for-java by Microsoft.

the class DropDownHandler method pullDropdown.

public void pullDropdown(Event event) {
    Widget widget = event.widget;
    if (widget instanceof ToolItem) {
        ToolItem toolItem = (ToolItem) widget;
        Listener[] listeners = toolItem.getListeners(SWT.Selection);
        if (listeners.length > 0) {
            Listener listener = listeners[0];
            Event eve = new Event();
            eve.type = SWT.Selection;
            eve.widget = toolItem;
            eve.detail = SWT.DROP_DOWN;
            eve.x = toolItem.getBounds().x;
            eve.y = toolItem.getBounds().height;
            listener.handleEvent(eve);
        }
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Widget(org.eclipse.swt.widgets.Widget) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Event(org.eclipse.swt.widgets.Event) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 17 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.

the class DataMapTableView method createComponents.

private void createComponents() {
    final Display display = this.getDisplay();
    if (WindowSystem.isGTK()) {
        Color systemColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
        setBackground(new Color(display, systemColor.getRed(), systemColor.getGreen(), systemColor.getBlue()));
        setBackgroundMode(SWT.INHERIT_NONE);
    } else {
        Color listBackground = display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
        this.setBackground(listBackground);
    }
    GridLayout mainLayout = new GridLayout();
    int marginMainLayout = 0;
    mainLayout.marginLeft = marginMainLayout;
    mainLayout.marginRight = marginMainLayout;
    mainLayout.marginTop = marginMainLayout;
    mainLayout.marginBottom = marginMainLayout;
    mainLayout.marginWidth = marginMainLayout;
    mainLayout.marginHeight = marginMainLayout;
    int spacingMainLayout = 2;
    mainLayout.horizontalSpacing = spacingMainLayout;
    mainLayout.verticalSpacing = spacingMainLayout;
    setLayout(mainLayout);
    headerComposite = new Composite(this, SWT.NONE);
    GridData headerGridData = new GridData(GridData.FILL_HORIZONTAL);
    headerGridData.heightHint = getHeaderHeight();
    headerComposite.setLayoutData(headerGridData);
    GridLayout headerLayout = new GridLayout();
    int margin = 0;
    headerLayout.marginLeft = 3;
    headerLayout.marginRight = margin;
    headerLayout.marginTop = margin;
    headerLayout.marginBottom = margin;
    headerLayout.marginWidth = margin;
    headerLayout.marginHeight = margin;
    int spacing = 2;
    headerLayout.horizontalSpacing = spacing;
    headerLayout.verticalSpacing = spacing;
    headerComposite.setLayout(headerLayout);
    nameLabel = new Label(headerComposite, SWT.NONE);
    nameLabel.setFont(FontProviderMapper.getFont(FontInfo.FONT_SYSTEM_BOLD));
    nameLabel.setText(getTitle());
    nameLabel.setToolTipText(getTitle());
    nameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL));
    int rightStyle = toolbarNeedToHaveRightStyle() ? SWT.RIGHT : SWT.NONE;
    toolBarActions = new ToolBar(headerComposite, SWT.FLAT | rightStyle);
    toolBarActions.setFont(FontProviderMapper.getFont(FontInfo.FONT_SYSTEM));
    if (addToolItems()) {
        addToolItemSeparator();
    }
    minimizeButton = new ToolItem(toolBarActions, SWT.PUSH);
    realToolbarSize.x += 45;
    Point sizeToolBar = toolBarActions.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    GridData gridDataToolbar = new GridData();
    if (toolbarNeedToHaveRightStyle() && WindowSystem.isWIN32()) {
        if (realToolbarSize != null) {
            gridDataToolbar.widthHint = realToolbarSize.x;
        }
    }
    if (WindowSystem.isGTK()) {
        gridDataToolbar.heightHint = 26;
    } else {
    // gridDataToolbar.heightHint = 30; // Win32
    }
    if (WindowSystem.isGTK()) {
        toolBarActions.setLayoutData(gridDataToolbar);
    } else {
        toolBarActions.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL));
    }
    headerLayout.numColumns = headerComposite.getChildren().length;
    centerComposite = new Composite(this, SWT.NONE);
    GridData centerData = new GridData(GridData.FILL_BOTH);
    centerComposite.setLayoutData(centerData);
    GridLayout centerLayout = new GridLayout();
    int marginCenterLayout = 0;
    centerLayout.marginLeft = marginCenterLayout;
    centerLayout.marginRight = marginCenterLayout;
    centerLayout.marginTop = marginCenterLayout;
    centerLayout.marginBottom = marginCenterLayout;
    centerLayout.marginWidth = marginCenterLayout;
    centerLayout.marginHeight = marginCenterLayout;
    int spacingCenterLayout = 2;
    centerLayout.horizontalSpacing = spacingCenterLayout;
    centerLayout.verticalSpacing = spacingCenterLayout;
    centerComposite.setLayout(centerLayout);
    initTableFilters(centerComposite);
    createTableForColumns(centerComposite);
    new DragNDrop(mapperManager, tableForEntries, true, true);
    Composite footerComposite = new Composite(this, SWT.NONE);
    GridData footerGridData = new GridData(10, 2);
    footerComposite.setLayoutData(footerGridData);
    headerComposite.moveAbove(nameLabel);
    if (WindowSystem.isGTK()) {
        sizeToolBar = toolBarActions.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        gridDataToolbar.widthHint = sizeToolBar.x + 20;
        headerComposite.layout();
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) DragNDrop(org.talend.designer.dbmap.ui.dnd.DragNDrop) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) ToolBar(org.eclipse.swt.widgets.ToolBar) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) ToolItem(org.eclipse.swt.widgets.ToolItem) Display(org.eclipse.swt.widgets.Display)

Example 18 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.

the class DataMapTableView method createFiltersToolItems.

protected void createFiltersToolItems() {
    ToolItem addFilterButton = new ToolItem(toolBarActions, SWT.PUSH);
    //$NON-NLS-1$
    addFilterButton.setToolTipText(Messages.getString("DataMapTableView.buttonTooltip.addFilterRow"));
    addFilterButton.setImage(ImageProviderMapper.getImage(ImageInfo.ADD_FILTER_ICON));
    // /////////////////////////////////////////////////////////////////
    if (addFilterButton != null) {
        addFilterButton.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            @Override
            public void widgetSelected(SelectionEvent e) {
                onFiltersToolItemsSelected(e, getTableViewerCreatorForWhereFilters(), FilterTableEntry.WHERE_FILTER);
            }
        });
    }
}
Also used : SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)

Example 19 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.

the class InputDataMapTableView method addToolItems.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView#addEntriesActionsComponents()
     */
@Override
protected boolean addToolItems() {
    // DROP DOWN
    dropDownItem = new ToolItem(toolBarActions, SWT.DROP_DOWN | SWT.BORDER);
    if (WindowSystem.isGTK()) {
        refreshLabelForJoinDropDown();
    }
    dropDownItem.addSelectionListener(new DropDownSelectionListener());
    return true;
}
Also used : ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 20 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.

the class MultiSchemasUI method createMenuBar.

private void createMenuBar(final ToolBar menuBar) {
    ToolItem pullDownButton = new ToolItem(menuBar, SWT.PUSH);
    // Image hoverImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_RENDERED_VIEW_MENU);
    //$NON-NLS-1$
    Image hoverImage = PlatformUI.getWorkbench().getSharedImages().getImage("IMG_LCL_RENDERED_VIEW_MENU");
    pullDownButton.setDisabledImage(hoverImage);
    pullDownButton.setImage(hoverImage);
    pullDownButton.setToolTipText("Menu");
    pullDownButton.setWidth(5);
    //$NON-NLS-1$
    MenuManager menuManager = new MenuManager("MultiSchema");
    columnAction = new SchameDetailsColumnAction(schemaDetailsViewer);
    columnAction.setChecked(!ExternalMultiSchemasUIProperties.isSchemaDetailsModel());
    menuManager.add(columnAction);
    propertyAction = new SchameDetailsPropertyAction(schemaDetailsViewer);
    propertyAction.setChecked(ExternalMultiSchemasUIProperties.isSchemaDetailsModel());
    menuManager.add(propertyAction);
    final Menu aMenu = menuManager.createContextMenu(menuBar.getParent());
    pullDownButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Point toolbarSize = menuBar.getSize();
            toolbarSize = menuBar.toDisplay(0, toolbarSize.y);
            aMenu.setLocation(toolbarSize);
            aMenu.setVisible(true);
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

ToolItem (org.eclipse.swt.widgets.ToolItem)112 SelectionEvent (org.eclipse.swt.events.SelectionEvent)89 ToolBar (org.eclipse.swt.widgets.ToolBar)85 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)79 GridData (org.eclipse.swt.layout.GridData)62 Composite (org.eclipse.swt.widgets.Composite)50 GridLayout (org.eclipse.swt.layout.GridLayout)47 Image (org.eclipse.swt.graphics.Image)28 DisposeEvent (org.eclipse.swt.events.DisposeEvent)24 DisposeListener (org.eclipse.swt.events.DisposeListener)24 Label (org.eclipse.swt.widgets.Label)21 Cursor (org.eclipse.swt.graphics.Cursor)20 TableViewer (org.eclipse.jface.viewers.TableViewer)16 SelectionListener (org.eclipse.swt.events.SelectionListener)14 Point (org.eclipse.swt.graphics.Point)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 SashForm (org.eclipse.swt.custom.SashForm)10 FillLayout (org.eclipse.swt.layout.FillLayout)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9