use of org.eclipse.core.internal.resources.Workspace in project tdi-studio-se by Talend.
the class StandAloneTalendJavaEditor method doSetInput.
@Override
public void doSetInput(IEditorInput input) throws CoreException {
// Lock the process :
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
if (input instanceof RepositoryEditorInput) {
rEditorInput = (RepositoryEditorInput) input;
} else {
FileEditorInput fileInput = (FileEditorInput) input;
rEditorInput = new RepositoryEditorInput(fileInput.getFile(), rEditorInput.getItem());
}
if (rEditorInput.getRepositoryNode() == null) {
// retrieve node
rEditorInput.setRepositoryNode(null);
}
try {
// see bug 1321
item = (FileItem) rEditorInput.getItem();
if (!rEditorInput.isReadOnly()) {
if (getRepositoryFactory().getStatus(item).isPotentiallyEditable()) {
item.getProperty().eAdapters().add(dirtyListener);
repFactory.lock(item);
}
} else {
rEditorInput.getFile().setReadOnly(true);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
rEditorInput.getFile().refreshLocal(IResource.DEPTH_ONE, null);
super.doSetInput(rEditorInput);
setName();
// only for sql template
if (item instanceof SQLPatternItem) {
Workspace ws = (Workspace) ResourcesPlugin.getWorkspace();
ws.broadcastBuildEvent(item, IResourceChangeEvent.POST_CHANGE, 1);
}
}
use of org.eclipse.core.internal.resources.Workspace in project tdi-studio-se by Talend.
the class StandAloneTalendJavaEditor method dispose.
@SuppressWarnings("restriction")
@Override
public void dispose() {
// remove the Runtines .java file in the .Java Project.
// try {
// rEditorInput.getFile().delete(true, null);
// } catch (CoreException e1) {
// RuntimeExceptionHandler.process(e1);
// }
super.dispose();
if (lockService != null) {
lockService.unregister();
}
// Unlock the process :
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
try {
item.getProperty().eAdapters().remove(dirtyListener);
repFactory.unlock(item);
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (LoginException e) {
ExceptionHandler.process(e);
}
// }
if (!isEditable) {
rEditorInput.getFile().setReadOnly(false);
}
// dispose custom color
if (bgColorForReadOnlyItem != null) {
bgColorForReadOnlyItem.dispose();
}
if (bgColorForEditabeItem != null) {
bgColorForEditabeItem.dispose();
}
ITalendProcessJavaProject talendProcessJavaProject = CorePlugin.getDefault().getRunProcessService().getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
talendProcessJavaProject.updateRoutinesPom(true, true);
}
// only for sql template
if (item instanceof SQLPatternItem) {
IProject jProject = talendProcessJavaProject.getProject();
ResourceChangeEvent event = new ResourceChangeEvent(item, IResourceChangeEvent.PRE_CLOSE, 1, null);
try {
//$NON-NLS-1$
Field resourceField = event.getClass().getDeclaredField("resource");
resourceField.setAccessible(true);
resourceField.set(event, jProject);
} catch (Exception e) {
ExceptionHandler.process(e);
}
Workspace ws = (Workspace) ResourcesPlugin.getWorkspace();
ws.getNotificationManager().broadcastChanges(ws.getElementTree(), event, false);
}
}
Aggregations