Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

Commit

Permalink
Added ability to (not) minify json output. #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob van Mourik committed Apr 27, 2016
1 parent ef43851 commit 1dba435
Show file tree
Hide file tree
Showing 50 changed files with 1,044 additions and 112 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: java
install: cd parent && mvn install && cd ../editor && mvn compile
install: cd editor && mvn compile
jdk:
- oraclejdk8
17 changes: 0 additions & 17 deletions parent/.project

This file was deleted.

4 changes: 0 additions & 4 deletions parent/.settings/org.eclipse.m2e.core.prefs

This file was deleted.

Binary file removed parent/lib/filedrop-1.1.jar
Binary file not shown.
54 changes: 0 additions & 54 deletions parent/pom.xml

This file was deleted.

30 changes: 20 additions & 10 deletions editor/pom.xml → pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jvms</groupId>
<artifactId>i18n-editor-parent</artifactId>
<version>0.4.0</version>
<relativePath>../parent</relativePath>
</parent>
<groupId>com.jvms</groupId>
<artifactId>i18n-editor</artifactId>
<version>0.5.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
Expand All @@ -21,13 +17,27 @@
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>net.iharder</groupId>
<artifactId>dnd</artifactId>
<version>1.1</version>
</dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jvms.i18neditor.Resource.ResourceType;
import com.jvms.i18neditor.swing.JFileDrop;
import com.jvms.i18neditor.swing.JScrollablePanel;
import com.jvms.i18neditor.util.ExtendedProperties;
import com.jvms.i18neditor.util.MessageBundle;
import com.jvms.i18neditor.util.Resources;
import com.jvms.i18neditor.util.TranslationKeys;

import net.iharder.dnd.FileDrop;

/**
* This class represents the main class of the editor.
*
Expand All @@ -53,13 +52,15 @@ public class Editor extends JFrame {

public final static Path SETTINGS_PATH = Paths.get(System.getProperty("user.home"), ".i18n-editor");
public final static String TITLE = "i18n Editor";
public final static String VERSION = "0.4.0";
public final static String VERSION = "0.5.0";
public final static String COPYRIGHT_YEAR = "2016";
public final static int DEFAULT_WIDTH = 1024;
public final static int DEFAULT_HEIGHT = 768;

private List<Resource> resources = Lists.newLinkedList();
private Path resourcesDir;
private boolean dirty;
private boolean minifyOutput;

private EditorMenu editorMenu;
private JSplitPane contentPane;
Expand Down Expand Up @@ -124,7 +125,7 @@ public void saveResources() {
boolean error = false;
for (Resource resource : resources) {
try {
Resources.write(resource);
Resources.write(resource, !minifyOutput);
} catch (Exception e) {
error = true;
e.printStackTrace();
Expand Down Expand Up @@ -199,6 +200,14 @@ public void setDirty(boolean dirty) {
editorMenu.setSaveable(dirty);
}

public boolean isMinifyOutput() {
return minifyOutput;
}

public void setMinifyOutput(boolean minifyOutput) {
this.minifyOutput = minifyOutput;
}

public void showError(String message) {
showMessageDialog(MessageBundle.get("dialogs.error.title"), message, JOptionPane.ERROR_MESSAGE);
}
Expand Down Expand Up @@ -332,15 +341,13 @@ public void showFindTranslationDialog() {

public void showAboutDialog() {
showMessage(MessageBundle.get("dialogs.about.title", TITLE),
"<html>" +
"<body style=\"text-align:center;width:200px;\"><br>" +
"<span style=\"font-weight:bold;font-size:1.2em;\">" + TITLE + "</span><br>" +
"v" + VERSION + "<br><br>" +
"(c) Copyright 2015<br>" +
"Jacob van Mourik<br>" +
"MIT Licensed<br><br>" +
"</body>" +
"</html>");
"<html><body style=\"text-align:center;width:200px;\"><br>" +
"<span style=\"font-weight:bold;font-size:1.2em;\">" + TITLE + "</span><br>" +
"v" + VERSION + "<br><br>" +
"(c) Copyright " + COPYRIGHT_YEAR + "<br>" +
"Jacob van Mourik<br>" +
"MIT Licensed<br><br>" +
"</body></html>");
}

public boolean closeCurrentSession() {
Expand All @@ -359,6 +366,9 @@ public boolean closeCurrentSession() {

public void launch() {
settings.load(SETTINGS_PATH);

// Restore editor settings
minifyOutput = settings.getBooleanProperty("minify_output");

// Restore window bounds
setPreferredSize(new Dimension(settings.getIntegerProperty("window_width", 1024), settings.getIntegerProperty("window_height", 768)));
Expand All @@ -368,9 +378,7 @@ public void launch() {
pack();
setVisible(true);

boolean showImportDialog = !loadResourcesFromHistory();

if (showImportDialog) {
if (!loadResourcesFromHistory()) {
showImportDialog();
} else {
// Restore last expanded nodes
Expand Down Expand Up @@ -488,7 +496,7 @@ private void setupUI() {
}

private void setupFileDrop() {
new FileDrop(this, new FileDrop.Listener() {
new JFileDrop(this, new JFileDrop.Listener() {
@Override
public void filesDropped(java.io.File[] files) {
try {
Expand All @@ -507,6 +515,9 @@ private Image getResourceImage(String path) {
}

private void storeEditorState() {
// Store editor settings
settings.setProperty("minify_output", minifyOutput);

// Store window bounds
settings.setProperty("window_width", getWidth());
settings.setProperty("window_height", getHeight());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.nio.file.Paths;
import java.util.List;

import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
Expand Down Expand Up @@ -164,17 +165,22 @@ private void setupUI() {
viewMenu.add(new ExpandTranslationsMenuItem(tree));
viewMenu.add(new CollapseTranslationsMenuItem(tree));

JMenu settingsMenu = new JMenu(MessageBundle.get("menu.settings.title"));
settingsMenu.setMnemonic(MessageBundle.getMnemonic("menu.settings.vk"));
JCheckBoxMenuItem minifyMenuItem = new JCheckBoxMenuItem(MessageBundle.get("menu.settings.minify.title"), editor.isMinifyOutput());
minifyMenuItem.addActionListener(e -> editor.setMinifyOutput(minifyMenuItem.isSelected()));
settingsMenu.add(minifyMenuItem);

JMenu helpMenu = new JMenu(MessageBundle.get("menu.help.title"));
helpMenu.setMnemonic(MessageBundle.getMnemonic("menu.help.vk"));

JMenuItem aboutMenuItem = new JMenuItem(MessageBundle.get("menu.help.about.title", Editor.TITLE), MessageBundle.getMnemonic("menu.help.about.vk"));
aboutMenuItem.addActionListener(e -> editor.showAboutDialog());

helpMenu.add(aboutMenuItem);

add(fileMenu);
add(editMenu);
add(viewMenu);
add(settingsMenu);
add(helpMenu);

tree.addTreeSelectionListener(e -> {
Expand Down
Loading

0 comments on commit 1dba435

Please sign in to comment.