use of org.talend.core.ui.process.IGEFProcess 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();
}
}
}
use of org.talend.core.ui.process.IGEFProcess 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.process.IGEFProcess in project tdi-studio-se by Talend.
the class ContextParameterExtractor method saveContext.
/**
* qzhang Comment method "saveContext".
*
* @param parameterName
* @param elem
* @param replaceCode
*/
public static void saveContext(final String parameterName, final IElement elem, String replaceCode, IProcess2 process) {
PropertyChangeCommand cmd = new PropertyChangeCommand(elem, parameterName, replaceCode);
boolean executed = false;
if (process != null && process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, cmd);
}
}
if (!executed) {
cmd.execute();
}
// note that no undo will be available
}
use of org.talend.core.ui.process.IGEFProcess in project tdi-studio-se by Talend.
the class WebServiceManager method executeCommand.
public void executeCommand(Command cmd) {
IProcess process = this.getWebServiceComponent().getProcess();
boolean executed = false;
if (process != null && process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, cmd);
}
}
if (!executed) {
cmd.execute();
}
}
Aggregations