language selection UI

This commit is contained in:
bancika
2020-04-22 23:52:37 +02:00
parent fda3b22db8
commit 0d556b66e8
6 changed files with 42 additions and 15 deletions
@@ -66,7 +66,7 @@ public enum IconLoader {
Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
JarBeanInto("jar_bean_into.png"), GraphEdgeDirected("graph_edge_directed.png"), LaserPointer("laserpointer.png"), TapeMeasure("tape_measure1.png"),
Elements("elements1.png"), GraphNodes("graph_nodes.png"), User("user1.png"), FlexibleLeads("flexible_leads.png"), Pads("pads.png"), Lock("lock.png"),
Unlock("lock_open.png");
Unlock("lock_open.png"), Earth("earth.png");
protected String name;
Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

@@ -21,14 +21,18 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.EnumSet;
import java.util.List;
import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.IConfigListener;
import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.components.autocreate.SolderPadAutoCreator;
import org.diylc.core.Theme;
import org.diylc.images.IconLoader;
import org.diylc.lang.TranslateUtil;
import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI;
@@ -52,6 +56,7 @@ public class ConfigPlugin implements IPlugIn {
public static final String COMPONENT_BROWSER = "componentBrowser";
public static final String SEARCHABLE_TREE = "Searchable Tree";
public static final String TABBED_TOOLBAR = "Tabbed Toolbar";
private static final String LANGUAGE_MENU = "Language";
private ISwingUI swingUI;
@@ -132,6 +137,21 @@ public class ConfigPlugin implements IPlugIn {
swingUI.injectMenuAction(
ActionFactory.getInstance()
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
try {
List<String> languages = TranslateUtil.getAvailableLanguages();
if (languages != null && languages.size() > 0) {
swingUI.injectSubmenu(LANGUAGE_MENU, IconLoader.Earth.getIcon(), CONFIG_MENU);
for(String language : languages) {
swingUI.injectMenuAction(
ActionFactory.getInstance().createToggleAction(language, IPlugInPort.LANGUAGE, LANGUAGE_MENU, IPlugInPort.LANGUAGE_DEFAULT),
LANGUAGE_MENU);
}
}
} catch (Exception e) {
LOG.error("Error while setting up language menu", e);
}
File themeDir = new File("themes");
if (themeDir.exists()) {
@@ -157,6 +177,15 @@ public class ConfigPlugin implements IPlugIn {
COMPONENT_BROWSER_MENU);
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(TABBED_TOOLBAR),
COMPONENT_BROWSER_MENU);
// notify the user that language selection is not immediate
ConfigurationManager.getInstance().addConfigListener(IPlugInPort.LANGUAGE, new IConfigListener() {
@Override
public void valueChanged(String key, Object value) {
swingUI.showMessage("Language selection will be applied after the application is restarted.", "Language", ISwingUI.INFORMATION_MESSAGE);
}
});
}
@Override