Search in sources :

Example 66 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class DirectoryController method createControl.

/*
     * (non-Javadoc)
     *
     * @see org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#
     * createControl( org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
    this.curParameter = param;
    FormData data;
    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    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);
    }
    //$NON-NLS-1$
    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    data = new FormData();
    data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
    data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, DIRECTORY);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text labelText = (Text) dField.getControl();
    cLayout.setBackground(subComposite.getBackground());
    if (!elem.isReadOnly()) {
        if (param.isRepositoryValueUsed()) {
            addRepositoryPropertyListener(labelText);
        }
        labelText.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
    } else {
        labelText.setEditable(false);
    }
    labelText.setData(PARAMETER_NAME, param.getName());
    editionControlHelper.register(param.getName(), labelText);
    addDragAndDropTarget(labelText);
    if (elem instanceof Node) {
        labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    // **************************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    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.right = new FormAttachment(btnEdit, 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    cLayout.setLayoutData(data);
    hashCurControls.put(param.getName(), labelText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnEdit;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) Text(org.eclipse.swt.widgets.Text) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 67 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class InsertionIndicator method createComponents.

/**
     * DOC amaumont Comment method "createComponents".
     */
private void createComponents() {
    leftArrowDraggingIndicator = new Composite(tablesZoneViewParent, SWT.NONE | SWT.NO_BACKGROUND);
    leftArrowDraggingIndicator.setVisible(false);
    leftArrowDraggingIndicator.setBackgroundMode(SWT.INHERIT_DEFAULT);
    FormData formDataLeftArrow = new FormData();
    formDataLeftArrow.width = 12;
    formDataLeftArrow.height = HEIGHT_INDICATOR;
    formDataLeftArrow.left = new FormAttachment(0, 0);
    formDataLeftArrow.left = new FormAttachment(0, -formDataLeftArrow.width + 2);
    formDataLeftArrow.top = new FormAttachment(0, 0);
    leftArrowDraggingIndicator.setLayoutData(formDataLeftArrow);
    rightArrowDraggingIndicator = new Composite(tablesZoneViewParent, SWT.NONE | SWT.NO_BACKGROUND);
    rightArrowDraggingIndicator.setVisible(false);
    rightArrowDraggingIndicator.setBackgroundMode(SWT.INHERIT_DEFAULT);
    FormData formDataRightArrow = new FormData();
    formDataRightArrow.width = 13;
    formDataRightArrow.height = HEIGHT_INDICATOR;
    // this property is recalculated at each top changement
    formDataRightArrow.left = new FormAttachment(0, 0);
    formDataRightArrow.top = new FormAttachment(0, 0);
    rightArrowDraggingIndicator.setLayoutData(formDataRightArrow);
    addListeners();
}
Also used : FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 68 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class MapperManager method addRejectOutput.

public void addRejectOutput() {
    String baseName = ERROR_REJECT;
    IProcess process = getAbstractMapComponent().getProcess();
    String tableName = baseName;
    if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
        final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
        tableName = uniqueName;
        ((IProcess2) process).addUniqueConnectionName(uniqueName);
    } else if (process instanceof IProcess2) {
        tableName = baseName;
        ((IProcess2) process).addUniqueConnectionName(baseName);
    }
    IMetadataTable metadataTable = getNewMetadataTable();
    metadataTable.setTableName(tableName);
    MetadataColumn errorMessageCol = new MetadataColumn();
    errorMessageCol.setLabel(ERROR_REJECT_MESSAGE);
    errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorMessageCol.setNullable(true);
    errorMessageCol.setOriginalDbColumnName(ERROR_REJECT_MESSAGE);
    errorMessageCol.setReadOnly(true);
    errorMessageCol.setCustom(true);
    errorMessageCol.setCustomId(0);
    metadataTable.getListColumns().add(errorMessageCol);
    MetadataColumn errorStackTrace = new MetadataColumn();
    errorStackTrace.setLabel(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorStackTrace.setNullable(true);
    errorStackTrace.setOriginalDbColumnName(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setReadOnly(true);
    errorStackTrace.setCustom(true);
    errorStackTrace.setCustomId(1);
    metadataTable.getListColumns().add(errorStackTrace);
    OutputTable abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
    abstractDataMapTable.setErrorRejectTable(true);
    abstractDataMapTable.initFromExternalData(null);
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView rejectDataMapTableView = uiManager.createNewOutputTableView(null, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
    int sizeList = outputsTablesView.size();
    for (int i = 0; i < sizeList; i++) {
        if (i + 1 < sizeList) {
            FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
            formData.top = new FormAttachment(outputsTablesView.get(i));
        }
    }
    CustomTableManager.addCustomManagementToTable(uiManager.getOutputMetaEditorView(), true);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    uiManager.selectDataMapTableView(rejectDataMapTableView, true, false);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) FormData(org.eclipse.swt.layout.FormData) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IProcess2(org.talend.core.model.process.IProcess2) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) FormAttachment(org.eclipse.swt.layout.FormAttachment) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 69 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method createControls.

@Override
protected void createControls(Composite parent) {
    chartsPage = new Composite(parent, SWT.NULL);
    parent.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    chartsPage.setBackground(parent.getBackground());
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 0;
    formLayout.marginHeight = 0;
    chartsPage.setLayout(formLayout);
    FormData pageData = new FormData();
    pageData.top = new FormAttachment(0, 0);
    pageData.bottom = new FormAttachment(100, 0);
    pageData.left = new FormAttachment(0, 0);
    pageData.right = new FormAttachment(100, 0);
    chartsPage.setLayoutData(pageData);
    mBeanServerChangeListener = new IMBeanServerChangeListener() {

        @Override
        public void serverChanged(MBeanServerEvent event) {
            new RefreshJob(Messages.reconstructChartJobLabel, toString()) {

                @Override
                protected void refreshUI() {
                    IActiveJvm jvm = getJvm();
                    if (jvm != null) {
                        reconstructCharts(jvm, false);
                    }
                }
            }.schedule();
        }
    };
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.TIMELINE_PAGE);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) RefreshJob(org.talend.designer.runtime.visualization.internal.ui.RefreshJob) IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IMBeanServerChangeListener(org.talend.designer.runtime.visualization.MBean.IMBeanServerChangeListener) MBeanServerEvent(org.talend.designer.runtime.visualization.MBean.MBeanServerEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 70 with FormData

use of org.eclipse.swt.layout.FormData 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)

Aggregations

FormData (org.eclipse.swt.layout.FormData)1050 FormAttachment (org.eclipse.swt.layout.FormAttachment)999 FormLayout (org.eclipse.swt.layout.FormLayout)667 Label (org.eclipse.swt.widgets.Label)554 Button (org.eclipse.swt.widgets.Button)550 SelectionEvent (org.eclipse.swt.events.SelectionEvent)477 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)433 Composite (org.eclipse.swt.widgets.Composite)423 Text (org.eclipse.swt.widgets.Text)420 ModifyListener (org.eclipse.swt.events.ModifyListener)360 Shell (org.eclipse.swt.widgets.Shell)358 ModifyEvent (org.eclipse.swt.events.ModifyEvent)356 Listener (org.eclipse.swt.widgets.Listener)356 Event (org.eclipse.swt.widgets.Event)355 Display (org.eclipse.swt.widgets.Display)342 ShellEvent (org.eclipse.swt.events.ShellEvent)331 ShellAdapter (org.eclipse.swt.events.ShellAdapter)324 TextVar (org.pentaho.di.ui.core.widget.TextVar)234 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)224 TableView (org.pentaho.di.ui.core.widget.TableView)219