Search in sources :

Example 1 with BaseTransformMeta

use of org.apache.hop.pipeline.transform.BaseTransformMeta in project hop by apache.

the class WidgetUtils method createFieldDropDown.

/**
 * creates a ComboVar populated with fields from the previous transform.
 *
 * @param parentComposite - the composite in which the widget will be placed
 * @param props - PropsUi props for L&F
 * @param transformMeta - transformMeta of the current transform
 * @param formData - FormData to use for placement
 */
public static ComboVar createFieldDropDown(Composite parentComposite, PropsUi props, IVariables variables, BaseTransformMeta transformMeta, FormData formData) {
    PipelineMeta pipelineMeta = transformMeta.getParentTransformMeta().getParentPipelineMeta();
    ComboVar fieldDropDownCombo = new ComboVar(variables, parentComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(fieldDropDownCombo);
    fieldDropDownCombo.addModifyListener(e -> transformMeta.setChanged());
    fieldDropDownCombo.setLayoutData(formData);
    Listener focusListener = e -> {
        String current = fieldDropDownCombo.getText();
        fieldDropDownCombo.getCComboWidget().removeAll();
        fieldDropDownCombo.setText(current);
        try {
            IRowMeta rmi = pipelineMeta.getPrevTransformFields(variables, transformMeta.getParentTransformMeta().getName());
            List ls = rmi.getValueMetaList();
            for (Object l : ls) {
                ValueMetaBase vmb = (ValueMetaBase) l;
                fieldDropDownCombo.add(vmb.getName());
            }
        } catch (HopTransformException ex) {
            // can be ignored, since previous transform may not be set yet.
            transformMeta.logDebug(ex.getMessage(), ex);
        }
    };
    fieldDropDownCombo.getCComboWidget().addListener(SWT.FocusIn, focusListener);
    return fieldDropDownCombo;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) IRowMeta(org.apache.hop.core.row.IRowMeta) CTabFolder(org.eclipse.swt.custom.CTabFolder) FormLayout(org.eclipse.swt.layout.FormLayout) IVariables(org.apache.hop.core.variables.IVariables) FormData(org.eclipse.swt.layout.FormData) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment) HopTransformException(org.apache.hop.core.exception.HopTransformException) CTabItem(org.eclipse.swt.custom.CTabItem) List(java.util.List) ComboVar(org.apache.hop.ui.core.widget.ComboVar) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) SWT(org.eclipse.swt.SWT) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Control(org.eclipse.swt.widgets.Control) ComboVar(org.apache.hop.ui.core.widget.ComboVar) Listener(org.eclipse.swt.widgets.Listener) IRowMeta(org.apache.hop.core.row.IRowMeta) List(java.util.List) HopTransformException(org.apache.hop.core.exception.HopTransformException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase)

Example 2 with BaseTransformMeta

use of org.apache.hop.pipeline.transform.BaseTransformMeta in project hop by apache.

the class LoadSaveBase method createMeta.

public T createMeta() {
    try {
        T meta = clazz.newInstance();
        if (meta instanceof BaseTransformMeta) {
            TransformMeta mockParentTransformMeta = mock(TransformMeta.class);
            ((BaseTransformMeta) meta).setParentTransformMeta(mockParentTransformMeta);
            PipelineMeta mockPipelineMeta = mock(PipelineMeta.class);
            when(mockParentTransformMeta.getParentPipelineMeta()).thenReturn(mockPipelineMeta);
        }
        return meta;
    } catch (Exception e) {
        throw new RuntimeException("Unable to create meta of class " + clazz.getCanonicalName(), e);
    }
}
Also used : BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) HopException(org.apache.hop.core.exception.HopException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Aggregations

PipelineMeta (org.apache.hop.pipeline.PipelineMeta)2 BaseTransformMeta (org.apache.hop.pipeline.transform.BaseTransformMeta)2 List (java.util.List)1 StringUtils (org.apache.commons.lang.StringUtils)1 HopException (org.apache.hop.core.exception.HopException)1 HopTransformException (org.apache.hop.core.exception.HopTransformException)1 IRowMeta (org.apache.hop.core.row.IRowMeta)1 ValueMetaBase (org.apache.hop.core.row.value.ValueMetaBase)1 IVariables (org.apache.hop.core.variables.IVariables)1 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)1 ComboVar (org.apache.hop.ui.core.widget.ComboVar)1 SWT (org.eclipse.swt.SWT)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Listener (org.eclipse.swt.widgets.Listener)1