use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class QueryTypeController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createControl(org.eclipse
* .swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
* org.eclipse.swt.widgets.Control)
*/
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
Control lastControlUsed = super.createControl(subComposite, param, numInRow, nbInRow, top, lastControl);
IElementParameter queryStoreTypeParameter = param.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
if (queryStoreTypeParameter != null) {
String queryStoreType = (String) queryStoreTypeParameter.getValue();
if (queryStoreType != null && queryStoreType.equals(EmfComponent.BUILTIN)) {
lastControlUsed = addGuessQueryButton(subComposite, param, lastControlUsed, numInRow, top);
}
}
return lastControlUsed;
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method save.
protected void save() {
List<String> checkedObjects = new ArrayList<String>();
List<IRepositoryViewObject> allProcess = null;
try {
allProcess = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS);
} catch (PersistenceException e1) {
ExceptionHandler.process(e1);
}
for (IRepositoryViewObject object : allProcess) {
if (isStatUseProjectSetting(object)) {
if (!checkedObjects.contains(object.getProperty().getId())) {
checkedObjects.add(object.getProperty().getId());
if (!checkedNodeObject.contains(object)) {
checkedNodeObject.add(object);
}
}
}
}
List<IProcess2> allOpenedProcessList = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(getEditors());
if (allOpenedProcessList != null) {
for (int i = 0; i < allOpenedProcessList.size(); i++) {
if (checkedObjects.contains(allOpenedProcessList.get(i).getProperty().getId())) {
openedProcessList.add(allOpenedProcessList.get(i));
}
}
}
//
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(getTaskMessages(), (checkedNodeObject.size()) * 100);
final Map<String, Set<String>> contextVars = DetectContextVarsUtils.detectByPropertyType(elem, true);
// must init this
addContextModel = false;
if (!contextVars.isEmpty()) {
// boolean showDialog = false;
Set<String> contextSet = new HashSet<String>();
for (String key : contextVars.keySet()) {
contextSet = contextVars.get(key);
break;
}
Connection connection = null;
IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (ptParam != null) {
IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
Object proValue = propertyElem.getValue();
if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) repositoryElem.getValue();
ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
connection = connectionItem.getConnection();
if (connection != null && connection.isContextMode()) {
addContextModel = true;
// ContextItem contextItem =
// ContextUtils.getContextItemById(connection.getContextId());
// for (IProcess process : openedProcessList) {
// Set<String> addedContext =
// ConnectionContextHelper.checkAndAddContextVariables(contextItem,
// contextSet, process.getContextManager(), false);
// if (addedContext != null && !addedContext.isEmpty()) {
// showDialog = true;
// break;
// }
// }
}
}
}
if (addContextModel) {
// if the context is not existed in job, will add or not.
Display disp = Display.getCurrent();
if (disp == null) {
disp = Display.getDefault();
}
if (disp != null) {
disp.syncExec(new Runnable() {
@Override
public void run() {
showContextAndCheck(contextVars);
}
});
} else {
showContextAndCheck(contextVars);
}
}
}
monitor.worked(10);
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
for (IRepositoryViewObject object : checkedNodeObject) {
saveProcess(object, addContextModel, contextVars, monitor);
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
workspace.run(workspaceRunnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
monitor.done();
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(true, true, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class ElementParameter2ParameterType method saveElementParameters.
/**
* save the EMF Model's parameters to Element
*
* @param elem
* @param pType
*/
public static void saveElementParameters(Element elem, ParametersType pType) {
EList<ElementParameterType> listParamType = pType.getElementParameter();
listParamType.clear();
Element defaultElement = getDefaultElement(pType);
List<? extends IElementParameter> paramList = elem.getElementParametersWithChildrens();
for (IElementParameter param : paramList) {
ElementParameterType type = getElemeterParameterType(param);
IElementParameter defalutParam = defaultElement.getElementParameter(type.getName());
if (defalutParam != null) {
listParamType.add(type);
}
}
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method updateProjectSetting.
public void updateProjectSetting() {
String[] split = getRepositoryPropertyName().split(":");
String parentParamName = split[0];
Element elementParams = elem;
IElementParameter elementParameter = elementParams.getElementParameter(parentParamName);
if (elementParameter != null && elementParameter.isShow(elem.getElementParameters()) && elementParameter.getChildParameters() != null) {
if (elementParameter.getChildParameters().get("PROPERTY_TYPE") != null && !EmfComponent.BUILTIN.equals(elementParameter.getChildParameters().get("PROPERTY_TYPE").getValue())) {
DatabaseConnection connection = null;
String id = (String) elementParameter.getChildParameters().get("REPOSITORY_PROPERTY_TYPE").getValue();
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(id);
if (lastVersion != null && lastVersion.getProperty() != null) {
Item item = lastVersion.getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
connection = (DatabaseConnection) dbItem.getConnection();
}
}
if (connection != null) {
boolean sameValues = true;
for (IElementParameter param : elementParams.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(elementParams.getElementParameters()) && repositoryValue != null && !param.getName().equals("PROPERTY_TYPE")) {
Object repValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, null);
if (repValue == null) {
continue;
}
if (repositoryValue.equals(UpdatesConstants.TYPE)) {
// datebase type
boolean found = false;
String[] list = param.getListRepositoryItems();
for (int i = 0; (i < list.length) && (!found); i++) {
if (repValue.equals(list[i])) {
found = true;
}
}
if (!found) {
sameValues = false;
break;
}
} else {
// check the value
if (!param.getValue().equals(repValue)) {
sameValues = false;
break;
}
}
}
}
if (!sameValues) {
boolean ok = MessageDialog.openQuestion(getShell(), getDisplayName(), "Connection has been changed , do you want to change value from repository ?");
if (ok) {
ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(elem, connection, getRepositoryPropertyName(), id);
changeValuesFromRepository.execute();
isConnectionChanged = true;
}
}
} else {
MessageDialog.openInformation(getShell(), getDisplayName(), "Connection has been deleted ,change to build in automaticlly");
ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem, null, getPropertyTypeName(), EmfComponent.BUILTIN);
changeValuesFromRepository1.execute();
isConnectionChanged = true;
}
}
}
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class JobSettingProjectSettingPage method performOk.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.PreferencePage#performOk()
*/
@Override
public boolean performOk() {
if (mComposite != null) {
ImplicitContextSettings implicit = pro.getEmfProject().getImplicitContextSettings();
if (implicit != null) {
// save to emf Model
ElementParameter2ParameterType.setParameterValue(implicit.getParameters(), EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName(), Boolean.valueOf(implicitBtn.getSelection()));
// save to the memory
IElementParameter elementParameter = pro.getInitialContextLoad().getElementParameter(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName());
if (elementParameter != null) {
elementParameter.setValue(Boolean.valueOf(implicitBtn.getSelection()));
}
}
StatAndLogsSettings stat = pro.getEmfProject().getStatAndLogsSettings();
if (stat != null) {
ElementParameter2ParameterType.setParameterValue(stat.getParameters(), EParameterName.STATS_DEFAULT_PROJECTSETTING.getName(), Boolean.valueOf(statBtn.getSelection()));
IElementParameter elementParameter = pro.getStatsAndLog().getElementParameter(EParameterName.STATS_DEFAULT_PROJECTSETTING.getName());
if (elementParameter != null) {
elementParameter.setValue(Boolean.valueOf(statBtn.getSelection()));
}
}
ProjectSettingManager.saveProject();
}
return super.performOk();
}
Aggregations