mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 17:09:23 +00:00
register name is configurable
This commit is contained in:
@@ -16,6 +16,16 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.configuration.ConfigurationItem;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
@@ -30,6 +40,21 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
View.centerScreen(this);
|
||||
View.setWindowIcon(this);
|
||||
pack();
|
||||
|
||||
configurationTable.setCellEditor(configurationTable.getDefaultEditor(null));
|
||||
|
||||
Map<String, Field> fields = Configuration.getConfigurationFields();
|
||||
for (Entry<String, Field> entry : fields.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Field field = entry.getValue();
|
||||
DefaultTableModel model = (DefaultTableModel) configurationTable.getModel();
|
||||
try {
|
||||
ConfigurationItem item = (ConfigurationItem) field.get(null);
|
||||
model.addRow(new Object[]{name, item.get()});
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||
Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,23 +66,115 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
configurationTable = new com.jpexs.decompiler.flash.gui.EachRowRendererEditor();
|
||||
btnOk = new javax.swing.JButton();
|
||||
btnCancel = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setResizable(false);
|
||||
|
||||
configurationTable.setModel(new javax.swing.table.DefaultTableModel(
|
||||
new Object [][] {
|
||||
|
||||
},
|
||||
new String [] {
|
||||
"Name", "Value"
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.String.class, java.lang.Object.class
|
||||
};
|
||||
boolean[] canEdit = new boolean [] {
|
||||
false, true
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types [columnIndex];
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit [columnIndex];
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(configurationTable);
|
||||
configurationTable.getColumnModel().getColumn(1).setCellEditor(configurationTable.getCellEditor());
|
||||
|
||||
btnOk.setText("OK");
|
||||
btnOk.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnOkActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
btnCancel.setText("Cancel");
|
||||
btnCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(btnCancel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnOk)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnOk)
|
||||
.addComponent(btnCancel))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
TableModel model = configurationTable.getModel();
|
||||
int count = model.getRowCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
String name = (String) model.getValueAt(i, 0);
|
||||
Object value = model.getValueAt(i, 1);
|
||||
Map<String, Field> fields = Configuration.getConfigurationFields();
|
||||
Field field = fields.get(name);
|
||||
ConfigurationItem item = null;
|
||||
try {
|
||||
item = (ConfigurationItem) field.get(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||
Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
if (item.get() != null && !item.get().equals(value)) {
|
||||
item.set(value);
|
||||
}
|
||||
}
|
||||
Configuration.saveConfig();
|
||||
setVisible(false);
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
setVisible(false);
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
private javax.swing.JButton btnOk;
|
||||
private com.jpexs.decompiler.flash.gui.EachRowRendererEditor configurationTable;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user