Search in sources :

Example 21 with Display

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

the class DebugProcessTosComposite method runProcessContextChanged.

private void runProcessContextChanged(final PropertyChangeEvent evt) {
    String propName = evt.getPropertyName();
    Display dis = Display.getCurrent();
    if (dis == null) {
        dis = Display.getDefault();
    }
    if (ProcessMessageManager.PROP_MESSAGE_ADD.equals(propName) || ProcessMessageManager.PROP_DEBUG_MESSAGE_ADD.equals(propName)) {
        IProcessMessage psMess = (IProcessMessage) evt.getNewValue();
        if (errorMessMap.size() <= CorePlugin.getDefault().getPreferenceStore().getInt(ITalendCorePrefConstants.PREVIEW_LIMIT)) {
            if (!(LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL))) {
                getAllErrorMess(psMess);
            } else {
                addPerlMark(psMess);
            }
        }
        appendToConsole(psMess);
    } else if (ProcessMessageManager.PROP_MESSAGE_CLEAR.equals(propName)) {
        dis.asyncExec(new Runnable() {

            @Override
            public void run() {
                if (!consoleText.isDisposed()) {
                    //$NON-NLS-1$
                    consoleText.setText("");
                }
            }
        });
    } else if (RunProcessContext.PROP_MONITOR.equals(propName)) {
    // perfBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.TRACE_MONITOR.equals(propName)) {
    // traceBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
        dis.asyncExec(new Runnable() {

            @Override
            public void run() {
                if (isDisposed()) {
                    return;
                }
                boolean running = ((Boolean) evt.getNewValue()).booleanValue();
                setRunnable(!running);
                if (!killBtn.isDisposed() && killBtn != null) {
                    killBtn.setEnabled(running);
                }
                isRuning = false;
            // previousRow.setEnabled(running);
            // nextRow.setEnabled(running);
            // nextBreakPoint.setEnabled(running);
            }
        });
    }
}
Also used : IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Display(org.eclipse.swt.widgets.Display)

Example 22 with Display

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

the class AbstractMultiPageTalendEditor method updateRunJobContext.

protected void updateRunJobContext() {
    final JobContextManager manager = (JobContextManager) getProcess().getContextManager();
    if (manager.isModified()) {
        final Map<String, String> nameMap = manager.getNameMap();
        // gcui:add a progressDialog.
        Shell shell = null;
        Display display = PlatformUI.getWorkbench().getDisplay();
        if (display != null) {
            shell = display.getActiveShell();
        }
        if (shell == null) {
            display = Display.getCurrent();
            if (display == null) {
                display = Display.getDefault();
            }
            if (display != null) {
                shell = display.getActiveShell();
            }
        }
        ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            @Override
            public void run(final IProgressMonitor monitor) {
                //$NON-NLS-1$
                monitor.beginTask(Messages.getString("AbstractMultiPageTalendEditor_pleaseWait"), IProgressMonitor.UNKNOWN);
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
                        factory.executeRepositoryWorkUnit(new //$NON-NLS-1$
                        RepositoryWorkUnit<Object>(//$NON-NLS-1$
                        "..", //$NON-NLS-1$
                        this) {

                            @Override
                            protected void run() throws LoginException, PersistenceException {
                                try {
                                    IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
                                    Set<String> curContextVars = getCurrentContextVariables(manager);
                                    IProcess2 process2 = getProcess();
                                    String jobId = process2.getProperty().getId();
                                    IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
                                    List<IProcess2> processes = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
                                    // gcui:if nameMap is empty it do nothing.
                                    if (!nameMap.isEmpty()) {
                                        UpdateRunJobComponentContextHelper.updateItemRunJobComponentReference(factory, nameMap, jobId, curContextVars);
                                        UpdateRunJobComponentContextHelper.updateOpenedJobRunJobComponentReference(processes, nameMap, jobId, curContextVars);
                                    }
                                    // add for bug 9564
                                    List<IRepositoryViewObject> all = factory.getAll(ERepositoryObjectType.PROCESS, true);
                                    List<ProcessItem> allProcess = new ArrayList<ProcessItem>();
                                    for (IRepositoryViewObject repositoryObject : all) {
                                        Item item = repositoryObject.getProperty().getItem();
                                        if (item instanceof ProcessItem) {
                                            ProcessItem processItem = (ProcessItem) item;
                                            allProcess.add(processItem);
                                        }
                                    }
                                    UpdateRunJobComponentContextHelper.updateRefJobRunJobComponentContext(factory, allProcess, process2);
                                } catch (PersistenceException e) {
                                    // e.printStackTrace();
                                    ExceptionHandler.process(e);
                                }
                                manager.setModified(false);
                            }
                        });
                    }
                });
                monitor.done();
                if (monitor.isCanceled()) {
                    try {
                        //$NON-NLS-1$
                        throw new InterruptedException("Save Fail");
                    } catch (InterruptedException e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        };
        try {
            progressDialog.run(true, true, runnable);
        } catch (InvocationTargetException e1) {
            ExceptionHandler.process(e1);
        } catch (InterruptedException e1) {
            ExceptionHandler.process(e1);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) Shell(org.eclipse.swt.widgets.Shell) IEditorReference(org.eclipse.ui.IEditorReference) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) JobContextManager(org.talend.core.model.context.JobContextManager) Display(org.eclipse.swt.widgets.Display)

Example 23 with Display

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

the class AbstractMultiPageTalendEditor method init.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
     */
@Override
public void init(final IEditorSite site, IEditorInput editorInput) throws PartInitException {
    setSite(site);
    setInput(editorInput);
    if (!(editorInput instanceof JobEditorInput)) {
        return;
    }
    site.setSelectionProvider(new MultiPageTalendSelectionProvider(this));
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
    // Lock the process :
    IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
    final IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
    processEditorInput = (JobEditorInput) editorInput;
    final IProcess2 currentProcess = processEditorInput.getLoadedProcess();
    if (!currentProcess.isReadOnly()) {
        try {
            Property property = processEditorInput.getItem().getProperty();
            propertyInformation = new ArrayList(property.getInformations());
            property.eAdapters().add(dirtyListener);
            repFactory.lock(currentProcess);
            boolean locked = repFactory.getStatus(currentProcess) == ERepositoryStatus.LOCK_BY_USER;
            if (!locked) {
                setReadOnly(true);
            }
            revisionChanged = true;
        } catch (PersistenceException e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
        } catch (BusinessException e) {
            // Nothing to do
            ExceptionHandler.process(e);
        }
    } else {
        setReadOnly(true);
        Bundle bundle = FrameworkUtil.getBundle(AbstractMultiPageTalendEditor.class);
        final Display display = getSite().getShell().getDisplay();
        this.lockService = bundle.getBundleContext().registerService(EventHandler.class.getName(), new EventHandler() {

            @Override
            public void handleEvent(Event event) {
                String lockTopic = Constant.REPOSITORY_ITEM_EVENT_PREFIX + Constant.ITEM_LOCK_EVENT_SUFFIX;
                if (lockTopic.equals(event.getTopic())) {
                    Object o = event.getProperty(Constant.ITEM_EVENT_PROPERTY_KEY);
                    if (o != null && o instanceof Item) {
                        Item item = (Item) o;
                        String itemId = item.getProperty().getId();
                        if (itemId.equals(currentProcess.getId())) {
                            if (currentProcess.isReadOnly()) {
                                boolean readOnly = currentProcess.checkReadOnly();
                                boolean orginalReadOnlyStatus = designerEditor.isReadOnly();
                                setReadOnly(readOnly);
                                if (!readOnly) {
                                    display.asyncExec(new Runnable() {

                                        @Override
                                        public void run() {
                                            setFocus();
                                        }
                                    });
                                    if (orginalReadOnlyStatus == true) {
                                        // refresh to the given item version, nomally it is the latest
                                        // version,
                                        // means the editor/process will be refreshed to the latest version
                                        refreshProcess(item, false);
                                    }
                                    Property property = processEditorInput.getItem().getProperty();
                                    propertyInformation = new ArrayList(property.getInformations());
                                    property.eAdapters().add(dirtyListener);
                                }
                            }
                        }
                    }
                }
            }
        }, new Hashtable<String, String>(Collections.singletonMap(EventConstants.EVENT_TOPIC, //$NON-NLS-1$
        Constant.REPOSITORY_ITEM_EVENT_PREFIX + "*")));
        revisionChanged = true;
    }
    // setTitleImage(ImageProvider.getImage(getEditorTitleImage()));
    updateTitleImage(processEditorInput.getItem().getProperty());
    getSite().getWorkbenchWindow().getPartService().addPartListener(partListener);
}
Also used : Bundle(org.osgi.framework.Bundle) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) EventHandler(org.osgi.service.event.EventHandler) IRepositoryService(org.talend.repository.model.IRepositoryService) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) BusinessException(org.talend.commons.exception.BusinessException) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) Event(org.osgi.service.event.Event) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) Display(org.eclipse.swt.widgets.Display)

Example 24 with Display

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

the class AbstractProcessAction method checkUnLoadedNodeForProcess.

public void checkUnLoadedNodeForProcess(JobEditorInput fileEditorInput) {
    if (fileEditorInput == null || fileEditorInput.getLoadedProcess() == null) {
        return;
    }
    IProcess2 loadedProcess = fileEditorInput.getLoadedProcess();
    List<NodeType> unloadedNode = loadedProcess.getUnloadedNode();
    if (unloadedNode != null && !unloadedNode.isEmpty()) {
        String message = "Some Component are not loaded:\n";
        for (int i = 0; i < unloadedNode.size(); i++) {
            message = message + unloadedNode.get(i).getComponentName() + "\n";
        }
        if (!CommonsPlugin.isHeadless() && PlatformUI.isWorkbenchRunning()) {
            Display display = Display.getCurrent();
            if (display == null) {
                display = Display.getDefault();
            }
            if (display != null) {
                final Display tmpDis = display;
                final String tmpMess = message;
                display.syncExec(new Runnable() {

                    public void run() {
                        Shell shell = null;
                        final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                        if (activeWorkbenchWindow != null) {
                            shell = activeWorkbenchWindow.getShell();
                        } else {
                            if (tmpDis != null) {
                                shell = tmpDis.getActiveShell();
                            } else {
                                shell = new Shell();
                            }
                        }
                        MessageDialog.openWarning(shell, "Warning", tmpMess);
                    }
                });
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Shell(org.eclipse.swt.widgets.Shell) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IProcess2(org.talend.core.model.process.IProcess2) Display(org.eclipse.swt.widgets.Display)

Example 25 with Display

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

the class MapperUI method init.

public void init(MapperModel mapperModel) {
    // long time1 = System.currentTimeMillis();
    // CommandStack commandStack = new CommandStackForComposite(this.mapperUIParent);
    // mapperManager.setCommandStack(commandStack);
    final UIManager uiManager = mapperManager.getUiManager();
    final ExternalDbMapUiProperties uiProperties = uiManager.getUiProperties();
    addParentListeners(uiManager, uiProperties);
    final Display display = mapperUIParent.getDisplay();
    bgColorLinksZone = ColorProviderMapper.getColor(ColorInfo.COLOR_BACKGROUND_LINKS_ZONE);
    GridLayout parentLayout = new GridLayout(1, true);
    mapperUIParent.setLayout(parentLayout);
    addKeyListener(uiManager, display);
    addBackgroundRefreshLimiters(display);
    this.dropTargetOperationListener = new DropTargetOperationListener(mapperManager);
    dropTargetOperationListener.addControl(this.mapperUIParent.getShell());
    mainSashForm = new SashForm(mapperUIParent, SWT.SMOOTH | SWT.VERTICAL);
    GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
    mainSashForm.setLayoutData(mainSashFormGridData);
    datasFlowViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
    datasFlowViewSashForm.setBackgroundMode(SWT.INHERIT_FORCE);
    initBackgroundComponents();
    if (WindowSystem.isGTK()) {
        datasFlowViewSashForm.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
    }
    // dropTargetOperationListener.addControl(datasFlowViewSashForm);
    // datasFlowViewSashForm.addControlListener(new ControlListener() {
    //
    // public void controlMoved(ControlEvent e) {
    // }
    //
    // public void controlResized(ControlEvent e) {
    // createBgImages();
    // updateBackground(true, false);
    // }
    //
    // });
    /* Create the tabs */
    String dbmsId = null;
    if (mapperModel.getInputDataMapTables() != null && !mapperModel.getInputDataMapTables().isEmpty()) {
        InputTable input = mapperModel.getInputDataMapTables().get(0);
        if (input.getMetadataTable() != null) {
            dbmsId = input.getMetadataTable().getDbms();
        }
    }
    tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, mapperManager, dbmsId);
    createInputZoneWithTables(mapperModel, uiManager, display);
    createVarsZoneWithTables(mapperModel, display);
    createOutputZoneWithTables(mapperModel, uiManager, display);
    mapperManager.initInternalData();
    uiManager.parseAllExpressionsForAllTables();
    mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
    this.draggingInfosPopup = DraggingInfosPopup.getNewShell(this.mapperUIParent.getShell());
    configureZoneScrollBars(display);
    int[] weightsDatasFlowViewSashForm = uiProperties.getWeightsDatasFlowViewSashForm();
    datasFlowViewSashForm.setWeights(weightsDatasFlowViewSashForm.length != 0 ? weightsDatasFlowViewSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_DATAS_FLOW_SASH_FORM);
    int[] weightsMainSashForm = uiProperties.getWeightsMainSashForm();
    mainSashForm.setWeights(weightsMainSashForm.length != 0 ? weightsMainSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_MAIN_SASH_FORM);
    new FooterComposite(this.mapperUIParent, SWT.NONE, mapperManager);
    if (WindowSystem.isGTK()) {
        // resize especially for GTK
        new AsynchronousThreading(1000, false, display, new Runnable() {

            public void run() {
                resizeNotMinimizedTablesAtExpandedSize(display);
                mapperUIParent.getShell().layout();
            }
        }).start();
    }
    if (WindowSystem.isWIN32()) {
        List<DataMapTableView> inputsTablesView = uiManager.getInputsTablesView();
        for (DataMapTableView view : inputsTablesView) {
            ((InputDataMapTableView) view).refreshLabelForJoinDropDown();
        }
    }
    selectFirstInOutTablesView();
    mapperManager.getUiManager().refreshSqlExpression();
}
Also used : TabFolderEditors(org.talend.designer.dbmap.ui.tabs.TabFolderEditors) FooterComposite(org.talend.designer.dbmap.ui.footer.FooterComposite) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) UIManager(org.talend.designer.dbmap.managers.UIManager) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) ExternalDbMapUiProperties(org.talend.designer.dbmap.external.data.ExternalDbMapUiProperties) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading) SashForm(org.eclipse.swt.custom.SashForm) InputTable(org.talend.designer.dbmap.model.table.InputTable) GridLayout(org.eclipse.swt.layout.GridLayout) DropTargetOperationListener(org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener) GridData(org.eclipse.swt.layout.GridData) 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