Search in sources :

Example 1 with ResourceChangeEvent

use of org.eclipse.core.internal.events.ResourceChangeEvent 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);
    }
}
Also used : Field(java.lang.reflect.Field) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) ResourceChangeEvent(org.eclipse.core.internal.events.ResourceChangeEvent) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryService(org.talend.repository.model.IRepositoryService) Workspace(org.eclipse.core.internal.resources.Workspace) IWorkspace(org.eclipse.core.resources.IWorkspace)

Aggregations

Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ResourceChangeEvent (org.eclipse.core.internal.events.ResourceChangeEvent)1 Workspace (org.eclipse.core.internal.resources.Workspace)1 IProject (org.eclipse.core.resources.IProject)1 IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 CoreException (org.eclipse.core.runtime.CoreException)1 PartInitException (org.eclipse.ui.PartInitException)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)1 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1 IRepositoryService (org.talend.repository.model.IRepositoryService)1