Author: snjeza
Date: 2011-12-09 04:53:58 -0500 (Fri, 09 Dec 2011)
New Revision: 37148
Modified:
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/AbstractJBossCentralPage.java
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
Log:
JBDS-1935 if Welcome screen is maximized on startup, JBoss Central can't be resized /
doesn't auto-resize to fill editor pane
Modified:
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
===================================================================
---
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-12-09
09:48:23 UTC (rev 37147)
+++
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-12-09
09:53:58 UTC (rev 37148)
@@ -32,17 +32,21 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.internal.WorkbenchWindow;
import org.eclipse.ui.internal.browser.WebBrowserPreference;
import org.eclipse.ui.internal.browser.WorkbenchBrowserSupport;
import org.eclipse.ui.menus.CommandContributionItem;
@@ -68,7 +72,7 @@
public class JBossCentralActivator extends AbstractUIPlugin {
public static final String JBOSS_DISCOVERY_DIRECTORY =
"jboss.discovery.directory.url";
-
+
public static final String ICON = "icon";
private static final String DESCRIPTION = "description";
@@ -88,7 +92,7 @@
public static final String NAME = "name";
public static final String CATEGORY = "category";
-
+
public static final String PROJECT_EXAMPLE_TYPE = "projectExample";
// The plug-in ID
@@ -97,26 +101,30 @@
public static final String SHOW_JBOSS_CENTRAL_ON_STARTUP =
"showJBossCentralOnStartup";
public static final boolean SHOW_JBOSS_CENTRAL_ON_STARTUP_DEFAULT_VALUE = true;
-
+
public static final String PROFILE_ID = "profileId";
public static final String PROFILE_TIMESTAMP = "profileTimestamp";
-
+
public static final String NEW_PROJECT_EXAMPLES_WIZARD_ID =
"org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard";
-
+
public static final String FORM_END_TAG = "</p></form>";
public static final String FORM_START_TAG = "<form><p>";
- public static final String CANCELED = FORM_START_TAG + "<span
color=\"header\" font=\"header\">Canceled.</span>" +
FORM_END_TAG;
- public static final String LOADING = FORM_START_TAG + "<span
color=\"header\" font=\"header\">Loading...</span>" +
FORM_END_TAG;
-
+ public static final String CANCELED = FORM_START_TAG
+ + "<span color=\"header\"
font=\"header\">Canceled.</span>"
+ + FORM_END_TAG;
+ public static final String LOADING = FORM_START_TAG
+ + "<span color=\"header\"
font=\"header\">Loading...</span>"
+ + FORM_END_TAG;
+
public static final String TUTORIALS_EXTENSION_ID =
"org.jboss.tools.central.tutorials";
-
+
public static final String CONFIGURATORS_EXTENSION_ID =
"org.jboss.tools.central.configurators";
-
+
private IJBossCentralConfigurator configurator;
-
- //public static final String SEARCH_PROJECT_PAGES = "Search Project Pages";
+ // public static final String SEARCH_PROJECT_PAGES = "Search Project Pages";
+
public static final String SEARCH_THE_COMMUNITY = "Search JBoss Community";
public static final String SEARCH_RED_HAT_CUSTOMER_PORTAL = "Search Red Hat
Customer Portal ";
@@ -124,11 +132,13 @@
public Map<String, TutorialCategory> tutorialCategories;
private BundleContext bundleContext;
-
+
public static final int MAX_FEEDS = 100;
private static final Object CONFIGURATOR = "configurator";
-
+
+ private static final String ORG_ECLIPSE_UI_INTERNAL_INTROVIEW =
"org.eclipse.ui.internal.introview";
+
// The shared instance
private static JBossCentralActivator plugin;
@@ -142,7 +152,10 @@
/*
* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -152,7 +165,10 @@
/*
* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -163,7 +179,7 @@
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static JBossCentralActivator getDefault() {
@@ -171,21 +187,22 @@
}
/**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
- *
- * @param path the path
+ * Returns an image descriptor for the image file at the given plug-in
+ * relative path
+ *
+ * @param path
+ * the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
-
+
public IEclipsePreferences getPreferences() {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(PLUGIN_ID);
return prefs;
}
-
+
public void savePreferences() {
IEclipsePreferences prefs = getPreferences();
try {
@@ -194,37 +211,39 @@
log(e);
}
}
-
+
public static void log(Exception e, String message) {
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
plugin.getLog().log(status);
}
public static void log(Throwable e) {
- IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e
- .getLocalizedMessage(), e);
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID,
+ e.getLocalizedMessage(), e);
plugin.getLog().log(status);
}
-
+
public static void log(String message) {
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message);
plugin.getLog().log(status);
}
-
+
public static void logWarning(String message) {
IStatus status = new Status(IStatus.WARNING, PLUGIN_ID, message);
plugin.getLog().log(status);
}
public boolean showJBossCentralOnStartup() {
- IEclipsePreferences prefs = JBossCentralActivator.getDefault().getPreferences();
- return prefs.getBoolean(SHOW_JBOSS_CENTRAL_ON_STARTUP,
SHOW_JBOSS_CENTRAL_ON_STARTUP_DEFAULT_VALUE);
+ IEclipsePreferences prefs = JBossCentralActivator.getDefault()
+ .getPreferences();
+ return prefs.getBoolean(SHOW_JBOSS_CENTRAL_ON_STARTUP,
+ SHOW_JBOSS_CENTRAL_ON_STARTUP_DEFAULT_VALUE);
}
-
+
public static void openUrl(String location, Shell shell) {
openUrl(location, shell, false);
}
-
+
public static void openUrl(String location, Shell shell, boolean asExternal) {
URL url = null;
try {
@@ -232,14 +251,16 @@
url = new URL(location);
}
- if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.EXTERNAL ||
asExternal) {
+ if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.EXTERNAL
+ || asExternal) {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
.getBrowserSupport();
support.getExternalBrowser().openURL(url);
} else {
IWebBrowser browser = null;
int flags;
- if (WorkbenchBrowserSupport.getInstance().isInternalWebBrowserAvailable()) {
+ if (WorkbenchBrowserSupport.getInstance()
+ .isInternalWebBrowserAvailable()) {
flags = IWorkbenchBrowserSupport.AS_EDITOR
| IWorkbenchBrowserSupport.LOCATION_BAR
| IWorkbenchBrowserSupport.NAVIGATION_BAR;
@@ -249,8 +270,10 @@
| IWorkbenchBrowserSupport.NAVIGATION_BAR;
}
- String generatedId = JBossCentralActivator.PLUGIN_ID + System.currentTimeMillis();
- browser = WorkbenchBrowserSupport.getInstance().createBrowser(flags, generatedId,
null, null);
+ String generatedId = JBossCentralActivator.PLUGIN_ID
+ + System.currentTimeMillis();
+ browser = WorkbenchBrowserSupport.getInstance().createBrowser(
+ flags, generatedId, null, null);
browser.openURL(url);
}
} catch (PartInitException e) {
@@ -258,17 +281,17 @@
JBossCentralActivator.PLUGIN_ID,
"Browser initialization failed");
JBossCentralActivator.getDefault().getLog().log(status);
- MessageDialog.openError(shell, "Open Location",
- status.getMessage());
+ MessageDialog
+ .openError(shell, "Open Location", status.getMessage());
} catch (MalformedURLException e) {
Status status = new Status(IStatus.ERROR,
JBossCentralActivator.PLUGIN_ID, "Invalid URL");
JBossCentralActivator.getDefault().getLog().log(status);
- MessageDialog.openError(shell, "Open Location",
- status.getMessage());
+ MessageDialog
+ .openError(shell, "Open Location", status.getMessage());
}
}
-
+
public Image getImage(ImageDescriptor imageDescriptor) {
ImageRegistry imageRegistry = getImageRegistry();
String id = getImageId(imageDescriptor);
@@ -283,16 +306,54 @@
private String getImageId(ImageDescriptor imageDescriptor) {
return PLUGIN_ID + "/" + imageDescriptor.hashCode();
}
-
- public static CommandContributionItem createContributionItem(IServiceLocator
serviceLocator, String commandId) {
+
+ public static CommandContributionItem createContributionItem(
+ IServiceLocator serviceLocator, String commandId) {
CommandContributionItemParameter parameter = new CommandContributionItemParameter(
serviceLocator, commandId, commandId,
CommandContributionItem.STYLE_PUSH);
return new CommandContributionItem(parameter);
}
-
+
public static JBossCentralEditor getJBossCentralEditor() {
- IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final WorkbenchWindow window = (WorkbenchWindow) PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow();
+ final IWorkbenchPage page = window.getActivePage();
+ if (page.findView(ORG_ECLIPSE_UI_INTERNAL_INTROVIEW) != null
+ && !window.getCoolBarVisible()
+ && !window.getPerspectiveBarVisible()) {
+ IViewReference viewRef = page
+ .findViewReference(ORG_ECLIPSE_UI_INTERNAL_INTROVIEW);
+ if (page.getPartState(viewRef) == IWorkbenchPage.STATE_MAXIMIZED) {
+ window.addPropertyChangeListener(new IPropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ if (WorkbenchWindow.PROP_COOLBAR_VISIBLE
+ .equals(property)
+ || WorkbenchWindow.PROP_COOLBAR_VISIBLE
+ .equals(property)) {
+ Object newValue = event.getNewValue();
+ if (newValue instanceof Boolean
+ && ((Boolean) newValue).booleanValue()) {
+ openJBossCentralEditor(page);
+ window.removePropertyChangeListener(this);
+ }
+ }
+ }
+ });
+ } else {
+ return openJBossCentralEditor(page);
+ }
+ } else {
+ return openJBossCentralEditor(page);
+ }
+ return null;
+ }
+
+ protected static JBossCentralEditor openJBossCentralEditor(
+ IWorkbenchPage page) {
IEditorInput input = JBossCentralEditorInput.INSTANCE;
try {
IEditorPart editor = page.openEditor(input, JBossCentralEditor.ID);
@@ -304,7 +365,7 @@
}
return null;
}
-
+
public IJBossCentralConfigurator getConfigurator() {
if (configurator == null) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
@@ -319,7 +380,8 @@
IConfigurationElement configurationElement = configurationElements[j];
if (CONFIGURATOR.equals(configurationElement.getName())) {
try {
- configurator = (IJBossCentralConfigurator)
configurationElement.createExecutableExtension("class");
+ configurator = (IJBossCentralConfigurator) configurationElement
+ .createExecutableExtension("class");
} catch (CoreException e) {
JBossCentralActivator.log(e);
continue;
@@ -327,7 +389,7 @@
break;
}
}
-
+
}
if (configurator == null) {
configurator = new DefaultJBossCentralConfigurator();
@@ -335,7 +397,7 @@
}
return configurator;
}
-
+
public Map<String, TutorialCategory> getTutorialCategories() {
if (tutorialCategories == null) {
tutorialCategories = new HashMap<String, TutorialCategory>();
@@ -352,8 +414,10 @@
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);
+ String description = configurationElement
+ .getAttribute(DESCRIPTION);
+ String priorityString = configurationElement
+ .getAttribute(PRIORITY);
int priority = Integer.MAX_VALUE;
if (priorityString != null) {
try {
@@ -363,7 +427,8 @@
log(e);
}
}
- TutorialCategory category = new TutorialCategory(id, name, priority, description);
+ TutorialCategory category = new TutorialCategory(id,
+ name, priority, description);
tutorialCategories.put(id, category);
}
}
@@ -373,10 +438,14 @@
String name = configurationElement.getAttribute(NAME);
String id = configurationElement.getAttribute(ID);
String type = configurationElement.getAttribute(TYPE);
- String reference = configurationElement.getAttribute(REFERENCE);
- String priorityString = configurationElement.getAttribute(PRIORITY);
- String description = configurationElement.getAttribute(DESCRIPTION);
- String iconPath = configurationElement.getAttribute(ICON);
+ String reference = configurationElement
+ .getAttribute(REFERENCE);
+ String priorityString = configurationElement
+ .getAttribute(PRIORITY);
+ String description = configurationElement
+ .getAttribute(DESCRIPTION);
+ String iconPath = configurationElement
+ .getAttribute(ICON);
int priority = Integer.MAX_VALUE;
if (priorityString != null) {
try {
@@ -386,28 +455,32 @@
log(e);
}
}
- String categoryId = configurationElement.getAttribute(CATEGORY_ID);
- TutorialCategory category = tutorialCategories.get(categoryId);
+ String categoryId = configurationElement
+ .getAttribute(CATEGORY_ID);
+ TutorialCategory category = tutorialCategories
+ .get(categoryId);
if (category == null) {
log("Invalid tutorial: id=" + id);
continue;
}
- Tutorial tutorial = new Tutorial(id, name, type, reference, priority, category,
description, iconPath);
+ Tutorial tutorial = new Tutorial(id, name, type,
+ reference, priority, category, description,
+ iconPath);
category.getTutorials().add(tutorial);
}
}
}
List<TutorialCategory> emptyCategories = new
ArrayList<TutorialCategory>();
- for (TutorialCategory category:tutorialCategories.values()) {
+ for (TutorialCategory category : tutorialCategories.values()) {
if (category.getTutorials().size() == 0) {
emptyCategories.add(category);
}
}
- for (TutorialCategory category:emptyCategories) {
+ for (TutorialCategory category : emptyCategories) {
tutorialCategories.remove(category.getId());
}
}
-
+
return tutorialCategories;
}
@@ -427,7 +500,7 @@
Map<String, TutorialCategory> tutorialCategories) {
this.tutorialCategories = tutorialCategories;
}
-
+
public String getDescription(Tutorial tutorial) {
String description = tutorial.getDescription();
Project project = tutorial.getProjectExamples();
@@ -440,22 +513,26 @@
buffer.append("Size: ");
buffer.append(project.getSizeAsText());
if (project.getUnsatisfiedFixes().size() > 0) {
- buffer.append("\n\n");
+ buffer.append("\n\n");
}
return buffer.toString();
}
-
+
public static Dictionary<Object, Object> getEnvironment() {
- Dictionary<Object, Object> environment = new Hashtable<Object,
Object>(System.getProperties());
+ Dictionary<Object, Object> environment = new Hashtable<Object, Object>(
+ System.getProperties());
Bundle bundle = Platform.getBundle("org.jboss.tools.central"); //$NON-NLS-1$
Version version = bundle.getVersion();
environment.put("org.jboss.tools.central.version", version.toString());
//$NON-NLS-1$
- environment.put("org.jboss.tools.central.version.major", version.getMajor());
//$NON-NLS-1$
- environment.put("org.jboss.tools.central.version.minor", version.getMinor());
//$NON-NLS-1$
- environment.put("org.jboss.tools.central.version.micro", version.getMicro());
//$NON-NLS-1$
+ environment.put(
+ "org.jboss.tools.central.version.major", version.getMajor());
//$NON-NLS-1$
+ environment.put(
+ "org.jboss.tools.central.version.minor", version.getMinor());
//$NON-NLS-1$
+ environment.put(
+ "org.jboss.tools.central.version.micro", version.getMicro());
//$NON-NLS-1$
return environment;
}
-
+
public Object getService(String name) {
if (bundleContext == null)
return null;
@@ -470,7 +547,7 @@
public BundleContext getBundleContext() {
return bundleContext;
}
-
+
public static boolean isInternalWebBrowserAvailable() {
if (isInternalWebBrowserAvailable != null) {
return isInternalWebBrowserAvailable.booleanValue();
Modified:
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/AbstractJBossCentralPage.java
===================================================================
---
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/AbstractJBossCentralPage.java 2011-12-09
09:48:23 UTC (rev 37147)
+++
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/AbstractJBossCentralPage.java 2011-12-09
09:53:58 UTC (rev 37148)
@@ -101,6 +101,9 @@
}
protected void setBusyIndicator(Composite composite, boolean busy) {
+ if (composite == null || composite.isDisposed()) {
+ return;
+ }
Control[] children = composite.getChildren();
for (Control child:children) {
if (child instanceof RefreshIndicator) {
Modified:
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
===================================================================
---
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2011-12-09
09:48:23 UTC (rev 37147)
+++
branches/jbosstools-3.3.0.M5/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2011-12-09
09:53:58 UTC (rev 37148)
@@ -1223,6 +1223,9 @@
@Override
public void run() {
+ if (blogsLoadingComposite == null || blogsLoadingComposite.isDisposed()) {
+ return;
+ }
setBusyIndicator(blogsLoadingComposite, false);
refreshBlogs();
setItemVisible(blogsToolBarManager, BLOGS_WARNING_ID, false);
@@ -1276,6 +1279,9 @@
@Override
public void run() {
+ if (tutorialsLoadingComposite == null || tutorialsLoadingComposite.isDisposed()) {
+ return;
+ }
setBusyIndicator(tutorialsLoadingComposite, false);
refreshTutorials();
@@ -1327,6 +1333,9 @@
@Override
public void run() {
+ if (newsLoadingComposite == null || newsLoadingComposite.isDisposed()) {
+ return;
+ }
setBusyIndicator(newsLoadingComposite, false);
refreshNews();
setItemVisible(newsToolBarManager, NEWS_WARNING_ID, false);