Author: snjeza
Date: 2011-11-16 08:34:30 -0500 (Wed, 16 Nov 2011)
New Revision: 36364
Modified:
trunk/central/plugins/org.jboss.tools.central/plugin.xml
trunk/central/plugins/org.jboss.tools.central/schema/tutorials.exsd
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/DescriptionToolTip.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java
Log:
JBIDE-10054 Support Readme/description at Group level for Project Examples
Modified: trunk/central/plugins/org.jboss.tools.central/plugin.xml
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/plugin.xml 2011-11-16 10:46:04 UTC (rev
36363)
+++ trunk/central/plugins/org.jboss.tools.central/plugin.xml 2011-11-16 13:34:30 UTC (rev
36364)
@@ -208,10 +208,12 @@
<category
id="org.jboss.tools.central.jbossas.quickstart"
name="JBoss AS 7 Quickstarts"
+ description="These quickstarts are aimed to get you up to writing
applications with minimal fuss. We recommend that you work through the quickstarts in the
order they are presented in this guide, however if you have previous experience with Java
EE 6, you may wish to skip some or all of the quickstarts."
priority="2" />
<category
id="org.jboss.tools.central.seam2"
name="Seam 2 Tutorials"
+ description="These tutorials are intended to help you develop Seam 2
applications."
priority="5" />
<tutorial
id="org.jboss.tools.central.jbossas.quickstart.helloworld"
Modified: trunk/central/plugins/org.jboss.tools.central/schema/tutorials.exsd
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/schema/tutorials.exsd 2011-11-16
10:46:04 UTC (rev 36363)
+++ trunk/central/plugins/org.jboss.tools.central/schema/tutorials.exsd 2011-11-16
13:34:30 UTC (rev 36364)
@@ -145,6 +145,13 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-11-16
10:46:04 UTC (rev 36363)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-11-16
13:34:30 UTC (rev 36364)
@@ -314,6 +314,7 @@
if (CATEGORY.equals(configurationElement.getName())) {
String name = configurationElement.getAttribute(NAME);
String id = configurationElement.getAttribute(ID);
+ String description = configurationElement.getAttribute(DESCRIPTION);
String priorityString = configurationElement.getAttribute(PRIORITY);
int priority = Integer.MAX_VALUE;
if (priorityString != null) {
@@ -324,7 +325,7 @@
log(e);
}
}
- TutorialCategory category = new TutorialCategory(id, name, priority);
+ TutorialCategory category = new TutorialCategory(id, name, priority, description);
tutorialCategories.put(id, category);
}
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/DescriptionToolTip.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/DescriptionToolTip.java 2011-11-16
10:46:04 UTC (rev 36363)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/DescriptionToolTip.java 2011-11-16
13:34:30 UTC (rev 36364)
@@ -10,8 +10,10 @@
************************************************************************************/
package org.jboss.tools.central.editors;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.window.ToolTip;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -46,11 +48,18 @@
layout.marginLeft = 2;
composite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = 300;
composite.setLayoutData(gd);
composite.setBackground(parent.getDisplay().getSystemColor(
SWT.COLOR_INFO_BACKGROUND));
Text text = new Text(composite,
- SWT.READ_ONLY | SWT.WRAP);
+ SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ GC gc = new GC(parent);
+ gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
+ .getFontMetrics(), (description.length()/40) + 1);
+ gc.dispose();
+ text.setLayoutData(gd);
text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
text.setText(description);
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2011-11-16
10:46:04 UTC (rev 36363)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2011-11-16
13:34:30 UTC (rev 36364)
@@ -54,6 +54,7 @@
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -64,6 +65,9 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbenchWindow;
@@ -87,6 +91,7 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.internal.forms.widgets.FormFonts;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -150,6 +155,7 @@
private Section settingsSection;
private Composite settingsComposite;
private Point oldSize;
+ private Font categoryFont;
public GettingStartedPage(FormEditor editor) {
super(editor, ID, "Getting Started");
@@ -719,6 +725,10 @@
RefreshTutorialsJob.INSTANCE.removeJobChangeListener(refreshTutorialsJobChangeListener);
refreshTutorialsJobChangeListener = null;
}
+ if (categoryFont != null) {
+ categoryFont.dispose();
+ categoryFont = null;
+ }
super.dispose();
}
@@ -839,10 +849,15 @@
if (expandedCategories.contains(category)) {
style|=ExpandableComposite.EXPANDED;
}
- final ExpandableComposite categoryComposite =
toolkit.createExpandableComposite(tutorialsComposite,
+
+ final CategoryExpandableComposite categoryComposite = new
CategoryExpandableComposite(tutorialsComposite, toolkit.getOrientation(),
style);
+
+ categoryComposite.setFont(getBoldFont(categoryComposite.getFont()));
+
categoryComposite.setTitleBarForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
categoryComposite.setText(category.getName());
+
GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
categoryComposite.setLayoutData(gd);
categoryComposite.setLayout(new GridLayout());
@@ -872,6 +887,11 @@
hookTooltip(tutorialText, tutorial);
}
categoryComposite.setClient(composite);
+ String description = category.getDescription();
+ if (description != null && !description.isEmpty() &&
categoryComposite.getControl() != null) {
+ final ToolTip toolTip = new DescriptionToolTip(categoryComposite.getControl(),
description);
+ toolTip.activate();
+ }
}
tutorialPageBook.showPage(tutorialsComposite);
@@ -882,6 +902,18 @@
//recomputeScrollComposite(tutorialScrollComposite, tutorialPageBook);
}
+ private Font getBoldFont(Font font) {
+ if (categoryFont != null) {
+ return categoryFont;
+ }
+ if (font == null || toolkit == null || toolkit.getColors() == null) {
+ return null;
+ }
+ categoryFont = FormFonts.getInstance().getBoldFont(toolkit.getColors().getDisplay(),
+ font);
+ return categoryFont;
+ }
+
private void hookTooltip(FormText tutorialText, Tutorial tutorial) {
final String description =
JBossCentralActivator.getDefault().getDescription(tutorial);
if (description != null && !description.isEmpty()) {
@@ -1241,5 +1273,20 @@
}
}
+
+ private class CategoryExpandableComposite extends ExpandableComposite {
+ public CategoryExpandableComposite(Composite parent, int style,
+ int expansionStyle) {
+ super(parent, style, expansionStyle);
+ setMenu(tutorialsComposite.getMenu());
+ toolkit.adapt(this, true, true);
+ }
+
+ public Control getControl() {
+ return textLabel;
+ }
+
+ }
+
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java 2011-11-16
10:46:04 UTC (rev 36363)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java 2011-11-16
13:34:30 UTC (rev 36364)
@@ -23,15 +23,17 @@
private String id;
private String name;
private int priority;
+ private String description;
private Set<Tutorial> tutorials = new TreeSet<Tutorial>();
public TutorialCategory() {
}
- public TutorialCategory(String id, String name, int priority) {
+ public TutorialCategory(String id, String name, int priority, String description) {
this.id = id;
this.name = name;
this.priority = priority;
+ this.description = description;
}
public String getId() {
@@ -84,12 +86,6 @@
}
@Override
- public String toString() {
- return "TutorialCategory [id=" + id + ", name=" + name + ",
priority="
- + priority + "]";
- }
-
- @Override
public int compareTo(TutorialCategory o) {
if (o == null)
return 1;
@@ -105,4 +101,18 @@
return tutorials;
}
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ return "TutorialCategory [id=" + id + ", name=" + name + ",
priority="
+ + priority + ", description=" + description + "]";
+ }
+
}