Skip to content
Open
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
7 changes: 5 additions & 2 deletions soapui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,11 @@
<artifactId>swagger-parser</artifactId>
<version>${io.swagger.swagger-parser.version}</version>
</dependency>


<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
<version>3.1</version>
</dependency>
</dependencies>

</project>
216 changes: 192 additions & 24 deletions soapui/src/main/java/com/eviware/soapui/SoapUI.java

Large diffs are not rendered by default.

86 changes: 64 additions & 22 deletions soapui/src/main/java/com/eviware/soapui/StandaloneSoapUICore.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* SoapUI, Copyright (C) 2004-2022 SmartBear Software
*
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
* versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the Licence for the specific language governing permissions and limitations
* under the Licence.
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
* versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the Licence for the specific language governing permissions and limitations
* under the Licence.
*/

package com.eviware.soapui;
Expand All @@ -20,6 +20,7 @@
import com.eviware.soapui.support.UISupport;
import com.eviware.soapui.ui.desktop.DesktopRegistry;
import com.eviware.soapui.ui.desktop.standalone.StandaloneDesktopFactory;
import com.formdev.flatlaf.FlatDarkLaf;
import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;
import com.jgoodies.looks.plastic.theme.SkyBluer;

Expand Down Expand Up @@ -74,15 +75,29 @@ public void initSoapUILookAndFeel() {
} else {
SoapUITheme theme = new SoapUITheme();

PlasticXPLookAndFeel.setCurrentTheme(theme);
PlasticXPLookAndFeel.setTabStyle("Metal");

UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
UIManager.put("TabbedPane.tabAreaInsets", new Insets(3, 2, 0, 0));
UIManager.put("TabbedPane.unselectedBackground", new Color(220, 220, 220));
UIManager.put("TabbedPane.selected", new Color(240, 240, 240));
// Check if dark mode is enabled (you can create a setting for this)
boolean isDarkmode = getSettings().getBoolean("UISettings.DARK_MODE", true);

// Dark mode customization
if (isDarkmode) {
UIManager.setLookAndFeel(new FlatDarkLaf());
UIManager.put("TabbedPane.tabAreaInsets", new Insets(3, 2, 0, 0));
UIManager.put("TabbedPane.unselectedBackground", Color.DARK_GRAY);
UIManager.put("TabbedPane.selected", Color.BLACK);
UIManager.put("Button.background", Color.DARK_GRAY);
UIManager.put("Panel.background", Color.BLACK);
UIManager.put("Label.foreground", Color.WHITE);
UIManager.put("CheckBox.background", Color.DARK_GRAY);
} else {
PlasticXPLookAndFeel.setCurrentTheme(theme);
PlasticXPLookAndFeel.setTabStyle("Metal");
UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
UIManager.put("TabbedPane.tabAreaInsets", new Insets(3, 2, 0, 0));
UIManager.put("TabbedPane.unselectedBackground", new Color(220, 220, 220));
UIManager.put("TabbedPane.selected", new Color(240, 240, 240));
PlasticXPLookAndFeel.setPlasticTheme(theme);
}

PlasticXPLookAndFeel.setPlasticTheme(theme);
}
} catch (Exception e) {
SoapUI.logError(e, "Error initializing Look and Feel");
Expand All @@ -96,7 +111,13 @@ public void initSoapUILookAndFeel() {
*/

public static class SoapUITheme extends SkyBluer {
public static final Color BACKGROUND_COLOR = new Color(240, 240, 240);
private static boolean isDarkmode = SoapUI.getSettings().getBoolean("UISettings.DARK_MODE", false);

public static final Color BACKGROUND_COLOR = isDarkmode ? new Color(45, 45, 45) : new Color(240, 240, 240);
public static final Color MENU_BACKGROUND_COLOR = new Color(35, 35, 35);
public static final Color MENU_ITEM_BACKGROUND_COLOR = new Color(50, 50, 50);
public static final Color TEXT_COLOR = new Color(230, 230, 230);


@Override
public ColorUIResource getControl() {
Expand All @@ -105,12 +126,33 @@ public ColorUIResource getControl() {

@Override
public ColorUIResource getMenuBackground() {
return getControl();
return isDarkmode ? new ColorUIResource(MENU_BACKGROUND_COLOR) : getControl();
}

@Override
public ColorUIResource getMenuItemBackground() {
return new ColorUIResource(new Color(248, 248, 248));
return new ColorUIResource(isDarkmode ? MENU_ITEM_BACKGROUND_COLOR : new Color(248, 248, 248));
}

@Override
public ColorUIResource getWindowBackground() {
return isDarkmode ? new ColorUIResource(BACKGROUND_COLOR) : super.getWindowBackground();
}

// Override the correct methods for text color
@Override
public ColorUIResource getSystemTextColor() {
return isDarkmode ? new ColorUIResource(TEXT_COLOR) : super.getSystemTextColor();
}

@Override
public ColorUIResource getControlTextColor() {
return isDarkmode ? new ColorUIResource(TEXT_COLOR) : super.getControlTextColor();
}

@Override
public ColorUIResource getWindowTitleForeground() {
return isDarkmode ? new ColorUIResource(TEXT_COLOR) : super.getWindowTitleForeground();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* SoapUI, Copyright (C) 2004-2022 SmartBear Software
*
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
* versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the Licence for the specific language governing permissions and limitations
* under the Licence.
*/

package com.eviware.soapui.actions;

import com.eviware.soapui.SoapUI;
import com.eviware.soapui.analytics.Analytics;
import com.eviware.soapui.impl.WorkspaceImpl;
import com.eviware.soapui.model.project.Project;
import com.eviware.soapui.model.workspace.Workspace;
import com.eviware.soapui.model.workspace.WorkspaceListener;
import com.eviware.soapui.support.action.support.AbstractSoapUIAction;

import javax.swing.*;

import static com.eviware.soapui.analytics.SoapUIActions.SWITCH_THEME;

/**
* Action to switch dark or light mode
*
* @author rrivero
*/

public class SwitchThemeAction extends AbstractSoapUIAction<WorkspaceImpl> implements WorkspaceListener {
public static final String SOAPUI_ACTION_ID = "SwitchThemeAction";

public SwitchThemeAction() {
super("Switch theme", "Switches theme");

Workspace workspace = SoapUI.getWorkspace();
if (workspace == null) {
setEnabled(true);
} else {
setEnabled(workspace.getProjectCount() > 0);
workspace.addWorkspaceListener(this);
}
}

public void perform(WorkspaceImpl workspace, Object param) {
try {
boolean newDarkModeState = !SoapUI.getSettings().getBoolean("UISettings.DARK_MODE", false);
SoapUI.getSettings().setBoolean("UISettings.DARK_MODE", newDarkModeState);
SoapUI.saveSettings();

SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null, "Dark mode " + (newDarkModeState ? "enabled" : "disabled") + ". Restart required.");
});
Analytics.trackAction(SWITCH_THEME);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}

public void projectAdded(Project project) {
setEnabled(true);
}

public void projectChanged(Project project) {
}

public void projectRemoved(Project project) {
setEnabled(project.getWorkspace().getProjectCount() == 0);
}

public void workspaceSwitched(Workspace workspace) {
setEnabled(workspace.getProjectCount() > 0);
}

public void workspaceSwitching(Workspace workspace) {
}

@Override
public void projectClosed(Project project) {
}

@Override
public void projectOpened(Project project) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public enum SoapUIActions {

//Stay Tuned
STAY_TUNED_DIALOG_SKIPPED("SkippedStayInLoopForm", null, NO),
STAY_TUNED_DIALOG_ACCEPTED("CompletedStayInLoopForm", null, NO);
STAY_TUNED_DIALOG_ACCEPTED("CompletedStayInLoopForm", null, NO),

SWITCH_THEME("SwitchThemeAction", null, STATIC_MAIN_TOOLBAR);

private String actionName;
private ModuleType moduleType;
Expand Down
Loading