1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
// CLASSIFICATION: UNCLASSIFIED
/*
* Delete.java
*
* Created on September 5, 2000, 10:58 AM
*/
package geotrans3.gui;
import geotrans3.enumerations.ListType;
import geotrans3.exception.CoordinateConversionException;
import geotrans3.jni.JNICoordinateConversionService;
import geotrans3.jni.JNIDatumLibrary;
import geotrans3.jni.JNIEllipsoidLibrary;
import geotrans3.misc.FillList;
import geotrans3.misc.Info;
import geotrans3.misc.StringHandler;
import geotrans3.utility.Utility;
import geotrans3.utility.Platform;
/**
*
* @author finnc
* @version
*/
public class DeleteDlg extends javax.swing.JDialog {
private JNICoordinateConversionService jniCoordinateConversionService;
private JNIDatumLibrary jniDatumLibrary;
private JNIEllipsoidLibrary jniEllipsoidLibrary;
private int listType;
private int index;
private boolean deleted;
/** Creates new form DeleteDlg */
public DeleteDlg(JNICoordinateConversionService _jniCoordinateConversionService, java.awt.Frame parent, boolean modal, int _listType) throws CoordinateConversionException
{
super(parent, modal);
jniCoordinateConversionService = _jniCoordinateConversionService;
jniDatumLibrary = new JNIDatumLibrary(_jniCoordinateConversionService.getDatumLibrary());
jniEllipsoidLibrary = new JNIEllipsoidLibrary(_jniCoordinateConversionService.getEllipsoidLibrary());
listType = _listType;
initComponents();
index = 0;
deleted = false;
if(listType == ListType.DATUM)
{
setTitle("Delete Datum");
deleteLabel.setText("Datum:");
new FillList(jniDatumLibrary, jniEllipsoidLibrary, comboBox, ListType.DATUM);
}
else
{
setTitle("Delete Ellipsoid");
deleteLabel.setText("Ellipsoid:");
new FillList(jniDatumLibrary, jniEllipsoidLibrary, comboBox, ListType.ELLIPSOID);
}
pack();
Utility.center(parent, this);
if(Platform.isJavaV1_3)
deleteLabel.setForeground(java.awt.Color.black);
if(Platform.isUnix)
{
deleteLabel.setFont(new java.awt.Font("Dialog", 1, 10));
comboBox.setFont(new java.awt.Font("Dialog", 1, 10));
okButton.setFont(new java.awt.Font("Dialog", 1, 10));
cancelButton.setFont(new java.awt.Font("Dialog", 1, 10));
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
comboBoxPanel = new javax.swing.JPanel();
deleteLabel = new javax.swing.JLabel();
comboBox = new javax.swing.JComboBox();
buttonsPanel = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints4;
setTitle("DELETE ");
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
comboBoxPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
deleteLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
deleteLabel.setText("Select Datum");
deleteLabel.setAlignmentX(1.0F);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(15, 20, 0, 20);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
comboBoxPanel.add(deleteLabel, gridBagConstraints1);
comboBox.setMaximumRowCount(6);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.insets = new java.awt.Insets(0, 20, 10, 20);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
comboBoxPanel.add(comboBox, gridBagConstraints1);
gridBagConstraints4 = new java.awt.GridBagConstraints();
getContentPane().add(comboBoxPanel, gridBagConstraints4);
buttonsPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
okButton.setMnemonic(java.awt.event.KeyEvent.VK_O);
okButton.setText("OK");
okButton.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
okButton.setMaximumSize(new java.awt.Dimension(43, 22));
okButton.setMinimumSize(new java.awt.Dimension(43, 22));
okButton.setPreferredSize(new java.awt.Dimension(43, 22));
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okActionPerformed(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.ipadx = 25;
gridBagConstraints3.insets = new java.awt.Insets(0, 0, 0, 10);
buttonsPanel.add(okButton, gridBagConstraints3);
cancelButton.setMnemonic(java.awt.event.KeyEvent.VK_C);
cancelButton.setText("Cancel");
cancelButton.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
cancelButton.setMaximumSize(new java.awt.Dimension(43, 22));
cancelButton.setMinimumSize(new java.awt.Dimension(43, 22));
cancelButton.setPreferredSize(new java.awt.Dimension(43, 22));
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelActionPerformed(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 2;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.ipadx = 25;
gridBagConstraints3.insets = new java.awt.Insets(0, 10, 0, 0);
buttonsPanel.add(cancelButton, gridBagConstraints3);
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 1;
gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints4.insets = new java.awt.Insets(5, 0, 8, 0);
getContentPane().add(buttonsPanel, gridBagConstraints4);
}//GEN-END:initComponents
private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
setVisible (false);
dispose ();
deleted = false;
}//GEN-LAST:event_cancelActionPerformed
private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
deleted = false;
StringHandler stringHandler = new StringHandler();
index = comboBox.getSelectedIndex();
try
{
if (listType == ListType.DATUM)
{
Info datumInfo = jniDatumLibrary.getDatumInfo(index);
jniDatumLibrary.removeDatum(datumInfo.getCode());
}
else
{
Info ellipsoidInfo = jniEllipsoidLibrary.getEllipsoidInfo(index);
jniEllipsoidLibrary.removeEllipsoid(ellipsoidInfo.getCode());
}
setVisible (false);
dispose ();
deleted = true;
}
catch(CoordinateConversionException e)
{
stringHandler.displayErrorMsg(this, e.getMessage());
}
}//GEN-LAST:event_okActionPerformed
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
setVisible (false);
dispose ();
deleted = false;
}//GEN-LAST:event_closeDialog
/**
* @param args the command line arguments
*/
public static void main (String args[]) {
/* try
{
new DeleteDlg (new JNICoordinateConversionService(), new javax.swing.JFrame (), true, ListType.DATUM).show ();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}*/
}
// Return index of item to be deleted
public int getIndex()
{
return (int)index;
}
public boolean getDeleted()
{
return deleted;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel comboBoxPanel;
private javax.swing.JLabel deleteLabel;
private javax.swing.JComboBox comboBox;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
}
// CLASSIFICATION: UNCLASSIFIED
|