Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public class WorkbenchMessages extends NLS {
public static String ThemeChangeWarningText;
public static String ThemeChange_useAsDefault;
public static String ThemeChangeWarningTitle;
public static String ThemeDefault_manageButton;
public static String ThemeDefault_dialogTitle;
public static String ThemeDefault_description;
public static String ThemeDefault_currentDefault;
public static String ThemeDefault_noDefault;
public static String ThemeDefault_setDefault;
public static String ThemeDefault_removeDefault;

public static String BundleSigningTray_Cant_Find_Service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering;
import org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
Expand Down Expand Up @@ -149,7 +150,14 @@ protected Control createContents(Composite parent) {

new Label(comp, SWT.NONE).setText(WorkbenchMessages.ViewsPreferencePage_Theme);

themeIdCombo = new ComboViewer(comp, SWT.READ_ONLY);
Composite themeComposite = new Composite(comp, SWT.NONE);
GridLayout themeLayout = new GridLayout(2, false);
themeLayout.marginWidth = 0;
themeLayout.marginHeight = 0;
themeComposite.setLayout(themeLayout);
themeComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

themeIdCombo = new ComboViewer(themeComposite, SWT.READ_ONLY);
themeIdCombo.setLabelProvider(createTextProvider(element -> ((ITheme) element).getLabel()));
themeIdCombo.setContentProvider(ArrayContentProvider.getInstance());
themeIdCombo.setInput(engine.getThemes());
Expand All @@ -159,6 +167,11 @@ protected Control createContents(Composite parent) {
themeIdCombo.setSelection(new StructuredSelection(currentTheme));
}
themeComboDecorator = new ControlDecoration(themeIdCombo.getCombo(), SWT.TOP | SWT.LEFT);

Button manageDefaultButton = new Button(themeComposite, SWT.PUSH);
manageDefaultButton.setText(WorkbenchMessages.ThemeDefault_manageButton);
manageDefaultButton.addSelectionListener(widgetSelectedAdapter(e -> openManageDefaultThemeDialog()));

themeIdCombo.addSelectionChangedListener(event -> {
ITheme selection = getSelectedTheme();
if (!selection.equals(currentTheme)) {
Expand Down Expand Up @@ -324,6 +337,62 @@ private ITheme getSelectedTheme() {
return (ITheme) (themeIdCombo.getStructuredSelection().getFirstElement());
}

private void openManageDefaultThemeDialog() {
IEclipsePreferences configNode = ConfigurationScope.INSTANCE.getNode(E4_THEME_EXTENSION_POINT);
String currentDefaultId = configNode.get("themeid", null); //$NON-NLS-1$

String currentDefaultLabel = null;
if (currentDefaultId != null) {
for (ITheme t : engine.getThemes()) {
if (t.getId().equals(currentDefaultId)) {
currentDefaultLabel = t.getLabel();
break;
}
}
if (currentDefaultLabel == null) {
currentDefaultLabel = currentDefaultId;
}
}

String message;
if (currentDefaultLabel != null) {
message = NLS.bind(WorkbenchMessages.ThemeDefault_currentDefault, currentDefaultLabel);
} else {
message = WorkbenchMessages.ThemeDefault_noDefault;
}
message = WorkbenchMessages.ThemeDefault_description + "\n\n" + message; //$NON-NLS-1$

ITheme selectedTheme = getSelectedTheme();
List<String> buttonLabels = new ArrayList<>();
buttonLabels.add(WorkbenchMessages.ThemeDefault_setDefault);
if (currentDefaultId != null) {
buttonLabels.add(WorkbenchMessages.ThemeDefault_removeDefault);
}
buttonLabels.add(IDialogConstants.CLOSE_LABEL);

MessageDialog dialog = new MessageDialog(getShell(), WorkbenchMessages.ThemeDefault_dialogTitle, null, message,
MessageDialog.INFORMATION, 0, buttonLabels.toArray(new String[0]));

int result = dialog.open();
if (result == 0 && selectedTheme != null) {
// Set as default
configNode.put("themeid", selectedTheme.getId()); //$NON-NLS-1$
try {
configNode.flush();
} catch (BackingStoreException e) {
WorkbenchPlugin.log("Failed to set default theme in configuration scope", e); //$NON-NLS-1$
}
} else if (currentDefaultId != null && result == 1) {
// Remove default
configNode.remove("themeid"); //$NON-NLS-1$
try {
configNode.flush();
} catch (BackingStoreException e) {
WorkbenchPlugin.log("Failed to remove default theme from configuration scope", e); //$NON-NLS-1$
}
}
}

@Override
public void init(IWorkbench workbench) {
MApplication application = workbench.getService(MApplication.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,13 @@ ThemingEnabled = E&nable theming
ThemeChangeWarningText = Restart to fully apply theme changes
ThemeChange_useAsDefault = &Use as default theme (only applies to workspaces without a configured theme)
ThemeChangeWarningTitle = Theme Changed
ThemeDefault_manageButton = Manage &default...
ThemeDefault_dialogTitle = Manage Default Theme
ThemeDefault_description = The default theme is used for new workspaces and workspaces in which no explicit theme has been set.
ThemeDefault_currentDefault = Current default theme: {0}
ThemeDefault_noDefault = No default theme configured. The product default will be used.
ThemeDefault_setDefault = &Set current theme as default
ThemeDefault_removeDefault = &Remove default
RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed
RescaleAtRuntimeSettingChangeWarningText = Restart for the DPI setting changes to take effect
RescaleAtRuntimeDescription = Activating this option will dynamically scale all windows according to the monitor they are currently in
Expand Down
Loading