Search in sources :

Example 81 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method createReportField.

/*  private void createInfoField(Composite parent) {

        infoComposite = createFlatFormComposite(parent, new FormToolkit(Display.getDefault()));
        FormLayout reportLayout = new FormLayout();
        reportLayout.marginWidth = 0;
        reportLayout.marginHeight = 0;
        infoComposite.setLayout(reportLayout);
        FormData reportData = new FormData();
        reportData.left = new FormAttachment(65, 5);
        reportData.right = new FormAttachment(100, -5);
        reportData.top = new FormAttachment(50, 0);
        reportData.bottom = new FormAttachment(100, -5);
        infoComposite.setLayoutData(reportData);

        Group group = new Group(infoComposite, SWT.NULL);
        FormLayout groupLayout = new FormLayout();
        groupLayout.marginWidth = 0;
        groupLayout.marginHeight = 0;
        group.setLayout(groupLayout);
        FormData groupData = new FormData();
        groupData.left = new FormAttachment(0, 0);
        groupData.right = new FormAttachment(100, 0);
        groupData.top = new FormAttachment(0, 0);
        groupData.bottom = new FormAttachment(100, 0);
        group.setLayoutData(groupData);
        group.setText("Run job Informations");

        infoField = new Text(group, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
        infoField.setEditable(false);
        infoField.setBackground(group.getBackground());

        FormData data;
        data = new FormData();
        data.left = new FormAttachment(0, 0);
        data.right = new FormAttachment(100, 0);
        data.top = new FormAttachment(0, 0);
        data.bottom = new FormAttachment(100, 0);
        infoField.setLayoutData(data);
    }*/
private void createReportField(Composite parent) {
    reportComposite = createFlatFormComposite(parent, new FormToolkit(Display.getDefault()));
    FormLayout reportLayout = new FormLayout();
    reportComposite.setLayout(reportLayout);
    FormData reportData = new FormData();
    reportData.left = new FormAttachment(65, 5);
    reportData.right = new FormAttachment(100, -5);
    reportData.top = new FormAttachment(0, 0);
    reportData.bottom = new FormAttachment(100, -5);
    reportComposite.setLayoutData(reportData);
    Group group = new Group(reportComposite, SWT.NULL);
    FormLayout groupLayout = new FormLayout();
    group.setLayout(groupLayout);
    FormData groupData = new FormData();
    groupData.left = new FormAttachment(0, 0);
    groupData.right = new FormAttachment(100, 0);
    groupData.top = new FormAttachment(0, 0);
    groupData.bottom = new FormAttachment(100, 0);
    group.setLayoutData(groupData);
    //$NON-NLS-1$
    group.setText("Job execution information");
    reportField = new StyledText(group, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
    //may be CoreUIPlugin.setCSSClass can do this globally ,check later
    reportField.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    FormData data;
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(93, 0);
    reportField.setLayoutData(data);
    displayReportField();
    //export button
    Button exportButton = new Button(group, SWT.PUSH);
    //$NON-NLS-1$
    exportButton.setText("Export");
    FormData exportData = new FormData();
    exportData.left = new FormAttachment(100, -70);
    exportData.right = new FormAttachment(100, 0);
    exportData.bottom = new FormAttachment(100, -1);
    exportButton.setLayoutData(exportData);
    exportButton.setEnabled(true);
    exportButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (messageManager == null || messageManager.getMessages().size() < 1) {
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", "No log to export.");
                return;
            }
            UnboundedFifoBuffer messages = messageManager.getMessages();
            Iterator iterator = messages.iterator();
            StringBuilder content = new StringBuilder();
            while (iterator.hasNext()) {
                ReportMessage message = (ReportMessage) iterator.next();
                content.append(message.getContent());
            }
            if (isMonitoring) {
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", "Waiting for job done.");
                return;
            }
            FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
            //$NON-NLS-1$
            dialog.setFilterPath(".");
            String fileName = dialog.open();
            if (fileName != null) {
                FileWriter writer = null;
                try {
                    writer = new FileWriter(fileName);
                    writer.write(content.toString());
                } catch (IOException e1) {
                    e1.printStackTrace();
                } finally {
                    try {
                        if (writer != null) {
                            writer.close();
                        }
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    });
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) Group(org.eclipse.swt.widgets.Group) StyledText(org.eclipse.swt.custom.StyledText) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FileWriter(java.io.FileWriter) ReportMessage(org.talend.designer.runtime.visualization.ReportMessage) IOException(java.io.IOException) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) UnboundedFifoBuffer(org.apache.commons.collections.buffer.UnboundedFifoBuffer) FileDialog(org.eclipse.swt.widgets.FileDialog) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 82 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.

the class SaveChartSetAsDialog method createDeleteButton.

/**
     * Creates the delete button.
     * 
     * @param parent The parent composite
     */
private void createDeleteButton(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    deleteButton = new Button(composite, SWT.PUSH);
    deleteButton.setText(Messages.deleteButtonLabel);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    deleteButton.setLayoutData(gridData);
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) chartSetViewer.getSelection();
            String element = (String) selection.getFirstElement();
            chartSets.remove(element);
            chartSetViewer.setInput(chartSets.toArray(new String[chartSets.size()]));
        }
    });
}
Also used : 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) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 83 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.

the class JSONFileSelectWizardPage method addListeners.

private void addListeners() {
    inputModeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isInputModel = true;
            ((JSONFileConnection) connectionItem.getConnection()).setInputModel(true);
        }
    });
    outputModeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isInputModel = false;
            ((JSONFileConnection) connectionItem.getConnection()).setInputModel(false);
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 84 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.

the class UseDynamicJobSelectionDialog method createSelectionButton.

/**
     * DOC hcw Comment method "createSelectionButton".
     * 
     * @param itemComposite
     */
private void createSelectionButton(Composite itemComposite) {
    Composite buttonComposite = new Composite(itemComposite, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(0, 25).applyTo(buttonComposite);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(buttonComposite);
    Button selectAll = new Button(buttonComposite, SWT.PUSH);
    // selectAll.setText(DataTransferMessages.DataTransfer_selectAll);
    //$NON-NLS-1$
    selectAll.setText(Messages.getString("DataTransferMessages.DataTransfer_selectAll"));
    selectAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.setAllChecked(true);
        }
    });
    setButtonLayoutData(selectAll);
    Button deselectAll = new Button(buttonComposite, SWT.PUSH);
    // deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll);
    //$NON-NLS-1$
    deselectAll.setText(Messages.getString("DataTransferMessages.DataTransfer_deselectAll"));
    deselectAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.setAllChecked(false);
        }
    });
    setButtonLayoutData(deselectAll);
    Button expandBtn = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    expandBtn.setText(Messages.getString("UseDynamicJobSelectionDialog.expandBtnText"));
    expandBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.expandAll();
        }
    });
    setButtonLayoutData(expandBtn);
    Button collapseBtn = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    collapseBtn.setText(Messages.getString("UseDynamicJobSelectionDialog.collapseBtnText"));
    collapseBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.collapseAll();
        }
    });
    setButtonLayoutData(collapseBtn);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 85 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.

the class ComponentRefController method createControl.

@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("ComboController.valueFromRepository"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();
    FormData data;
    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    GenericElementParameter gParam = (GenericElementParameter) param;
    ComponentReferenceProperties props = (ComponentReferenceProperties) gParam.getWidget().getContent();
    combo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            if (!(event.getSource() instanceof CCombo)) {
                return;
            }
            Command cmd = createComboCommand(event, gParam, props);
            executeCommand(cmd);
        }
    });
    combo.setData(PARAMETER_NAME, param.getName());
    int nbLines = param.getNbLines();
    if (nbLines > 5) {
        combo.setVisibleItemCount(nbLines);
    }
    if (elem instanceof Node) {
        combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, Messages.getString("ComponentRefController.connectionLabel"));
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(Messages.getString("ComponentRefController.connectionLabel"));
    gc.dispose();
    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }
    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), combo);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GC(org.eclipse.swt.graphics.GC) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3041 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3036 GridData (org.eclipse.swt.layout.GridData)1608 Button (org.eclipse.swt.widgets.Button)1600 Composite (org.eclipse.swt.widgets.Composite)1220 Label (org.eclipse.swt.widgets.Label)1106 GridLayout (org.eclipse.swt.layout.GridLayout)1095 Text (org.eclipse.swt.widgets.Text)773 ModifyListener (org.eclipse.swt.events.ModifyListener)638 ModifyEvent (org.eclipse.swt.events.ModifyEvent)630 Group (org.eclipse.swt.widgets.Group)459 FormAttachment (org.eclipse.swt.layout.FormAttachment)428 FormData (org.eclipse.swt.layout.FormData)428 Shell (org.eclipse.swt.widgets.Shell)407 FormLayout (org.eclipse.swt.layout.FormLayout)406 Event (org.eclipse.swt.widgets.Event)384 Listener (org.eclipse.swt.widgets.Listener)378 Display (org.eclipse.swt.widgets.Display)353 ShellEvent (org.eclipse.swt.events.ShellEvent)323 ShellAdapter (org.eclipse.swt.events.ShellAdapter)321