use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class GetJobImageServlet method generateJobImage.
private BufferedImage generateJobImage(JobMeta jobMeta) throws Exception {
float magnification = 1.0f;
Point maximum = jobMeta.getMaximum();
maximum.multiply(magnification);
SwingGC gc = new SwingGC(null, maximum, 32, 0, 0);
JobPainter jobPainter = new JobPainter(gc, jobMeta, maximum, null, null, null, null, null, new ArrayList<AreaOwner>(), new ArrayList<JobEntryCopy>(), 32, 1, 0, 0, true, "Arial", 10);
jobPainter.setMagnification(magnification);
jobPainter.drawJob();
BufferedImage image = (BufferedImage) gc.getImage();
return image;
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class GetTransStatusServlet method doGet.
/**
* <div id="mindtouch">
* <h1>/kettle/transStatus</h1>
* <a name="GET"></a>
* <h2>GET</h2>
* <p>Retrieves status of the specified transformation. Status is returned as HTML or XML output
* depending on the input parameters. Status contains information about last execution of the transformation.</p>
* <p><b>Example Request:</b><br />
* <pre function="syntax.xml">
* GET /kettle/transStatus/?name=dummy-trans&xml=Y
* </pre>
*
* </p>
* <h3>Parameters</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>name</th>
* <th>description</th>
* <th>type</th>
* </tr>
* <tr>
* <td>name</td>
* <td>Name of the transformation to be used for status generation.</td>
* <td>query</td>
* </tr>
* <tr>
* <td>xml</td>
* <td>Boolean flag which defines output format <code>Y</code> forces XML output to be generated.
* HTML is returned otherwise.</td>
* <td>boolean, optional</td>
* </tr>
* <tr>
* <td>id</td>
* <td>Carte id of the transformation to be used for status generation.</td>
* <td>query, optional</td>
* </tr>
* <tr>
* <td>from</td>
* <td>Start line number of the execution log to be included into response.</td>
* <td>integer, optional</td>
* </tr>
* </tbody>
* </table>
*
* <h3>Response Body</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <td align="right">element:</td>
* <td>(custom)</td>
* </tr>
* <tr>
* <td align="right">media types:</td>
* <td>text/xml, text/html</td>
* </tr>
* </tbody>
* </table>
* <p> Response XML or HTML response containing details about the transformation specified.
* If an error occurs during method invocation <code>result</code> field of the response
* will contain <code>ERROR</code> status.</p>
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.xml">
* <?xml version="1.0" encoding="UTF-8"?>
* <transstatus>
* <transname>dummy-trans</transname>
* <id>c56961b2-c848-49b8-abde-76c8015e29b0</id>
* <status_desc>Stopped</status_desc>
* <error_desc/>
* <paused>N</paused>
* <stepstatuslist>
* <stepstatus><stepname>Dummy (do nothing)</stepname>
* <copy>0</copy><linesRead>0</linesRead>
* <linesWritten>0</linesWritten><linesInput>0</linesInput>
* <linesOutput>0</linesOutput><linesUpdated>0</linesUpdated>
* <linesRejected>0</linesRejected><errors>0</errors>
* <statusDescription>Stopped</statusDescription><seconds>0.0</seconds>
* <speed>-</speed><priority>-</priority><stopped>Y</stopped>
* <paused>N</paused>
* </stepstatus>
* </stepstatuslist>
* <first_log_line_nr>0</first_log_line_nr>
* <last_log_line_nr>37</last_log_line_nr>
* <result>
* <lines_input>0</lines_input>
* <lines_output>0</lines_output>
* <lines_read>0</lines_read>
* <lines_written>0</lines_written>
* <lines_updated>0</lines_updated>
* <lines_rejected>0</lines_rejected>
* <lines_deleted>0</lines_deleted>
* <nr_errors>0</nr_errors>
* <nr_files_retrieved>0</nr_files_retrieved>
* <entry_nr>0</entry_nr>
* <result>Y</result>
* <exit_status>0</exit_status>
* <is_stopped>Y</is_stopped>
* <log_channel_id>10e2c832-07da-409a-a5ba-4b90a234e957</log_channel_id>
* <log_text/>
* <result-file></result-file>
* <result-rows></result-rows>
* </result>
* <logging_string><![CDATA[H4sIAAAAAAAAADMyMDTRNzTUNzJRMDSyMrC0MjFV0FVIKc3NrdQtKUrMKwbyXDKLCxJLkjMy89IViksSi0pSUxTS8osUwPJARm5iSWZ+nkI0kq5YXi4AQVH5bFoAAAA=]]></logging_string>
* </transstatus>
* </pre>
*
* <h3>Status Codes</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>code</th>
* <th>description</th>
* </tr>
* <tr>
* <td>200</td>
* <td>Request was processed.</td>
* </tr>
* <tr>
* <td>500</td>
* <td>Internal server error occurs during request processing.</td>
* </tr>
* </tbody>
* </table>
* </div>
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (isJettyMode() && !request.getContextPath().startsWith(CONTEXT_PATH)) {
return;
}
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "TransStatusServlet.Log.TransStatusRequested"));
}
String transName = request.getParameter("name");
String id = request.getParameter("id");
boolean useXML = "Y".equalsIgnoreCase(request.getParameter("xml"));
int startLineNr = Const.toInt(request.getParameter("from"), 0);
response.setStatus(HttpServletResponse.SC_OK);
if (useXML) {
response.setContentType("text/xml");
response.setCharacterEncoding(Const.XML_ENCODING);
} else {
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
}
// ID is optional...
//
Trans trans;
CarteObjectEntry entry;
if (Utils.isEmpty(id)) {
// get the first transformation that matches...
//
entry = getTransformationMap().getFirstCarteObjectEntry(transName);
if (entry == null) {
trans = null;
} else {
id = entry.getId();
trans = getTransformationMap().getTransformation(entry);
}
} else {
// Take the ID into account!
//
entry = new CarteObjectEntry(transName, id);
trans = getTransformationMap().getTransformation(entry);
}
if (trans != null) {
if (useXML) {
try {
OutputStream out = null;
byte[] data = null;
String logId = trans.getLogChannelId();
boolean finishedOrStopped = trans.isFinishedOrStopped();
boolean sendResultXmlWithStatus = "Y".equalsIgnoreCase(request.getParameter(SEND_RESULT));
boolean dontUseCache = sendResultXmlWithStatus;
if (finishedOrStopped && (data = cache.get(logId, startLineNr)) != null && !dontUseCache) {
response.setContentLength(XML_HEADER.length + data.length);
out = response.getOutputStream();
out.write(XML_HEADER);
out.write(data);
out.flush();
} else {
int lastLineNr = KettleLogStore.getLastBufferLineNr();
String logText = getLogText(trans, startLineNr, lastLineNr);
response.setContentType("text/xml");
response.setCharacterEncoding(Const.XML_ENCODING);
SlaveServerTransStatus transStatus = new SlaveServerTransStatus(transName, entry.getId(), trans.getStatus());
transStatus.setFirstLoggingLineNr(startLineNr);
transStatus.setLastLoggingLineNr(lastLineNr);
transStatus.setLogDate(trans.getLogDate());
for (int i = 0; i < trans.nrSteps(); i++) {
StepInterface baseStep = trans.getRunThread(i);
if ((baseStep.isRunning()) || baseStep.getStatus() != StepExecutionStatus.STATUS_EMPTY) {
StepStatus stepStatus = new StepStatus(baseStep);
transStatus.getStepStatusList().add(stepStatus);
}
}
// The log can be quite large at times, we are going to putIfAbsent a base64 encoding around a compressed
// stream
// of bytes to handle this one.
String loggingString = HttpUtil.encodeBase64ZippedString(logText);
transStatus.setLoggingString(loggingString);
// transStatus.setLoggingUncompressedSize( logText.length() );
// Also set the result object...
//
transStatus.setResult(trans.getResult());
// Is the transformation paused?
//
transStatus.setPaused(trans.isPaused());
// Send the result back as XML
//
String xml = transStatus.getXML(sendResultXmlWithStatus);
data = xml.getBytes(Charset.forName(Const.XML_ENCODING));
out = response.getOutputStream();
response.setContentLength(XML_HEADER.length + data.length);
out.write(XML_HEADER);
out.write(data);
out.flush();
if (finishedOrStopped && logId != null && !dontUseCache) {
cache.put(logId, xml, startLineNr);
}
}
response.flushBuffer();
} catch (KettleException e) {
throw new ServletException("Unable to get the transformation status in XML format", e);
}
} else {
PrintWriter out = response.getWriter();
int lastLineNr = KettleLogStore.getLastBufferLineNr();
response.setContentType("text/html;charset=UTF-8");
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>" + BaseMessages.getString(PKG, "TransStatusServlet.KettleTransStatus") + "</TITLE>");
if (EnvUtil.getSystemProperty(Const.KETTLE_CARTE_REFRESH_STATUS, "N").equalsIgnoreCase("Y")) {
out.println("<META http-equiv=\"Refresh\" content=\"10;url=" + convertContextPath(CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">");
}
out.println("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<H1>" + Encode.forHtml(BaseMessages.getString(PKG, "TransStatusServlet.TopTransStatus", transName)) + "</H1>");
try {
out.println("<table border=\"1\">");
out.print("<tr> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.TransName") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.CarteObjectId") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.TransStatus") + "</th> </tr>");
out.print("<tr>");
out.print("<td>" + Encode.forHtml(transName) + "</td>");
out.print("<td>" + Encode.forHtml(id) + "</td>");
out.print("<td>" + Encode.forHtml(trans.getStatus()) + "</td>");
out.print("</tr>");
out.print("</table>");
out.print("<p>");
// Get the transformation image
//
// out.print("<a href=\"" + convertContextPath(GetTransImageServlet.CONTEXT_PATH) + "?name=" +
// URLEncoder.encode(transName, "UTF-8") + "&id="+id+"\">"
// + BaseMessages.getString(PKG, "TransStatusServlet.GetTransImage") + "</a>");
Point max = trans.getTransMeta().getMaximum();
max.x += 20;
max.y += 20;
out.print("<iframe height=\"" + max.y + "\" width=\"" + max.x + "\" seamless src=\"" + convertContextPath(GetTransImageServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\"></iframe>");
out.print("<p>");
if ((trans.isFinished() && trans.isRunning()) || (!trans.isRunning() && !trans.isPreparing() && !trans.isInitializing())) {
out.print("<a href=\"" + convertContextPath(StartTransServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.StartTrans") + "</a>");
out.print("<p>");
out.print("<a href=\"" + convertContextPath(PrepareExecutionTransServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.PrepareTrans") + "</a><br>");
} else if (trans.isRunning()) {
out.print("<a href=\"" + convertContextPath(PauseTransServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "PauseStatusServlet.PauseResumeTrans") + "</a><br>");
out.print("<a href=\"" + convertContextPath(StopTransServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.StopTrans") + "</a><br>");
out.print("<a href=\"" + convertContextPath(StopTransServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "&inputOnly=Y" + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.SafeStopTrans") + "</a>");
out.print("<p>");
}
out.print("<a href=\"" + convertContextPath(CleanupTransServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.CleanupTrans") + "</a>");
out.print("<p>");
out.println("<table border=\"1\">");
out.print("<tr> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Stepname") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.CopyNr") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Read") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Written") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Input") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Output") + "</th> " + "<th>" + BaseMessages.getString(PKG, "TransStatusServlet.Updated") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Rejected") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Errors") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Active") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.Time") + "</th> " + "<th>" + BaseMessages.getString(PKG, "TransStatusServlet.Speed") + "</th> <th>" + BaseMessages.getString(PKG, "TransStatusServlet.prinout") + "</th> </tr>");
for (int i = 0; i < trans.nrSteps(); i++) {
StepInterface step = trans.getRunThread(i);
if ((step.isRunning()) || step.getStatus() != StepExecutionStatus.STATUS_EMPTY) {
StepStatus stepStatus = new StepStatus(step);
boolean snif = false;
if (step.isRunning() && !step.isStopped() && !step.isPaused()) {
snif = true;
String sniffLink = " <a href=\"" + convertContextPath(SniffStepServlet.CONTEXT_PATH) + "?trans=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "&lines=50" + "©nr=" + step.getCopy() + "&type=" + SniffStepServlet.TYPE_OUTPUT + "&step=" + URLEncoder.encode(step.getStepname(), "UTF-8") + "\">" + Encode.forHtml(stepStatus.getStepname()) + "</a>";
stepStatus.setStepname(sniffLink);
}
out.print(stepStatus.getHTMLTableRow(snif));
}
}
out.println("</table>");
out.println("<p>");
out.print("<a href=\"" + convertContextPath(GetTransStatusServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "&xml=y\">" + BaseMessages.getString(PKG, "TransStatusServlet.ShowAsXml") + "</a><br>");
out.print("<a href=\"" + convertContextPath(GetStatusServlet.CONTEXT_PATH) + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.BackToStatusPage") + "</a><br>");
out.print("<p><a href=\"" + convertContextPath(GetTransStatusServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.Refresh") + "</a>");
// Put the logging below that.
out.println("<p>");
out.println("<textarea id=\"translog\" cols=\"120\" rows=\"20\" " + "wrap=\"off\" name=\"Transformation log\" readonly=\"readonly\">" + Encode.forHtml(getLogText(trans, startLineNr, lastLineNr)) + "</textarea>");
out.println("<script type=\"text/javascript\"> ");
out.println(" translog.scrollTop=translog.scrollHeight; ");
out.println("</script> ");
out.println("<p>");
} catch (Exception ex) {
out.println("<p>");
out.println("<pre>");
out.println(Encode.forHtml(Const.getStackTracker(ex)));
out.println("</pre>");
}
out.println("<p>");
out.println("</BODY>");
out.println("</HTML>");
}
} else {
PrintWriter out = response.getWriter();
if (useXML) {
out.println(new WebResult(WebResult.STRING_ERROR, BaseMessages.getString(PKG, "TransStatusServlet.Log.CoundNotFindSpecTrans", transName)));
} else {
out.println("<H1>" + Encode.forHtml(BaseMessages.getString(PKG, "TransStatusServlet.Log.CoundNotFindTrans", transName)) + "</H1>");
out.println("<a href=\"" + convertContextPath(GetStatusServlet.CONTEXT_PATH) + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.BackToStatusPage") + "</a><p>");
}
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransMeta method getSelectedNoteLocations.
/**
* Get an array of all the selected note locations.
*
* @return The selected note locations.
*/
public Point[] getSelectedNoteLocations() {
List<Point> points = new ArrayList<>();
for (NotePadMeta ni : getSelectedNotes()) {
Point p = ni.getLocation();
// explicit copy of location
points.add(new Point(p.x, p.y));
}
return points.toArray(new Point[points.size()]);
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransMeta method getSelectedStepLocations.
/**
* Get an array of all the selected step locations.
*
* @return The selected step locations.
*/
public Point[] getSelectedStepLocations() {
List<Point> points = new ArrayList<>();
for (StepMeta stepMeta : getSelectedSteps()) {
Point p = stepMeta.getLocation();
// explicit copy of location
points.add(new Point(p.x, p.y));
}
return points.toArray(new Point[points.size()]);
}
use of org.pentaho.di.core.gui.Point 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);
}
Aggregations