Skip to content

Commit

Permalink
TISTUD-6896
Browse files Browse the repository at this point in the history
Importing Alloy project and changing Titanium SDK 
in tiapp.xml causes the Global Toolbar to become 
inactive
  • Loading branch information
sujmishra committed Sep 10, 2014
1 parent b4179bd commit 248527b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
Expand Up @@ -106,23 +106,36 @@ public List<String> getPotentialNatures(IProject project)
{
return Collections.emptyList();
}
return getPotentialNaturesFromPath(project.getLocation());
}

/**
* Returns the potential natures applicable to the project represented by this path, with the primary nature being
* first in the list.
*
* @param project
* @return
*/
public List<String> getPotentialNaturesFromPath(IPath path)
{
if (path == null || path.isEmpty())
{
return Collections.emptyList();
}
lazyInit();
List<String> potentialNatures = new ArrayList<String>(natureIdRanks.size());
for (String natureId : natureIdRanks.keySet())
{
IPrimaryNatureContributor primaryNatureContributor = natureIdRanks.get(natureId);
IPath location = project.getLocation();
if (location != null)

int primaryNatureRank = primaryNatureContributor.getPrimaryNatureRank(path);
if (primaryNatureRank == IPrimaryNatureContributor.CAN_BE_PRIMARY)
{
int primaryNatureRank = primaryNatureContributor.getPrimaryNatureRank(location);
if (primaryNatureRank == IPrimaryNatureContributor.CAN_BE_PRIMARY)
{
potentialNatures.add(natureId);
}
else if (primaryNatureRank == IPrimaryNatureContributor.IS_PRIMARY)
{
potentialNatures.add(0, natureId);
}
potentialNatures.add(natureId);
}
else if (primaryNatureRank == IPrimaryNatureContributor.IS_PRIMARY)
{
potentialNatures.add(0, natureId);
}
}
return potentialNatures;
Expand Down
Expand Up @@ -445,6 +445,17 @@ else if (!new File(directoryPathField.getText()).exists())
IdeLog.logWarning(UIEplPlugin.getDefault(), "Error reading project description for " + name, e); //$NON-NLS-1$
}
}
// .project file does not exist. Lets get the natures from the Primary natures manager
else
{
List<String> potentialNatures = PrimaryNaturesManager.getManager().getPotentialNaturesFromPath(path);

// Add web nature to potential natures
potentialNatures.add(APTANA_WEB_NATURE);

// set the natures checked in the nature table as they are the most relevant ones.
fTableViewer.setCheckedElements(potentialNatures.toArray(new String[potentialNatures.size()]));
}
}
setMessage(null);
setErrorMessage(null);
Expand Down

0 comments on commit 248527b

Please sign in to comment.