Search in sources :

Example 16 with ToolBar

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

the class JobHierarchyViewPart method createPartControl.

@Override
public void createPartControl(Composite container) {
    fParent = container;
    addResizeListener(fParent);
    fPagebook = new PageBook(container, SWT.NONE);
    // page 1 of page book (no hierarchy label)
    fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
    fNoHierarchyShownLabel.setText(showEmptyLabel);
    // page 2 of page book (viewers)
    fTypeMethodsSplitter = new SashForm(fPagebook, SWT.VERTICAL);
    fTypeMethodsSplitter.setVisible(false);
    fTypeViewerViewForm = new ViewForm(fTypeMethodsSplitter, SWT.NONE);
    Control typeViewerControl = createTypeViewerControl(fTypeViewerViewForm);
    fTypeViewerViewForm.setContent(typeViewerControl);
    dependencyViewerViewForm = new ViewForm(fTypeMethodsSplitter, SWT.NONE);
    fTypeMethodsSplitter.setWeights(new int[] { 65, 35 });
    Control dependencyViewerPart = createMethodViewerControl(dependencyViewerViewForm);
    dependencyViewerViewForm.setContent(dependencyViewerPart);
    dependencyViewerPaneLabel = new CLabel(dependencyViewerViewForm, SWT.NONE);
    dependencyViewerViewForm.setTopLeft(dependencyViewerPaneLabel);
    ToolBar methodViewerToolBar = new ToolBar(dependencyViewerViewForm, SWT.FLAT | SWT.WRAP);
    dependencyViewerViewForm.setTopCenter(methodViewerToolBar);
    initDragAndDrop();
    MenuManager menu = new MenuManager();
    menu.add(focusOnTypeAction);
    fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
    fPagebook.showPage(fNoHierarchyShownLabel);
    int layout;
    try {
        layout = fDialogSettings.getInt(DIALOGSTORE_VIEWLAYOUT);
        if (layout < 0 || layout > 3) {
            layout = VIEW_LAYOUT_AUTOMATIC;
        }
    } catch (NumberFormatException e) {
        layout = VIEW_LAYOUT_AUTOMATIC;
    }
    // force the update
    fCurrentLayout = -1;
    // will fill the main tool bar
    setViewLayout(layout);
    // set the filter menu items
    IActionBars actionBars = getViewSite().getActionBars();
    IMenuManager viewMenu = actionBars.getMenuManager();
    // for (int i = 0; i < fViewActions.length; i++) {
    // ToggleViewAction action = fViewActions[i];
    // viewMenu.add(action);
    // action.setEnabled(false);
    // }
    // viewMenu.add(new Separator());
    // IMenuManager layoutSubMenu = new MenuManager(TypeHierarchyMessages.TypeHierarchyViewPart_layout_submenu);
    //$NON-NLS-1$
    IMenuManager layoutSubMenu = new MenuManager(Messages.getString("FocusOnJobAction.TypeHierarchyViewPart_layout_submenu"));
    viewMenu.add(layoutSubMenu);
    for (int i = 0; i < fToggleOrientationActions.length; i++) {
        layoutSubMenu.add(fToggleOrientationActions[i]);
    }
    viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    // selection provider
    int nHierarchyViewers = fAllViewers.length;
    StructuredViewer[] trackedViewers = new StructuredViewer[nHierarchyViewers + 1];
    for (int i = 0; i < nHierarchyViewers; i++) {
        trackedViewers[i] = fAllViewers[i];
    }
    trackedViewers[nHierarchyViewers] = dependencyViewer;
    fSelectionProviderMediator = new SelectionProviderMediator(trackedViewers, getCurrentViewer());
    getSite().setSelectionProvider(fSelectionProviderMediator);
    ActionGroup[] actionGroups = new ActionGroup[] { new JobActionGroup() };
    fActionGroups = new CompositeActionGroup(actionGroups);
    fActionGroups.fillActionBars(actionBars);
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) CompositeActionGroup(org.eclipse.jdt.internal.ui.actions.CompositeActionGroup) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) SelectionProviderMediator(org.eclipse.jdt.internal.ui.viewsupport.SelectionProviderMediator) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) ViewForm(org.eclipse.swt.custom.ViewForm) Control(org.eclipse.swt.widgets.Control) PageBook(org.eclipse.ui.part.PageBook) ActionGroup(org.eclipse.ui.actions.ActionGroup) CompositeActionGroup(org.eclipse.jdt.internal.ui.actions.CompositeActionGroup) ToolBar(org.eclipse.swt.widgets.ToolBar) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) IActionBars(org.eclipse.ui.IActionBars) Separator(org.eclipse.jface.action.Separator)

Example 17 with ToolBar

use of org.eclipse.swt.widgets.ToolBar 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 ToolBar

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

the class MultiSchemasUI method createCardComposite.

private void createCardComposite(Composite parent) {
    Composite cardComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cardComposite.setLayout(layout);
    GridData layoutData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    cardComposite.setLayoutData(layoutData);
    final ToolBar menuBar = new ToolBar(cardComposite, SWT.FLAT | SWT.NO_BACKGROUND);
    GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.TOP).span(2, 1).applyTo(menuBar);
    createMenuBar(menuBar);
    cardText = new LabelledText(cardComposite, "Cardinality");
    layoutData = new GridData();
    layoutData.minimumWidth = 90;
    layoutData.widthHint = 90;
    cardText.getTextControl().setLayoutData(layoutData);
    cardText.setEnabled(false);
}
Also used : LabelledText(org.talend.commons.ui.swt.formtools.LabelledText) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) CommandStackForComposite(org.talend.commons.ui.command.CommandStackForComposite) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar)

Example 19 with ToolBar

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

the class ScdSection method createToolbar.

/**
     * DOC chuang Comment method "createToolbar".
     * 
     * @param headerComposite
     */
protected void createToolbar(Composite headerComposite) {
    toolBar = new ToolBar(headerComposite, SWT.FLAT | SWT.RIGHT | SWT.NONE);
    addEntryItem = new ToolItem(toolBar, SWT.PUSH);
    addEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
    toolBar.setBackground(SWTResourceManager.getColor(IColorConstants.YELLOW));
    removeEntryItem = new ToolItem(toolBar, SWT.PUSH);
    removeEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.MINUS_ICON)));
    // removeEntryItem.setBackground(SWTResourceManager.getColor(IColorConstants.YELLOW));
    moveUpEntryItem = new ToolItem(toolBar, SWT.PUSH);
    moveUpEntryItem.setImage(ImageProvider.getImage(EImage.UP_ICON));
    moveDownEntryItem = new ToolItem(toolBar, SWT.PUSH);
    moveDownEntryItem.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
    addToolbarListener();
}
Also used : ToolBar(org.eclipse.swt.widgets.ToolBar) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 20 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project cubrid-manager by CUBRID.

the class BrokerConfigEditorPart method createToolBarComp.

/**
	 * Create the toolbar composition.
	 *
	 * @param parent
	 */
public void createToolBarComp(Composite parent) {
    final Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    comp.setLayoutData(gridData);
    final GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = -1;
    comp.setLayout(layout);
    final ToolBar toolbar = new ToolBar(comp, SWT.LEFT_TO_RIGHT | SWT.FLAT);
    toolbar.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    // Show/hide of the history pane
    saveConfItem = new ToolItem(toolbar, SWT.PUSH);
    saveConfItem.setImage(getImage("icons/queryeditor/file_save.png"));
    saveConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveItemLabel);
    saveConfItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // check whether contains duplicate property name
            String errMsg = editorComp.validate();
            if (isNotBlank(errMsg)) {
                openErrorBox(errMsg);
                return;
            }
            if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveConfirm)) {
                return;
            }
            saveData();
        }
    });
    // Show/hide of the history pane
    saveAsConfItem = new ToolItem(toolbar, SWT.PUSH);
    saveAsConfItem.setImage(getImage("icons/queryeditor/file_saveas.png"));
    saveAsConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveAsItemLabel);
    saveAsConfItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // Check whether contains duplicate property or broker name
            String errMsg = editorComp.validate();
            if (isNotBlank(errMsg)) {
                openErrorBox(errMsg);
                return;
            }
            if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveAsConfirm)) {
                return;
            }
            final FileDialog dialog = new FileDialog(getSite().getShell(), SWT.OPEN | SWT.MULTI);
            dialog.setFilterPath(PersistUtils.getPreferenceValue(PLUGIN_ID, BrokerConfOpenFileDialog.CUBRIDBROKERCONFPATH));
            dialog.setText(Messages.cubridBrokerConfEditorSaveAsDialogTitle);
            dialog.setFilterExtensions(new String[] { "*.conf" });
            dialog.setOverwrite(false);
            String path = dialog.open();
            File saveAsFile = null;
            if (path == null) {
                return;
            }
            if (!path.endsWith(".conf")) {
                path += ".conf";
            }
            saveAsFile = new File(path);
            BrokerConfig brokerConf = editorComp.getBrokerConfig();
            String contents = persistUtil.readBrokerConfig(brokerConf);
            try {
                persistUtil.writeBrokerConfig(saveAsFile, charset, contents);
                openInformationBox(Messages.titleSuccess, Messages.cubridBrokerConfEditorSaveSucessMsg);
                setDirty(false);
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
                openErrorBox(e.getMessage());
            }
        }
    });
    new ToolItem(toolbar, SWT.SEPARATOR);
    addPropItem = new ToolItem(toolbar, SWT.PUSH);
    addPropItem.setImage(getImage("icons/queryeditor/table_record_insert.png"));
    addPropItem.setToolTipText(Messages.cubridBrokerConfEditorAddPropItemLabel);
    addPropItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editorComp.addPropData();
        }
    });
    deletePropItem = new ToolItem(toolbar, SWT.PUSH);
    deletePropItem.setImage(getImage("icons/queryeditor/table_record_delete.png"));
    deletePropItem.setToolTipText(Messages.cubridBrokerConfEditorDeletePropItemLabel);
    deletePropItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editorComp.deletePropData();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUITool.createGridData(com.cubrid.common.ui.spi.util.CommonUITool.createGridData) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) BrokerConfOpenFileDialog(com.cubrid.common.ui.common.dialog.BrokerConfOpenFileDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) ToolItem(org.eclipse.swt.widgets.ToolItem) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

ToolBar (org.eclipse.swt.widgets.ToolBar)92 ToolItem (org.eclipse.swt.widgets.ToolItem)85 SelectionEvent (org.eclipse.swt.events.SelectionEvent)76 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)68 GridData (org.eclipse.swt.layout.GridData)63 GridLayout (org.eclipse.swt.layout.GridLayout)50 Composite (org.eclipse.swt.widgets.Composite)48 Image (org.eclipse.swt.graphics.Image)27 DisposeEvent (org.eclipse.swt.events.DisposeEvent)26 DisposeListener (org.eclipse.swt.events.DisposeListener)26 Cursor (org.eclipse.swt.graphics.Cursor)22 Label (org.eclipse.swt.widgets.Label)22 TableViewer (org.eclipse.jface.viewers.TableViewer)18 SashForm (org.eclipse.swt.custom.SashForm)11 SelectionListener (org.eclipse.swt.events.SelectionListener)10 FillLayout (org.eclipse.swt.layout.FillLayout)10 ArrayList (java.util.ArrayList)9 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)9 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)9 KeyAdapter (org.eclipse.swt.events.KeyAdapter)9