Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch generation of gui code from java to compiled classes #4103

Merged
merged 4 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 36 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,16 @@ buildscript {
// Access Git info from build script
plugins {
id "application"
id "base"
id "java"
id "org.ajoberstar.grgit" version "5.0.0"
id "com.diffplug.spotless" version "6.18.0"
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.runtime' version '1.13.0'
id "com.google.protobuf" version "0.8.19"
id 'io.github.file5.guidesigner' version '1.0.2'
}

// Apply the java plugin to add support for Java
apply plugin: 'base'
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.google.protobuf'

// Definitions
defaultTasks 'clean', 'build'
sourceCompatibility = 20
Expand Down Expand Up @@ -161,6 +156,39 @@ run {
}
}

tasks.register('deleteUiClasses') {
doFirst {
// add all classes generated from intellij forms xml here to force rebuild of them.
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/swing/colorpicker/ColorPanelView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/swing/htmleditorsplit/HtmlEditorSplitGui.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/tool/boardtool/AdjustBoardControlPanelView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/tool/gridtool/AdjustGridControlPanelView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/tool/layerselectiondialog/LayerSelectionDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/tool/texttool/EditLabelDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/addresource/AddResourcesDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/campaignproperties/TokenPropertiesManagementPanelView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/connectioninfodialog/ConnectionInfoDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/connecttoserverdialog/ConnectToServerDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/exportdialog/ExportDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/io/CampaignItemListView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/io/UpdateRepoDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/lookuptable/EditLookupTablePanelView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/lookuptable/LookupTablePaneView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/macrobuttons/dialog/MacroButtonDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/mappropertiesdialog/MapPropertiesDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/startserverdialog/StartServerDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/token/dialog/create/NewTokenDialogView.class")
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/token/dialog/edit/TokenPropertiesDialog..class")
cwisniew marked this conversation as resolved.
Show resolved Hide resolved
delete("${buildDir}/classes/java/main/net/rptools/maptool/client/ui/transferprogressdialog/TransferProgressDialogView.class")
}
}

compileJava {
dependsOn(deleteUiClasses)
}

// Badass Runtime Plugin Options
runtime {
options = ['--strip-debug', '--strip-native-commands', '--compress', '2', '--no-header-files', '--no-man-pages']
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ColorPicker(JFrame owner) {
paintChooser = new PaintChooser();
paintChooser.setPreferredSize(new Dimension(450, 400));

AbeillePanel panel = new AbeillePanel(new ColorPanelView().$$$getRootComponent$$$());
AbeillePanel panel = new AbeillePanel(new ColorPanelView().getRootComponent());

ColorWellListener listener = new ColorWellListener(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class HtmlEditorSplit extends JPanel {
public HtmlEditorSplit() {
setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
add(
gui.$$$getRootComponent$$$(),
gui.getRootComponent(),
new GridConstraints(
0,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
*/
package net.rptools.maptool.client.swing.htmleditorsplit;

import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.Method;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
Expand Down Expand Up @@ -60,94 +55,10 @@ public class HtmlEditorSplitGui {
private JFXPanel jfxPanel;
private JComboBox textTypeComboBox;

/* spotless:off */

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
rootPanel = new JPanel();
rootPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
tabPanel = new JTabbedPane();
tabPanel.setName("");
tabPanel.setTabPlacement(3);
rootPanel.add(tabPanel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false));
textTab = new JPanel();
textTab.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 4, 0), -1, -1));
textTab.setName("");
tabPanel.addTab(this.$$$getMessageFromBundle$$$("net/rptools/maptool/language/i18n", "EditTokenDialog.tab.hero.text"), textTab);
sectionPanel = new CollapsibleSectionPanel();
sectionPanel.setLayout(new BorderLayout(0, 0));
sectionPanel.setName("");
textTab.add(sectionPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
textScrollPane = new RTextScrollPane();
textScrollPane.setFoldIndicatorEnabled(false);
textScrollPane.setIconRowHeaderEnabled(false);
textScrollPane.setLineNumbersEnabled(false);
sectionPanel.add(textScrollPane, BorderLayout.CENTER);
sourceTextArea = new RSyntaxTextArea();
sourceTextArea.setCodeFoldingEnabled(true);
sourceTextArea.setLineWrap(true);
sourceTextArea.setMarkOccurrences(true);
sourceTextArea.setName("");
sourceTextArea.setSelectionEnd(0);
sourceTextArea.setSelectionStart(0);
sourceTextArea.setSyntaxEditingStyle("text/html");
sourceTextArea.setText("");
textScrollPane.setViewportView(sourceTextArea);
htmlTab = new JPanel();
htmlTab.setLayout(new GridLayoutManager(1, 1, new Insets(2, 2, 6, 2), -1, -1));
htmlTab.setName("");
tabPanel.addTab(this.$$$getMessageFromBundle$$$("net/rptools/maptool/language/i18n", "EditTokenDialog.tab.hero.html"), htmlTab);
jfxPanel = new JFXPanel();
htmlTab.add(jfxPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Text type");
rootPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
textTypeComboBox = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
textTypeComboBox.setModel(defaultComboBoxModel1);
rootPanel.add(textTypeComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
rootPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
}

private static Method $$$cachedGetBundleMethod$$$ = null;

private String $$$getMessageFromBundle$$$(String path, String key) {
ResourceBundle bundle;
try {
Class<?> thisClass = this.getClass();
if ($$$cachedGetBundleMethod$$$ == null) {
Class<?> dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle");
$$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class);
}
bundle = (ResourceBundle) $$$cachedGetBundleMethod$$$.invoke(null, path, thisClass);
} catch (Exception e) {
bundle = ResourceBundle.getBundle(path);
}
return bundle.getString(key);
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return rootPanel;
}
public JComponent getRootComponent() {
return rootPanel;
}

/* spotless:on */
private HTMLEditor htmlEditor;

private SearchListener searchListener =
Expand Down