Skip to content

Commit

Permalink
JBTIS-95: Closing and opening project is an incompatible solution
Browse files Browse the repository at this point in the history
* NewModelProjectWizard
 * The overlay icons do display so it is unnecessary to close/open the
   project during the project's creation. More importantly, it is
   incompatible with the Savara project, which is installed as part of
   JBDS.

* ModelWorkspaceManager
 * Errors concerning folders being processed under the project is being
   created start to be logged. Readjusts the logic to address and remove
   there errors.
  • Loading branch information
Paul Richardson committed Jun 17, 2013
1 parent 933c5c5 commit de3eeb9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -280,56 +279,46 @@ private ModelWorkspaceManager() {
* @param project
* @since 4.3
*/
private void add( final IResource resource,
ModelProjectImpl project ) {
private void add( final IResource resource, ModelProjectImpl project ) {
// there should be no existing item for the resource being added
final ModelWorkspaceItem resourceItem = this.modelWorkspace.getWorkspaceItem(resource.getFullPath(), resource.getType());
if (resourceItem != null) // if there is return, no need to add
return;
return;

if (project == null) {
// We don't have a project yet. If the resource is being created while the project
// is also being created then its expected that the project has not been added.
project = new ModelProjectImpl(resource.getProject(), this.modelWorkspace);
}

// create new ModelWorkspaceItem for resource
ModelWorkspaceItem newResource = null;
ModelWorkspaceItem parentItem = null;
if (resource instanceof IProject && project == null) {
project = new ModelProjectImpl((IProject)resource, this.modelWorkspace);
if (resource.getType() == IResource.PROJECT) {
newResource = project;
parentItem = this.modelWorkspace;
} else if (!(resource instanceof IProject)) {
// 11/4/03 LLP: We are periodically getting into this logic with a resource for which we
// can not resolve a project. This is causing a NPE in the first line of the try below.
// To resolve this, return in this case, but log a warning message so we can see how
// often this situation is occurring.

// 11/19/03 GC: This should not occur any more, this was occuring when
// projects are getting opeaned and they are not getting added to the workspace.
if (project == null) {
final String msg = ModelerCore.Util.getString("ModelWorkspaceManager.Encountered_null_project_for_resource_of_type_{0}_1", resource.getClass().getName()); //$NON-NLS-1$
ModelerCore.Util.log(IStatus.WARNING, msg);
return;
}

} else {
// create the item and update the cache
try {
if (ModelerCore.DEBUG_MODEL_WORKSPACE || ModelerCore.DEBUG_MODEL_WORKSPACE_EVENT) {
final Object[] params = new Object[] {resource};
final String debugMsg = ModelerCore.Util.getString("ModelWorkspaceManager.DEBUG.Creating_ModelResource_instance_for_0_2", params); //$NON-NLS-1$
ModelerCore.Util.log(IStatus.INFO, debugMsg);
}

if (resource.getType() == IResource.FILE && ((IFile)resource).getFileExtension() != null
&& ModelUtil.isModelFile(resource)) {
newResource = project.createModelResource((IFile)resource);
} else if (resource.getType() == IResource.FOLDER) newResource = project.createModelFolder((IFolder)resource);
} else if (resource.getType() == IResource.FOLDER) {
newResource = project.createModelFolder((IFolder)resource);
}

parentItem = this.modelWorkspace.getParent(resource);
} catch (final Exception e) {
ModelerCore.Util.log(IStatus.ERROR,
e,
ModelerCore.Util.getString("ModelWorkspaceManager.Error_creating_new_model_workspace_item___{0}_1", e.getMessage())); //$NON-NLS-1$
}
} else if (resource instanceof IProject && project != null) parentItem = this.modelWorkspace;
else {
ModelerCore.Util.log(IStatus.ERROR,
ModelerCore.Util.getString("ModelWorkspaceManager.Unable_to_create_workspace_item_for_{0}_2", resource.getFullPath())); //$NON-NLS-1$
return;
}

if (parentItem == null) {
Expand All @@ -338,8 +327,10 @@ private void add( final IResource resource,
ModelerCore.Util.getString("ModelWorkspaceManager.Unable_to_find_parent_item_for_{0})_3", resource.getFullPath())); //$NON-NLS-1$
return;
}
final ModelWorkspaceItemInfo parentInfo = (ModelWorkspaceItemInfo)getInfo(parentItem);
if (parentInfo != null) parentInfo.addChild(newResource);

final ModelWorkspaceItemInfo parentInfo = (ModelWorkspaceItemInfo) getInfo(parentItem);
if (parentInfo != null)
parentInfo.addChild(newResource);
}

private void addChangeNotifier( final Container container ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@
*/
package org.teiid.designer.ui.wizards;

import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.AbstractOperation;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
Expand All @@ -38,8 +28,6 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.eclipse.ui.ide.undo.CreateFolderOperation;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
import org.teiid.core.designer.util.CoreArgCheck;
import org.teiid.core.designer.util.CoreStringUtil;
Expand Down Expand Up @@ -153,9 +141,9 @@ public boolean performFinish() {
}
}
project.setDescription(desc, null);
// Defect 11480 - closing and opening the project sets the overlay icon properly
project.close(null);
project.open(null);
// // Defect 11480 - closing and opening the project sets the overlay icon properly
// project.close(null);
// project.open(null);

if( designerProperties != null ) {
DesignerPropertiesUtil.setProjectName(designerProperties, project.getName());
Expand Down

0 comments on commit de3eeb9

Please sign in to comment.