Search in sources :

Example 66 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project tdi-studio-se by Talend.

the class ProcessComposite method initGraphicComponents.

/**
     * DOC amaumont Comment method "initGraphicComponents".
     * 
     * @param parent
     */
private void initGraphicComponents(Composite parent) {
    setExpandHorizontal(true);
    setExpandVertical(true);
    this.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    FormData layouData = new FormData();
    layouData.left = new FormAttachment(0, 0);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 0);
    layouData.bottom = new FormAttachment(100, 0);
    setLayoutData(layouData);
    this.setLayout(new FormLayout());
    final Composite panel = new Composite(this, SWT.NONE);
    setContent(panel);
    // panel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_RED));
    FormLayout layout2 = new FormLayout();
    layout2.marginWidth = 5 + 2;
    layout2.marginHeight = 4;
    layout2.spacing = 6 + 1;
    panel.setLayout(layout2);
    GridData data;
    GridLayout layout = new GridLayout();
    // panel.setLayout(layout);
    // Splitter
    // sash = new SashForm(this, SWT.HORIZONTAL | SWT.SMOOTH);
    // sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    //
    // layout = new GridLayout();
    // sash.setLayout(layout);
    //
    // // group Button
    // // qli,see the feature 6366.
    //
    // Composite buttonComposite = new Composite(sash, SWT.ERROR);
    // buttonComposite.setLayout(new GridLayout());
    //
    // moveButton = new Button(buttonComposite, SWT.PUSH);
    //        moveButton.setText("<<"); //$NON-NLS-1$
    //        moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext")); //$NON-NLS-1$
    //
    // final GridData layoutData = new GridData();
    // layoutData.verticalAlignment = GridData.CENTER;
    // layoutData.horizontalAlignment = GridData.CENTER;
    // layoutData.grabExcessHorizontalSpace = true;
    // layoutData.grabExcessVerticalSpace = true;
    // moveButton.setLayoutData(layoutData);
    // Group execution
    Group execGroup = new Group(panel, SWT.NONE);
    //$NON-NLS-1$
    execGroup.setText(Messages.getString("ProcessComposite.execGroup"));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    execGroup.setLayout(layout);
    FormData layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 0);
    layouDatag.right = new FormAttachment(100, 0);
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    execGroup.setLayoutData(layouDatag);
    // leftTabFolder = new CTabFolder(this, SWT.BORDER);
    // leftTabFolder.setSimple(false);
    // //
    // leftTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    // //
    // // // Group context
    // //
    // CTabItem contextTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        contextTabItem.setText(Messages.getString("ProcessComposite.contextTab")); //$NON-NLS-1$
    // // contextComposite = new ProcessContextComposite(this, SWT.NONE);
    // // contextComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // // contextTabItem.setControl(contextComposite);
    // //
    // Composite targetExecutionComposite = createTargetExecutionComposite(leftTabFolder);
    // targetExecutionComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // //
    // targetExecutionTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        targetExecutionTabItem.setText(Messages.getString("ProcessComposite.targetExecutionTab")); //$NON-NLS-1$
    // targetExecutionTabItem.setToolTipText(Messages.getString("ProcessComposite.targetExecutionTabTooltipAvailable"));
    // targetExecutionTabItem.setControl(targetExecutionComposite);
    // //
    // // // Job Run VM Arguments Tab if language is java.
    // if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
    // jobVMTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //            jobVMTabItem.setText(Messages.getString("ProcessComposite.JVMTab")); //$NON-NLS-1$
    // argumentsComposite = new Composite(leftTabFolder, SWT.NONE);
    // argumentsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // GridLayout gridLayoutArguments = new GridLayout(1, false);
    // argumentsComposite.setLayout(gridLayoutArguments);
    // argumentsViewer = new JobVMArgumentsComposite("vmarguments", Messages
    //                    .getString("RunProcessPreferencePage.vmArgument"), //$NON-NLS-1$
    // argumentsComposite);
    // // argumentsViewer.setEnabled(false, argumentsComposite);
    // jobVMTabItem.setControl(argumentsComposite);
    // }
    ScrolledComposite execScroll = new ScrolledComposite(execGroup, SWT.V_SCROLL | SWT.H_SCROLL);
    execScroll.setExpandHorizontal(true);
    execScroll.setExpandVertical(true);
    execScroll.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite execContent = new Composite(execScroll, SWT.NONE);
    layout = new GridLayout();
    execContent.setLayout(new FormLayout());
    execScroll.setContent(execContent);
    Composite execHeader = new Composite(execContent, SWT.NONE);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 7;
    formLayout.marginHeight = 4;
    formLayout.spacing = 7;
    execHeader.setLayout(formLayout);
    FormData layoutData = new FormData();
    layoutData.left = new FormAttachment(0, 0);
    layoutData.right = new FormAttachment(100, 0);
    layoutData.top = new FormAttachment(0, 0);
    layoutData.bottom = new FormAttachment(0, 50);
    // new GridData(GridData.FILL_HORIZONTAL)
    execHeader.setLayoutData(layoutData);
    // qli
    // see the feature 6366
    run = new Button(execHeader, SWT.PUSH);
    // itemDropDown = new ToolItem(toolBar, SWT.ARROW);
    //$NON-NLS-1$//$NON-NLS-2$
    run.setText(" " + Messages.getString("ProcessComposite.exec"));
    run.setData(ProcessView.EXEC_ID);
    //$NON-NLS-1$
    run.setToolTipText(Messages.getString("ProcessComposite.execHint"));
    run.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    // final Menu menu = new Menu(execHeader);
    run.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            execRun();
        }
    });
    // Run
    // final MenuItem menuItem1 = new MenuItem(menu, SWT.PUSH);
    //        menuItem1.setText(" " + Messages.getString("ProcessComposite.exec"));//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
    // menuItem1.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    // menuItem1.setData(ProcessView.EXEC_ID);
    // menuItem1.addSelectionListener(new SelectionAdapter() {
    //
    // public void widgetSelected(SelectionEvent event) {
    // if (!itemDropDown.getData().equals(ProcessView.PAUSE_ID) &&
    // !itemDropDown.getData().equals(ProcessView.RESUME_ID)) {
    // itemDropDown.setText(menuItem1.getText());
    // itemDropDown.setData(ProcessView.EXEC_ID);
    // itemDropDown.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    //                    itemDropDown.setToolTipText(Messages.getString("ProcessComposite.execHint"));//$NON-NLS-1$
    // toolBar.getParent().layout();
    // }
    // }
    // });
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    // }
    if (processContext == null) {
        run.setEnabled(false);
    }
    // toolBar.setEnabled(false);
    FormData formData = new FormData();
    // see the feature 6366,qli comment.
    // make a judge when the text change in diffrent languages.
    Point debugSize = null;
    Point execSize = null;
    formData.left = new FormAttachment(0);
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // // set debug text to judge size
    // itemDropDown.setText(debugMenuItem.getText());
    // debugSize = computeSize(itemDropDown.getText());
    //
    // // set exec text to judge size
    // itemDropDown.setText(menuItem1.getText());
    // execSize = computeSize(itemDropDown.getText());
    // if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(0, debugSize.x + 70);
    // } else {
    // formData.right = new FormAttachment(0, execSize.x + 70);
    // }
    // } else {
    // set exec text to judge size
    execSize = computeSize(run.getText());
    formData.right = new FormAttachment(0, execSize.x + 70);
    formData.height = 30;
    // }
    run.setLayoutData(formData);
    killBtn = new Button(execHeader, SWT.PUSH);
    //$NON-NLS-1$
    killBtn.setText(Messages.getString("ProcessComposite.kill"));
    //$NON-NLS-1$
    killBtn.setToolTipText(Messages.getString("ProcessComposite.killHint"));
    killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
    setButtonLayoutData(killBtn);
    killBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(run, 0, SWT.TOP);
    formData.left = new FormAttachment(run, 0, SWT.RIGHT);
    // qli modified to fix the bug "7302".
    Point killSize = computeSize(killBtn.getText());
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // if ((killSize.x > debugSize.x) && (killSize.x > execSize.x)) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, debugSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // } else {
    // if (killSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // }
    formData.right = new FormAttachment(run, 30 + 70, SWT.RIGHT);
    formData.height = 30;
    killBtn.setLayoutData(formData);
    // saveJobBeforeRunButton = new Button(execHeader, SWT.CHECK);
    //        saveJobBeforeRunButton.setText(Messages.getString("ProcessComposite.saveBeforeRun")); //$NON-NLS-1$
    //        saveJobBeforeRunButton.setToolTipText(Messages.getString("ProcessComposite.saveBeforeRunHint")); //$NON-NLS-1$
    // // saveJobBeforeRunButton.setEnabled(false);
    // saveJobBeforeRunButton.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSAVEBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // saveJobBeforeRunButton.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(toolBar, 0, SWT.LEFT);
    // saveJobBeforeRunButton.setLayoutData(formData);
    // clearBeforeExec = new Button(execHeader, SWT.CHECK);
    //        clearBeforeExec.setText(Messages.getString("ProcessComposite.clearBefore")); //$NON-NLS-1$
    //        clearBeforeExec.setToolTipText(Messages.getString("ProcessComposite.clearBeforeHint")); //$NON-NLS-1$
    // // clearBeforeExec.setEnabled(false);
    // clearBeforeExec.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISCLEARBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // clearBeforeExec.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(saveJobBeforeRunButton, 0, SWT.RIGHT);
    // clearBeforeExec.setLayoutData(formData);
    //
    // watchBtn = new Button(execHeader, SWT.CHECK);
    //        watchBtn.setText(Messages.getString("ProcessComposite.execTime")); //$NON-NLS-1$
    //        watchBtn.setToolTipText(Messages.getString("ProcessComposite.execTimeHint")); //$NON-NLS-1$
    // watchBtn.setEnabled(false);
    // watchBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISEXECTIMERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // watchBtn.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(killBtn, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(clearBeforeExec, 0, SWT.RIGHT);
    // watchBtn.setLayoutData(formData);
    //
    // Group statisticsComposite = new Group(execHeader, SWT.NONE);
    //        statisticsComposite.setText(Messages.getString("ProcessComposite2.statsComposite")); //$NON-NLS-1$
    // layout = new GridLayout(3, false);
    // layout.marginWidth = 0;
    // statisticsComposite.setLayout(layout);
    // formData = new FormData();
    // // formData.right = new FormAttachment(100, 0);
    // / formData.left = new FormAttachment(watchBtn, 0, SWT.RIGHT);
    // statisticsComposite.setLayoutData(formData);
    //
    // Composite statisticsButtonComposite = new Composite(statisticsComposite, SWT.NONE);
    // layout = new GridLayout(1, false);
    // layout.marginWidth = 0;
    // statisticsButtonComposite.setLayout(layout);
    // statisticsButtonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    // perfBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        perfBtn.setText(Messages.getString("ProcessComposite.stat")); //$NON-NLS-1$
    //        perfBtn.setToolTipText(Messages.getString("ProcessComposite.statHint")); //$NON-NLS-1$
    // perfBtn.setEnabled(false);
    // perfBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSTATISTICSRUN));
    // traceBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        traceBtn.setText(Messages.getString("ProcessComposite.trace")); //$NON-NLS-1$
    //        traceBtn.setToolTipText(Messages.getString("ProcessComposite.traceHint")); //$NON-NLS-1$
    // traceBtn.setEnabled(false);
    // traceBtn
    // .setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(RunProcessPrefsConstants.ISTRACESRUN));
    clearTracePerfBtn = new Button(execHeader, SWT.PUSH);
    //$NON-NLS-1$
    clearTracePerfBtn.setText(Messages.getString("ProcessComposite.clear"));
    //$NON-NLS-1$
    clearTracePerfBtn.setToolTipText(Messages.getString("ProcessComposite.clearHint"));
    clearTracePerfBtn.setImage(ImageProvider.getImage(RunProcessPlugin.imageDescriptorFromPlugin(RunProcessPlugin.PLUGIN_ID, //$NON-NLS-1$
    "icons/process_stat_clear.gif")));
    clearTracePerfBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(killBtn, 0, SWT.TOP);
    formData.left = new FormAttachment(killBtn, 0, SWT.RIGHT);
    formData.right = new FormAttachment(killBtn, 10 + 70, SWT.RIGHT);
    formData.height = 30;
    clearTracePerfBtn.setLayoutData(formData);
    consoleText = new StyledText(execContent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    consoleText.setWordWrap(true);
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.minimumHeight = MINIMUM_HEIGHT;
    data.minimumWidth = MINIMUM_WIDTH;
    layouData = new FormData();
    layouData.left = new FormAttachment(0, 10);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 50);
    layouData.bottom = new FormAttachment(100, -30);
    consoleText.setLayoutData(layouData);
    // feature 6875, add searching capability, nma
    consoleText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent evt) {
            // select all
            if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'a')) {
                if (consoleText.getText().length() > 0) {
                    consoleText.setSelection(0, (consoleText.getText().length() - 1));
                }
            } else // search special string value
            if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'f')) {
                FindDialog td = new FindDialog(Display.getCurrent().getActiveShell());
                td.setConsoleText(consoleText);
                td.setBlockOnOpen(true);
                td.open();
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }
    });
    // see feature 0004895: Font size of the output console are very small
    setConsoleFont();
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
            if (TalendDesignerPrefConstants.CONSOLT_TEXT_FONT.endsWith(event.getProperty())) {
                setConsoleFont();
            }
        }
    });
    // execScroll.setMinSize(execContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // sash.setSashWidth(1);
    // sash.setWeights(new int[] { 7, 1, H_WEIGHT });
    pcl = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            runProcessContextChanged(evt);
        }
    };
    streamListener = new IStreamListener() {

        @Override
        public void streamAppended(String text, IStreamMonitor monitor) {
            IProcessMessage message = new ProcessMessage(ProcessMessage.MsgType.STD_OUT, text);
            processContext.addDebugResultToConsole(message);
        }
    };
    addListeners();
    createLineLimitedControl(execContent);
}
Also used : IStreamListener(org.eclipse.debug.core.IStreamListener) Group(org.eclipse.swt.widgets.Group) PropertyChangeListener(java.beans.PropertyChangeListener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IBrandingService(org.talend.core.ui.branding.IBrandingService) Point(org.eclipse.swt.graphics.Point) IStreamMonitor(org.eclipse.debug.core.model.IStreamMonitor) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) GridData(org.eclipse.swt.layout.GridData) KeyListener(org.eclipse.swt.events.KeyListener) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 67 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project tdi-studio-se by Talend.

the class PromptDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new FillLayout());
    final ScrolledComposite sc = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    final Composite child = new Composite(sc, SWT.NONE);
    child.setLayout(new GridLayout(1, false));
    // Prompt for context values ?
    for (final IContextParameter parameter : context.getContextParameterList()) {
        if (parameter.isPromptNeeded()) {
            if (DefaultCellEditorFactory.isBoolean(parameter.getType())) {
                final Composite composite2 = new Composite(child, SWT.NONE);
                final GridLayout gridLayout = new GridLayout(2, false);
                gridLayout.horizontalSpacing = 5;
                gridLayout.marginBottom = 0;
                gridLayout.marginHeight = 0;
                gridLayout.marginLeft = 0;
                gridLayout.marginRight = 0;
                gridLayout.marginTop = 0;
                gridLayout.marginWidth = 0;
                composite2.setLayout(gridLayout);
                composite2.setLayoutData(new GridData(GridData.BEGINNING));
                Label label = new Label(composite2, SWT.NONE);
                label.setText(parameter.getPrompt());
                label.setAlignment(SWT.LEFT);
                GridData data = new GridData(GridData.FILL_HORIZONTAL);
                data.minimumWidth = MINIMUM_WIDTH;
                label.setLayoutData(data);
                final Button button = new Button(composite2, SWT.CHECK);
                button.setSelection(Boolean.parseBoolean(parameter.getValue()));
                button.addSelectionListener(new SelectionAdapter() {

                    /*
                         * (non-Javadoc)
                         * 
                         * @see
                         * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
                         */
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        parameter.setValue((new Boolean(button.getSelection())).toString());
                    }
                });
            } else {
                Label label = new Label(child, SWT.NONE);
                label.setText(parameter.getPrompt());
                label.setAlignment(SWT.LEFT);
                GridData data = new GridData(GridData.FILL_HORIZONTAL);
                data.minimumWidth = MINIMUM_WIDTH;
                label.setLayoutData(data);
                createParameterComposite(child, parameter, label);
            }
        }
    }
    sc.setContent(child);
    // Set the minimum size
    // sc.setMinSize(400, 400);
    // Expand both horizontally and vertically
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            Rectangle r = sc.getClientArea();
            sc.setMinSize(child.computeSize(r.width, SWT.DEFAULT));
        }
    });
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) FillLayout(org.eclipse.swt.layout.FillLayout) IContextParameter(org.talend.core.model.process.IContextParameter) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 68 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project tesb-studio-se by Talend.

the class CamelDependenciesEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    parent.setLayout(new GridLayout());
    //create search group, hide button and refresh button
    Composite toolsPanel = toolkit.createComposite(parent);
    toolsPanel.setLayout(new GridLayout(4, false));
    toolsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    toolsPanel.setBackgroundMode(SWT.INHERIT_FORCE);
    toolkit.createLabel(toolsPanel, Messages.RouterDependenciesEditor_filterLabel);
    SearchControl searchComposite = new SearchControl(toolsPanel, SWT.NONE);
    searchComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    searchComposite.setActiveImage(CamelDesignerPlugin.getImage(CamelDesignerPlugin.HIGHLIGHT_REM_ICON));
    searchComposite.setDeactiveImage(CamelDesignerPlugin.getImage(CamelDesignerPlugin.GRAY_REM_ICON));
    Text filterText = searchComposite.getText();
    Button hideBuiltIn = toolkit.createButton(toolsPanel, Messages.RouterDependenciesEditor_hideBuiltInItems, SWT.CHECK);
    Button refreshBtn = toolkit.createButton(toolsPanel, null, SWT.PUSH);
    refreshBtn.setImage(CamelDesignerPlugin.getImage(CamelDesignerPlugin.REFRESH_ICON));
    refreshBtn.setToolTipText(Messages.RouterDependenciesEditor_refreshDependenciesTooltip);
    refreshBtn.setEnabled(!isReadOnly());
    // create data tables
    ScrolledComposite top = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    SashForm mainForm = new SashForm(top, SWT.VERTICAL);
    manageRouteResourcePanel = createResourceTableViewer(mainForm, toolkit, Messages.CamelDependenciesEditor_Resources);
    SashForm topPart = new SashForm(mainForm, SWT.HORIZONTAL);
    importPackageViewer = createTableViewer(topPart, toolkit, Messages.RouterDependenciesEditor_importPackageSec, ManifestItem.IMPORT_PACKAGE);
    bundleClasspathViewer = createTableViewer(topPart, toolkit, Messages.RouterDependenciesEditor_classpathSec, ManifestItem.BUNDLE_CLASSPATH);
    SashForm centerPart = new SashForm(mainForm, SWT.HORIZONTAL);
    exportPackageViewer = createTableViewer(centerPart, toolkit, Messages.RouterDependenciesEditor_exportPackage, ManifestItem.EXPORT_PACKAGE);
    requireBundleViewer = createTableViewer(centerPart, toolkit, Messages.RouterDependenciesEditor_requireBundleSec, ManifestItem.REQUIRE_BUNDLE);
    top.setExpandHorizontal(true);
    top.setExpandVertical(true);
    top.setContent(mainForm);
    top.setMinSize(mainForm.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    //create status
    Composite statusComposite = toolkit.createComposite(parent);
    statusComposite.setLayout(new GridLayout(2, false));
    statusComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    statusLabel = toolkit.createLabel(statusComposite, null);
    statusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    //		if (isReadOnly()) {
    //			statusLabel.setText(Messages.RouterDependenciesEditor_itemIsLockedByOther);
    //		}
    Label shortCuts = toolkit.createLabel(statusComposite, Messages.RouterDependenciesEditor_KeyBindingw, SWT.SHADOW_OUT);
    shortCuts.setEnabled(false);
    // add filter listener
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            final String filterString = ((Text) e.widget).getText().trim();
            importPackageViewer.setFilterString(filterString);
            requireBundleViewer.setFilterString(filterString);
            bundleClasspathViewer.setFilterString(filterString);
            exportPackageViewer.setFilterString(filterString);
            manageRouteResourcePanel.setFilterString(filterString);
        }
    });
    // add hide listener
    hideBuiltIn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final boolean show = ((Button) e.widget).getSelection();
            importPackageViewer.setShowBuiltIn(!show);
            requireBundleViewer.setShowBuiltIn(!show);
            bundleClasspathViewer.setShowBuiltIn(!show);
            exportPackageViewer.setShowBuiltIn(!show);
            manageRouteResourcePanel.setShowBuiltIn(!show);
        }
    });
    refreshBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            //	          setDirty(false);
            updateInput();
        }
    });
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SearchControl(org.talend.camel.designer.ui.editor.dependencies.controls.SearchControl)

Example 69 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project tdi-studio-se by Talend.

the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.

public void moveScrollBarZoneAtSelectedTableItem(ITableEntry entry) {
    if (entry != null) {
        DataMapTableView dataMapTableView = mapperManager.retrieveAbstractDataMapTableView(entry.getParent());
        Rectangle tableViewBounds = dataMapTableView.getBounds();
        IDataMapTable table = entry.getParent();
        TableItem tableItem = mapperManager.retrieveTableItem(entry);
        if (table != null && tableItem != null) {
            Rectangle tableItemBounds = tableItem.getBounds();
            int selection = tableViewBounds.y + tableItemBounds.y;
            ScrolledComposite scrollComposite = null;
            if (table instanceof InputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewInputs();
            } else if (table instanceof VarsTable) {
                scrollComposite = uiManager.getScrolledCompositeViewVars();
            } else if (table instanceof OutputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewOutputs();
            }
            if (scrollComposite != null) {
                setPositionOfVerticalScrollBarZone(scrollComposite, selection);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 70 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project tdi-studio-se by Talend.

the class ComponentSettingsView method createDynamicComposite.

/**
     * yzhang Comment method "createDynamicComposite".
     * 
     * @param parent
     * @param element
     * @param category
     */
private void createDynamicComposite(final Composite parent, Element element, EComponentCategory category) {
    // DynamicComposite dc = null;
    getParentMap().put(ComponentSettingsView.PARENT, parent);
    getCategoryMap().put(ComponentSettingsView.CATEGORY, category);
    if (element instanceof Node) {
        IComponent component = ((Node) element).getComponent();
        IGenericWizardService wizardService = null;
        boolean generic = false;
        if (EComponentType.GENERIC.equals(component.getComponentType())) {
            generic = true;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
                wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
            }
        }
        tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
        if (category == EComponentCategory.BASIC) {
            // getElementMap().put(ComponentSettingsView.ELEMENT, element);
            createButtonListener();
            boolean isCompactView = true;
            if (ComponentSettingsView.TABLEVIEW.equals(getPreference().getString(TalendDesignerPrefConstants.VIEW_OPTIONS))) {
                isCompactView = false;
            }
            tabFactory.getTabbedPropertyComposite().setCompactViewVisible(true);
            tabFactory.getTabbedPropertyComposite().setCompactView(isCompactView);
            // Generic
            if (generic && wizardService != null) {
                Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.BASIC, true);
                if (composite instanceof MultipleThreadDynamicComposite) {
                    dc = (MultipleThreadDynamicComposite) composite;
                }
            } else {
                dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, isCompactView);
            }
        } else if (category == EComponentCategory.DYNAMICS_SETTINGS) {
            dc = new AdvancedContextComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        } else if (category == EComponentCategory.SQL_PATTERN) {
            dc = new SQLPatternComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        } else if (category == EComponentCategory.ADVANCED) {
            dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
            // Generic
            if (generic && wizardService != null) {
                Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.ADVANCED, true);
                if (composite instanceof MultipleThreadDynamicComposite) {
                    dc = (MultipleThreadDynamicComposite) composite;
                }
            }
        } else {
            dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
        }
    } else if (element instanceof Connection) {
        dc = new MainConnectionComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element);
    } else if (element instanceof Note) {
        if (category == EComponentCategory.BASIC) {
            if (parent.getLayout() instanceof FillLayout) {
                FillLayout layout = (FillLayout) parent.getLayout();
                layout.type = SWT.VERTICAL;
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.spacing = 0;
            }
            ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
            scrolled.setExpandHorizontal(true);
            scrolled.setExpandVertical(true);
            scrolled.setMinWidth(600);
            scrolled.setMinHeight(400);
            Composite composite = tabFactory.getWidgetFactory().createComposite(scrolled);
            scrolled.setContent(composite);
            composite.setLayout(new FormLayout());
            FormData d = new FormData();
            d.left = new FormAttachment(0, 0);
            d.right = new FormAttachment(100, 0);
            d.top = new FormAttachment(0, 0);
            d.bottom = new FormAttachment(100, 0);
            composite.setLayoutData(d);
            AbstractNotePropertyComposite c1 = new BasicNotePropertyComposite(composite, (Note) element, tabFactory);
            // AbstractNotePropertyComposite c2 = new TextNotePropertyComposite(composite, (Note) element,
            // tabFactory);
            // FormData data = new FormData();
            // data.top = new FormAttachment(c1.getComposite(), 20, SWT.DOWN);
            // data.left = new FormAttachment(0, 0);
            // data.right = new FormAttachment(100, 0);
            // c2.getComposite().setLayoutData(data);
            parent.layout();
        }
    } else if (element instanceof SubjobContainer) {
        if (category == EComponentCategory.BASIC) {
            dc = new SubjobBasicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        }
    } else {
        tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
        dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
    }
    if (parent.getChildren().length == 0) {
        if (parent.getLayout() instanceof FillLayout) {
            FillLayout layout = (FillLayout) parent.getLayout();
            layout.type = SWT.VERTICAL;
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            layout.spacing = 0;
        }
        Composite composite = tabFactory.getWidgetFactory().createComposite(parent);
        composite.setLayout(new FormLayout());
        FormData d = new FormData();
        d.left = new FormAttachment(2, 0);
        d.right = new FormAttachment(100, 0);
        d.top = new FormAttachment(5, 0);
        d.bottom = new FormAttachment(100, 0);
        composite.setLayoutData(d);
        Label alertText = new Label(composite, SWT.NONE);
        //$NON-NLS-1$
        alertText.setText(Messages.getString("ComponentSettingsView.noAdvancedSetting"));
        alertText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        parent.layout();
    }
    if (dc != null) {
        dc.refresh();
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) Composite(org.eclipse.swt.widgets.Composite) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) Label(org.eclipse.swt.widgets.Label) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) FillLayout(org.eclipse.swt.layout.FillLayout) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Note(org.talend.designer.core.ui.editor.notes.Note) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)89 Composite (org.eclipse.swt.widgets.Composite)67 GridData (org.eclipse.swt.layout.GridData)55 GridLayout (org.eclipse.swt.layout.GridLayout)51 Label (org.eclipse.swt.widgets.Label)39 Point (org.eclipse.swt.graphics.Point)27 Button (org.eclipse.swt.widgets.Button)21 Text (org.eclipse.swt.widgets.Text)20 FillLayout (org.eclipse.swt.layout.FillLayout)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Control (org.eclipse.swt.widgets.Control)13 Group (org.eclipse.swt.widgets.Group)13 ControlEvent (org.eclipse.swt.events.ControlEvent)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)8 ArrayList (java.util.ArrayList)7 Combo (org.eclipse.swt.widgets.Combo)7 Image (org.eclipse.swt.graphics.Image)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)6