use of org.talend.designer.runprocess.ui.actions.ClearPerformanceAction in project tdi-studio-se by Talend.
the class ProcessView method fillActionBars.
private void fillActionBars() {
IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
clearPerfAction = new ClearPerformanceAction();
menuManager.add(clearPerfAction);
}
use of org.talend.designer.runprocess.ui.actions.ClearPerformanceAction in project tdi-studio-se by Talend.
the class ProcessComposite method addListeners.
protected void addListeners() {
// qli comment "addSelectionListener" .
/*
* moveButton.addSelectionListener(new SelectionAdapter() {
*
* @Override public void widgetSelected(final SelectionEvent e) { if (moveButton.getText().equals("<<")) {
* //$NON-NLS-1$ sash.setWeights(new int[] { 0, 1, 23 }); moveButton.setText(">>"); //$NON-NLS-1$
* moveButton.setToolTipText(Messages.getString("ProcessComposite.showContext")); //$NON-NLS-1$ } else if
* (moveButton.getText().equals(">>")) { //$NON-NLS-1$ sash.setWeights(new int[] { 7, 1, H_WEIGHT });
* moveButton.setText("<<"); //$NON-NLS-1$
* moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext"));//$NON-NLS-1$ } } });
*/
// perfBtn.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(final SelectionEvent e) {
// processContext.setMonitorPerf(perfBtn.getSelection());
// }
// });
//
// traceBtn.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(final SelectionEvent e) {
// processContext.setMonitorTrace(traceBtn.getSelection());
// org.talend.core.model.process.IProcess process = processContext.getProcess();
// List<INode> nodeList = (List<INode>) process.getGraphicalNodes();
// for (INode node : nodeList) {
// for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
// ConnectionTrace traceNode = connection.getConnectionTrace();
// if (traceNode == null) {
// continue;
// }
// traceNode.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), traceBtn.getSelection());
// if (connection != null) {
// connection.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), traceBtn.getSelection());
// }
// }
// }
//
// }
// });
clearTracePerfBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (processContext == null) {
clearTracePerfBtn.setEnabled(false);
return;
}
if (processContext.isRunning()) {
if (consoleText != null && !consoleText.isDisposed()) {
processContext.clearMessages();
}
} else {
ClearPerformanceAction clearPerfAction = new ClearPerformanceAction();
clearPerfAction.setProcess(processContext.getProcess());
clearPerfAction.run();
ClearTraceAction clearTraceAction = new ClearTraceAction();
clearTraceAction.setProcess(processContext.getProcess());
clearTraceAction.run();
//$NON-NLS-1$
consoleText.setText("");
processContext.clearMessages();
refreshNodeContainer();
refreshSubjobContainer();
}
}
});
killBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
kill();
}
});
// watchBtn.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(SelectionEvent e) {
// processContext.setWatchAllowed(watchBtn.getSelection());
// }
//
// });
// saveJobBeforeRunButton.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(SelectionEvent e) {
// processContext.setSaveBeforeRun(saveJobBeforeRunButton.getSelection());
// }
// });
// clearBeforeExec.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(SelectionEvent e) {
// processContext.setClearBeforeExec(clearBeforeExec.getSelection());
// }
// });
}
use of org.talend.designer.runprocess.ui.actions.ClearPerformanceAction in project tdi-studio-se by Talend.
the class DebugProcessTosComposite method debug.
@Override
public void debug() {
if (manager.getClearBeforeExec()) {
processContext.clearMessages();
}
setHideconsoleLine(false);
if ((processContext.getProcess()) instanceof org.talend.designer.core.ui.editor.process.Process) {
((org.talend.designer.core.ui.editor.process.Process) processContext.getProcess()).checkDifferenceWithRepository();
}
// final IPreferenceStore preferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
final IPreferenceStore preferenceStore = DebugUITools.getPreferenceStore();
final boolean oldValueConsoleOnOut = preferenceStore.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT);
final boolean oldValueConsoleOnErr = preferenceStore.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR);
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, false);
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, false);
// java debug to collect when tos
int num = RunProcessPlugin.getDefault().getPreferenceStore().getInt(RunProcessTokenCollector.TOS_COUNT_DEBUG_RUNS.getPrefKey());
RunProcessPlugin.getDefault().getPreferenceStore().setValue(RunProcessTokenCollector.TOS_COUNT_DEBUG_RUNS.getPrefKey(), num + 1);
checkSaveBeforeRunSelection();
if (contextComposite.promptConfirmLauch()) {
setRunnable(false);
final IContext context = contextComposite.getSelectedContext();
IRunnableWithProgress worker = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
IProcessor processor = ProcessorUtilities.getProcessor(processContext.getProcess(), processContext.getProcess().getProperty(), context);
//$NON-NLS-1$
monitor.beginTask("Launching debugger", IProgressMonitor.UNKNOWN);
try {
// use this function to generate childrens also.
ProcessorUtilities.generateCode(processContext.getProcess(), context, false, false, true, monitor);
ILaunchConfiguration config = ((Processor) processor).getDebugConfiguration(processContext.getStatisticsPort(), processContext.getTracesPort(), null);
// code is correct before launching
if (!JobErrorsChecker.hasErrors(DebugProcessTosComposite.this.getShell())) {
if (config != null) {
// PlatformUI.getWorkbench().
// getActiveWorkbenchWindow
// ().addPerspectiveListener(new
// DebugInNewWindowListener());
DebugUITools.launch(config, ILaunchManager.DEBUG_MODE);
} else {
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("ProcessDebugDialog.debugBtn"), //$NON-NLS-1$
Messages.getString("ProcessDebugDialog.errortext"));
}
}
} catch (ProcessorException e) {
IStatus status = new Status(IStatus.ERROR, RunProcessPlugin.PLUGIN_ID, IStatus.OK, "Debug launch failed.", //$NON-NLS-1$
e);
RunProcessPlugin.getDefault().getLog().log(status);
//$NON-NLS-1$ //$NON-NLS-2$
MessageDialog.openError(getShell(), Messages.getString("ProcessDebugDialog.debugBtn"), "");
} finally {
monitor.done();
}
}
};
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
try {
progressService.runInUI(PlatformUI.getWorkbench().getProgressService(), worker, ResourcesPlugin.getWorkspace().getRoot());
} catch (InvocationTargetException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
debugMode = true;
try {
Thread thread = new Thread() {
@Override
public void run() {
while (debugMode) {
final IProcess process = DebugUITools.getCurrentProcess();
if (process != null && process.isTerminated()) {
Display dis = Display.getCurrent();
if (dis == null) {
dis = Display.getDefault();
}
dis.asyncExec(new Runnable() {
@Override
public void run() {
setRunnable(true);
if (!killBtn.isDisposed() && killBtn != null) {
killBtn.setEnabled(false);
}
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, oldValueConsoleOnOut);
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, oldValueConsoleOnErr);
if (isAddedStreamListener) {
process.getStreamsProxy().getOutputStreamMonitor().removeListener(streamListener);
isAddedStreamListener = false;
if (processContext.isRunning()) {
//$NON-NLS-1$
final String endingPattern = Messages.getString("ProcessComposite.endPattern");
MessageFormat mf = new MessageFormat(endingPattern);
String byeMsg;
try {
byeMsg = //$NON-NLS-1$
"\n" + mf.format(new Object[] { processContext.getProcess().getName(), new Date(), new Integer(process.getExitValue()) });
processContext.addDebugResultToConsole(new ProcessMessage(MsgType.CORE_OUT, byeMsg));
} catch (DebugException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
processContext.setRunning(false);
}
}
debugMode = false;
}
});
} else {
if (process != null) {
// (one at leat) process
// still running
Display dis = Display.getCurrent();
if (dis == null) {
dis = Display.getDefault();
}
dis.asyncExec(new Runnable() {
@Override
public void run() {
setRunnable(false);
if (!killBtn.isDisposed() && killBtn != null) {
killBtn.setEnabled(true);
}
processContext.setRunning(true);
processContext.setDebugProcess(process);
if (!isAddedStreamListener) {
process.getStreamsProxy().getOutputStreamMonitor().addListener(streamListener);
// if (clearBeforeExec.getSelection()) {
// processContext.clearMessages();
// }
// if (watchBtn.getSelection()) {
// processContext.switchTime();
// }
ClearPerformanceAction clearPerfAction = new ClearPerformanceAction();
clearPerfAction.setProcess(processContext.getProcess());
clearPerfAction.run();
ClearTraceAction clearTraceAction = new ClearTraceAction();
clearTraceAction.setProcess(processContext.getProcess());
clearTraceAction.run();
isAddedStreamListener = true;
//$NON-NLS-1$
final String startingPattern = Messages.getString("ProcessComposite.startPattern");
MessageFormat mf = new MessageFormat(startingPattern);
String welcomeMsg = mf.format(new Object[] { processContext.getProcess().getName(), new Date() });
processContext.addDebugResultToConsole(new ProcessMessage(MsgType.CORE_OUT, //$NON-NLS-1$
welcomeMsg + "\r\n"));
}
}
});
} else {
// no process running
Display dis = Display.getCurrent();
if (dis == null) {
dis = Display.getDefault();
}
dis.asyncExec(new Runnable() {
@Override
public void run() {
setRunnable(true);
if (!killBtn.isDisposed() && killBtn != null) {
killBtn.setEnabled(false);
}
}
});
}
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
}
};
thread.start();
} catch (Exception e) {
ExceptionHandler.process(e);
processContext.addErrorMessage(e);
kill();
}
}
use of org.talend.designer.runprocess.ui.actions.ClearPerformanceAction in project tdi-studio-se by Talend.
the class DebugProcessTosComposite method addListeners.
@Override
protected void addListeners() {
clearTracePerfBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (processContext == null) {
clearTracePerfBtn.setEnabled(false);
return;
}
if (processContext.isRunning()) {
if (consoleText != null && !consoleText.isDisposed()) {
processContext.clearMessages();
}
} else {
ClearPerformanceAction clearPerfAction = new ClearPerformanceAction();
clearPerfAction.setProcess(processContext.getProcess());
clearPerfAction.run();
ClearTraceAction clearTraceAction = new ClearTraceAction();
clearTraceAction.setProcess(processContext.getProcess());
clearTraceAction.run();
//$NON-NLS-1$
consoleText.setText("");
processContext.clearMessages();
}
}
});
killBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
kill();
}
});
}
use of org.talend.designer.runprocess.ui.actions.ClearPerformanceAction in project tdi-studio-se by Talend.
the class ProcessComposite method debug.
public void debug() {
setHideconsoleLine(false);
if ((processContext.getProcess()) instanceof org.talend.designer.core.ui.editor.process.Process) {
((org.talend.designer.core.ui.editor.process.Process) processContext.getProcess()).checkDifferenceWithRepository();
}
// final IPreferenceStore preferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
final IPreferenceStore preferenceStore = DebugUITools.getPreferenceStore();
final boolean oldValueConsoleOnOut = preferenceStore.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT);
final boolean oldValueConsoleOnErr = preferenceStore.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR);
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, false);
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, false);
checkSaveBeforeRunSelection();
if (contextComposite.promptConfirmLauch()) {
setRunnable(false);
final IContext context = contextComposite.getSelectedContext();
IRunnableWithProgress worker = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
IProcessor processor = ProcessorUtilities.getProcessor(processContext.getProcess(), processContext.getProcess().getProperty(), context);
//$NON-NLS-1$
monitor.beginTask("Launching debugger", IProgressMonitor.UNKNOWN);
try {
// use this function to generate childrens also.
ProcessorUtilities.generateCode(processContext.getProcess(), context, false, false, true, monitor);
ILaunchConfiguration config = ((Processor) processor).getDebugConfiguration(processContext.getStatisticsPort(), processContext.getTracesPort(), null);
// code is correct before launching
if (!JobErrorsChecker.hasErrors(ProcessComposite.this.getShell())) {
if (config != null) {
// PlatformUI.getWorkbench().
// getActiveWorkbenchWindow
// ().addPerspectiveListener(new
// DebugInNewWindowListener());
DebugUITools.launch(config, ILaunchManager.DEBUG_MODE);
} else {
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("ProcessDebugDialog.debugBtn"), //$NON-NLS-1$
Messages.getString("ProcessDebugDialog.errortext"));
}
}
} catch (ProcessorException e) {
IStatus status = new Status(IStatus.ERROR, RunProcessPlugin.PLUGIN_ID, IStatus.OK, "Debug launch failed.", //$NON-NLS-1$
e);
RunProcessPlugin.getDefault().getLog().log(status);
//$NON-NLS-1$ //$NON-NLS-2$
MessageDialog.openError(getShell(), Messages.getString("ProcessDebugDialog.debugBtn"), "");
} finally {
monitor.done();
}
}
};
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
try {
progressService.runInUI(PlatformUI.getWorkbench().getProgressService(), worker, ResourcesPlugin.getWorkspace().getRoot());
} catch (InvocationTargetException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
debugMode = true;
try {
Thread thread = new Thread() {
@Override
public void run() {
while (debugMode) {
final IProcess process = DebugUITools.getCurrentProcess();
if (process != null && process.isTerminated()) {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
setRunnable(true);
killBtn.setEnabled(false);
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, oldValueConsoleOnOut);
preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, oldValueConsoleOnErr);
if (isAddedStreamListener) {
process.getStreamsProxy().getOutputStreamMonitor().removeListener(streamListener);
isAddedStreamListener = false;
if (processContext.isRunning()) {
//$NON-NLS-1$
final String endingPattern = Messages.getString("ProcessComposite.endPattern");
MessageFormat mf = new MessageFormat(endingPattern);
String byeMsg;
try {
byeMsg = //$NON-NLS-1$
"\n" + mf.format(new Object[] { processContext.getProcess().getName(), new Date(), new Integer(process.getExitValue()) });
processContext.addDebugResultToConsole(new ProcessMessage(MsgType.CORE_OUT, byeMsg));
} catch (DebugException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
processContext.setRunning(false);
}
}
debugMode = false;
}
});
} else {
if (process != null) {
// (one at leat) process
// still running
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
setRunnable(false);
killBtn.setEnabled(true);
processContext.setRunning(true);
processContext.setDebugProcess(process);
if (!isAddedStreamListener) {
process.getStreamsProxy().getOutputStreamMonitor().addListener(streamListener);
// if (clearBeforeExec.getSelection()) {
// processContext.clearMessages();
// }
// if (watchBtn.getSelection()) {
// processContext.switchTime();
// }
ClearPerformanceAction clearPerfAction = new ClearPerformanceAction();
clearPerfAction.setProcess(processContext.getProcess());
clearPerfAction.run();
ClearTraceAction clearTraceAction = new ClearTraceAction();
clearTraceAction.setProcess(processContext.getProcess());
clearTraceAction.run();
isAddedStreamListener = true;
//$NON-NLS-1$
final String startingPattern = Messages.getString("ProcessComposite.startPattern");
MessageFormat mf = new MessageFormat(startingPattern);
String welcomeMsg = mf.format(new Object[] { processContext.getProcess().getName(), new Date() });
processContext.addDebugResultToConsole(new ProcessMessage(MsgType.CORE_OUT, //$NON-NLS-1$
welcomeMsg + "\r\n"));
}
}
});
} else {
// no process running
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
setRunnable(true);
killBtn.setEnabled(false);
}
});
}
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
}
};
thread.start();
} catch (Exception e) {
ExceptionHandler.process(e);
processContext.addErrorMessage(e);
kill();
}
}
Aggregations