Skip to content

Commit

Permalink
[#27] Added translation for quickinfo text
Browse files Browse the repository at this point in the history
  • Loading branch information
vatbub committed Nov 5, 2016
1 parent 9f344a6 commit de0156a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/java/applist/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ public void removeFromImportedAppList() throws FileNotFoundException, IOExceptio
(new XMLOutputter(Format.getPrettyFormat())).output(appsDoc, new FileOutputStream(fileName));
}

public void createShortCut(File shortcutFile) throws IOException {
public void createShortCut(File shortcutFile, String quickInfoText) throws IOException {
System.out.println(new File(Common.getPathAndNameOfCurrentJar()).toPath().toString());
if (SystemUtils.IS_OS_WINDOWS) {
ShellLink sl = ShellLink.createLink(new File(Common.getPathAndNameOfCurrentJar()).toPath().toString());
Expand Down
39 changes: 28 additions & 11 deletions src/main/java/view/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Level;

import javax.swing.filechooser.FileSystemView;

import applist.App;
import applist.AppList;
import common.Common;
Expand Down Expand Up @@ -402,25 +405,39 @@ public void run() {
}
});

MenuItem createShortcutOnDesktopMenuItem = new MenuItem();
createShortcutOnDesktopMenuItem.setText(bundle.getString("createShortcutOnDesktop"));
createShortcutOnDesktopMenuItem.setOnAction(event3 -> {
log.getLogger().info("Creating shortcut...");
App app = cell.getItem();
File file = new File(FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath()
+ File.separator + app.getMavenArtifactID() + ".lnk");
try {
log.getLogger().info("Creating shortcut for app " + app.getName()
+ " at the following location: " + file.getAbsolutePath());
app.createShortCut(file, bundle.getString("shortcutQuickInfo"));
} catch (Exception e) {
log.getLogger().log(Level.SEVERE, "An error occurred", e);
currentMainWindowInstance.showErrorMessage(e.toString());
}
});

MenuItem createShortcutMenuItem = new MenuItem();
createShortcutMenuItem.setText("Create shortcut");
// TODO Translation
createShortcutMenuItem.setText(bundle.getString("createShortcut"));
createShortcutMenuItem.setOnAction(event3 -> {
FileChooser fileChooser = new FileChooser();
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Shortcut", "*.lnk"));
// TODO Translation
fileChooser.setTitle("Save Shortcut");
// TODO Translation
fileChooser.getExtensionFilters()
.addAll(new FileChooser.ExtensionFilter(bundle.getString("shortcut"), "*.lnk"));
fileChooser.setTitle(bundle.getString("saveShortcut"));
File file = fileChooser.showSaveDialog(stage);
if (file != null) {
log.getLogger().info("Creating shortcut...");
// App app = apps.get(cell.getIndex());
App app = cell.getItem();

try {
log.getLogger().info("Creating shortcut for app " + app.getName()
+ " at the following location: " + file.getAbsolutePath());
app.createShortCut(file);
app.createShortCut(file, bundle.getString("shortcutQuickInfo"));
} catch (Exception e) {
log.getLogger().log(Level.SEVERE, "An error occurred", e);
currentMainWindowInstance.showErrorMessage(e.toString());
Expand Down Expand Up @@ -453,8 +470,8 @@ public void run() {
}
});

contextMenu.getItems().addAll(launchSpecificVersionItem, deleteItem, createShortcutMenuItem,
exportInfoItem);
contextMenu.getItems().addAll(launchSpecificVersionItem, deleteItem,
createShortcutOnDesktopMenuItem, createShortcutMenuItem, exportInfoItem);

MenuItem removeImportedApp = new MenuItem();
contextMenu.setOnShowing(event5 -> {
Expand Down Expand Up @@ -588,7 +605,7 @@ void appListOnDragDetected(MouseEvent event) {
File tempFile = new File(
Common.getAndCreateAppDataPath() + currentlySelectedApp.getMavenArtifactID() + ".foklauncher");
try {
currentlySelectedApp.exportInfo(tempFile);
currentlySelectedApp.createShortCut(tempFile, bundle.getString("shortcutQuickInfo"));
Dragboard db = appList.startDragAndDrop(TransferMode.MOVE);
ClipboardContent content = new ClipboardContent();
content.putFiles(Arrays.asList(tempFile));
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/view/MainWindow.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ progress.checkingVersionInfo=Getting version info...
launchSpecificVersion=Launch a specific version of %s
waitForVersionList=Loading version list...
deleteVersion=Delete %s
createShortcut=Create a shortcut
createShortcutOnDesktop=Create a desktop shortcut
shortcut=Shortcut
saveShortcut=Save shortcut
shortcutQuickInfo=Launch %s
languageSelector.promptText=Select your language
langaugeSelector.chooseAutomatically=Choose automatically
kilobyte=KB
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/view/MainWindow_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ progress.checkingVersionInfo = Auf Aktualisierungen pr
launchSpecificVersion = Eine bestimmte Version von %s starten
waitForVersionList = Laden...
deleteVersion = %s löschen
createShortcut=Verknüpfung erstellen
createShortcutOnDesktop=Desktopverknüpfung erstellen
shortcut=Verknüpfung
saveShortcut=Verknüpfung speichern
shortcutQuickInfo=%s starten
languageSelector.promptText=Sprache wählen
langaugeSelector.chooseAutomatically=Automatisch bestimmen
kilobyte=KB
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/view/MainWindow_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ progress.checkingVersionInfo=Getting version info...
launchSpecificVersion=Launch a specific version of %s
waitForVersionList=Loading version list...
deleteVersion=Delete %s
createShortcut=Create a shortcut
createShortcutOnDesktop=Create a desktop shortcut
shortcut=Shortcut
saveShortcut=Save shortcut
shortcutQuickInfo=Launch %s
languageSelector.promptText=Select your language
langaugeSelector.chooseAutomatically=Choose automatically
kilobyte=KB
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/view/MainWindow_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ progress.checkingVersionInfo = Recherche des mises
launchSpecificVersion = Démarrer une version differente de %s
waitForVersionList = Chargement...
deleteVersion = Supprimer une version de %s
createShortcut=Créer un raccourci
createShortcutOnDesktop=Créer un raccourci sur le bureau
shortcut=Raccourci
saveShortcut=Enregistrer le raccourci
shortcutQuickInfo=Lancer %s
launchLauncherAfterAppExitCheckbox = Reafficher le launcher après que l'application s'est terminé
languageSelector.promptText=Changer la langue
langaugeSelector.chooseAutomatically=Choisir automatiquement
Expand Down

0 comments on commit de0156a

Please sign in to comment.