Search in sources :

Example 31 with Display

use of org.eclipse.swt.widgets.Display 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 32 with Display

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

the class InsertionIndicator method isLeftArrowMustBeRefreshed.

/**
     * DOC amaumont Comment method "isIntersect".
     * 
     * @param boundsPopupFromMapperShellOrigin
     * @return
     */
public boolean isLeftArrowMustBeRefreshed(Rectangle boundsPopupFromMapperShellOrigin) {
    Shell parentShell = tablesZoneViewParent.getShell();
    Display display = parentShell.getDisplay();
    Point positionFromMapperShellOrigin = display.map(leftArrowDraggingIndicator, parentShell, new Point(0, 0));
    Rectangle leftArrowDraggingIndicatorBounds = leftArrowDraggingIndicator.getBounds();
    Rectangle boundsFromPositionOrigin = new Rectangle(positionFromMapperShellOrigin.x - 4, positionFromMapperShellOrigin.y - 4, leftArrowDraggingIndicatorBounds.width + 8, leftArrowDraggingIndicatorBounds.height + 8);
    Rectangle rectangleIntersect = boundsFromPositionOrigin.intersection(boundsPopupFromMapperShellOrigin);
    int nPixelsCoveredByPopup = rectangleIntersect.width * rectangleIntersect.height;
    boolean response = false;
    if (nPixelsCoveredByPopup < this.lastNPixelsCovered) {
        response = true;
    }
    this.lastNPixelsCovered = nPixelsCoveredByPopup;
    return response;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Example 33 with Display

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

the class TalendPaletteViewer method filterPalette.

private void filterPalette(final Text text) {
    final List<Text> disposed = new ArrayList<Text>();
    final Display display = DisplayUtils.getDisplay();
    display.syncExec(new Runnable() {

        @Override
        public void run() {
            TalendPaletteViewer.this.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_APPSTARTING));
            prepareFilterPalette(text, disposed);
        }
    });
    if (!currentFilterText.equals(SEARCH_COMPONENT)) {
        ComponentPaletteUtilities.filterPalette(currentFilterText.trim());
    }
    filters.removeAll(disposed);
    display.asyncExec(new Runnable() {

        @Override
        public void run() {
            TalendPaletteViewer.this.setCursor(null);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) Display(org.eclipse.swt.widgets.Display)

Example 34 with Display

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

the class AbstractJobSettingsPage method save.

protected void save() {
    List<String> checkedObjects = new ArrayList<String>();
    List<IRepositoryViewObject> allProcess = null;
    try {
        allProcess = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS);
    } catch (PersistenceException e1) {
        ExceptionHandler.process(e1);
    }
    for (IRepositoryViewObject object : allProcess) {
        if (isStatUseProjectSetting(object)) {
            if (!checkedObjects.contains(object.getProperty().getId())) {
                checkedObjects.add(object.getProperty().getId());
                if (!checkedNodeObject.contains(object)) {
                    checkedNodeObject.add(object);
                }
            }
        }
    }
    List<IProcess2> allOpenedProcessList = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(getEditors());
    if (allOpenedProcessList != null) {
        for (int i = 0; i < allOpenedProcessList.size(); i++) {
            if (checkedObjects.contains(allOpenedProcessList.get(i).getProperty().getId())) {
                openedProcessList.add(allOpenedProcessList.get(i));
            }
        }
    }
    //
    final IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitor.beginTask(getTaskMessages(), (checkedNodeObject.size()) * 100);
            final Map<String, Set<String>> contextVars = DetectContextVarsUtils.detectByPropertyType(elem, true);
            // must init this
            addContextModel = false;
            if (!contextVars.isEmpty()) {
                // boolean showDialog = false;
                Set<String> contextSet = new HashSet<String>();
                for (String key : contextVars.keySet()) {
                    contextSet = contextVars.get(key);
                    break;
                }
                Connection connection = null;
                IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
                if (ptParam != null) {
                    IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
                    Object proValue = propertyElem.getValue();
                    if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
                        IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                        String value = (String) repositoryElem.getValue();
                        ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
                        connection = connectionItem.getConnection();
                        if (connection != null && connection.isContextMode()) {
                            addContextModel = true;
                        // ContextItem contextItem =
                        // ContextUtils.getContextItemById(connection.getContextId());
                        // for (IProcess process : openedProcessList) {
                        // Set<String> addedContext =
                        // ConnectionContextHelper.checkAndAddContextVariables(contextItem,
                        // contextSet, process.getContextManager(), false);
                        // if (addedContext != null && !addedContext.isEmpty()) {
                        // showDialog = true;
                        // break;
                        // }
                        // }
                        }
                    }
                }
                if (addContextModel) {
                    // if the context is not existed in job, will add or not.
                    Display disp = Display.getCurrent();
                    if (disp == null) {
                        disp = Display.getDefault();
                    }
                    if (disp != null) {
                        disp.syncExec(new Runnable() {

                            @Override
                            public void run() {
                                showContextAndCheck(contextVars);
                            }
                        });
                    } else {
                        showContextAndCheck(contextVars);
                    }
                }
            }
            monitor.worked(10);
            IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {

                @Override
                public void run(IProgressMonitor monitor) throws CoreException {
                    for (IRepositoryViewObject object : checkedNodeObject) {
                        saveProcess(object, addContextModel, contextVars, monitor);
                    }
                }
            };
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            try {
                ISchedulingRule schedulingRule = workspace.getRoot();
                workspace.run(workspaceRunnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
            } catch (CoreException e) {
                throw new InvocationTargetException(e);
            }
            monitor.done();
        }
    };
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {
        dialog.run(true, true, runnable);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ArrayList(java.util.ArrayList) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IElementParameter(org.talend.core.model.process.IElementParameter) HashSet(java.util.HashSet) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IWorkspace(org.eclipse.core.resources.IWorkspace) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Display(org.eclipse.swt.widgets.Display)

Example 35 with Display

use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.

the class TestMovePage method main.

public static void main(String[] args) {
    Display display = Display.getDefault();
    Shell shell = new Shell();
    shell.setLayout(new FillLayout());
    final Composite TabFolderComp = new Composite(shell, SWT.NONE);
    GridLayout layout = new GridLayout(1, true);
    layout.verticalSpacing = 1;
    TabFolderComp.setLayout(layout);
    for (int i = 0; i < 3; i++) {
        final Composite TabPageComp = new Composite(TabFolderComp, SWT.NONE);
        TabPageComp.setLayoutData(new GridData(GridData.FILL_BOTH));
        final GridLayout gridLayout = new GridLayout(1, true);
        gridLayout.verticalSpacing = 1;
        gridLayout.marginHeight = 1;
        gridLayout.marginRight = 1;
        gridLayout.marginWidth = 1;
        TabPageComp.setLayout(gridLayout);
        Button TabItemButton = new Button(TabPageComp, SWT.FLAT);
        GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
        gd.heightHint = 20;
        TabItemButton.setLayoutData(gd);
        final Composite TabItemComp = new Composite(TabPageComp, SWT.FLAT | SWT.CENTER | SWT.BORDER);
        TabItemComp.setLayoutData(new GridData(GridData.FILL_BOTH));
        TabItemButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent arg0) {
                boolean b = TabItemComp.getVisible();
                if (!b) {
                    TabPageComp.setLayoutData(new GridData(GridData.FILL_BOTH));
                } else {
                    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
                    gd.heightHint = 20;
                    TabPageComp.setLayoutData(gd);
                }
                TabItemComp.setVisible(!b);
                TabFolderComp.layout();
            }
        });
    }
    shell.setSize(50, 300);
    shell.layout();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FillLayout(org.eclipse.swt.layout.FillLayout) Display(org.eclipse.swt.widgets.Display)

Aggregations

Display (org.eclipse.swt.widgets.Display)485 Shell (org.eclipse.swt.widgets.Shell)184 Point (org.eclipse.swt.graphics.Point)76 Test (org.junit.Test)63 FillLayout (org.eclipse.swt.layout.FillLayout)62 Color (org.eclipse.swt.graphics.Color)52 Button (org.eclipse.swt.widgets.Button)50 Rectangle (org.eclipse.swt.graphics.Rectangle)48 GridLayout (org.eclipse.swt.layout.GridLayout)43 Composite (org.eclipse.swt.widgets.Composite)43 GridData (org.eclipse.swt.layout.GridData)39 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)32 Image (org.eclipse.swt.graphics.Image)32 Label (org.eclipse.swt.widgets.Label)32 SWT (org.eclipse.swt.SWT)29 InvocationTargetException (java.lang.reflect.InvocationTargetException)28 StyledText (org.eclipse.swt.custom.StyledText)24 Text (org.eclipse.swt.widgets.Text)24 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)23 Font (org.eclipse.swt.graphics.Font)23