[jbosstools-commits] JBoss Tools SVN: r39923 - trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Mar 29 16:20:04 EDT 2012


Author: snjeza
Date: 2012-03-29 16:20:02 -0400 (Thu, 29 Mar 2012)
New Revision: 39923

Modified:
   trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
Log:
JBIDE-11440 - JBoss Perspective does not include JBoss Central

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	2012-03-29 18:07:23 UTC (rev 39922)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java	2012-03-29 20:20:02 UTC (rev 39923)
@@ -30,9 +30,12 @@
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IPerspectiveListener;
 import org.eclipse.ui.IViewReference;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
@@ -60,22 +63,10 @@
  */
 public class JBossCentralActivator extends AbstractUIPlugin {
 
+	private static final String JBOSS_PERSPECTIVE_ID = "org.jboss.tools.common.ui.JBossPerspective";
+
 	public static final Object JBOSS_CENTRAL_FAMILY = new Object();
 
-//	public static final String ICON = "icon";
-//
-//	private static final String DESCRIPTION = "description";
-//
-//	private static final String TUTORIAL = "tutorial";
-//
-//	public static final String CATEGORY_ID = "categoryId";
-//
-//	public static final String REFERENCE = "reference";
-//
-//	public static final String TYPE = "type";
-//
-//	public static final String PRIORITY = "priority";
-
 	public static final String ID = "id";
 
 	public static final String NAME = "name";
@@ -106,10 +97,6 @@
 			+ "<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 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,6 +111,23 @@
 	private static JBossCentralActivator plugin;
 
 	private static Boolean isInternalWebBrowserAvailable;
+	
+	private IPerspectiveListener perspectiveListener = new IPerspectiveListener() {
+		
+		@Override
+		public void perspectiveChanged(IWorkbenchPage page,
+				IPerspectiveDescriptor perspective, String changeId) {
+		}
+		
+		@Override
+		public void perspectiveActivated(IWorkbenchPage page,
+				IPerspectiveDescriptor perspective) {
+			String id = perspective.getId();
+			if (JBOSS_PERSPECTIVE_ID.equals(id) && showJBossCentralOnStartup()) {
+				getJBossCentralEditor();
+			}
+		}
+	};
 
 	/**
 	 * The constructor
@@ -142,6 +146,13 @@
 		super.start(context);
 		this.bundleContext = context;
 		plugin = this;
+		Display.getDefault().asyncExec(new Runnable() {
+			
+			@Override
+			public void run() {
+				PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(perspectiveListener);
+			}
+		});
 	}
 
 	/*
@@ -152,6 +163,17 @@
 	 * )
 	 */
 	public void stop(BundleContext context) throws Exception {
+		Display.getDefault().syncExec(new Runnable() {
+			
+			@Override
+			public void run() {
+				try {
+					PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePerspectiveListener(perspectiveListener);
+				} catch (Throwable e) {
+					// ignore
+				}
+			}
+		});
 		Job.getJobManager().cancel(JBOSS_CENTRAL_FAMILY); 
 		Job.getJobManager().join(JBOSS_CENTRAL_FAMILY, new NullProgressMonitor());
 		



More information about the jbosstools-commits mailing list