Index: src/org/teiid/designer/runtime/preview/jobs/CreatePreviewVdbJob.java =================================================================== --- src/org/teiid/designer/runtime/preview/jobs/CreatePreviewVdbJob.java (revision 2629) +++ src/org/teiid/designer/runtime/preview/jobs/CreatePreviewVdbJob.java (working copy) @@ -115,38 +115,48 @@ try { IResource resource = ((this.project == null) ? this.model : this.project); - // if the file was deleted from outside Eclipse, Eclipse will think it still exists - if (this.pvdbFile.exists() && !this.pvdbFile.getLocation().toFile().exists()) { - this.pvdbFile.delete(true, monitor); - } + if (resource.exists()) { + if (resource instanceof IFile) { + if (!this.model.isSynchronized(IResource.DEPTH_INFINITE)) { + this.model.refreshLocal(IResource.DEPTH_INFINITE, null); + } + } - boolean isNew = false; - // create if necessary - if (!this.pvdbFile.exists()) { - isNew = true; - this.pvdbFile.create(new ByteArrayInputStream(new byte[0]), false, null); - } + // if the file was deleted from outside Eclipse, Eclipse will think it still exists + if (this.pvdbFile.exists() && !this.pvdbFile.getLocation().toFile().exists()) { + this.pvdbFile.delete(true, monitor); + } - // make sure the file is hidden - this.pvdbFile.setHidden(true); + boolean isNew = false; + // create if necessary + if (!this.pvdbFile.exists()) { + isNew = true; + this.pvdbFile.create(new ByteArrayInputStream(new byte[0]), false, null); + } - Vdb pvdb = new Vdb(this.pvdbFile, true, monitor); + // make sure the file is hidden + this.pvdbFile.setHidden(true); - // don't do if a project PVDB - if (resource instanceof IFile) { - // don't add if already in the PVDB (only one model per PVDB) - if (pvdb.getModelEntries().isEmpty()) { - pvdb.addModelEntry(this.model.getFullPath(), monitor); + Vdb pvdb = new Vdb(this.pvdbFile, true, monitor); + + // don't do if a project PVDB + if (resource instanceof IFile) { + // don't add if already in the PVDB (only one model per PVDB) + if (pvdb.getModelEntries().isEmpty()) { + pvdb.addModelEntry(this.model.getFullPath(), monitor); + } } - } - // this will trigger an resource change event which will eventually get an update job to run - if (isNew || pvdb.isModified()) { - pvdb.save(monitor); + // this will trigger an resource change event which will eventually get an update job to run + if (isNew || pvdb.isModified()) { + pvdb.save(monitor); + } + } else { + cancel(); } } catch (Exception e) { IProject proj = ((this.project == null) ? this.model.getProject() : this.project); - + // When a project is closed if an editor is open and dirty a dialog is presented to the user asking them if they // want to save the file. If the user saves the file a resource change event gets fired but when this job gets run // the model's project has been closed. Return a good status in this case. Otherwise return a bad status. Index: src/org/teiid/designer/runtime/preview/jobs/ModelChangedJob.java =================================================================== --- src/org/teiid/designer/runtime/preview/jobs/ModelChangedJob.java (revision 2629) +++ src/org/teiid/designer/runtime/preview/jobs/ModelChangedJob.java (working copy) @@ -9,11 +9,13 @@ package org.teiid.designer.runtime.preview.jobs; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; import org.eclipse.osgi.util.NLS; import org.teiid.designer.runtime.Server; import org.teiid.designer.runtime.preview.Messages; import org.teiid.designer.runtime.preview.PreviewContext; import org.teiid.designer.runtime.preview.PreviewManager; +import com.metamatrix.modeler.dqp.DqpPlugin; /** * The ModelChangedJob job synchronizes and saves the Preview VDB associated with the changed model. If the Preview @@ -60,11 +62,24 @@ private void process( Server previewServer ) throws Exception { PreviewContext context = getContext(); - // make sure Preview VDB exists for model - add(new CreatePreviewVdbJob(this.changedModel, context)); + try { + if (this.changedModel.exists()) { + if (!this.changedModel.isSynchronized(IResource.DEPTH_INFINITE)) { + this.changedModel.refreshLocal(IResource.DEPTH_INFINITE, null); + } - // sync Preview VDB with workspace - add(new UpdatePreviewVdbJob(this.changedModel, previewServer, context)); + // make sure Preview VDB exists for model + add(new CreatePreviewVdbJob(this.changedModel, context)); + + // sync Preview VDB with workspace + add(new UpdatePreviewVdbJob(this.changedModel, previewServer, context)); + } else { + cancel(); + } + } catch (Exception e) { + cancel(); + DqpPlugin.Util.log(e); + } } }