Replace icons for standard actions using theme constants #PL-5884

This commit is contained in:
Yuriy Artamonov 2015-08-28 10:43:22 +00:00
parent f2616683ec
commit cd1cdc9b68
20 changed files with 103 additions and 49 deletions

View File

@ -21,4 +21,14 @@ public class DesktopThemeConstantsManager implements ThemeConstantsManager {
public ThemeConstants getConstants() {
return App.getInstance().getThemeConstants();
}
@Override
public String getThemeValue(String key) {
return getConstants().get(key);
}
@Override
public int getThemeValueInt(String key) {
return getConstants().getInt(key);
}
}

View File

@ -1800,7 +1800,7 @@ public class DesktopWindowManager extends WindowManager {
@Override
public String getIcon() {
return messages.getMainMessage(type.getIconMsgKey());
return messages.getMainMessage(type.getIconKey());
}
@Override

View File

@ -532,7 +532,7 @@ public class BulkEditorWindow extends AbstractWindow {
MessageType.CONFIRMATION, new Action[]{
new AbstractAction("actions.Apply") {
{
setIcon("icons/ok.png");
icon = themeConstants.get("actions.dialog.Ok.icon");
}
@Override

View File

@ -47,7 +47,7 @@
<split id="split" orientation="horizontal" pos="30" width="100%">
<vbox id="topBox" spacing="true" margin="false,true,false,false" height="100%" expand="groupsTree">
<buttonsPanel>
<popupButton id="groupCreateButton" caption="msg://create.caption" icon="msg://actions.Create.icon"/>
<popupButton id="groupCreateButton" caption="msg://create.caption" icon="theme://actions.Create.icon"/>
<button action="groupsTree.edit"/>
<button id="removeButton" action="groupsTree.remove"/>
<button action="groupsTree.refresh"/>

View File

@ -391,7 +391,7 @@ public class UserEditor extends AbstractEditor<User> {
public AddRoleAction() {
super("add");
icon = messages.getMainMessage("actions.Add.icon");
icon = themeConstants.get("actions.Add.icon");
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
setShortcut(clientConfig.getTableAddShortcut());
@ -468,7 +468,7 @@ public class UserEditor extends AbstractEditor<User> {
public EditRoleAction() {
super("edit");
icon = messages.getMainMessage("actions.Edit.icon");
icon = themeConstants.get("actions.Edit.icon");
}
@Override
@ -537,7 +537,7 @@ public class UserEditor extends AbstractEditor<User> {
public AddSubstitutedAction() {
super("add");
icon = messages.getMainMessage("actions.Add.icon");
icon = themeConstants.get("actions.Add.icon");
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
setShortcut(clientConfig.getTableAddShortcut());
@ -573,7 +573,7 @@ public class UserEditor extends AbstractEditor<User> {
public EditSubstitutedAction() {
super("edit");
icon = messages.getMainMessage("actions.Edit.icon");
icon = themeConstants.get("actions.Edit.icon");
}
@Override

View File

@ -4,6 +4,9 @@
*/
package com.haulmont.cuba.gui.components;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
/**
* @author krivopustov
* @version $Id$
@ -19,12 +22,12 @@ public class DialogAction extends AbstractAction {
private String id;
private String msgKey;
private String iconMsgKey;
private String iconKey;
Type(String id, String msgKey, String iconMsgKey) {
Type(String id, String msgKey, String iconKey) {
this.id = id;
this.msgKey = msgKey;
this.iconMsgKey = iconMsgKey;
this.iconKey = iconKey;
}
public String getId() {
@ -35,8 +38,8 @@ public class DialogAction extends AbstractAction {
return msgKey;
}
public String getIconMsgKey() {
return iconMsgKey;
public String getIconKey() {
return iconKey;
}
}
@ -56,6 +59,9 @@ public class DialogAction extends AbstractAction {
this(type);
this.primary = status == Status.PRIMARY;
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue(type.iconKey);
}
@Override
@ -63,11 +69,6 @@ public class DialogAction extends AbstractAction {
return messages.getMainMessage(type.msgKey);
}
@Override
public String getIcon() {
return messages.getMainMessage(type.iconMsgKey);
}
public Type getType() {
return type;
}

View File

@ -16,6 +16,7 @@ import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.NestedDatasource;
import com.haulmont.cuba.gui.data.PropertyDatasource;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.security.entity.EntityAttrAccess;
import javax.annotation.Nullable;
@ -86,7 +87,9 @@ public class AddAction extends BaseAction implements Action.HasOpenType {
this.handler = handler;
this.openType = openType;
this.caption = messages.getMainMessage("actions.Add");
this.icon = messages.getMainMessage("actions.Add.icon");
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue("actions.Add.icon");
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);

View File

@ -14,6 +14,7 @@ import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.config.WindowConfig;
import com.haulmont.cuba.gui.data.*;
import com.haulmont.cuba.gui.data.impl.DatasourceImplementation;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.security.entity.EntityAttrAccess;
import com.haulmont.cuba.security.entity.EntityOp;
@ -89,8 +90,11 @@ public class CreateAction extends BaseAction implements Action.HasOpenType {
this.target = target;
this.openType = openType;
this.caption = messages.getMainMessage("actions.Create");
this.icon = messages.getMainMessage("actions.Create.icon");
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue("actions.Create.icon");
this.metadata = AppBeans.get(Metadata.NAME);
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
setShortcut(clientConfig.getTableInsertShortcut());

View File

@ -21,6 +21,7 @@ import com.haulmont.cuba.gui.config.WindowConfig;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.PropertyDatasource;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.security.entity.EntityOp;
import java.util.HashMap;
@ -94,7 +95,9 @@ public class EditAction extends BaseAction implements Action.HasOpenType {
this.target = target;
this.openType = openType;
this.icon = messages.getMainMessage("actions.Edit.icon");
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue("actions.Edit.icon");
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig config = configuration.getConfig(ClientConfig.class);

View File

@ -4,11 +4,13 @@
*/
package com.haulmont.cuba.gui.components.actions;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.AppConfig;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.components.DialogAction.Type;
import com.haulmont.cuba.gui.export.ExcelExporter;
import com.haulmont.cuba.gui.export.ExportDisplay;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import static com.haulmont.cuba.gui.export.ExcelExporter.ExportMode;
@ -57,7 +59,9 @@ public class ExcelAction extends BaseAction {
this.table = table;
this.display = display;
this.caption = messages.getMainMessage("actions.Excel");
this.icon = messages.getMainMessage("actions.Excel.icon");
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue("actions.Excel.icon");
}
/**

View File

@ -16,6 +16,7 @@ import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.NestedDatasource;
import com.haulmont.cuba.gui.data.PropertyDatasource;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.security.entity.EntityAttrAccess;
import java.util.Set;
@ -64,8 +65,10 @@ public class ExcludeAction extends RemoveAction {
this.confirm = confirm;
this.caption = messages.getMainMessage("actions.Exclude");
this.icon = messages.getMainMessage("actions.Exclude.icon");
this.metadata = AppBeans.get(Metadata.NAME);
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue("actions.Exclude.icon");
}
@Override

View File

@ -4,9 +4,11 @@
*/
package com.haulmont.cuba.gui.components.actions;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.ListComponent;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import java.util.Map;
@ -43,7 +45,9 @@ public class RefreshAction extends BaseAction {
super(id);
this.owner = target;
this.caption = messages.getMainMessage("actions.Refresh");
this.icon = messages.getMainMessage("actions.Refresh.icon");
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue("actions.Refresh.icon");
}
/**

View File

@ -18,6 +18,7 @@ import com.haulmont.cuba.gui.components.DialogAction.Type;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.PropertyDatasource;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.security.entity.EntityAttrAccess;
import com.haulmont.cuba.security.entity.EntityOp;
@ -81,7 +82,9 @@ public class RemoveAction extends ItemTrackingAction {
this.target = target;
this.autocommit = autocommit;
this.caption = messages.getMainMessage("actions.Remove");
this.icon = messages.getMainMessage("actions.Remove.icon");
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
this.icon = thCM.getThemeValue("actions.Remove.icon");
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig config = configuration.getConfig(ClientConfig.class);

View File

@ -16,20 +16,6 @@ actions.Clear=Clear
actions.Apply=Apply
actions.Add=Add
actions.Create.icon=icons/create.png
actions.Edit.icon=icons/edit.png
actions.Remove.icon=icons/remove.png
actions.Refresh.icon=icons/refresh.png
actions.Add.icon=icons/add.png
actions.Exclude.icon=icons/remove.png
actions.Excel.icon=icons/excel.png
actions.dialog.Ok.icon=icons/ok.png
actions.dialog.Cancel.icon=icons/cancel.png
actions.dialog.Yes.icon=icons/ok.png
actions.dialog.No.icon=icons/cancel.png
actions.dialog.Close.icon=
actions.Yes=Yes
actions.No=No
actions.Ok=OK

View File

@ -14,4 +14,7 @@ public interface ThemeConstantsManager {
String NAME = "cuba_ThemeManager";
ThemeConstants getConstants();
String getThemeValue(String key);
int getThemeValueInt(String key);
}

View File

@ -324,7 +324,8 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
if (element.attribute("icon") != null) {
String icon = element.attributeValue("icon");
icon = loadResourceString(icon);
String themeValue = loadThemeString(icon);
icon = loadResourceString(themeValue);
component.setIcon(icon);
}
}

View File

@ -141,4 +141,18 @@ cuba.gui.report.TemplateEditor.width=700
cuba.gui.report.ShowChartController.width=1024
cuba.gui.report.ShowChartController.height=800
cuba.gui.report.ReportWizard.width=800
cuba.gui.report.ReportWizard.height=400
cuba.gui.report.ReportWizard.height=400
actions.Create.icon=icons/create.png
actions.Edit.icon=icons/edit.png
actions.Remove.icon=icons/remove.png
actions.Refresh.icon=icons/refresh.png
actions.Add.icon=icons/add.png
actions.Exclude.icon=icons/remove.png
actions.Excel.icon=icons/excel.png
actions.dialog.Ok.icon=icons/ok.png
actions.dialog.Cancel.icon=icons/cancel.png
actions.dialog.Yes.icon=icons/ok.png
actions.dialog.No.icon=icons/cancel.png
actions.dialog.Close.icon=

View File

@ -20,6 +20,7 @@ import com.haulmont.cuba.gui.components.mainwindow.FoldersPane;
import com.haulmont.cuba.gui.components.mainwindow.UserIndicator;
import com.haulmont.cuba.gui.config.WindowInfo;
import com.haulmont.cuba.gui.theme.ThemeConstants;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.gui.xml.layout.LayoutLoaderConfig;
import com.haulmont.cuba.web.gui.WebWindow;
import com.haulmont.cuba.web.gui.components.WebAbstractComponent;
@ -761,16 +762,17 @@ public class WebWindowManager extends WindowManager {
MessageType.WARNING,
new Action[]{
new AbstractAction(messages.getMessage(WebWindow.class, "closeApplication")) {
{
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
icon = thCM.getThemeValue("actions.dialog.Ok.icon");
}
@Override
public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
closeAllWindows();
runIfOk.run();
}
@Override
public String getIcon() {
return messages.getMainMessage("actions.dialog.Ok.icon");
}
},
new DialogAction(Type.CANCEL, Status.PRIMARY) {
@Override

View File

@ -21,4 +21,14 @@ public class WebThemeConstantsManager implements ThemeConstantsManager {
public ThemeConstants getConstants() {
return App.getInstance().getThemeConstants();
}
@Override
public String getThemeValue(String key) {
return getConstants().get(key);
}
@Override
public int getThemeValueInt(String key) {
return getConstants().getInt(key);
}
}

View File

@ -21,6 +21,7 @@ import com.haulmont.cuba.gui.components.Window;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.settings.Settings;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.web.AppUI;
import com.haulmont.cuba.web.AppWindow;
import com.haulmont.cuba.web.WebWindowManager;
@ -907,14 +908,16 @@ public class WebWindow implements Window, Component.Wrapper,
}
},
new AbstractAction("discard") {
{
ThemeConstantsManager thCM = AppBeans.get(ThemeConstantsManager.NAME);
icon = thCM.getThemeValue("actions.dialog.Cancel.icon");
}
@Override
public String getCaption() {
return messages.getMainMessage("closeUnsaved.discard");
}
@Override
public String getIcon() {
return messages.getMainMessage("actions.dialog.Cancel.icon");
}
@Override
public void actionPerform(Component component) {
close(actionId, true);