use of org.talend.designer.runprocess.RunProcessContext in project tdi-studio-se by Talend.
the class JavaProcessor method getJVMArgs.
@Override
public String[] getJVMArgs() {
String[] vmargs = getSettingsJVMArguments();
/* check parameter won't happened on exportingJob */
List<String> asList = convertArgsToList(vmargs);
if (!isExportConfig() && !isRunAsExport()) {
//$NON-NLS-1$
String fileEncoding = System.getProperty("file.encoding");
//$NON-NLS-1$
String encodingFromIni = "-Dfile.encoding=" + fileEncoding;
boolean encodingSetInjob = false;
for (String arg : asList) {
if (arg.startsWith("-Dfile.encoding") && fileEncoding != null) {
//$NON-NLS-1$
/* if user has set the encoding on .ini file,should use this when exetucte job */
arg = encodingFromIni;
encodingSetInjob = true;
}
}
if (!encodingSetInjob) {
asList.add(encodingFromIni);
}
}
// add args if using JMX.
RunProcessContext runProcessContext = RunProcessPlugin.getDefault().getRunProcessContextManager().getActiveContext();
if (runProcessContext != null) {
ITargetExecutionConfig config = runProcessContext.getSelectedTargetExecutionConfig();
if (config != null && config.getCommandlineServerConfig() == null) {
if (config.isRemote()) {
if (config.isUseJMX()) {
//$NON-NLS-1$
asList.add("-Dcom.sun.management.jmxremote");
//$NON-NLS-1$
asList.add("-Dcom.sun.management.jmxremote.port=" + config.getRemotePort());
//$NON-NLS-1$
asList.add("-Dcom.sun.management.jmxremote.ssl=false");
//$NON-NLS-1$
asList.add("-Dcom.sun.management.jmxremote.authenticate=false");
}
}
}
}
vmargs = asList.toArray(new String[0]);
return vmargs;
}
use of org.talend.designer.runprocess.RunProcessContext in project tdi-studio-se by Talend.
the class ToolbarInputZone method addPreviewToolItems.
private void addPreviewToolItems() {
if (PluginChecker.isTraceDebugPluginLoaded() && getMapperManager().isTracesActive()) {
final RunProcessContext activeContext = RunProcessPlugin.getDefault().getRunProcessContextManager().getActiveContext();
if (activeContext == null) {
return;
}
new ToolItem(getToolBarActions(), SWT.SEPARATOR);
previousRow = new ToolItem(getToolBarActions(), SWT.PUSH);
previousRow.setEnabled(activeContext.isRunning());
previousRow.setToolTipText("Previous Row");
previousRow.setImage(ImageProvider.getImage(EImage.LEFT_ICON));
currentRowLabel = new ToolItem(getToolBarActions(), SWT.PUSH | SWT.BORDER);
currentRowLabel.setEnabled(false);
currentRowLabel.setText(getCurrentRowString());
currentRowLabel.setToolTipText("Current Row");
currentRowLabel.setWidth(50);
nextRow = new ToolItem(getToolBarActions(), SWT.PUSH);
nextRow.setEnabled(!getMapperManager().componentIsReadOnly());
nextRow.setToolTipText("Next Row");
nextRow.setImage(ImageProvider.getImage(EImage.RIGHT_ICON));
nextBreakpoint = new ToolItem(getToolBarActions(), SWT.PUSH);
nextBreakpoint.setToolTipText("Next Breakpoint");
nextBreakpoint.setImage(ImageProvider.getImage(EImage.RIGHTX_ICON));
Boolean bc = activeContext.checkBreakpoint();
if (!bc) {
nextBreakpoint.setEnabled(bc);
} else {
nextBreakpoint.setEnabled(activeContext.isRunning());
}
killBtn = new ToolItem(getToolBarActions(), SWT.PUSH);
killBtn.setToolTipText("Kill");
killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
killBtn.setEnabled(activeContext.isRunning());
previousRow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeContext.setPreviousRow(true);
}
});
nextRow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!activeContext.isRunning()) {
for (DataMapTableView dataMapTableView : getMapperManager().getUiManager().getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
if (getMapperManager().isDataChanged()) {
boolean closeWindow = MessageDialog.openConfirm(getComposite().getShell(), //$NON-NLS-1$
"tMap configuration modified", //$NON-NLS-1$
"Do you want to apply the modification of the tMap now ?");
// save change and regenerate code
if (closeWindow) {
IExternalNode externalNode = getMapperManager().getAbstractMapComponent().getExternalNode();
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
INode node = externalNode.getOriginalNode();
if (node != null && node instanceof Node) {
Command cmd = new ExternalNodeChangeCommand((Node) node, externalNode);
CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
cmdStack.execute(cmd);
}
}
}
}
activeContext.setLastIsRow(true);
IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
service.debugProcess();
} else {
activeContext.setNextRow(true);
}
}
});
nextBreakpoint.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeContext.setNextBreakPoint(true);
}
});
killBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
service.debugKill();
killBtn.setEnabled(false);
previousRow.setEnabled(false);
nextBreakpoint.setEnabled(false);
}
});
propertyListener = new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent evt) {
final String propName = evt.getPropertyName();
ProcessManager.getInstance().getProcessShell().getDisplay().syncExec(new Runnable() {
public void run() {
if (RunProcessContext.PREVIOUS_ROW.equals(propName)) {
boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
previousRow.setEnabled(enabled);
}
} else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
previousRow.setEnabled(enabled);
}
if (!nextBreakpoint.isDisposed() && enabled != nextBreakpoint.isEnabled()) {
Boolean bc = activeContext.checkBreakpoint();
if (!bc) {
nextBreakpoint.setEnabled(bc);
} else {
nextBreakpoint.setEnabled(enabled);
}
}
if (!killBtn.isDisposed() && enabled != killBtn.isEnabled()) {
killBtn.setEnabled(enabled);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(true);
}
} else if (RunProcessContext.NEXTBREAKPOINT.equals(propName)) {
boolean running = ((Boolean) evt.getNewValue()).booleanValue();
if (!nextBreakpoint.isDisposed()) {
nextBreakpoint.setEnabled(running);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(true);
}
} else if (RunProcessContext.BREAKPOINT_BAR.equals(propName)) {
boolean enable = ((Boolean) evt.getNewValue()).booleanValue();
if (!enable) {
if (!previousRow.isDisposed()) {
previousRow.setEnabled(false);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(false);
}
if (!nextBreakpoint.isDisposed()) {
nextBreakpoint.setEnabled(false);
}
}
}
}
});
}
};
activeContext.addPropertyChangeListener(propertyListener);
}
}
use of org.talend.designer.runprocess.RunProcessContext in project tdi-studio-se by Talend.
the class ProcessErrorUtilTest method testGetAllErrorMess.
/**
* Test method for
* {@link org.talend.designer.runprocess.ui.ProcessComposite#getAllErrorMess(org.talend.designer.runprocess.IProcessMessage)}
* .
*/
@Test
public void testGetAllErrorMess() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("ParentJob");
Process process = new Process(property1);
IComponent tOracleSPComponent = ComponentsFactoryProvider.getInstance().get("tOracleSP", ComponentCategory.CATEGORY_4_DI.getName());
Node tOracleSP_1 = new Node(tOracleSPComponent, process);
process.addNodeContainer(new NodeContainer(tOracleSP_1));
RunProcessContext context = new RunProcessContext(process);
String errorMessage1 = "Exception in component tOracleSP_1 (ParentJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message1 = new ProcessMessage(MsgType.STD_ERR, errorMessage1);
HashMap<String, IProcessMessage> errorMessMap = ProcessErrorUtil.getAllErrorMess(message1, context);
Assert.assertEquals(errorMessMap.get(tOracleSP_1.getUniqueName()).getContent(), errorMessage1);
String errorMessage2 = "Exception in component tOracleSP_1 (ChildJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message2 = new ProcessMessage(MsgType.STD_ERR, errorMessage2);
HashMap<String, IProcessMessage> errorMessMap2 = ProcessErrorUtil.getAllErrorMess(message2, context);
Assert.assertNull(errorMessMap2.get(tOracleSP_1.getUniqueName()));
}
use of org.talend.designer.runprocess.RunProcessContext in project tdi-studio-se by Talend.
the class RunProcessContextTest method testLoadLog4jContextFromProcess.
@Test
public void testLoadLog4jContextFromProcess() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("job1");
Process process = new Process(property1);
IComponent tMysqlInputComponent = //$NON-NLS-1$
ComponentsFactoryProvider.getInstance().get(//$NON-NLS-1$
"tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
Node tMysqlInput_1 = new Node(tMysqlInputComponent, process);
process.addNodeContainer(new NodeContainer(tMysqlInput_1));
RunProcessContext context = new RunProcessContext(process);
Assert.assertFalse(context.isUseCustomLevel());
//$NON-NLS-1$
Assert.assertEquals("", context.getLog4jLevel());
//
process.getElementParameter(EParameterName.LOG4J_RUN_ACTIVATE.getName()).setValue(true);
//$NON-NLS-1$
process.getElementParameter(EParameterName.LOG4J_RUN_LEVEL.getName()).setValue("Info");
context.loadLog4jContextFromProcess();
Assert.assertTrue(context.isUseCustomLevel());
//$NON-NLS-1$
Assert.assertEquals("Info", context.getLog4jLevel());
}
use of org.talend.designer.runprocess.RunProcessContext in project tdi-studio-se by Talend.
the class ProcessView method refresh.
public void refresh() {
RunProcessContext activeContext = RunProcessPlugin.getDefault().getRunProcessContextManager().getActiveContext();
boolean disableAll = false;
if (activeContext != null) {
disableAll = activeContext.getProcess().disableRunJobView();
}
processContext = activeContext;
rubjobManager.setProcessContext(processContext);
// }
if (contextComposite.isDisposed()) {
return;
}
if (activeContext != null && !activeContext.getProcess().getComponentsType().equals(oldJobType)) {
oldJobType = activeContext.getProcess().getComponentsType();
setElement();
}
contextComposite.setProcess(((activeContext != null) && !disableAll ? activeContext.getProcess() : null));
// clearPerfAction.setProcess(activeContext != null ? activeContext.getProcess() : null);
rubjobManager.setSelectContext(contextComposite.getSelectedContext());
if (activeContext != null) {
activeContext.setSelectedContext(contextComposite.getSelectedContext());
}
if (dc != null && dc == processComposite) {
processComposite.setProcessContext(activeContext);
} else if (dc != null && dc == debugTisProcessComposite) {
debugTisProcessComposite.setProcessContext(activeContext);
debugTisProcessComposite.setContextComposite(this.contextComposite);
} else if (dc != null && dc == advanceComposite) {
advanceComposite.setProcessContext(activeContext);
} else if (dc != null && dc == targetComposite) {
targetComposite.setProcessContext(activeContext);
} else if (dc != null && dc == memoryRunComposite) {
memoryRunComposite.setProcessContext(activeContext);
} else if (dc != null) {
if (processContext != null && processContext.getProcess() != null) {
if (dc instanceof MultipleThreadDynamicComposite) {
if (dc.getElement() != processContext.getProcess()) {
for (Control curControl : tabFactory.getTabComposite().getChildren()) {
curControl.dispose();
}
dc = new MultipleThreadDynamicComposite(tabFactory.getTabComposite(), SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, currentSelectedTab.getCategory(), (Element) processContext.getProcess(), true, Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
}
dc.refresh();
}
}
if (processContext == null || processContext.getProcess() == null) {
for (Control curControl : tabFactory.getTabComposite().getChildren()) {
curControl.dispose();
}
}
}
if (activeContext != null) {
//$NON-NLS-1$
String jobName = Messages.getString("ProcessView.jobName");
if (activeContext.getProcess().disableRunJobView()) {
// ?? joblet
//$NON-NLS-1$
jobName = "Joblet";
}
//$NON-NLS-1$
jobName = jobName + " " + activeContext.getProcess().getLabel();
setTitleToolTip(jobName);
//$NON-NLS-1$
setPartName(Messages.getString("ProcessView.title", jobName));
// processNameLab.setText(jobName);
tabFactory.setTitle(jobName, null);
} else {
//$NON-NLS-1$
setPartName(Messages.getString("ProcessView.titleEmpty"));
//processNameLab.setText(Messages.getString("ProcessView.subtitleEmpty")); //$NON-NLS-1$
tabFactory.setTitle(Messages.getString("ProcessView.subtitleEmpty"), null);
}
// processNameLab.getParent().layout(true, true);
}
Aggregations