use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.
the class Spoon method quitFile.
public boolean quitFile(boolean canCancel) throws KettleException {
if (log.isDetailed()) {
// "Quit application."
log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.QuitApplication"));
}
boolean exit = true;
saveSettings();
if (props.showExitWarning() && canCancel) {
// Display message: are you sure you want to exit?
//
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, // "Warning!"
BaseMessages.getString(PKG, "System.Warning"), null, BaseMessages.getString(PKG, "Spoon.Message.Warning.PromptExit"), MessageDialog.WARNING, new String[] { // "Yes",
BaseMessages.getString(PKG, "Spoon.Message.Warning.Yes"), // "No"
BaseMessages.getString(PKG, "Spoon.Message.Warning.No") }, 1, // "Please, don't show this warning anymore."
BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowWarning"), !props.showExitWarning());
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
int idx = md.open();
props.setExitWarningShown(!md.getToggleState());
props.saveProps();
if ((idx & 0xFF) == 1) {
// No selected: don't exit!
return false;
}
}
// Check all tabs to see if we can close them...
//
List<TabMapEntry> list = delegates.tabs.getTabs();
for (TabMapEntry mapEntry : list) {
TabItemInterface itemInterface = mapEntry.getObject();
if (!itemInterface.canBeClosed()) {
// Show the tab
tabfolder.setSelected(mapEntry.getTabItem());
// Unsaved work that needs to changes to be applied?
//
int reply = itemInterface.showChangedWarning();
if (reply == SWT.YES) {
exit = itemInterface.applyChanges();
} else {
if (reply == SWT.CANCEL) {
return false;
} else {
// SWT.NO
exit = true;
}
}
}
}
if (exit || !canCancel) {
// all the tabs, stop the running transformations
for (TabMapEntry mapEntry : list) {
if (!mapEntry.getObject().canBeClosed()) {
//
if (mapEntry.getObject() instanceof TransGraph) {
TransMeta transMeta = (TransMeta) mapEntry.getObject().getManagedObject();
if (transMeta.hasChanged()) {
delegates.tabs.removeTab(mapEntry);
}
}
//
if (mapEntry.getObject() instanceof TransGraph) {
TransGraph transGraph = (TransGraph) mapEntry.getObject();
if (transGraph.isRunning()) {
transGraph.stop();
delegates.tabs.removeTab(mapEntry);
}
}
}
}
}
try {
lifecycleSupport.onExit(this);
} catch (LifecycleException e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
box.setMessage(e.getMessage());
box.open();
}
if (exit) {
// so we first move the focus to somewhere else
if (this.selectionFilter != null && !this.selectionFilter.isDisposed()) {
this.selectionFilter.forceFocus();
}
close();
}
return exit;
}
use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.
the class Spoon method zoom100Percent.
public void zoom100Percent() {
TransGraph transGraph = getActiveTransGraph();
if (transGraph != null) {
transGraph.zoom100Percent();
}
JobGraph jobGraph = getActiveJobGraph();
if (jobGraph != null) {
jobGraph.zoom100Percent();
}
}
use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.
the class Spoon method printTransFile.
private void printTransFile(TransMeta transMeta) {
TransGraph transGraph = getActiveTransGraph();
if (transGraph == null) {
return;
}
PrintSpool ps = new PrintSpool();
Printer printer = ps.getPrinter(shell);
// Create an image of the screen
Point max = transMeta.getMaximum();
Image img = transGraph.getTransformationImage(printer, max.x, max.y, 1.0f);
ps.printImage(shell, img);
img.dispose();
ps.dispose();
}
use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.
the class CsvInputDialog method updatePreview.
/**
* Load metadata from step window
*/
protected void updatePreview() {
if (initializing) {
return;
}
if (previewBusy.get()) {
return;
}
try {
previewBusy.set(true);
CsvInputMeta meta = new CsvInputMeta();
getInfo(meta);
//
if (Utils.isEmpty(meta.getFilename())) {
return;
}
if (Utils.isEmpty(meta.getInputFields())) {
return;
}
String stepname = wStepname.getText();
// StepMeta stepMeta = new StepMeta(stepname, meta);
StringBuffer buffer = new StringBuffer();
final List<Object[]> rowsData = new ArrayList<Object[]>();
final RowMetaInterface rowMeta = new RowMeta();
try {
meta.getFields(rowMeta, stepname, null, null, transMeta, repository, metaStore);
TransMeta previewTransMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, meta, stepname);
final Trans trans = new Trans(previewTransMeta);
trans.prepareExecution(null);
StepInterface step = trans.getRunThread(stepname, 0);
step.addRowListener(new RowAdapter() {
@Override
public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
rowsData.add(row);
//
if (rowsData.size() > PropsUI.getInstance().getDefaultPreviewSize()) {
trans.stopAll();
}
}
});
trans.startThreads();
trans.waitUntilFinished();
if (trans.getErrors() > 0) {
StringBuffer log = KettleLogStore.getAppender().getBuffer(trans.getLogChannelId(), false);
buffer.append(log);
}
KettleLogStore.discardLines(trans.getLogChannelId(), false);
LoggingRegistry.getInstance().removeIncludingChildren(trans.getLogChannelId());
} catch (Exception e) {
buffer.append(Const.getStackTracker(e));
}
TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
if (transGraph != null) {
if (!transGraph.isExecutionResultsPaneVisible()) {
transGraph.showExecutionResults();
}
transGraph.extraViewTabFolder.setSelection(5);
transGraph.transPreviewDelegate.addPreviewData(stepMeta, rowMeta, rowsData, buffer);
transGraph.transPreviewDelegate.setSelectedStep(stepMeta);
transGraph.transPreviewDelegate.refreshView();
}
} finally {
previewBusy.set(false);
}
}
use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.
the class SpoonTransformationDelegate method executeTransformation.
public void executeTransformation(final TransMeta transMeta, final boolean local, final boolean remote, final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe, LogLevel logLevel) throws KettleException {
if (transMeta == null) {
return;
}
// See if we need to ask for debugging information...
//
TransDebugMeta transDebugMeta = null;
TransExecutionConfiguration executionConfiguration = null;
if (preview) {
executionConfiguration = spoon.getTransPreviewExecutionConfiguration();
} else if (debug) {
executionConfiguration = spoon.getTransDebugExecutionConfiguration();
} else {
executionConfiguration = spoon.getTransExecutionConfiguration();
}
// Set defaults so the run configuration can set it up correctly
executionConfiguration.setExecutingLocally(true);
executionConfiguration.setExecutingRemotely(false);
executionConfiguration.setExecutingClustered(false);
// Set repository and safe mode information in both the exec config and the metadata
transMeta.setRepository(spoon.rep);
transMeta.setMetaStore(spoon.metaStore);
executionConfiguration.setRepository(spoon.rep);
executionConfiguration.setSafeModeEnabled(safe);
if (debug) {
// See if we have debugging information stored somewhere?
//
transDebugMeta = transDebugMetaMap.get(transMeta);
if (transDebugMeta == null) {
transDebugMeta = new TransDebugMeta(transMeta);
transDebugMetaMap.put(transMeta, transDebugMeta);
}
// Set the default number of rows to retrieve on all selected steps...
//
List<StepMeta> selectedSteps = transMeta.getSelectedSteps();
if (selectedSteps != null && selectedSteps.size() > 0) {
transDebugMeta.getStepDebugMetaMap().clear();
for (StepMeta stepMeta : transMeta.getSelectedSteps()) {
StepDebugMeta stepDebugMeta = new StepDebugMeta(stepMeta);
stepDebugMeta.setRowCount(PropsUI.getInstance().getDefaultPreviewSize());
stepDebugMeta.setPausingOnBreakPoint(true);
stepDebugMeta.setReadingFirstRows(false);
transDebugMeta.getStepDebugMetaMap().put(stepMeta, stepDebugMeta);
}
}
} else if (preview) {
// See if we have preview information stored somewhere?
//
transDebugMeta = transPreviewMetaMap.get(transMeta);
if (transDebugMeta == null) {
transDebugMeta = new TransDebugMeta(transMeta);
transPreviewMetaMap.put(transMeta, transDebugMeta);
}
// Set the default number of preview rows on all selected steps...
//
List<StepMeta> selectedSteps = transMeta.getSelectedSteps();
if (selectedSteps != null && selectedSteps.size() > 0) {
transDebugMeta.getStepDebugMetaMap().clear();
for (StepMeta stepMeta : transMeta.getSelectedSteps()) {
StepDebugMeta stepDebugMeta = new StepDebugMeta(stepMeta);
stepDebugMeta.setRowCount(PropsUI.getInstance().getDefaultPreviewSize());
stepDebugMeta.setPausingOnBreakPoint(false);
stepDebugMeta.setReadingFirstRows(true);
transDebugMeta.getStepDebugMetaMap().put(stepMeta, stepDebugMeta);
}
}
}
int debugAnswer = TransDebugDialog.DEBUG_CONFIG;
if (debug || preview) {
// pass repository for mappings
transDebugMeta.getTransMeta().setRepository(spoon.rep);
TransDebugDialog transDebugDialog = new TransDebugDialog(spoon.getShell(), transDebugMeta);
debugAnswer = transDebugDialog.open();
if (debugAnswer != TransDebugDialog.DEBUG_CANCEL) {
executionConfiguration.setExecutingLocally(true);
executionConfiguration.setExecutingRemotely(false);
executionConfiguration.setExecutingClustered(false);
} else {
//
return;
}
}
Object[] data = spoon.variables.getData();
String[] fields = spoon.variables.getRowMeta().getFieldNames();
Map<String, String> variableMap = new HashMap<String, String>();
// the default
variableMap.putAll(executionConfiguration.getVariables());
for (int idx = 0; idx < fields.length; idx++) {
String value = executionConfiguration.getVariables().get(fields[idx]);
if (Utils.isEmpty(value)) {
value = data[idx].toString();
}
variableMap.put(fields[idx], value);
}
executionConfiguration.setVariables(variableMap);
executionConfiguration.getUsedVariables(transMeta);
executionConfiguration.getUsedArguments(transMeta, spoon.getArguments());
executionConfiguration.setReplayDate(replayDate);
executionConfiguration.setLogLevel(logLevel);
boolean execConfigAnswer = true;
if (debugAnswer == TransDebugDialog.DEBUG_CONFIG && replayDate == null && transMeta.isShowDialog()) {
TransExecutionConfigurationDialog dialog = new TransExecutionConfigurationDialog(spoon.getShell(), executionConfiguration, transMeta);
execConfigAnswer = dialog.open();
}
if (execConfigAnswer) {
TransGraph activeTransGraph = spoon.getActiveTransGraph();
activeTransGraph.transLogDelegate.addTransLog();
// Set the named parameters
Map<String, String> paramMap = executionConfiguration.getParams();
for (String key : paramMap.keySet()) {
transMeta.setParameterValue(key, Const.NVL(paramMap.get(key), ""));
}
transMeta.activateParameters();
//
if (executionConfiguration.getLogLevel() != null) {
transMeta.setLogLevel(executionConfiguration.getLogLevel());
}
// Set the run options
transMeta.setClearingLog(executionConfiguration.isClearingLog());
transMeta.setSafeModeEnabled(executionConfiguration.isSafeModeEnabled());
transMeta.setGatheringMetrics(executionConfiguration.isGatheringMetrics());
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonTransMetaExecutionStart.id, transMeta);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonTransExecutionConfiguration.id, executionConfiguration);
try {
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, transMeta, transMeta, spoon.getRepository() });
} catch (KettleException e) {
log.logError(e.getMessage(), transMeta.getFilename());
return;
}
if (!executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely()) {
if (transMeta.hasChanged()) {
activeTransGraph.showSaveFileMessage();
}
}
//
if (debug || preview) {
if (transDebugMeta.getNrOfUsedSteps() == 0) {
MessageBox box = new MessageBox(spoon.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);
box.setText(BaseMessages.getString(PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Title"));
box.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Message"));
int answer = box.open();
if (answer != SWT.YES) {
return;
}
}
}
//
if (executionConfiguration.isExecutingLocally()) {
if (debug || preview) {
activeTransGraph.debug(executionConfiguration, transDebugMeta);
} else {
activeTransGraph.start(executionConfiguration);
}
// Are we executing remotely?
//
} else if (executionConfiguration.isExecutingRemotely()) {
activeTransGraph.handleTransMetaChanges(transMeta);
if (transMeta.hasChanged()) {
showSaveTransformationBeforeRunningDialog(spoon.getShell());
} else if (executionConfiguration.getRemoteServer() != null) {
String carteObjectId = Trans.sendToSlaveServer(transMeta, executionConfiguration, spoon.rep, spoon.metaStore);
monitorRemoteTrans(transMeta, carteObjectId, executionConfiguration.getRemoteServer());
spoon.delegates.slaves.addSpoonSlave(executionConfiguration.getRemoteServer());
} else {
MessageBox mb = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message"));
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title"));
mb.open();
}
// Are we executing clustered?
//
} else if (executionConfiguration.isExecutingClustered()) {
activeTransGraph.handleTransMetaChanges(transMeta);
if (transMeta.hasChanged()) {
showSaveTransformationBeforeRunningDialog(spoon.getShell());
} else {
splitTrans(transMeta, executionConfiguration);
}
}
}
}
Aggregations