Added file associations to settings panel

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@332 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
Jared Gould 2006-11-09 00:37:50 +00:00
parent 82e7c6208e
commit 581309400a
3 changed files with 385 additions and 173 deletions

View File

@ -16,6 +16,7 @@
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
@ -25,24 +26,9 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="reset" min="-2" max="-2" attributes="1"/>
<EmptySpace pref="34" max="32767" attributes="0"/>
<Component id="btnApply" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel1" alignment="0" min="0" max="32767" attributes="0"/>
<Component id="calcConflictWarning" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="obsoleteWarning" alignment="0" min="-2" max="-2" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
@ -51,7 +37,14 @@
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="debug" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="reset" min="-2" max="-2" attributes="1"/>
<EmptySpace pref="34" max="32767" attributes="0"/>
<Component id="btnApply" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -74,14 +67,14 @@
<Component id="debug" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="34" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnApply" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="reset" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -164,7 +157,8 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel4" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" alignment="1" groupAlignment="0" attributes="0">
@ -172,7 +166,7 @@
<Component id="displayHighTables" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="valueLimitWarning" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblCellHeight" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblFont" alignment="0" min="-2" max="-2" attributes="0"/>
@ -182,7 +176,7 @@
<Component id="btnChooseFont" alignment="0" min="-2" max="-2" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
<Component id="cellHeight" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace pref="18" max="32767" attributes="0"/>
<EmptySpace pref="42" max="32767" attributes="0"/>
<Component id="lblCellWidth" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cellWidth" min="-2" pref="50" max="-2" attributes="0"/>
@ -190,7 +184,7 @@
</Group>
</Group>
</Group>
<EmptySpace pref="71" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="47" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -200,13 +194,15 @@
<Component id="jPanel2" min="-2" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="1"/>
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel4" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Component id="saveDebugTables" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="displayHighTables" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="valueLimitWarning" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblCellWidth" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cellWidth" alignment="3" min="-2" max="-2" attributes="0"/>
@ -524,6 +520,88 @@
</Property>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel4">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="File Associations"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="extensionBin" min="-2" max="-2" attributes="0"/>
<Component id="extensionHex" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="93" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="btnAddAssocs" alignment="0" max="32767" attributes="1"/>
<Component id="btnRemoveAssocs" alignment="0" min="-2" max="-2" attributes="1"/>
</Group>
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnAddAssocs" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="extensionHex" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnRemoveAssocs" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="extensionBin" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="extensionHex">
<Properties>
<Property name="text" type="java.lang.String" value="HEX"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
</Border>
</Property>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[0, 0, 0, 0]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="extensionBin">
<Properties>
<Property name="text" type="java.lang.String" value="BIN"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
</Border>
</Property>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[0, 0, 0, 0]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnAddAssocs">
<Properties>
<Property name="text" type="java.lang.String" value="Add Associations"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnRemoveAssocs">
<Properties>
<Property name="text" type="java.lang.String" value="Remove Associations"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel1">

View File

@ -3,11 +3,14 @@ package enginuity.swing;
import ZoeloeSoft.projects.JFontChooser.JFontChooser;
import enginuity.ECUEditor;
import enginuity.Settings;
import javax.swing.*;
import java.awt.*;
import enginuity.util.FileAssociator;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
public class SettingsForm extends JFrame implements MouseListener {
@ -33,6 +36,8 @@ public class SettingsForm extends JFrame implements MouseListener {
btnCancel.addMouseListener(this);
btnChooseFont.addMouseListener(this);
reset.addMouseListener(this);
btnAddAssocs.addMouseListener(this);
btnRemoveAssocs.addMouseListener(this);
tableClickCount.setBackground(Color.WHITE);
@ -104,6 +109,11 @@ public class SettingsForm extends JFrame implements MouseListener {
saveDebugTables = new javax.swing.JCheckBox();
displayHighTables = new javax.swing.JCheckBox();
valueLimitWarning = new javax.swing.JCheckBox();
jPanel4 = new javax.swing.JPanel();
extensionHex = new javax.swing.JCheckBox();
extensionBin = new javax.swing.JCheckBox();
btnAddAssocs = new javax.swing.JButton();
btnRemoveAssocs = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
tableClickCount = new javax.swing.JComboBox();
@ -273,20 +283,61 @@ public class SettingsForm extends JFrame implements MouseListener {
valueLimitWarning.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
valueLimitWarning.setMargin(new java.awt.Insets(0, 0, 0, 0));
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("File Associations"));
extensionHex.setText("HEX");
extensionHex.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
extensionHex.setMargin(new java.awt.Insets(0, 0, 0, 0));
extensionBin.setText("BIN");
extensionBin.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
extensionBin.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnAddAssocs.setText("Add Associations");
btnRemoveAssocs.setText("Remove Associations");
org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(extensionBin)
.add(extensionHex))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 93, Short.MAX_VALUE)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(btnAddAssocs, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(btnRemoveAssocs))
.add(25, 25, 25))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(btnAddAssocs)
.add(extensionHex))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(btnRemoveAssocs)
.add(extensionBin)))
);
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel1Layout.createSequentialGroup()
.add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(saveDebugTables)
.add(displayHighTables)
.add(valueLimitWarning))
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()
.add(jPanel1Layout.createSequentialGroup()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(lblCellHeight)
.add(lblFont))
@ -295,11 +346,11 @@ public class SettingsForm extends JFrame implements MouseListener {
.add(btnChooseFont)
.add(jPanel1Layout.createSequentialGroup()
.add(cellHeight, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 18, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 42, Short.MAX_VALUE)
.add(lblCellWidth)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cellWidth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(71, Short.MAX_VALUE))
.add(47, 47, 47))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -307,13 +358,15 @@ public class SettingsForm extends JFrame implements MouseListener {
.add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(19, 19, 19)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(22, 22, 22)
.add(saveDebugTables)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(displayHighTables)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(valueLimitWarning)
.add(16, 16, 16)
.add(27, 27, 27)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblCellWidth)
.add(cellWidth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
@ -327,36 +380,31 @@ public class SettingsForm extends JFrame implements MouseListener {
jLabel1.setText("click to open tables");
tableClickCount.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Single", "Double"}));
tableClickCount.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Single", "Double" }));
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.addContainerGap()
.add(reset)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 34, Short.MAX_VALUE)
.add(btnApply)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(btnOk)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(btnCancel))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, calcConflictWarning)
.add(org.jdesktop.layout.GroupLayout.LEADING, obsoleteWarning)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(tableClickCount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel1))
.add(org.jdesktop.layout.GroupLayout.LEADING, debug))))
.add(org.jdesktop.layout.GroupLayout.LEADING, debug)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(reset)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 34, Short.MAX_VALUE)
.add(btnApply)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(btnOk)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(btnCancel)))
.addContainerGap())
);
layout.setVerticalGroup(
@ -374,13 +422,13 @@ public class SettingsForm extends JFrame implements MouseListener {
.add(debug)
.add(17, 17, 17)
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 34, Short.MAX_VALUE)
.add(22, 22, 22)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(btnCancel)
.add(btnApply)
.add(reset)
.add(btnOk))
.addContainerGap())
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
@ -445,6 +493,28 @@ public class SettingsForm extends JFrame implements MouseListener {
} else if (e.getSource() == reset) {
settings = new Settings();
initSettings();
} else if (e.getSource() == btnAddAssocs) {
// add file associations for selected file types
try {
if (extensionHex.isSelected()) {
FileAssociator.addAssociation("HEX", new File(".").getCanonicalPath() + "\\Enginuity.exe", "ECU Image");
}
if (extensionBin.isSelected()) {
FileAssociator.addAssociation("BIN", new File(".").getCanonicalPath() + "\\Enginuity.exe", "ECU Image");
}
} catch (Exception ex) { }
} else if (e.getSource() == btnRemoveAssocs) {
// remove file associations for selected file types
if (extensionHex.isSelected()) {
FileAssociator.removeAssociation("HEX");
}
if (extensionBin.isSelected()) {
FileAssociator.removeAssociation("HEX");
}
}
}
@ -506,22 +576,27 @@ public class SettingsForm extends JFrame implements MouseListener {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel axisColor;
private javax.swing.JButton btnAddAssocs;
private javax.swing.JButton btnApply;
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnChooseFont;
private javax.swing.JButton btnOk;
private javax.swing.JButton btnRemoveAssocs;
private javax.swing.JCheckBox calcConflictWarning;
private javax.swing.JTextField cellHeight;
private javax.swing.JTextField cellWidth;
private javax.swing.JCheckBox debug;
private javax.swing.JLabel decreaseColor;
private javax.swing.JCheckBox displayHighTables;
private javax.swing.JCheckBox extensionBin;
private javax.swing.JCheckBox extensionHex;
private javax.swing.JLabel highlightColor;
private javax.swing.JLabel increaseColor;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JLabel lblAxis;
private javax.swing.JLabel lblCellHeight;
private javax.swing.JLabel lblCellWidth;

View File

@ -0,0 +1,59 @@
package enginuity.util;
import java.io.File;
import java.util.StringTokenizer;
import org.jdesktop.jdic.filetypes.AssociationAlreadyRegisteredException;
import org.jdesktop.jdic.filetypes.AssociationNotRegisteredException;
import org.jdesktop.jdic.filetypes.AssociationService;
import org.jdesktop.jdic.filetypes.Association;
import org.jdesktop.jdic.filetypes.Action;
import org.jdesktop.jdic.filetypes.RegisterFailedException;
public class FileAssociator {
public static boolean addAssociation(String extension, String command, /*String iconFileName,*/ String description) {
// Add association
// StringTokenizer osName = new StringTokenizer(System.getProperties().getProperty("os.name"));
// remove association if it already exists
System.out.println("Removing 1...\n");
removeAssociation(extension);
System.out.println("Removing 2...\n");
AssociationService serv = new AssociationService();
Association logassoc = new Association();
logassoc.addFileExtension(extension.toUpperCase());
logassoc.setDescription(description);
logassoc.addAction(new Action("open", command + " %1"));
logassoc.setIconFileName(new File("").getAbsolutePath() + "/graphics/enginuity-ico.ico");
System.out.println("Adding ...\n" + logassoc + "\n\n\n");
try {
serv.registerUserAssociation(logassoc);
} catch (Exception e) {
System.err.println(e);
}
return true;
}
public static boolean removeAssociation(String extension) {
AssociationService serv = new AssociationService();
Association logassoc = serv.getFileExtensionAssociation(extension.toUpperCase());
System.out.println("Removing ...\n" + logassoc + "\n\n\n");
try {
serv.unregisterUserAssociation(logassoc);
} catch (Exception e) {
System.err.println(e);
}
return true;
}
}