Skip to content

Commit

Permalink
#2662 Avoid ClassCastException on WelcomeView
Browse files Browse the repository at this point in the history
Change-Id: Ie228d2257fe5f8ea5c5eabf22af9b96401b6545a
Signed-off-by: Erwann Traisnel <erwann.traisnel@obeo.fr>
  • Loading branch information
etraisnel2 authored and pdulth committed Jan 24, 2024
1 parent 8a4667b commit d9f48a2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.polarsys.capella.core.platform.sirius.ui.app;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.sirius.viewpoint.Customizable;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.IWorkbenchWindow;
Expand All @@ -25,7 +26,9 @@
import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
import org.eclipse.ui.internal.util.PrefUtil;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.intro.config.CustomizableIntroPart;
import org.eclipse.ui.part.IntroPart;
import org.polarsys.capella.common.bundle.FeatureHelper;
import org.polarsys.capella.common.mdsofa.common.constant.ICommonConstants;
import org.polarsys.capella.core.platform.sirius.ui.PerspectivePreferences;
Expand Down Expand Up @@ -75,13 +78,12 @@ boolean showPage(String pageId) {
// the page was not found in the current model, look for it in loaded
// models. return false if failed.
// avoid flicker.
CustomizableIntroPart currentIntroPart = (CustomizableIntroPart) IntroPlugin.getIntro();
currentIntroPart.getControl().setRedraw(false);

IIntroPart introPart = IntroPlugin.getIntro();
setRedraw(introPart, false);
IntroModelRoot modelRoot = IntroPlugin.getDefault().getIntroModelRoot();
boolean success = modelRoot.setCurrentPageId(pageId);
// we turned drawing off. Turn it on again.
currentIntroPart.getControl().setRedraw(true);
setRedraw(introPart, true);

if (success) {
// found page. Set the history
Expand Down Expand Up @@ -142,4 +144,12 @@ public boolean updateCapellaVersion() {
}
return updated;
}

private void setRedraw(IIntroPart part, boolean redraw) {
if (part instanceof IWelcomeView) {
((IWelcomeView) part).getControl().setRedraw(redraw);
} else if (part instanceof CustomizableIntroPart) {
((CustomizableIntroPart) part).getControl().setRedraw(redraw);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.polarsys.capella.core.platform.sirius.ui.app;

import org.eclipse.swt.widgets.Composite;

public interface IWelcomeView {

public Composite getControl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.polarsys.capella.core.ui.intro;singleton:=true
Bundle-Version: 7.0.0.qualifier
Export-Package: org.polarsys.capella.core.ui.intro.views
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.intro,
org.eclipse.ui.intro.universal,
org.polarsys.capella.core.platform.sirius.ui.project,
org.eclipse.ui.forms
org.eclipse.ui.forms,
org.polarsys.capella.core.platform.sirius.ui.perspective
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
import org.eclipse.ui.intro.IIntroSite;
import org.eclipse.ui.part.IntroPart;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.polarsys.capella.core.platform.sirius.ui.app.IWelcomeView;


public class WelcomeView extends IntroPart{
public class WelcomeView extends IntroPart implements IWelcomeView{

/**
* The ID of the view as specified by the extension.
Expand All @@ -63,6 +64,8 @@ public class WelcomeView extends IntroPart{
Font titleTextFont = null;
Font introTextFont = null;
Font hyperLinkFont = null;

ScrolledComposite container = null;

public WelcomeView() {
}
Expand All @@ -81,14 +84,14 @@ public void init(IIntroSite site, IMemento memento) throws PartInitException {
@Override
public void createPartControl(Composite parent) {

ScrolledComposite mainComposite = new ScrolledComposite(parent, SWT.FILL | SWT.H_SCROLL | SWT.V_SCROLL);
mainComposite.setExpandHorizontal(true);
mainComposite.setExpandVertical(true);
mainComposite.setMinHeight(1000);
mainComposite.setMinWidth(900);
container = new ScrolledComposite(parent, SWT.FILL | SWT.H_SCROLL | SWT.V_SCROLL);
container.setExpandHorizontal(true);
container.setExpandVertical(true);
container.setMinHeight(1000);
container.setMinWidth(900);

Composite intermediaryComposite = new Composite(mainComposite, SWT.FILL);
mainComposite.setContent(intermediaryComposite);
Composite intermediaryComposite = new Composite(container, SWT.FILL);
container.setContent(intermediaryComposite);

parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
intermediaryComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
Expand Down Expand Up @@ -399,4 +402,8 @@ public void dispose() {
public void saveState(IMemento memento) {
}

public Composite getControl() {
return container;
}

}

0 comments on commit d9f48a2

Please sign in to comment.