Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMazen Faraj2004-05-27 08:46:54 +0000
committerMazen Faraj2004-05-27 08:46:54 +0000
commitcb77b765539cf049025dc6b23290a38c6212d7d5 (patch)
tree7a9f1e41ef6e7a1db447fc5352eef14daf3c5864 /org.eclipse.ui.intro/src/org
parentc7513a99a9d010279e731246798d0eac00ede0f6 (diff)
downloadeclipse.platform.ua-cb77b765539cf049025dc6b23290a38c6212d7d5.tar.gz
eclipse.platform.ua-cb77b765539cf049025dc6b23290a38c6212d7d5.tar.xz
eclipse.platform.ua-cb77b765539cf049025dc6b23290a38c6212d7d5.zip
fixes for dyamic awarness
Diffstat (limited to 'org.eclipse.ui.intro/src/org')
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java1
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractBaseIntroElement.java2
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPartImplementation.java9
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java39
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java10
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ExtensionPointManager.java2
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java45
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java71
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java39
9 files changed, 130 insertions, 88 deletions
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java
index 24dbdb473..beb1d89b6 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java
@@ -182,7 +182,6 @@ public class IntroHTMLGenerator {
AbstractIntroElement[] children = introPage.getChildren();
for (int i = 0; i < children.length; i++) {
AbstractIntroElement child = children[i];
- Log.info(" in generateBodyElement, child is: " + child.getType());
// check to see if this element should be filtered from the HTML
// presentation
if(!filteredFromPresentation(child)){
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractBaseIntroElement.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractBaseIntroElement.java
index ebdec9f78..d8a5258c7 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractBaseIntroElement.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractBaseIntroElement.java
@@ -12,7 +12,6 @@
package org.eclipse.ui.internal.intro.impl.model;
import org.eclipse.core.runtime.*;
-import org.eclipse.ui.internal.intro.impl.util.*;
import org.osgi.framework.*;
import org.w3c.dom.*;
@@ -58,7 +57,6 @@ public abstract class AbstractBaseIntroElement extends AbstractIntroIdElement {
if (this.isOfType(AbstractIntroElement.MODEL_ROOT))
// root element is not filtered.
return false;
- Log.info("checkFilter: parent: " + getParentPage());
IntroModelRoot root = (IntroModelRoot) getParentPage().getParent();
return root.getPresentation().getImplementationKind().equals(
filteredFrom) ? true : false;
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPartImplementation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPartImplementation.java
index dca9189e7..5d0f9f9de 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPartImplementation.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPartImplementation.java
@@ -90,7 +90,7 @@ public abstract class AbstractIntroPartImplementation {
getIntroPart().getIntroSite().getShell(),
new IntroModelLabelProvider(),
new IntroModelContentProvider());
- treeViewer.setInput(getModelRoot());
+ treeViewer.setInput(getModel());
treeViewer.open();
}
};
@@ -120,7 +120,7 @@ public abstract class AbstractIntroPartImplementation {
/**
* @return
*/
- public IntroModelRoot getModelRoot() {
+ public IntroModelRoot getModel() {
return IntroPlugin.getDefault().getIntroModelRoot();
}
@@ -311,7 +311,7 @@ public abstract class AbstractIntroPartImplementation {
* @param memento
*/
protected void saveCurrentPage(IMemento memento) {
- IntroModelRoot model = getModelRoot();
+ IntroModelRoot model = getModel();
if (memento == null || model == null)
return;
@@ -361,9 +361,6 @@ public abstract class AbstractIntroPartImplementation {
navigationLocation = 0;
// give implementation a chance to react to change.
handleRegistryChanged(event);
- getModelRoot().firePropertyChange(
- IntroModelRoot.CURRENT_PAGE_PROPERTY_ID);
- Log.info("fired current page event");
}
/*
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
index a47136dfa..358b3314e 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
@@ -54,6 +54,10 @@ import org.w3c.dom.*;
* be resolved correctly.</li>
* <li>unresolved includes are left as children of the parent container.</li>
* <li>Unresolved extensions are left as children of the targetted model.</li>
+ * <li>For dynamic awarness, the model is nulled and then reloaded. However, we
+ * need to preserve the presentation instance since the UI is already loaded.
+ * This is done by reloading the model, and directly resetting the presentation
+ * to what it was.</li>
* </ol>
*/
public class IntroModelRoot extends AbstractIntroContainer {
@@ -152,6 +156,19 @@ public class IntroModelRoot extends AbstractIntroContainer {
setModelState(true, true, getHomePage().isDynamic());
}
+ /**
+ * Sets the presentation to the given presentation. The model always has the
+ * presentation as the first child, so use that fact. This method is used
+ * for dynamic awarness to enable replacing the new presentation with the
+ * existing one after a model refresh.
+ *
+ * @param presentation
+ */
+ public void setPresentation(IntroPartPresentation presentation) {
+ this.introPartPresentation = presentation;
+ presentation.setParent(this);
+ children.set(0, presentation);
+ }
/**
* Resolve each include in this container's children.
@@ -449,12 +466,19 @@ public class IntroModelRoot extends AbstractIntroContainer {
* id, the message is logged, and the model retains its old current page.
*
* @param currentPageId
- * The currentPageId to set.
+ * The currentPageId to set. *
+ * @param fireEvent
+ * flag to indicate if event notification is needed.
* @return true if the model has a page with the passed id, false otherwise.
* If the method fails, the current page remains the same as the
* last state.
*/
- public boolean setCurrentPageId(String pageId) {
+ public boolean setCurrentPageId(String pageId, boolean fireEvent) {
+ if (pageId == currentPageId)
+ // setting to the same page does nothing. Return true because we did
+ // not actually fail. just a no op.
+ return true;
+
AbstractIntroPage page = (AbstractIntroPage) findChild(pageId, PAGE);
if (page == null) {
// not a page. Test for root page.
@@ -466,10 +490,15 @@ public class IntroModelRoot extends AbstractIntroContainer {
}
currentPageId = pageId;
- firePropertyChange(CURRENT_PAGE_PROPERTY_ID);
+ if (fireEvent)
+ firePropertyChange(CURRENT_PAGE_PROPERTY_ID);
return true;
}
+ public boolean setCurrentPageId(String pageId) {
+ return setCurrentPageId(pageId, true);
+ }
+
public void addPropertyListener(IPropertyListener l) {
propChangeListeners.add(l);
}
@@ -483,16 +512,12 @@ public class IntroModelRoot extends AbstractIntroContainer {
*/
public void firePropertyChange(final int propertyId) {
Object[] array = propChangeListeners.getListeners();
- Log.info("entering fire Property change.");
for (int i = 0; i < array.length; i++) {
- Log.info("entering loop in Property change.");
final IPropertyListener l = (IPropertyListener) array[i];
Platform.run(new SafeRunnable() {
public void run() {
- Log.info("entering run Property change.");
l.propertyChanged(this, propertyId);
- Log.info("leaving Property change.");
}
public void handleException(Throwable e) {
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java
index c1bb2d9f6..459901844 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java
@@ -17,7 +17,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.*;
-import org.eclipse.ui.internal.intro.impl.*;
import org.eclipse.ui.internal.intro.impl.model.loader.*;
import org.eclipse.ui.internal.intro.impl.presentations.*;
import org.eclipse.ui.internal.intro.impl.util.*;
@@ -43,8 +42,7 @@ import org.eclipse.ui.intro.*;
* implmenetation.</li>
* <ul>
*/
-public class IntroPartPresentation extends AbstractIntroElement implements
- IRegistryChangeListener {
+public class IntroPartPresentation extends AbstractIntroElement {
protected static final String TAG_PRESENTATION = "presentation"; //$NON-NLS-1$
private static final String TAG_IMPLEMENTATION = "implementation"; //$NON-NLS-1$
@@ -162,9 +160,6 @@ public class IntroPartPresentation extends AbstractIntroElement implements
// there is no valid implementation.
this.introPart = introPart;
this.memento = memento;
- // add the registry listerner for dynamic awarness.
- Platform.getExtensionRegistry().addRegistryChangeListener(this,
- IIntroConstants.PLUGIN_ID);
}
/**
@@ -421,7 +416,6 @@ public class IntroPartPresentation extends AbstractIntroElement implements
public void dispose() {
if (implementation != null)
implementation.dispose();
- Platform.getExtensionRegistry().removeRegistryChangeListener(this);
}
/**
@@ -431,10 +425,8 @@ public class IntroPartPresentation extends AbstractIntroElement implements
* @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent)
*/
public void registryChanged(IRegistryChangeEvent event) {
- ExtensionPointManager.getInst().clear();
if (implementation != null)
implementation.registryChanged(event);
-
}
/**
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ExtensionPointManager.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ExtensionPointManager.java
index 445850b66..278a0d13d 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ExtensionPointManager.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ExtensionPointManager.java
@@ -105,7 +105,7 @@ public class ExtensionPointManager extends BaseExtensionPointManager {
currentModel = null;
sharedConfigExtensionsManager = null;
introModels.clear();
- Log.info("Cleared Intro model");
+ Log.info("Cleared Intro model"); //$NON-NLS-1$
}
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java
index ee7cf84a0..9516c8743 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java
@@ -46,11 +46,11 @@ public class BrowserIntroPartImplementation extends
public void run() {
// Home is URL of root page in static case, and root page in
// dynamic.
- IntroHomePage rootPage = getModelRoot().getHomePage();
+ IntroHomePage rootPage = getModel().getHomePage();
String location = null;
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
location = rootPage.getId();
- getModelRoot().setCurrentPageId(location);
+ getModel().setCurrentPageId(location);
} else {
location = rootPage.getUrl();
browser.setUrl(location);
@@ -60,7 +60,7 @@ public class BrowserIntroPartImplementation extends
};
protected void updateNavigationActionsState() {
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
forwardAction.setEnabled(canNavigateForward());
backAction.setEnabled(canNavigateBackward());
return;
@@ -111,13 +111,13 @@ public class BrowserIntroPartImplementation extends
addToolBarActions();
- if (!getModelRoot().hasValidConfig()) {
+ if (!getModel().hasValidConfig()) {
browser.setText(IntroPlugin.getString("Browser.invalidConfig")); //$NON-NLS-1$
return;
}
// root page is what decides if the model is dynamic or not.
- if (getModelRoot().isDynamic())
+ if (getModel().isDynamic())
handleDynamicIntro();
else
handleStaticIntro();
@@ -127,7 +127,7 @@ public class BrowserIntroPartImplementation extends
private void handleDynamicIntro() {
- IntroHomePage homePage = getModelRoot().getHomePage();
+ IntroHomePage homePage = getModel().getHomePage();
// check cache state.
String cachedPage = getCachedCurrentPage();
if (cachedPage != null) {
@@ -143,8 +143,8 @@ public class BrowserIntroPartImplementation extends
} else {
// Generate HTML for the cached page, and set it
// on the browser.
- getModelRoot().setCurrentPageId(cachedPage);
- generateDynamicContentForPage(getModelRoot().getCurrentPage());
+ getModel().setCurrentPageId(cachedPage);
+ generateDynamicContentForPage(getModel().getCurrentPage());
}
updateHistory(cachedPage);
@@ -157,7 +157,7 @@ public class BrowserIntroPartImplementation extends
// Add this presentation as a listener to model
// only in dynamic case, for now.
- getModelRoot().addPropertyListener(this);
+ getModel().addPropertyListener(this);
// REVISIT: update the history here. The design of the history
// navigation is that it has to be updated independant of the
@@ -173,7 +173,7 @@ public class BrowserIntroPartImplementation extends
String url = getCachedCurrentPage();
if (!isURL(url))
// no cached state, or invalid state.
- url = getModelRoot().getHomePage().getUrl();
+ url = getModel().getHomePage().getUrl();
if (url == null) {
// We have no content to display. log an error
@@ -267,11 +267,11 @@ public class BrowserIntroPartImplementation extends
*/
public void propertyChanged(Object source, int propId) {
if (propId == IntroModelRoot.CURRENT_PAGE_PROPERTY_ID) {
- String pageId = getModelRoot().getCurrentPageId();
+ String pageId = getModel().getCurrentPageId();
if (pageId == null || pageId.equals("")) //$NON-NLS-1$
// page ID was not set properly. exit.
return;
- generateDynamicContentForPage(getModelRoot().getCurrentPage());
+ generateDynamicContentForPage(getModel().getCurrentPage());
}
}
@@ -316,7 +316,7 @@ public class BrowserIntroPartImplementation extends
*/
public boolean navigateBackward() {
boolean success = false;
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
// dynamic case. Uses navigation history.
if (canNavigateBackward()) {
navigateHistoryBackward();
@@ -325,8 +325,7 @@ public class BrowserIntroPartImplementation extends
} else
// we need to regen HTML. Set current page, and this
// will triger regen.
- success = getModelRoot().setCurrentPageId(
- getCurrentLocation());
+ success = getModel().setCurrentPageId(getCurrentLocation());
} else
success = false;
} else
@@ -345,7 +344,7 @@ public class BrowserIntroPartImplementation extends
*/
public boolean navigateForward() {
boolean success = false;
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
// dynamic case. Uses navigation history.
if (canNavigateForward()) {
navigateHistoryForward();
@@ -354,8 +353,7 @@ public class BrowserIntroPartImplementation extends
} else
// we need to regen HTML. Set current page, and this
// will triger regen.
- success = getModelRoot().setCurrentPageId(
- getCurrentLocation());
+ success = getModel().setCurrentPageId(getCurrentLocation());
} else
success = false;
@@ -374,12 +372,13 @@ public class BrowserIntroPartImplementation extends
* @see org.eclipse.ui.internal.intro.impl.model.AbstractIntroPartImplementation#handleRegistryChanged(org.eclipse.core.runtime.IRegistryChangeEvent)
*/
protected void handleRegistryChanged(IRegistryChangeEvent event) {
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
// null generator first.
htmlGenerator = null;
- // Add this presentation as a listener to model
- // only in dynamic case, for now.
- getModelRoot().addPropertyListener(this);
+ // Add this presentation as a listener to mode only in dynamic case.
+ getModel().addPropertyListener(this);
+ getModel().firePropertyChange(
+ IntroModelRoot.CURRENT_PAGE_PROPERTY_ID);
}
}
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java
index d23ce1b33..008bec7b5 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java
@@ -21,6 +21,7 @@ import org.eclipse.ui.forms.*;
import org.eclipse.ui.forms.widgets.*;
import org.eclipse.ui.internal.intro.impl.*;
import org.eclipse.ui.internal.intro.impl.model.*;
+import org.eclipse.ui.internal.intro.impl.model.loader.*;
import org.eclipse.ui.internal.intro.impl.swt.*;
import org.eclipse.ui.internal.intro.impl.util.*;
import org.eclipse.ui.intro.config.*;
@@ -34,7 +35,7 @@ public class FormIntroPartImplementation extends
private FormToolkit toolkit = null;
private ScrolledPageBook mainPageBook = null;
// cache model instance for reuse.
- private IntroModelRoot model = getModelRoot();
+ private IntroModelRoot model = getModel();
private SharedStyleManager sharedStyleManager;
static {
@@ -61,12 +62,12 @@ public class FormIntroPartImplementation extends
}
public void run() {
- IntroHomePage rootPage = getModelRoot().getHomePage();
- if (getModelRoot().isDynamic()) {
+ IntroHomePage rootPage = getModel().getHomePage();
+ if (getModel().isDynamic()) {
CustomizableIntroPart currentIntroPart = (CustomizableIntroPart) IntroPlugin
.getIntro();
currentIntroPart.getControl().setRedraw(false);
- getModelRoot().setCurrentPageId(rootPage.getId());
+ getModel().setCurrentPageId(rootPage.getId());
updateHistory(rootPage.getId());
currentIntroPart.getControl().setRedraw(true);
}
@@ -75,7 +76,7 @@ public class FormIntroPartImplementation extends
protected void updateNavigationActionsState() {
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
forwardAction.setEnabled(canNavigateForward());
backAction.setEnabled(canNavigateBackward());
return;
@@ -85,12 +86,12 @@ public class FormIntroPartImplementation extends
public FormIntroPartImplementation() {
// Shared style manager
- sharedStyleManager = new SharedStyleManager(getModelRoot());
+ sharedStyleManager = new SharedStyleManager(getModel());
}
public void createPartControl(Composite container) {
- if (getModelRoot().isDynamic())
+ if (getModel().isDynamic())
handleDynamicIntro(container);
else {
// create just a dummy composite for now, to enable...
@@ -105,7 +106,7 @@ public class FormIntroPartImplementation extends
* of the root page.
*/
private void handleStaticIntro() {
- String rootPageUrl = getModelRoot().getHomePage().getUrl();
+ String rootPageUrl = getModel().getHomePage().getUrl();
Util.openBrowser(rootPageUrl);
}
@@ -142,7 +143,7 @@ public class FormIntroPartImplementation extends
mainPageBook = createMainPageBook(toolkit, mainForm);
// Add this presentation as a listener to model.
- getModelRoot().addPropertyListener(this);
+ getModel().addPropertyListener(this);
// Clear memory. No need for style manager any more.
sharedStyleManager = null;
@@ -186,7 +187,7 @@ public class FormIntroPartImplementation extends
String cachedPage = getCachedCurrentPage();
if (cachedPage != null & !isURL(cachedPage))
model.setCurrentPageId(cachedPage);
- AbstractIntroPage pageToShow = getModelRoot().getCurrentPage();
+ AbstractIntroPage pageToShow = getModel().getCurrentPage();
if (pageToShow != null) {
if (pageBook.hasPage(pageToShow.getId()))
@@ -221,26 +222,17 @@ public class FormIntroPartImplementation extends
*/
public void propertyChanged(Object source, int propId) {
if (propId == IntroModelRoot.CURRENT_PAGE_PROPERTY_ID) {
- try {
- Log.info("entering Property change.");
- String pageId = getModelRoot().getCurrentPageId();
- Log.info("current page id is: " + pageId);
- if (pageId == null | pageId.equals("")) //$NON-NLS-1$
- // If page ID was not set properly. exit.
- return;
-
- // if we are showing a regular intro page, or if the Home Page
- // has a
- // regular page layout, set the page id to the static PageForm
- // id.
- if (!mainPageBook.hasPage(pageId))
- pageId = PageForm.PAGE_FORM_ID;
- Log.info("before show page");
- mainPageBook.showPage(pageId);
- Log.info("after show page. ");
- } catch (Exception e) {
- Log.error("Property change failed.", e);
- }
+ String pageId = getModel().getCurrentPageId();
+ if (pageId == null | pageId.equals("")) //$NON-NLS-1$
+ // If page ID was not set properly. exit.
+ return;
+
+ // if we are showing a regular intro page, or if the Home Page
+ // has a regular page layout, set the page id to the static PageForm
+ // id.
+ if (!mainPageBook.hasPage(pageId))
+ pageId = PageForm.PAGE_FORM_ID;
+ mainPageBook.showPage(pageId);
}
}
@@ -285,7 +277,7 @@ public class FormIntroPartImplementation extends
*/
public boolean navigateBackward() {
boolean success = false;
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
// dynamic case. Uses navigation history.
if (canNavigateBackward()) {
navigateHistoryBackward();
@@ -296,8 +288,7 @@ public class FormIntroPartImplementation extends
CustomizableIntroPart currentIntroPart = (CustomizableIntroPart) IntroPlugin
.getIntro();
currentIntroPart.getControl().setRedraw(false);
- success = getModelRoot().setCurrentPageId(
- getCurrentLocation());
+ success = getModel().setCurrentPageId(getCurrentLocation());
currentIntroPart.getControl().setRedraw(true);
}
}
@@ -316,7 +307,7 @@ public class FormIntroPartImplementation extends
public boolean navigateForward() {
boolean success = false;
- if (getModelRoot().isDynamic()) {
+ if (getModel().isDynamic()) {
// dynamic case. Uses navigation history.
if (canNavigateForward()) {
navigateHistoryForward();
@@ -327,8 +318,7 @@ public class FormIntroPartImplementation extends
CustomizableIntroPart currentIntroPart = (CustomizableIntroPart) IntroPlugin
.getIntro();
currentIntroPart.getControl().setRedraw(false);
- success = getModelRoot().setCurrentPageId(
- getCurrentLocation());
+ success = getModel().setCurrentPageId(getCurrentLocation());
currentIntroPart.getControl().setRedraw(true);
}
}
@@ -344,7 +334,14 @@ public class FormIntroPartImplementation extends
* @see org.eclipse.ui.internal.intro.impl.model.AbstractIntroPartImplementation#handleRegistryChanged(org.eclipse.core.runtime.IRegistryChangeEvent)
*/
protected void handleRegistryChanged(IRegistryChangeEvent event) {
- // TODO Auto-generated method stub
+ if (getModel().isDynamic()) {
+ IntroPlugin.closeIntro();
+ String currentPageId = model.getCurrentPageId();
+ IntroModelRoot model = ExtensionPointManager.getInst()
+ .getCurrentModel();
+ model.setCurrentPageId(currentPageId, false);
+ IntroPlugin.showIntro(false);
+ }
}
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java
index be781a80d..d31fa434d 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java
@@ -54,13 +54,13 @@ import org.eclipse.ui.part.*;
* @since 3.0
*/
public final class CustomizableIntroPart extends IntroPart implements
- IIntroConstants {
+ IIntroConstants, IRegistryChangeListener {
- private IntroModelRoot model;
private IntroPartPresentation presentation;
private StandbyPart standbyPart;
private Composite container;
private IMemento memento;
+ private IntroModelRoot model;
// Adapter factory to abstract out the StandbyPart implementation from APIs.
IAdapterFactory factory = new IAdapterFactory() {
@@ -93,6 +93,7 @@ public final class CustomizableIntroPart extends IntroPart implements
}
+
/*
* (non-Javadoc)
*
@@ -120,6 +121,9 @@ public final class CustomizableIntroPart extends IntroPart implements
MEMENTO_PRESENTATION_TAG));
// standby part is not created here for performance.
this.memento = memento;
+ // add the registry listerner for dynamic awarness.
+ Platform.getExtensionRegistry().addRegistryChangeListener(this,
+ IIntroConstants.PLUGIN_ID);
}
if (model == null || !model.hasValidConfig())
@@ -242,6 +246,8 @@ public final class CustomizableIntroPart extends IntroPart implements
// clean platform adapter.
Platform.getAdapterManager().unregisterAdapters(factory,
CustomizableIntroPart.class);
+ if (model != null && model.hasValidConfig())
+ Platform.getExtensionRegistry().removeRegistryChangeListener(this);
}
/**
@@ -287,7 +293,36 @@ public final class CustomizableIntroPart extends IntroPart implements
return memento.getChild(key);
}
+ /**
+ * Support dynamic awarness.
+ *
+ * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent)
+ */
+ public void registryChanged(final IRegistryChangeEvent event) {
+ // Clear cached models first, then update UI by delegating to
+ // implementation. wrap in synchExec because notification is
+ // asynchronous. The design here is that the notification is centralized
+ // here, then this event propagates and each receiving class reacts
+ // accordingly.
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ String currentPageId = model.getCurrentPageId();
+ // clear model
+ ExtensionPointManager.getInst().clear();
+ // refresh to new model.
+ model = ExtensionPointManager.getInst().getCurrentModel();
+ // reuse existing presentation, since we just nulled it.
+ model.setPresentation(getPresentation());
+ // keep same page on refresh. No need for notification here.
+ model.setCurrentPageId(currentPageId, false);
+ if (presentation != null)
+ presentation.registryChanged(event);
+
+ }
+ });
+ }
}

Back to the top