Skip to content

Commit

Permalink
Reverts the developments made for #3210 and #3193
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Oct 4, 2021
1 parent 2c9c042 commit 047c034
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 26 deletions.
Expand Up @@ -89,7 +89,7 @@ public class ThemeHelper {
private static Bundle bundle = Platform.getBundle("msi.gama.application");

static {
DEBUG.ON();
DEBUG.OFF();
}

/** The Constant CORE_THEME_FOLLOW. */
Expand All @@ -111,7 +111,8 @@ public class ThemeHelper {
* @return whether a change has been made
*/
private static boolean chooseThemeBasedOnPreferences() {
return CORE_THEME_FOLLOW.getValue() && changeTo(!isSystemDarkTheme()) || changeTo(CORE_THEME_LIGHT.getValue());
if (CORE_THEME_FOLLOW.getValue()) return changeTo(!isSystemDarkTheme());
return changeTo(CORE_THEME_LIGHT.getValue());
}

/**
Expand Down Expand Up @@ -178,7 +179,8 @@ public static boolean isDark() {
final var theme = themeEngine.getActiveTheme();
id = theme == null ? null : theme.getId();
}
// DEBUG.OUT(" " + (id != null && id.contains("dark")) + " and OS is dark = " + isSystemDarkTheme());
DEBUG.OUT(" GAMA theme is dark = " + (id != null && id.contains("dark")) + " and OS is dark = "
+ isSystemDarkTheme());
return id != null && id.contains("dark");
}

Expand All @@ -188,7 +190,7 @@ public static boolean isDark() {
public static void install() {
// if ( !PlatformUI.isWorkbenchRunning() ) { return; }
// We transfer the preference to the system property (to be read by Eclipse)
System.setProperty(THEME_FOLLOW_PROPERTY, followOSTheme().toString());
System.setProperty(THEME_FOLLOW_PROPERTY, CORE_THEME_FOLLOW.getValue().toString());
final var eventBroker = Workbench.getInstance().getService(IEventBroker.class);
if (eventBroker != null) {
final var themeChangedHandler = new WorkbenchThemeChangedHandler();
Expand Down
Expand Up @@ -51,7 +51,8 @@ private static boolean get(final String name, final boolean def) {
* For debugging purposes, see #3164. True by default until bugs on Linux regarding the use of multiple threads in
* UI processes are solved.
*/
public static final boolean USE_OLD_ANIMATOR = get("use_old_animator", true);
public static final boolean USE_OLD_ANIMATOR =
get("use_old_animator", true /* System.getProperty("os.name").contains("Linux") */);

/**
* Used in LayeredDisplayView. True to use a combination of wait(), notify() and Thread.sleep() for synchronizing
Expand Down
Expand Up @@ -221,7 +221,7 @@ public void perspectiveActivated(final IWorkbenchPage page, final IPerspectiveDe
w.getMenuManager().update(true);
w.getMenuBarManager().update(true);
cm.updateAll(true);
WorkaroundForIssue3210.run(cm);
// WorkaroundForIssue3210.run(cm);
} catch (final Exception e) {}
});

Expand Down
Expand Up @@ -19,22 +19,21 @@

import msi.gama.common.interfaces.IGamaView;
import msi.gama.runtime.PlatformHelper;
import ummisco.gama.ui.views.toolbar.GamaToolbarFactory;

/**
* The Class WorkaroundForIssue3210.
*/
public class WorkaroundForIssue3210 {

/**
* Run.
* Run. This workaround doesnt seem to be necessary anymore
*/
public static void run(final CoolBarToTrimManager cm) {
// Workaround for issue #3210. Only visible on macOS so far and for specific version of Eclipse (all the ones <
// 2021-09)
if (PlatformHelper.isMac() && Library.SWT_VERSION < 4946) {
ToolBar tb = findToolBar(cm.getTopTrim().getWidget());
GamaToolbarFactory.visuallyUpdate(tb);
// GamaToolbarFactory.visuallyUpdate(tb);
for (IViewPart p : WorkbenchHelper.getPage().getViews()) {
if (p instanceof IGamaView) { ((IGamaView) p).updateToolbarState(); }
}
Expand Down
Expand Up @@ -145,7 +145,7 @@ public void addStateListener(final StateListener listener) {
@Override
public void updateToolbarState() {
if (toolbarUpdater != null) { toolbarUpdater.updateToReflectState(); }
if (toolbar != null && toolbar.isVisible()) { toolbar.visuallyUpdate(); }
// if (toolbar != null && toolbar.isVisible()) { toolbar.visuallyUpdate(); }
}

@Override
Expand Down
Expand Up @@ -470,10 +470,10 @@ public void refresh(final boolean layout) {
/**
* Visually update.
*/
public void visuallyUpdate() {
GamaToolbarFactory.visuallyUpdate(left);
GamaToolbarFactory.visuallyUpdate(right);
}
// public void visuallyUpdate() {
// GamaToolbarFactory.visuallyUpdate(left);
// GamaToolbarFactory.visuallyUpdate(right);
// }

/**
* Wipes the toolbar (left or right), including or not the simple tool items. Retuns the width of the toolbar once
Expand Down
Expand Up @@ -22,8 +22,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchSite;

Expand All @@ -32,7 +30,6 @@
import ummisco.gama.ui.resources.GamaColors;
import ummisco.gama.ui.resources.GamaIcons;
import ummisco.gama.ui.resources.IGamaColors;
import ummisco.gama.ui.utils.WorkbenchHelper;

/**
* The class GamaToolbarFactory.
Expand Down Expand Up @@ -444,14 +441,20 @@ public static void buildToolbar(final IToolbarDecoratedView view, final GamaTool
* @param tb
* the tb
*/
public static void visuallyUpdate(final ToolBar tb) {
WorkbenchHelper.run(() -> {
for (ToolItem o : tb.getItems()) { o.setImage(o.getImage()); }
tb.layout(true, true);
tb.redraw();
tb.update();
});

}
// public static void visuallyUpdate(final ToolBar tb) {
// Not needed anymore in Eclipse 2021-09. See issue #3210
// WorkbenchHelper.runInUI("", 0, m -> {
// if (tb.isDisposed()) return;
// for (ToolItem o : tb.getItems()) {
//
// o.setImage(o.getImage());
//
// }
// tb.layout(true, true);
// tb.redraw();
// tb.update();
// });

// }

}

0 comments on commit 047c034

Please sign in to comment.