Author: snjeza
Date: 2010-06-30 16:55:59 -0400 (Wed, 30 Jun 2010)
New Revision: 23137
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
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/messages.properties
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/preferences/ProjectExamplesPreferencePage.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
Log:
https://jira.jboss.org/browse/JBIDE-6238 Project Examples should let users know if a
project example site is unreachable
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2010-06-30
20:20:25 UTC (rev 23136)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2010-06-30
20:55:59 UTC (rev 23137)
@@ -14,6 +14,7 @@
public class Messages extends NLS {
private static final String BUNDLE_NAME =
"org.jboss.tools.project.examples.messages"; //$NON-NLS-1$
+ public static String NewProjectExamplesWizardPage_Cannot_access_the_following_sites;
public static String NewProjectExamplesWizardPage_Site;
public static String Category_Other;
public static String ECFExamplesTransport_Downloading;
@@ -48,12 +49,14 @@
public static String NewProjectExamplesWizardPage_Details;
public static String NewProjectExamplesWizardPage_Import_Project_Example;
public static String NewProjectExamplesWizardPage_Invalid_fix;
+ public static String NewProjectExamplesWizardPage_Invalid_Sites;
public static String NewProjectExamplesWizardPage_Note;
public static String NewProjectExamplesWizardPage_Project_Example;
public static String NewProjectExamplesWizardPage_Project_name;
public static String NewProjectExamplesWizardPage_Project_size;
public static String NewProjectExamplesWizardPage_Projects;
public static String NewProjectExamplesWizardPage_Show_the_Quick_Fix_dialog;
+ public static String NewProjectExamplesWizardPage_Show_this_dialog_next_time;
public static String NewProjectExamplesWizardPage_URL;
public static String PluginFix_Invalid_plugin_fix;
public static String Project_Unknown;
@@ -63,6 +66,7 @@
public static String ProjectExamplesPreferencePage_Edit;
public static String ProjectExamplesPreferencePage_Remove;
public static String ProjectExamplesPreferencePage_Show_experimental_sites;
+ public static String ProjectExamplesPreferencePage_Show_invalid_sites;
public static String ProjectExamplesPreferencePage_Sites;
public static String ProjectFix_Missing_Drools_Runtime;
public static String ProjectFix_Missing_plugin;
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 2010-06-30
20:20:25 UTC (rev 23136)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2010-06-30
20:55:59 UTC (rev 23137)
@@ -42,6 +42,8 @@
public static final String SHOW_EXPERIMENTAL_SITES = "showExperimentalSites";
//$NON-NLS-1$
public static final String USER_SITES = "userSites"; //$NON-NLS-1$
public static final boolean SHOW_EXPERIMENTAL_SITES_VALUE = false;
+ public static final String SHOW_INVALID_SITES = "invalidSites"; //$NON-NLS-1$
+ public static final boolean SHOW_INVALID_SITES_VALUE = true;
// The shared instance
private static ProjectExamplesActivator plugin;
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2010-06-30
20:20:25 UTC (rev 23136)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2010-06-30
20:55:59 UTC (rev 23137)
@@ -31,16 +31,19 @@
NewProjectExamplesWizard_New_Project_Example=New Project Example
NewProjectExamplesWizard_OverwriteProject=Overwrite project ''{0}''
NewProjectExamplesWizard_Question=Question
+NewProjectExamplesWizardPage_Cannot_access_the_following_sites=Cannot access the
following sites:\n\n
NewProjectExamplesWizardPage_Description=Description:
NewProjectExamplesWizardPage_Details=Details...
NewProjectExamplesWizardPage_Import_Project_Example=Import Project Example
NewProjectExamplesWizardPage_Invalid_fix=Invalid fix in {0}.
+NewProjectExamplesWizardPage_Invalid_Sites=Invalid Sites
NewProjectExamplesWizardPage_Note=This example has some requirements that could not be
automatically configured. When importing the example you might see some errors which would
need fixing manually or via Quick Fixes. Click "Details" to see more.
NewProjectExamplesWizardPage_Project_Example=Project Example
NewProjectExamplesWizardPage_Project_name=Project name:
NewProjectExamplesWizardPage_Project_size=Project size:
NewProjectExamplesWizardPage_Projects=Projects:
NewProjectExamplesWizardPage_Show_the_Quick_Fix_dialog=Show the Quick Fix dialog
+NewProjectExamplesWizardPage_Show_this_dialog_next_time=Show this dialog next time
NewProjectExamplesWizardPage_URL=URL:
PluginFix_Invalid_plugin_fix=Invalid plugin fix in {0}.
Project_Unknown=Unknown
@@ -50,6 +53,7 @@
ProjectExamplesPreferencePage_Edit=Edit
ProjectExamplesPreferencePage_Remove=Remove
ProjectExamplesPreferencePage_Show_experimental_sites=Show experimental sites
+ProjectExamplesPreferencePage_Show_invalid_sites=Show invalid sites
ProjectExamplesPreferencePage_Sites=Sites
ProjectFix_Missing_Drools_Runtime=Missing Drools Runtime
ProjectFix_Missing_plugin=Missing plugin
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 2010-06-30
20:20:25 UTC (rev 23136)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2010-06-30
20:55:59 UTC (rev 23137)
@@ -84,6 +84,8 @@
private static String EXPERIMENTAL_EXT = "experimental"; //$NON-NLS-1$
private static Set<ProjectExampleSite> pluginSites;
+
+ private static HashSet<ProjectExampleSite> invalidSites = new
HashSet<ProjectExampleSite>();
private ProjectUtil() {
}
@@ -210,6 +212,7 @@
public static List<Category> getProjects() {
Set<ProjectExampleSite> sites = getSites();
List<Category> list = new ArrayList<Category>();
+ invalidSites.clear();
Category other = Category.OTHER;
try {
for (ProjectExampleSite site : sites) {
@@ -221,6 +224,7 @@
"projectExamples", ".xml", null); //$NON-NLS-1$ //$NON-NLS-2$
if (file == null || !file.exists() || !file.isFile()) {
ProjectExamplesActivator.log(NLS.bind(Messages.ProjectUtil_Invalid_URL,site.getUrl().toString()));
+ invalidSites.add(site);
continue;
}
DocumentBuilderFactory dbf = DocumentBuilderFactory
@@ -490,5 +494,9 @@
}
}
return root;
+ }
+
+ public static HashSet<ProjectExampleSite> getInvalidSites() {
+ return invalidSites;
}
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencePage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencePage.java 2010-06-30
20:20:25 UTC (rev 23136)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencePage.java 2010-06-30
20:55:59 UTC (rev 23137)
@@ -35,10 +35,11 @@
public class ProjectExamplesPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
- private Button button;
+ private Button showExperimentalSites;
private Sites sites;
private TreeViewer viewer;
private ProjectExampleSite selectedSite;
+ private Button showInvalidSites;
@Override
protected Control createContents(Composite parent) {
@@ -48,10 +49,15 @@
layout.marginHeight = 0;
composite.setLayout(layout);
- button = new Button(composite,SWT.CHECK);
- button.setText(Messages.ProjectExamplesPreferencePage_Show_experimental_sites);
+ showExperimentalSites = new Button(composite,SWT.CHECK);
+ showExperimentalSites.setText(Messages.ProjectExamplesPreferencePage_Show_experimental_sites);
IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
- button.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES));
+ showExperimentalSites.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES));
+
+ showInvalidSites = new Button(composite,SWT.CHECK);
+ showInvalidSites.setText(Messages.ProjectExamplesPreferencePage_Show_invalid_sites);
+ showInvalidSites.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_INVALID_SITES));
+
Group sitesGroup = new Group(composite,SWT.NONE);
sitesGroup.setText(Messages.ProjectExamplesPreferencePage_Sites);
GridLayout gl = new GridLayout(2,false);
@@ -174,7 +180,8 @@
@Override
protected void performDefaults() {
- button.setSelection(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES_VALUE);
+ showExperimentalSites.setSelection(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES_VALUE);
+ showInvalidSites.setSelection(ProjectExamplesActivator.SHOW_INVALID_SITES_VALUE);
sites.getUserSites().clear();
storeSites();
super.performDefaults();
@@ -188,7 +195,9 @@
private void storeSites() {
IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
- store.setValue(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES,
button.getSelection());
+ store.setValue(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES,
showExperimentalSites.getSelection());
+ store.setValue(ProjectExamplesActivator.SHOW_INVALID_SITES,
showInvalidSites.getSelection());
+
try {
String userSites = ProjectUtil.getAsXML(sites.getUserSites());
store.setValue(ProjectExamplesActivator.USER_SITES, userSites);
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java 2010-06-30
20:20:25 UTC (rev 23136)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java 2010-06-30
20:55:59 UTC (rev 23137)
@@ -16,6 +16,10 @@
node.putBoolean(
ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES,
ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES_VALUE);
+
+ node.putBoolean(
+ ProjectExamplesActivator.SHOW_INVALID_SITES,
+ ProjectExamplesActivator.SHOW_INVALID_SITES_VALUE);
}
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2010-06-30
20:20:25 UTC (rev 23136)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2010-06-30
20:55:59 UTC (rev 23137)
@@ -12,6 +12,7 @@
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -19,7 +20,9 @@
import java.util.TreeSet;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.commands.ToggleState;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -58,6 +61,7 @@
import org.jboss.tools.project.examples.fixes.WTPRuntimeFix;
import org.jboss.tools.project.examples.model.Category;
import org.jboss.tools.project.examples.model.Project;
+import org.jboss.tools.project.examples.model.ProjectExampleSite;
import org.jboss.tools.project.examples.model.ProjectFix;
import org.jboss.tools.project.examples.model.ProjectUtil;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
@@ -136,7 +140,7 @@
viewer.setLabelProvider(new ProjectLabelProvider());
viewer.setContentProvider(new ProjectContentProvider());
- refresh(viewer);
+ refresh(viewer, false);
final SiteFilter siteFilter = new SiteFilter();
viewer.addFilter(siteFilter);
@@ -265,7 +269,7 @@
public void widgetSelected(SelectionEvent e) {
IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
store.setValue(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES,
button.getSelection());
- refresh(viewer);
+ refresh(viewer, true);
if (siteCombo != null) {
String[] items = getItems();
int index = siteCombo.getSelectionIndex();
@@ -303,18 +307,30 @@
return true;
}
- private void refresh(final TreeViewer viewer) {
- AdaptableList input = new AdaptableList(getCategories());
+ private void refresh(final TreeViewer viewer, boolean show) {
+ AdaptableList input = new AdaptableList(getCategories(show));
viewer.setInput(input);
viewer.refresh();
}
- private List<Category> getCategories() {
- return ProjectUtil.getProjects();
+ private List<Category> getCategories(boolean show) {
+ List<Category> categories = ProjectUtil.getProjects();
+ HashSet<ProjectExampleSite> invalidSites = ProjectUtil.getInvalidSites();
+ boolean showInvalidSites =
ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.SHOW_INVALID_SITES);
+ if (invalidSites.size() > 0 && showInvalidSites && show) {
+ String message =
Messages.NewProjectExamplesWizardPage_Cannot_access_the_following_sites;
+ for (ProjectExampleSite site:invalidSites) {
+ message = message + site.getName() + "\n"; //$NON-NLS-1$
+ }
+ MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(getShell(),
Messages.NewProjectExamplesWizardPage_Invalid_Sites, message,
Messages.NewProjectExamplesWizardPage_Show_this_dialog_next_time, true,
ProjectExamplesActivator.getDefault().getPreferenceStore(),
ProjectExamplesActivator.SHOW_INVALID_SITES);
+ boolean toggleState = dialog.getToggleState();
+ ProjectExamplesActivator.getDefault().getPreferenceStore().setValue(ProjectExamplesActivator.SHOW_INVALID_SITES,
toggleState);
+ }
+ return categories;
}
private String[] getItems() {
- List<Category> categories = getCategories();
+ List<Category> categories = getCategories(true);
Set<String> sites = new TreeSet<String>();
sites.add(ProjectExamplesActivator.ALL_SITES);
for (Category category:categories) {