Author: snjeza
Date: 2011-11-27 10:05:58 -0500 (Sun, 27 Nov 2011)
New Revision: 36679
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
Log:
JBIDE-10243 Improve cheatsheets
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2011-11-27
15:05:01 UTC (rev 36678)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2011-11-27
15:05:58 UTC (rev 36679)
@@ -102,6 +102,8 @@
*/
public class ProjectExamplesActivator extends AbstractUIPlugin {
+ private static final String README_HTML = "/readme.html";
+ private static final String CHEATSHEET_XML = "/cheatsheet.xml"; //$NON-NLS-1$
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.project.examples";
//$NON-NLS-1$
public static final String ALL_SITES = Messages.ProjectExamplesActivator_All;
@@ -373,6 +375,7 @@
return;
}
for(final Project project:projects) {
+ fixWelcome(project);
if (project.isWelcome()) {
String urlString = project.getWelcomeURL();
urlString = replace(urlString, project);
@@ -430,6 +433,41 @@
}
}
+ private static void fixWelcome(Project project) {
+ if (project == null || project.isWelcome()) {
+ return;
+ }
+ List<String> includedProjects = project.getIncludedProjects();
+ if (includedProjects == null || includedProjects.size() <= 0) {
+ return;
+ }
+ String projectName = includedProjects.get(0);
+ if (projectName == null || projectName.isEmpty()) {
+ return;
+ }
+ IProject eclipseProject =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (eclipseProject == null || !eclipseProject.exists()) {
+ return;
+ }
+ if (checkCheatsheet(project, eclipseProject, CHEATSHEET_XML, ProjectUtil.CHEATSHEETS))
{
+ return;
+ }
+ checkCheatsheet(project, eclipseProject, README_HTML, ProjectUtil.EDITOR);
+
+ }
+
+ private static boolean checkCheatsheet(Project project,
+ IProject eclipseProject, String path, String type) {
+ IResource cheatsheet = eclipseProject.findMember(path);
+ if (cheatsheet != null && cheatsheet.exists() && cheatsheet.getType()
== IResource.FILE) {
+ project.setWelcome(true);
+ project.setType(type);
+ project.setWelcomeURL(cheatsheet.getFullPath().toString());
+ return true;
+ }
+ return false;
+ }
+
public static boolean extractZipFile(File file, File destination,
IProgressMonitor monitor) {
ZipFile zipFile = null;
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-11-27
15:05:01 UTC (rev 36678)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-11-27
15:05:58 UTC (rev 36679)
@@ -72,7 +72,7 @@
private static final String SITE = "site"; //$NON-NLS-1$
- private static final String EDITOR = "editor"; //$NON-NLS-1$
+ public static final String EDITOR = "editor"; //$NON-NLS-1$
public static final String CHEATSHEETS = "cheatsheets"; //$NON-NLS-1$
Show replies by date