use of org.talend.repository.model.IRepositoryService in project tdi-studio-se by Talend.
the class TalendJavaSourceViewer method getImports.
private static String getImports() {
//$NON-NLS-1$
String imports = "";
if (!GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
return imports;
}
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repositoryFactory = service.getProxyRepositoryFactory();
Project project = ProjectManager.getInstance().getProject(null);
try {
List<IRepositoryViewObject> routines = repositoryFactory.getAll(ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject routine : routines) {
if (routine.getProperty().getItem() instanceof RoutineItem && ((RoutineItem) routine.getProperty().getItem()).isBuiltIn()) {
//$NON-NLS-1$ //$NON-NLS-2$
imports += "import routines." + routine.getLabel() + ";\n";
} else {
//$NON-NLS-1$ //$NON-NLS-2$
imports += "import routines." + routine.getLabel() + ";\n";
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
//$NON-NLS-1$
return "";
}
//$NON-NLS-1$
imports += "import routines.system.*;\n";
//$NON-NLS-1$
imports += "import java.text.ParseException;\n";
//$NON-NLS-1$
imports += "import java.text.SimpleDateFormat;\n";
//$NON-NLS-1$
imports += "import java.util.Date;\n";
//$NON-NLS-1$
imports += "import java.util.List;\n";
//$NON-NLS-1$
imports += "import java.math.BigDecimal;\n";
imports += "\n";
imports += "@SuppressWarnings(\"unused\")";
imports += "\n\n";
return imports;
}
use of org.talend.repository.model.IRepositoryService in project tdi-studio-se by Talend.
the class StandAloneTalendJavaEditor method resetItem.
public void resetItem() throws PersistenceException {
if (item.getProperty().eResource() == null || item.eResource() == null) {
IRepositoryService service = CoreRuntimePlugin.getInstance().getRepositoryService();
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
//
// Property updated = factory.getUptodateProperty(getItem().getProperty());
Property updatedProperty = null;
try {
factory.initialize();
IRepositoryViewObject repositoryViewObject = factory.getLastVersion(new Project(ProjectManager.getInstance().getProject(item.getProperty().getItem())), item.getProperty().getId());
if (repositoryViewObject != null) {
updatedProperty = repositoryViewObject.getProperty();
item = (FileItem) updatedProperty.getItem();
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.repository.model.IRepositoryService in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method doSave.
/**
* Saves the multi-page editor's document.
*/
@Override
public void doSave(final IProgressMonitor monitor) {
Item curItem = getProcess().getProperty().getItem();
IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
try {
// For TDI-23825, if not lock by user try to lock again.
if (!getProcess().isReadOnly()) {
repFactory.lock(curItem);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (getProcess().isReadOnly() || repFactory.isUserReadOnlyOnCurrentProject()) {
MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.readonly"), Messages.getString("AbstractMultiPageTalendEditor.readonlyMessage"));
return;
}
ERepositoryStatus status = repFactory.getStatus(curItem);
if (!status.equals(ERepositoryStatus.LOCK_BY_USER) && !repFactory.getRepositoryContext().isEditableAsReadOnly()) {
MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveTitle"), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveMessage"));
return;
}
if (!isDirty()) {
return;
}
Map<String, Boolean> jobletMap = new HashMap<String, Boolean>();
changeCollapsedState(true, jobletMap);
updateRunJobContext();
designerEditor.getProcess().getProperty().eAdapters().remove(dirtyListener);
repFactory.addRepositoryWorkUnitListener(repositoryWorkListener);
if (jobletEditor == getActiveEditor()) {
boolean isDirty = jobletEditor.isDirty();
refreshPropertyDirtyStatus();
jobletEditor.doSave(monitor);
try {
IProcess2 oldProcess = getProcess();
ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
ProcessType processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
IProcess2 newProcess = null;
Item item = getProcess().getProperty().getItem();
if (item instanceof ProcessItem) {
((Process) designerEditor.getProcess()).updateProcess(processType);
if (isDirty) {
getProcess().setProcessModified(true);
getProcess().setNeedRegenerateCode(true);
}
} else if (item instanceof JobletProcessItem) {
AbstractProcessProvider processProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (processProvider != null) {
newProcess = processProvider.buildNewGraphicProcess(item);
}
designerEditor.setProcess(newProcess);
Boolean lastVersion = null;
if (oldProcess instanceof ILastVersionChecker) {
lastVersion = ((ILastVersionChecker) oldProcess).isLastVersion(item);
}
if (designerEditor.getEditorInput() instanceof JobEditorInput) {
((JobEditorInput) designerEditor.getEditorInput()).checkInit(lastVersion, null, true);
}
}
getEditor(0).doSave(monitor);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
} else {
refreshPropertyDirtyStatus();
getEditor(0).doSave(monitor);
}
/*
* refresh should be executed before add the listener,or it will has eProxy on the property,it will cause a
* editor dirty problem. hywang commet bug 17357
*/
if (processEditorInput != null) {
propertyInformation = new ArrayList(processEditorInput.getItem().getProperty().getInformations());
propertyIsDirty = false;
}
if (designerEditor != null && dirtyListener != null) {
designerEditor.getProcess().getProperty().eAdapters().add(dirtyListener);
}
refreshJobSettingsView();
changeCollapsedState(false, jobletMap);
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
testContainerService.updateDetect(getProcess(), false);
}
}
if (isCheckout) {
CommandStack stack = (CommandStack) getAdapter(CommandStack.class);
stack.flush();
isCheckout = false;
}
}
use of org.talend.repository.model.IRepositoryService in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method dispose.
/**
* The <code>MultiPageEditorPart</code> implementation of this <code>IWorkbenchPart</code> method disposes all
* nested editors. Subclasses may extend.
*/
@Override
public void dispose() {
getSite().setSelectionProvider(null);
getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
/* after the release of eclipse3.6,this parameter can't be null */
// setInput(null);
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
getSite().getWorkbenchWindow().getPartService().removePartListener(partListener);
if (this.lockService != null) {
this.lockService.unregister();
}
super.dispose();
if (getProcess() != null && !getProcess().isReadOnly()) {
if (isKeepPropertyLocked()) {
return;
}
// Unlock the process :
IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
try {
getProcess().getProperty().eAdapters().remove(dirtyListener);
Property property = getProcess().getProperty();
if (property.eResource() == null || property.getItem().eResource() == null) {
property = repFactory.getUptodateProperty(property);
}
// fix for bug 12524 for db repository
// property = repFactory.reload(property);
JobletUtil jUtil = new JobletUtil();
jUtil.makeSureUnlockJoblet(getProcess());
Item item = getProcess().getProperty().getItem();
boolean keep = jUtil.keepLockJoblet(item);
if (keep) {
repFactory.unlock(property.getItem());
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (LoginException e) {
ExceptionHandler.process(e);
}
}
if (processEditorInput != null) {
processEditorInput.dispose();
processEditorInput = null;
}
designerEditor = null;
codeEditor = null;
if (processor instanceof IJavaBreakpointListener) {
JDIDebugModel.removeJavaBreakpointListener((IJavaBreakpointListener) processor);
}
processor = null;
dirtyListener = null;
NodeTransferDragSourceListener.getInstance().setEditPart(null);
}
use of org.talend.repository.model.IRepositoryService in project tdi-studio-se by Talend.
the class CreateProcess method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
final NewProcessWizard processWizard;
if (isToolbar()) {
processWizard = new NewProcessWizard(null);
} else {
ISelection selection = getSelection();
if (selection == null) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IPath path = service.getRepositoryPath((IRepositoryNode) obj);
if (RepositoryConstants.isSystemFolder(path.toString())) {
// Not allowed to create in system folder.
return;
}
processWizard = new NewProcessWizard(path);
}
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
if (dlg.open() == Window.OK) {
if (processWizard.getProcess() == null) {
return;
}
ProcessEditorInput fileEditorInput;
try {
// Set readonly to false since created job will always be editable.
fileEditorInput = new ProcessEditorInput(processWizard.getProcess(), false, true, false);
IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(fileEditorInput.getItem().getProperty().getId(), false);
fileEditorInput.setRepositoryNode(repositoryNode);
IWorkbenchPage page = getActivePage();
page.openEditor(fileEditorInput, MultiPageTalendEditor.ID, true);
// // use project setting true
// ProjectSettingManager.defaultUseProjectSetting(fileEditorInput.getLoadedProcess());
} catch (PartInitException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
} catch (PersistenceException e) {
MessageBoxExceptionHandler.process(e);
}
}
}
Aggregations