Search in sources :

Example 41 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class TransMeta method getThisStepFields.

/**
 * Returns the fields that are emitted by a step.
 *
 * @param stepMeta
 *          : The StepMeta object that's being queried
 * @param nextStep
 *          : if non-null this is the next step that's call back to ask what's being sent
 * @param row
 *          : A row containing the input fields or an empty row if no input is required.
 * @param monitor
 *          the monitor
 * @return A Row containing the output fields.
 * @throws KettleStepException
 *           the kettle step exception
 */
public RowMetaInterface getThisStepFields(StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row, ProgressMonitorListener monitor) throws KettleStepException {
    // Then this one.
    if (log.isDebug()) {
        log.logDebug(BaseMessages.getString(PKG, "TransMeta.Log.GettingFieldsFromStep", stepMeta.getName(), stepMeta.getStepID()));
    }
    String name = stepMeta.getName();
    if (monitor != null) {
        monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.GettingFieldsFromStepTask.Title", name));
    }
    StepMetaInterface stepint = stepMeta.getStepMetaInterface();
    RowMetaInterface[] inform = null;
    StepMeta[] lu = getInfoStep(stepMeta);
    if (Utils.isEmpty(lu)) {
        inform = new RowMetaInterface[] { stepint.getTableFields() };
    } else {
        inform = new RowMetaInterface[lu.length];
        for (int i = 0; i < lu.length; i++) {
            inform[i] = getStepFields(lu[i]);
        }
    }
    setRepositoryOnMappingSteps();
    // Go get the fields...
    // 
    RowMetaInterface before = row.clone();
    compatibleGetStepFields(stepint, row, name, inform, nextStep, this);
    if (!isSomethingDifferentInRow(before, row)) {
        stepint.getFields(before, name, inform, nextStep, this, repository, metaStore);
        // pass the clone object to prevent from spoiling data by other steps
        row = before;
    }
    return row;
}
Also used : StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 42 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class TransMeta method addStepChangeListener.

public void addStepChangeListener(int p, StepMetaChangeListenerInterface list) {
    int indexListener = -1;
    int indexListenerRemove = -1;
    StepMeta rewriteStep = steps.get(p);
    StepMetaInterface iface = rewriteStep.getStepMetaInterface();
    if (iface instanceof StepMetaChangeListenerInterface) {
        for (StepMetaChangeListenerInterface listener : stepChangeListeners) {
            indexListener++;
            if (listener.equals(iface)) {
                indexListenerRemove = indexListener;
            }
        }
        if (indexListenerRemove >= 0) {
            stepChangeListeners.add(indexListenerRemove, list);
        } else if (stepChangeListeners.size() == 0 && p == 0) {
            stepChangeListeners.add(list);
        }
    }
}
Also used : StepMetaChangeListenerInterface(org.pentaho.di.trans.step.StepMetaChangeListenerInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 43 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class TransMeta method getStringList.

/**
 * Gets a list of all the strings used in this transformation. The parameters indicate which collections to search and
 * which to exclude.
 *
 * @param searchSteps
 *          true if steps should be searched, false otherwise
 * @param searchDatabases
 *          true if databases should be searched, false otherwise
 * @param searchNotes
 *          true if notes should be searched, false otherwise
 * @param includePasswords
 *          true if passwords should be searched, false otherwise
 * @return a list of search results for strings used in the transformation.
 */
public List<StringSearchResult> getStringList(boolean searchSteps, boolean searchDatabases, boolean searchNotes, boolean includePasswords) {
    List<StringSearchResult> stringList = new ArrayList<>();
    if (searchSteps) {
        // Loop over all steps in the transformation and see what the used vars are...
        for (int i = 0; i < nrSteps(); i++) {
            StepMeta stepMeta = getStep(i);
            stringList.add(new StringSearchResult(stepMeta.getName(), stepMeta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.StepName")));
            if (stepMeta.getDescription() != null) {
                stringList.add(new StringSearchResult(stepMeta.getDescription(), stepMeta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.StepDescription")));
            }
            StepMetaInterface metaInterface = stepMeta.getStepMetaInterface();
            StringSearcher.findMetaData(metaInterface, 1, stringList, stepMeta, this);
        }
    }
    // Loop over all steps in the transformation and see what the used vars are...
    if (searchDatabases) {
        for (int i = 0; i < nrDatabases(); i++) {
            DatabaseMeta meta = getDatabase(i);
            stringList.add(new StringSearchResult(meta.getName(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabaseConnectionName")));
            if (meta.getHostname() != null) {
                stringList.add(new StringSearchResult(meta.getHostname(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabaseHostName")));
            }
            if (meta.getDatabaseName() != null) {
                stringList.add(new StringSearchResult(meta.getDatabaseName(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabaseName")));
            }
            if (meta.getUsername() != null) {
                stringList.add(new StringSearchResult(meta.getUsername(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabaseUsername")));
            }
            if (meta.getPluginId() != null) {
                stringList.add(new StringSearchResult(meta.getPluginId(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabaseTypeDescription")));
            }
            if (meta.getDatabasePortNumberString() != null) {
                stringList.add(new StringSearchResult(meta.getDatabasePortNumberString(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabasePort")));
            }
            if (meta.getServername() != null) {
                stringList.add(new StringSearchResult(meta.getServername(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabaseServer")));
            }
            if (includePasswords) {
                if (meta.getPassword() != null) {
                    stringList.add(new StringSearchResult(meta.getPassword(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.DatabasePassword")));
                }
            }
        }
    }
    // Loop over all steps in the transformation and see what the used vars are...
    if (searchNotes) {
        for (int i = 0; i < nrNotes(); i++) {
            NotePadMeta meta = getNote(i);
            if (meta.getNote() != null) {
                stringList.add(new StringSearchResult(meta.getNote(), meta, this, BaseMessages.getString(PKG, "TransMeta.SearchMetadata.NotepadText")));
            }
        }
    }
    return stringList;
}
Also used : ArrayList(java.util.ArrayList) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) StringSearchResult(org.pentaho.di.core.reflection.StringSearchResult) NotePadMeta(org.pentaho.di.core.NotePadMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 44 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class TransMeta method setStep.

/**
 * Changes the content of a step on a certain position. This is accomplished by setting the step's metadata at the
 * specified index to the specified meta-data object. The new step's parent transformation is updated to be this
 * transformation.
 *
 * @param i
 *          The index into the steps list
 * @param stepMeta
 *          The step meta-data to set
 */
public void setStep(int i, StepMeta stepMeta) {
    StepMetaInterface iface = stepMeta.getStepMetaInterface();
    if (iface instanceof StepMetaChangeListenerInterface) {
        addStepChangeListener(i, (StepMetaChangeListenerInterface) stepMeta.getStepMetaInterface());
    }
    steps.set(i, stepMeta);
    stepMeta.setParentTransMeta(this);
    clearCaches();
}
Also used : StepMetaChangeListenerInterface(org.pentaho.di.trans.step.StepMetaChangeListenerInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface)

Example 45 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class TransPainter method drawStep.

private void drawStep(StepMeta stepMeta) {
    if (stepMeta == null) {
        return;
    }
    int alpha = gc.getAlpha();
    StepIOMetaInterface ioMeta = stepMeta.getStepMetaInterface().getStepIOMeta();
    Point pt = stepMeta.getLocation();
    if (pt == null) {
        pt = new Point(50, 50);
    }
    Point screen = real2screen(pt.x, pt.y);
    int x = screen.x;
    int y = screen.y;
    boolean stepError = false;
    if (stepLogMap != null && !stepLogMap.isEmpty()) {
        String log = stepLogMap.get(stepMeta);
        if (!Utils.isEmpty(log)) {
            stepError = true;
        }
    }
    // 
    if (!stepMeta.getRemoteInputSteps().isEmpty()) {
        gc.setLineWidth(1);
        gc.setForeground(EColor.GRAY);
        gc.setBackground(EColor.BACKGROUND);
        gc.setFont(EFont.GRAPH);
        String nrInput = Integer.toString(stepMeta.getRemoteInputSteps().size());
        Point textExtent = gc.textExtent(nrInput);
        // add a tiny listartHopStepttle bit of a margin
        textExtent.x += 2;
        textExtent.y += 2;
        // Draw it an icon above the step icon.
        // Draw it an icon and a half to the left
        // 
        Point point = new Point(x - iconsize - iconsize / 2, y - iconsize);
        gc.drawRectangle(point.x, point.y, textExtent.x, textExtent.y);
        gc.drawText(nrInput, point.x + 1, point.y + 1);
        // Now we draw an arrow from the cube to the step...
        // 
        gc.drawLine(point.x + textExtent.x, point.y + textExtent.y / 2, x - iconsize / 2, point.y + textExtent.y / 2);
        drawArrow(EImage.ARROW_DISABLED, x - iconsize / 2, point.y + textExtent.y / 2, x + iconsize / 3, y, Math.toRadians(15), 15, 1.8, null, null, null);
        // Add to the list of areas...
        if (!shadow) {
            areaOwners.add(new AreaOwner(AreaType.REMOTE_INPUT_STEP, point.x, point.y, textExtent.x, textExtent.y, offset, stepMeta, STRING_REMOTE_INPUT_STEPS));
        }
    }
    // 
    if (!stepMeta.getRemoteOutputSteps().isEmpty()) {
        gc.setLineWidth(1);
        gc.setForeground(EColor.GRAY);
        gc.setBackground(EColor.BACKGROUND);
        gc.setFont(EFont.GRAPH);
        String nrOutput = Integer.toString(stepMeta.getRemoteOutputSteps().size());
        Point textExtent = gc.textExtent(nrOutput);
        // add a tiny little bit of a margin
        textExtent.x += 2;
        textExtent.y += 2;
        // Draw it an icon above the step icon.
        // Draw it an icon and a half to the right
        // 
        Point point = new Point(x + 2 * iconsize + iconsize / 2 - textExtent.x, y - iconsize);
        gc.drawRectangle(point.x, point.y, textExtent.x, textExtent.y);
        gc.drawText(nrOutput, point.x + 1, point.y + 1);
        // Now we draw an arrow from the cube to the step...
        // This time, we start at the left side...
        // 
        gc.drawLine(point.x, point.y + textExtent.y / 2, x + iconsize + iconsize / 2, point.y + textExtent.y / 2);
        drawArrow(EImage.ARROW_DISABLED, x + 2 * iconsize / 3, y, x + iconsize + iconsize / 2, point.y + textExtent.y / 2, Math.toRadians(15), 15, 1.8, null, null, null);
        // Add to the list of areas...
        if (!shadow) {
            areaOwners.add(new AreaOwner(AreaType.REMOTE_OUTPUT_STEP, point.x, point.y, textExtent.x, textExtent.y, offset, stepMeta, STRING_REMOTE_OUTPUT_STEPS));
        }
    }
    // 
    if (stepMeta.isPartitioned()) {
        gc.setLineWidth(1);
        gc.setForeground(EColor.RED);
        gc.setBackground(EColor.BACKGROUND);
        gc.setFont(EFont.GRAPH);
        PartitionSchema partitionSchema = stepMeta.getStepPartitioningMeta().getPartitionSchema();
        if (partitionSchema != null) {
            String nrInput;
            if (partitionSchema.isDynamicallyDefined()) {
                nrInput = "Dx" + partitionSchema.getNumberOfPartitionsPerSlave();
            } else {
                nrInput = "Px" + Integer.toString(partitionSchema.getPartitionIDs().size());
            }
            Point textExtent = gc.textExtent(nrInput);
            // add a tiny little bit of a margin
            textExtent.x += 2;
            textExtent.y += 2;
            // Draw it a 2 icons above the step icon.
            // Draw it an icon and a half to the left
            // 
            Point point = new Point(x - iconsize - iconsize / 2, y - iconsize - iconsize);
            gc.drawRectangle(point.x, point.y, textExtent.x, textExtent.y);
            gc.drawText(nrInput, point.x + 1, point.y + 1);
            // Now we draw an arrow from the cube to the step...
            // 
            gc.drawLine(point.x + textExtent.x, point.y + textExtent.y / 2, x - iconsize / 2, point.y + textExtent.y / 2);
            gc.drawLine(x - iconsize / 2, point.y + textExtent.y / 2, x + iconsize / 3, y);
            // Also draw the name of the partition schema below the box
            // 
            gc.setForeground(EColor.GRAY);
            gc.drawText(Const.NVL(partitionSchema.getName(), "<no partition name>"), point.x, point.y + textExtent.y + 3, true);
            // 
            if (!shadow) {
                areaOwners.add(new AreaOwner(AreaType.STEP_PARTITIONING, point.x, point.y, textExtent.x, textExtent.y, offset, stepMeta, STRING_PARTITIONING_CURRENT_STEP));
            }
        }
    }
    String name = stepMeta.getName();
    if (stepMeta.isSelected()) {
        gc.setLineWidth(linewidth + 2);
    } else {
        gc.setLineWidth(linewidth);
    }
    // Add to the list of areas...
    if (!shadow) {
        areaOwners.add(new AreaOwner(AreaType.STEP_ICON, x, y, iconsize, iconsize, offset, transMeta, stepMeta));
    }
    gc.setBackground(EColor.BACKGROUND);
    gc.fillRoundRectangle(x - 1, y - 1, iconsize + 1, iconsize + 1, 8, 8);
    gc.drawStepIcon(x, y, stepMeta, magnification);
    if (stepError || stepMeta.isMissing()) {
        gc.setForeground(EColor.RED);
    } else {
        gc.setForeground(EColor.CRYSTAL);
    }
    if (stepMeta.isSelected()) {
        gc.setForeground(0, 93, 166);
    }
    gc.drawRoundRectangle(x - 1, y - 1, iconsize + 1, iconsize + 1, 8, 8);
    Point namePosition = getNamePosition(name, screen, iconsize);
    if (stepMeta.isSelected()) {
        int tmpAlpha = gc.getAlpha();
        gc.setAlpha(192);
        gc.setBackground(216, 230, 241);
        gc.fillRoundRectangle(namePosition.x - 8, namePosition.y - 2, gc.textExtent(name).x + 15, 25, BasePainter.CORNER_RADIUS_5 + 15, BasePainter.CORNER_RADIUS_5 + 15);
        gc.setAlpha(tmpAlpha);
    }
    gc.setForeground(EColor.BLACK);
    gc.setFont(EFont.GRAPH);
    gc.drawText(name, namePosition.x, namePosition.y + 2, true);
    boolean partitioned = false;
    StepPartitioningMeta meta = stepMeta.getStepPartitioningMeta();
    if (stepMeta.isPartitioned() && meta != null) {
        partitioned = true;
    }
    String clusterMessage = "";
    if (stepMeta.getClusterSchema() != null) {
        clusterMessage = "C";
        if (stepMeta.getClusterSchema().isDynamic()) {
            clusterMessage += "xN";
        } else {
            clusterMessage += "x" + stepMeta.getClusterSchema().findNrSlaves();
        }
        Point textExtent = gc.textExtent(clusterMessage);
        gc.setBackground(EColor.BACKGROUND);
        gc.setForeground(EColor.BLACK);
        gc.drawText(clusterMessage, x - textExtent.x + 1, y - textExtent.y + 1);
    }
    if (stepMeta.getCopies() != 1 && !partitioned) {
        gc.setBackground(EColor.BACKGROUND);
        gc.setForeground(EColor.BLACK);
        String copies = "x" + stepMeta.getCopiesString();
        Point textExtent = gc.textExtent(copies);
        if (stepMeta.getClusterSchema() != null) {
            Point clusterTextExtent = gc.textExtent(clusterMessage);
            gc.drawText(copies, x - textExtent.x + 1, y - textExtent.y - clusterTextExtent.y + 1, false);
            areaOwners.add(new AreaOwner(AreaType.STEP_COPIES_TEXT, x - textExtent.x + 1, y - textExtent.y - clusterTextExtent.y + 1, textExtent.x, textExtent.y, offset, transMeta, stepMeta));
        } else {
            gc.drawText(copies, x - textExtent.x + 1, y - textExtent.y + 1, false);
            areaOwners.add(new AreaOwner(AreaType.STEP_COPIES_TEXT, x - textExtent.x + 1, y - textExtent.y + 1, textExtent.x, textExtent.y, offset, transMeta, stepMeta));
        }
    }
    // 
    if (stepError) {
        String log = stepLogMap.get(stepMeta);
        // Show an error lines icon in the upper right corner of the step...
        // 
        int xError = (x + iconsize) - (MINI_ICON_SIZE / 2) + 4;
        int yError = y - (MINI_ICON_SIZE / 2) - 1;
        Point ib = gc.getImageBounds(EImage.STEP_ERROR_RED);
        gc.drawImage(EImage.STEP_ERROR_RED, xError, yError, magnification);
        if (!shadow) {
            areaOwners.add(new AreaOwner(AreaType.STEP_ERROR_RED_ICON, pt.x + iconsize - 3, pt.y - 8, ib.x, ib.y, offset, log, STRING_STEP_ERROR_LOG));
        }
    }
    // 
    if (mouseOverSteps.contains(stepMeta)) {
        gc.setTransform(translationX, translationY, 0, BasePainter.FACTOR_1_TO_1);
        StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface();
        boolean mdiSupport = stepMetaInterface.getStepMetaInjectionInterface() != null || BeanInjectionInfo.isInjectionSupported(stepMetaInterface.getClass());
        EImage[] miniIcons;
        if (mdiSupport) {
            miniIcons = new EImage[] { EImage.INPUT, EImage.EDIT, EImage.CONTEXT_MENU, EImage.OUTPUT, EImage.INJECT };
        } else {
            miniIcons = new EImage[] { EImage.INPUT, EImage.EDIT, EImage.CONTEXT_MENU, EImage.OUTPUT };
        }
        int totalHeight = 0;
        int totalIconsWidth = 0;
        int totalWidth = 2 * MINI_ICON_MARGIN;
        for (EImage miniIcon : miniIcons) {
            Point bounds = gc.getImageBounds(miniIcon);
            totalWidth += bounds.x + MINI_ICON_MARGIN;
            totalIconsWidth += bounds.x + MINI_ICON_MARGIN;
            if (bounds.y > totalHeight) {
                totalHeight = bounds.y;
            }
        }
        totalHeight += 2 * MINI_ICON_MARGIN;
        gc.setFont(EFont.SMALL);
        String trimmedName = stepMeta.getName().length() < 30 ? stepMeta.getName() : stepMeta.getName().substring(0, 30);
        Point nameExtent = gc.textExtent(trimmedName);
        nameExtent.y += 2 * MINI_ICON_MARGIN;
        nameExtent.x += 3 * MINI_ICON_MARGIN;
        totalHeight += nameExtent.y;
        if (nameExtent.x > totalWidth) {
            totalWidth = nameExtent.x;
        }
        int areaX = translateToCurrentScale(x) + translateToCurrentScale(iconsize) / 2 - totalWidth / 2 + MINI_ICON_SKEW;
        int areaY = translateToCurrentScale(y) + translateToCurrentScale(iconsize) + MINI_ICON_DISTANCE + BasePainter.CONTENT_MENU_INDENT;
        gc.setForeground(EColor.CRYSTAL);
        gc.setBackground(EColor.CRYSTAL);
        gc.setLineWidth(1);
        gc.fillRoundRectangle(areaX, areaY, totalWidth, totalHeight, BasePainter.CORNER_RADIUS_5, BasePainter.CORNER_RADIUS_5);
        gc.setBackground(EColor.WHITE);
        gc.fillRoundRectangle(areaX, areaY + nameExtent.y, totalWidth, (totalHeight - nameExtent.y), BasePainter.CORNER_RADIUS_5, BasePainter.CORNER_RADIUS_5);
        gc.fillRectangle(areaX, areaY + nameExtent.y, totalWidth, (totalHeight - nameExtent.y) / 2);
        gc.drawRoundRectangle(areaX, areaY, totalWidth, totalHeight, BasePainter.CORNER_RADIUS_5, BasePainter.CORNER_RADIUS_5);
        gc.setForeground(EColor.WHITE);
        gc.drawText(trimmedName, areaX + (totalWidth - nameExtent.x) / 2 + MINI_ICON_MARGIN, areaY + MINI_ICON_MARGIN, true);
        gc.setForeground(EColor.CRYSTAL);
        gc.setBackground(EColor.CRYSTAL);
        gc.setFont(EFont.GRAPH);
        areaOwners.add(new AreaOwner(AreaType.MINI_ICONS_BALLOON, translateTo1To1(areaX), translateTo1To1(areaY), translateTo1To1(totalWidth), translateTo1To1(totalHeight), offset, stepMeta, ioMeta));
        gc.fillPolygon(new int[] { areaX + totalWidth / 2 - MINI_ICON_TRIANGLE_BASE / 2 + 1, areaY + 2, areaX + totalWidth / 2 + MINI_ICON_TRIANGLE_BASE / 2, areaY + 2, areaX + totalWidth / 2 - MINI_ICON_SKEW, areaY - MINI_ICON_DISTANCE - 3 });
        gc.setBackground(EColor.WHITE);
        // Put on the icons...
        // 
        int xIcon = areaX + (totalWidth - totalIconsWidth) / 2 + MINI_ICON_MARGIN;
        int yIcon = areaY + 5 + nameExtent.y;
        for (int i = 0; i < miniIcons.length; i++) {
            EImage miniIcon = miniIcons[i];
            Point bounds = gc.getImageBounds(miniIcon);
            boolean enabled = false;
            switch(i) {
                case // INPUT
                0:
                    enabled = ioMeta.isInputAcceptor() || ioMeta.isInputDynamic();
                    areaOwners.add(new AreaOwner(AreaType.STEP_INPUT_HOP_ICON, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, stepMeta, ioMeta));
                    break;
                case // EDIT
                1:
                    enabled = true;
                    areaOwners.add(new AreaOwner(AreaType.STEP_EDIT_ICON, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, stepMeta, ioMeta));
                    break;
                case // STEP_MENU
                2:
                    enabled = true;
                    areaOwners.add(new AreaOwner(AreaType.STEP_MENU_ICON, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, stepMeta, ioMeta));
                    break;
                case // OUTPUT
                3:
                    enabled = ioMeta.isOutputProducer() || ioMeta.isOutputDynamic();
                    areaOwners.add(new AreaOwner(AreaType.STEP_OUTPUT_HOP_ICON, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, stepMeta, ioMeta));
                    break;
                case // INJECT
                4:
                    enabled = mdiSupport;
                    StepMetaInterface mdiObject = mdiSupport ? stepMetaInterface : null;
                    areaOwners.add(new AreaOwner(AreaType.STEP_INJECT_ICON, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, stepMeta, mdiObject));
                    break;
                default:
                    break;
            }
            if (enabled) {
                gc.setAlpha(255);
            } else {
                gc.setAlpha(100);
            }
            gc.drawImage(miniIcon, xIcon, yIcon, BasePainter.FACTOR_1_TO_1);
            xIcon += bounds.x + 5;
        }
        // 
        if (showTargetStreamsStep != null) {
            ioMeta = showTargetStreamsStep.getStepMetaInterface().getStepIOMeta();
            List<StreamInterface> targetStreams = ioMeta.getTargetStreams();
            int targetsWidth = 0;
            int targetsHeight = 0;
            for (int i = 0; i < targetStreams.size(); i++) {
                String description = targetStreams.get(i).getDescription();
                Point extent = gc.textExtent(description);
                if (extent.x > targetsWidth) {
                    targetsWidth = extent.x;
                }
                targetsHeight += extent.y + MINI_ICON_MARGIN;
            }
            targetsWidth += MINI_ICON_MARGIN;
            gc.setBackground(EColor.LIGHTGRAY);
            gc.fillRoundRectangle(areaX, areaY + totalHeight + 2, targetsWidth, targetsHeight, 7, 7);
            gc.drawRoundRectangle(areaX, areaY + totalHeight + 2, targetsWidth, targetsHeight, 7, 7);
            int targetY = areaY + totalHeight + MINI_ICON_MARGIN;
            for (int i = 0; i < targetStreams.size(); i++) {
                String description = targetStreams.get(i).getDescription();
                Point extent = gc.textExtent(description);
                gc.drawText(description, areaX + MINI_ICON_MARGIN, targetY, true);
                if (i < targetStreams.size() - 1) {
                    gc.drawLine(areaX + MINI_ICON_MARGIN / 2, targetY + extent.y + 3, areaX + targetsWidth - MINI_ICON_MARGIN / 2, targetY + extent.y + 2);
                }
                areaOwners.add(new AreaOwner(AreaType.STEP_TARGET_HOP_ICON_OPTION, areaX, targetY, targetsWidth, extent.y + MINI_ICON_MARGIN, offset, stepMeta, targetStreams.get(i)));
                targetY += extent.y + MINI_ICON_MARGIN;
            }
            gc.setBackground(EColor.BACKGROUND);
        }
        gc.setTransform(translationX, translationY, 0, magnification);
    }
    TransPainterExtension extension = new TransPainterExtension(gc, shadow, areaOwners, transMeta, stepMeta, null, x, y, 0, 0, 0, 0, offset, iconsize);
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterStep.id, extension);
    } catch (Exception e) {
        LogChannel.GENERAL.logError("Error calling extension point(s) for the transformation painter step", e);
    }
    // Restore the previous alpha value
    // 
    gc.setAlpha(alpha);
}
Also used : EImage(org.pentaho.di.core.gui.PrimitiveGCInterface.EImage) PartitionSchema(org.pentaho.di.partition.PartitionSchema) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) StepPartitioningMeta(org.pentaho.di.trans.step.StepPartitioningMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException) AreaOwner(org.pentaho.di.core.gui.AreaOwner) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Aggregations

StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)77 StepMeta (org.pentaho.di.trans.step.StepMeta)40 KettleException (org.pentaho.di.core.exception.KettleException)31 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)21 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)20 TransMeta (org.pentaho.di.trans.TransMeta)16 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)16 TableItem (org.eclipse.swt.widgets.TableItem)15 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)15 SourceToTargetMapping (org.pentaho.di.core.SourceToTargetMapping)14 Trans (org.pentaho.di.trans.Trans)14 EnterMappingDialog (org.pentaho.di.ui.core.dialog.EnterMappingDialog)14 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)12 Point (org.pentaho.di.core.gui.Point)12 TransHopMeta (org.pentaho.di.trans.TransHopMeta)11 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)11 NotePadMeta (org.pentaho.di.core.NotePadMeta)8 KettleStepException (org.pentaho.di.core.exception.KettleStepException)8 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)8