use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class ExtraComposite method onReloadPreference.
@Override
protected void onReloadPreference() {
// ExtraComposite.this);
if (elem instanceof Process) {
Process process = (Process) elem;
LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName(), Boolean.TRUE);
boolean executed = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand(process, command);
}
if (!executed) {
command.execute();
}
}
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExportResources.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
* .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
exportFileResource = process;
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
selectedJobVersion = preExportResource(process, i, selectedJobVersion);
IProcess jobProcess = null;
// code is just kept like this to avoid too big changes right now.
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
if (contextName != null) {
jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
analysisModules(processItem.getProperty().getId(), selectedJobVersion);
} else {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
LastGenerationInfo.getInstance().setLastMainJob(null);
}
List<URL> resources = new ArrayList<URL>();
List<URL> childrenList = new ArrayList<URL>();
if (CommonsPlugin.isHeadless()) {
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
} else {
String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
String[] newCodeOptions = codeOptions;
if (!ArrayUtils.contains(codeOptions, log4jOption)) {
newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
}
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
}
resources.addAll(childrenList);
process[i].addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource libResource = getCompiledLibExportFileResource(process);
list.add(libResource);
// Gets jobInfo.properties
// only addClasspathJar not check in preferences ,then export the jobInfo.properties
boolean addClasspathJar = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
}
if (!addClasspathJar) {
if (!(process.length > 1)) {
for (ExportFileResource pro : process) {
ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
if (CommonsPlugin.isHeadless()) {
jobInfoResource = new ExportFileResource();
}
list.add(jobInfoResource);
List<URL> jobInfoList = getJobInfoFile(pro, contextName);
jobInfoResource.addResources(jobInfoList);
}
}
}
if (PluginChecker.isRulesPluginLoaded()) {
// hywang add for 6484,add final drl files or xls files to exported job script
//$NON-NLS-1$
ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
list.add(ruleFileResource);
try {
Map<String, List<URL>> map = initUrlForRulesFiles(process);
Object[] keys = map.keySet().toArray();
for (Object key : keys) {
List<URL> talendDrlFiles = map.get(key.toString());
ruleFileResource.addResources(key.toString(), talendDrlFiles);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return list;
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class StatsAndLogsViewHelper method applySettings.
/**
* yzhang Comment method "applySettings".
*
* @param element
* @param dynamicProperty
*/
public static void applySettings(IElement element, IElement applyTo, IDynamicProperty dynamicProperty) {
List<? extends IElementParameter> elementParameters = applyTo.getElementParameters();
for (IElementParameter elementParameterType : elementParameters) {
String parameterName = elementParameterType.getName();
if (parameterName.equals(EParameterName.ON_STATCATCHER_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_LOGCATCHER_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_METERCATCHER_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_FILES_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILE_PATH.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILE_PATH.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILENAME_STATS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILENAME_LOGS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILENAME_METTER.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_DATABASE_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PROPERTY_TYPE.getName())) {
String id = (String) element.getElementParameter(//$NON-NLS-1$
EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue();
String propertyType = (String) element.getElementParameter(EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName()).getValue();
/* 16969 */
Connection repositoryConnection = null;
// Map<String, ConnectionItem> repositoryConnectionItemMap =
// dynamicProperty.getRepositoryConnectionItemMap();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
// if (repositoryConnectionItemMap.containsKey(id)) {
// repositoryConnection = repositoryConnectionItemMap.get(id).getConnection();
// } else {
// repositoryConnection = null;
// }
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(applyTo, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(applyTo, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
CompoundCommand cc = new CompoundCommand();
cc.add(cmd1);
cc.add(cmd2);
boolean executed = false;
if (applyTo instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) applyTo, cc);
}
}
if (!executed) {
cc.execute();
}
continue;
}
if (PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTY_TYPE.getName()).equals(EmfComponent.BUILTIN)) {
if (parameterName.equals(EParameterName.DB_TYPE.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.DB_TYPE.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.HOST.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.HOST.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PORT.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.PORT.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.DBNAME.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.DBNAME.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PROPERTIES.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.PROPERTIES.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.DBFILE.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.DBFILE.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.SCHEMA_DB.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.SCHEMA_DB.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.USER.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.USER.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PASS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.PASS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.TABLE_STATS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_STATS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.TABLE_LOGS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_LOGS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.TABLE_METER.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_METER.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_RUNTIME_ERRORS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_USER_ERRORS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_USER_WARNING.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_REALTIME_STATS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_REALTIME_STATS.getName()).getValue());
continue;
}
}
}
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class UpdateManagerUtils method executeUpdate.
private static void executeUpdate(UpdateResult result, IProgressMonitor monitor, boolean updateAllJobs) {
if (result.isReadOnlyProcess()) {
return;
}
// update
Command command = null;
IUpdateItemType updateType = result.getUpdateType();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case NODE_PROPERTY:
case NODE_SCHEMA:
case NODE_QUERY:
case NODE_SAP_IDOC:
case NODE_SAP_FUNCTION:
case NODE_VALIDATION_RULE:
command = new UpdateNodeParameterCommand(result);
break;
case JOB_PROPERTY_EXTRA:
case JOB_PROPERTY_STATS_LOGS:
case JOB_PROPERTY_HEADERFOOTER:
case JOB_PROPERTY_STORM:
case JOB_PROPERTY_MAPREDUCE:
command = new UpdateMainParameterCommand(result);
break;
case CONTEXT:
command = executeContextUpdates(result);
break;
case CONTEXT_GROUP:
command = executeContextGroupUpdates(result);
break;
case JOBLET_RENAMED:
case JOBLET_SCHEMA:
case RELOAD:
command = executeJobletNodesUpdates(result);
break;
case JUNIT_RELOAD:
command = executeJunitNodesUpdates(result);
break;
// break;
case MAP_PATH:
command = new UpdateNodePathCommand(result);
break;
default:
break;
}
}
if (command != null) {
SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1 * UpdatesConstants.SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
subMonitor.beginTask(UpdatesConstants.EMPTY, 1);
subMonitor.subTask(getResultTaskInfor(result));
//
Object job = result.getJob();
boolean executed = false;
if (job != null && job instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) job, command);
}
}
if (!executed) {
command.execute();
}
subMonitor.worked(1);
}
// from extension point
UpdateManagerProviderDetector.INSTANCE.doUpdate(monitor, result);
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class UpdateNodePathCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
IUpdateItemType updateType = result.getUpdateType();
if (result == null || updateType == null) {
return;
}
Object updateObject = result.getUpdateObject();
if (updateObject == null || (!(updateObject instanceof Node))) {
return;
}
// instance of node before might not be good (loaded while check updates needed)
// so get the instance of the node of the current job in this object.
IProcess process = (IProcess) result.getJob();
for (INode node : process.getGraphicalNodes()) {
if (node.getUniqueName().equals(((Node) updateObject).getUniqueName())) {
updateObject = node;
result.setUpdateObject(updateObject);
break;
}
}
Node node = (Node) updateObject;
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case MAP_PATH:
Object parameter = result.getParameter();
if (!(parameter instanceof List)) {
return;
}
List<Object> params = (List<Object>) parameter;
if (params.size() != 3) {
return;
}
IElementParameter param = (IElementParameter) params.get(0);
if (param == null) {
return;
}
String oldPath = (String) params.get(1);
String newPath = (String) params.get(2);
String relativeNewPath = new Path(newPath).removeFirstSegments(2).removeFileExtension().toPortableString();
String fullOldPath = new Path(oldPath).removeFileExtension().toPortableString();
String relativeOldPath = new Path(oldPath).removeFirstSegments(2).removeFileExtension().toPortableString();
Object value = TalendTextUtils.removeQuotes(String.valueOf(param.getValue()));
if (!fullOldPath.equals(value) && !relativeOldPath.equals(value)) {
return;
}
if (fullOldPath.equals(value)) {
String newValue = TalendTextUtils.addQuotes(new Path(newPath).removeFileExtension().toPortableString());
param.setValue(newValue);
} else if (relativeOldPath.equals(value)) {
param.setValue(TalendTextUtils.addQuotes(relativeNewPath));
}
break;
default:
}
}
if (node.getProcess() instanceof IProcess2) {
PropertyChangeCommand pcc = new PropertyChangeCommand(node, EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
boolean executed = false;
if (process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, pcc);
}
}
if (!executed) {
pcc.execute();
}
}
}
Aggregations