mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
language selection UI
This commit is contained in:
@@ -92,7 +92,8 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
public static final String SNAP_TO_COMPONENTS = "Components";
|
||||
public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID;
|
||||
|
||||
public static final String LANGUAGE = "language";
|
||||
public static final String LANGUAGE = "language";
|
||||
public static final String LANGUAGE_DEFAULT = "English";
|
||||
|
||||
public static final int DND_TOGGLE_STICKY = 0x1;
|
||||
public static final int DND_TOGGLE_SNAP = 0x40000000;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TranslateUtil {
|
||||
}
|
||||
|
||||
public static void configure() {
|
||||
String language = ConfigurationManager.getInstance().readString(IPlugInPort.LANGUAGE, "English");
|
||||
String language = ConfigurationManager.getInstance().readString(IPlugInPort.LANGUAGE, IPlugInPort.LANGUAGE_DEFAULT);
|
||||
if (language != null)
|
||||
load(language);
|
||||
}
|
||||
@@ -128,7 +128,8 @@ public class TranslateUtil {
|
||||
public static List<String> getAvailableLanguages() {
|
||||
try (Stream<Path> walk = Files.walk(Paths.get(LANG_DIR))) {
|
||||
|
||||
return walk.filter(Files::isRegularFile).map(x -> x.toString()).collect(Collectors.toList());
|
||||
return walk.filter(Files::isRegularFile).map(x -> x.getFileName().toString().replaceFirst("[.][^.]+$", ""))
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error fetching available languages");
|
||||
return null;
|
||||
|
||||
@@ -22,12 +22,7 @@
|
||||
5 band
|
||||
5PDT
|
||||
5PDT (Center OFF)
|
||||
API de complemento
|
||||
API de componentes
|
||||
AWG
|
||||
Acceder a archivos de usuario
|
||||
Acerca de
|
||||
Actualizaciones recientes
|
||||
C-B-E BJT
|
||||
D-G-S JFET
|
||||
D-G-S MOSFET
|
||||
@@ -41,14 +36,13 @@ DP5T
|
||||
DPDT
|
||||
DPDT (Center OFF)
|
||||
E-B-C BJT
|
||||
Enviar un error
|
||||
English
|
||||
French
|
||||
G-D-S JFET
|
||||
G-D-S MOSFET
|
||||
G-S-D JFET
|
||||
G-S-D MOSFET
|
||||
Haz una donación
|
||||
Help
|
||||
Manual de usuario
|
||||
Language
|
||||
NPN
|
||||
Nor
|
||||
Not
|
||||
@@ -56,19 +50,21 @@ Or
|
||||
PAF
|
||||
PCB
|
||||
PNP
|
||||
Preguntas más frecuentes
|
||||
Project Cloud
|
||||
S-G-D JFET
|
||||
S-G-D MOSFET
|
||||
SPDT
|
||||
SPDT (Center OFF)
|
||||
SPST
|
||||
Test
|
||||
Spanish
|
||||
Xnor
|
||||
Xor
|
||||
cm
|
||||
ft
|
||||
in
|
||||
lang\English.txt
|
||||
lang\French.txt
|
||||
lang\Spanish.txt
|
||||
mm
|
||||
px
|
||||
yd
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user