use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class ShowRoutineItemsLabelProvider method getElements.
public Object[] getElements(Object inputElement) {
Set<Project> projects = allRoutineItems.keySet();
List<Object> objects = new ArrayList<Object>();
Project currentProject = ProjectManager.getInstance().getCurrentProject();
for (Project p : projects) {
if (p.equals(currentProject)) {
List<Property> items = allRoutineItems.get(p);
if (items != null) {
objects.addAll(items);
}
} else {
objects.add(p);
}
}
return objects.toArray();
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class StatsAndLogsHelper method changeRepositoryConnection.
static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
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;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class ProjectSettingManager method changeImplicitContextRepositoryItem.
static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
// change repository item
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
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;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesDialog method createButtonField.
private void createButtonField(Composite parent) {
Composite btnComposite = new Composite(parent, SWT.NONE);
btnComposite.setLayout(new GridLayout());
GridData layoutData = new GridData(GridData.FILL_VERTICAL);
layoutData.verticalAlignment = SWT.CENTER;
btnComposite.setLayoutData(layoutData);
addBtn = new Button(btnComposite, SWT.PUSH);
addBtn.setImage(ImageProvider.getImage(EImage.ADD_ICON));
addBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ListViewer currentViewer = getCurrentViewer();
if (currentViewer == null) {
return;
}
boolean system = (currentViewer == systemViewer);
List<RoutineItemRecord> currentRecords = getCurrentRecords();
ShowRoutineItemsDialog dialog = new ShowRoutineItemsDialog(getShell(), allRoutineItems, currentRecords, system);
if (dialog.open() == Window.OK) {
Property[] selectedItems = dialog.getSelectedItems();
List<Property> needAddedItems = new ArrayList<Property>();
// filter
for (Property p : selectedItems) {
boolean found = false;
for (RoutineItemRecord record : currentRecords) {
if (system) {
found = p.getLabel().equals(record.getLabel());
} else {
found = p.getId().equals(record.getId());
}
}
if (!found) {
needAddedItems.add(p);
}
}
// create
for (Property p : needAddedItems) {
RoutineItemRecord newOne = new RoutineItemRecord();
newOne.setId(p.getId());
newOne.setLabel(p.getLabel());
newOne.setName(p.getLabel());
newOne.setVersion(p.getVersion());
currentRecords.add(newOne);
}
//
currentViewer.setInput(currentRecords);
currentViewer.refresh();
updateButtons();
}
}
});
delBtn = new Button(btnComposite, SWT.PUSH);
delBtn.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
delBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ListViewer currentViewer = getCurrentViewer();
List<RoutineItemRecord> currentRecords = getCurrentRecords();
if (currentViewer != null && !((IStructuredSelection) currentViewer.getSelection()).isEmpty()) {
Iterator iterator = ((IStructuredSelection) currentViewer.getSelection()).iterator();
int index = 0;
while (iterator.hasNext()) {
Object selectedRecord = iterator.next();
if (currentRecords != null && selectedRecord != null) {
index = currentRecords.indexOf(selectedRecord);
currentRecords.remove(selectedRecord);
if (index > currentRecords.size() - 1) {
index = currentRecords.size() - 1;
} else if (index < 0) {
index = 0;
}
}
}
currentViewer.setInput(currentRecords);
currentViewer.getList().select(index);
currentViewer.refresh();
}
updateButtons();
}
});
upBtn = new Button(btnComposite, SWT.PUSH);
upBtn.setImage(ImageProvider.getImage(EImage.UP_ICON));
upBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
moveDatas(true);
}
});
downBtn = new Button(btnComposite, SWT.PUSH);
downBtn.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
downBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
moveDatas(false);
}
});
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method getNeededModulesForProcess.
public static Set<ModuleNeeded> getNeededModulesForProcess(IProcess process) {
Set<ModuleNeeded> neededLibraries = new TreeSet<ModuleNeeded>(new Comparator<ModuleNeeded>() {
@Override
public int compare(ModuleNeeded m1, ModuleNeeded m2) {
return m1.toString().compareTo(m2.toString());
}
});
Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(process.getId(), process.getVersion());
neededLibraries.addAll(neededModules);
if (process == null || !(process instanceof IProcess2)) {
if (neededLibraries.isEmpty() && process != null) {
neededLibraries = process.getNeededModules(true);
if (neededLibraries == null) {
neededLibraries = new HashSet<ModuleNeeded>();
// for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
// neededLibraries.add(moduleNeeded.getModuleName());
// }
}
} else {
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
neededLibraries.add(moduleNeeded);
}
}
return neededLibraries;
}
Property property = ((IProcess2) process).getProperty();
if (neededLibraries.isEmpty()) {
neededLibraries = process.getNeededModules(true);
if (neededLibraries == null) {
neededLibraries = new HashSet<ModuleNeeded>();
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
neededLibraries.add(moduleNeeded);
}
}
} else {
if (property != null && property.getItem() instanceof ProcessItem) {
neededLibraries.addAll(ModulesNeededProvider.getModulesNeededForProcess((ProcessItem) property.getItem(), process));
} else {
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
neededLibraries.add(moduleNeeded);
}
}
}
if (property != null && GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamel(property.getItem())) {
// http://jira.talendforge.org/browse/TESB-5887 LiXiaopeng 2012-6-19
// Synchronize Route resources
camelService.synchronizeRouteResource((ProcessItem) property.getItem());
try {
for (IRepositoryViewObject object : CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getAll(camelService.getBeansType())) {
Item item = object.getProperty().getItem();
if (item instanceof RoutineItem) {
RoutineItem routine = (RoutineItem) item;
for (Object o : routine.getImports()) {
IMPORTType type = (IMPORTType) o;
ModuleNeeded neededModule = new ModuleNeeded("camel bean dependencies", type.getMODULE(), "camel bean dependencies", true);
neededLibraries.add(neededModule);
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
return neededLibraries;
}
Aggregations