Skip to content

Commit

Permalink
Add empty view
Browse files Browse the repository at this point in the history
  • Loading branch information
sotasan committed Aug 3, 2023
1 parent 3e75ae1 commit 71081d8
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.hohltier.decompiler.controllers;

import com.hohltier.decompiler.views.EmptyView;

public class EmptyController extends BaseController<EmptyView> {

public EmptyController() {
super(new EmptyView());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public void show() {
getView().setVisible(true);
}

public void activate() {
getView().setContentPane(getView().getSplitPane());
getView().validate();
}

public void dispose() {
getView().dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static void load(File file) {
packageModel.getChildren().add(new FileModel(jar, entry));
}

WindowController.getINSTANCE().activate();
ViewerController.getINSTANCE().clearTabs();
ExplorerController.getINSTANCE().setArchive(archive);

Expand Down
28 changes: 27 additions & 1 deletion src/main/java/com/hohltier/decompiler/views/EmptyView.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
package com.hohltier.decompiler.views;

import com.hohltier.decompiler.services.LanguageService;
import lombok.Getter;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.event.KeyEvent;

@Getter
public class EmptyView extends JPanel {

private final JPanel root;
private final JLabel header;
private final JLabel open;
private final JLabel drag;

public EmptyView() {
add(new JLabel("TODO"));
setLayout(new MigLayout("fill"));

root = new JPanel(new MigLayout("gapy 15"));
add(root, "center");

header = new JLabel(LanguageService.getTranslation("empty"));
header.putClientProperty("FlatLaf.styleClass", "h1");
root.add(header, "wrap");

String text = LanguageService.getTranslation("file.openFile");
String modifier = KeyEvent.getModifiersExText(KeyEvent.CTRL_DOWN_MASK);
String key = KeyEvent.getKeyText(KeyEvent.VK_O);
open = new JLabel(String.format("%s (%s+%s)", text, modifier, key));
root.add(open, "wrap");

drag = new JLabel(LanguageService.getTranslation("empty.drag"));
root.add(drag, "wrap");
}

}
3 changes: 2 additions & 1 deletion src/main/java/com/hohltier/decompiler/views/WindowView.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hohltier.decompiler.views;

import com.hohltier.decompiler.controllers.EmptyController;
import com.hohltier.decompiler.controllers.ExplorerController;
import com.hohltier.decompiler.controllers.ViewerController;
import com.hohltier.decompiler.services.LoaderService;
Expand All @@ -25,6 +26,7 @@ public class WindowView extends JFrame {
private final JSplitPane splitPane;

public WindowView() {
setContentPane((Container) new EmptyController().getComponent());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setDropTarget(new WindowDropTarget());
setJMenuBar(new MenuBar());
Expand All @@ -41,7 +43,6 @@ public WindowView() {
splitPane.setDividerLocation(225);
splitPane.setLeftComponent(ExplorerController.getINSTANCE().getComponent());
splitPane.setRightComponent(ViewerController.getINSTANCE().getComponent());
setContentPane(splitPane);

pack();
setLocationRelativeTo(null);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/langs/language_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ file.exit=出口

help=ヘルプ

empty=ファイルが開いていません
empty.drag=ドラッグアンドドロップして開きます

about=約
about.version=バージョン %s
about.vm=仮想マシン
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/langs/language_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ file.exit=Выход

help=Помощь

empty=Ни один файл не открыт
empty.drag=Перетащите, чтобы открыть

about
about.version=Версия %s
about.vm=Виртуальная машина
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/langs/language_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ file.exit=出口

help=帮助

empty=没有文件打开
empty.drag=拖放打开

about=关于
about.version=版本 %s
about.vm=虚拟机
Expand Down

0 comments on commit 71081d8

Please sign in to comment.