|
@@ -128,10 +128,10 @@ public class AddObjectPopUp extends JDialog {
|
|
|
listModel = new DefaultListModel();
|
|
|
HolonElement hel = new HolonElement("Test", 100, 5);
|
|
|
String name = hel.getEleName();
|
|
|
- /*for (int i = 0; i < 11; i++) {
|
|
|
- hel.setEleName(name + i);
|
|
|
- addElement(hel);
|
|
|
- }*/
|
|
|
+ /*
|
|
|
+ * for (int i = 0; i < 11; i++) { hel.setEleName(name + i);
|
|
|
+ * addElement(hel); }
|
|
|
+ */
|
|
|
list = new JList(listModel);
|
|
|
scrollPane.setViewportView(list);
|
|
|
}
|
|
@@ -165,13 +165,11 @@ public class AddObjectPopUp extends JDialog {
|
|
|
okButton.addMouseListener(new MouseAdapter() {
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
Component frame = null;
|
|
|
- if (!sourcePath.getText().equals(filePath)) {
|
|
|
- //JOptionPane.showMessageDialog(frame, "No image selected!");
|
|
|
- }
|
|
|
- if(objectName.getText().length() == 0){
|
|
|
+ if (objectName.getText().length() == 0) {
|
|
|
JOptionPane.showMessageDialog(frame, "please enter a name");
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else if (!sourcePath.getText().equals(filePath)) {
|
|
|
+ JOptionPane.showMessageDialog(frame, "No image selected!");
|
|
|
+ } else {
|
|
|
copieFile();
|
|
|
theObject = new HolonObject(objectName.getText());
|
|
|
theObject.setElements(hElements);
|
|
@@ -192,9 +190,10 @@ public class AddObjectPopUp extends JDialog {
|
|
|
cancelButton.setActionCommand("Cancel");
|
|
|
buttonPane.add(cancelButton);
|
|
|
cancelButton.addActionListener(new ActionListener() {
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
- dispose();
|
|
|
- }});
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ dispose();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -214,8 +213,9 @@ public class AddObjectPopUp extends JDialog {
|
|
|
selectedFile = FileChooser.getSelectedFile();
|
|
|
filePath = selectedFile.getAbsolutePath();
|
|
|
sourcePath.setText(filePath);
|
|
|
-// Image image = createImage((ImageProducer) selectedFile);
|
|
|
- ImageIcon icon = new ImageIcon(new ImageIcon(filePath).getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH));
|
|
|
+ // Image image = createImage((ImageProducer) selectedFile);
|
|
|
+ ImageIcon icon = new ImageIcon(
|
|
|
+ new ImageIcon(filePath).getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH));
|
|
|
lblImagePreview.setIcon(icon);
|
|
|
} else {
|
|
|
System.out.println("Failed to Load");
|
|
@@ -229,7 +229,7 @@ public class AddObjectPopUp extends JDialog {
|
|
|
try {
|
|
|
File source = new File(filePath);
|
|
|
File dest = new File(System.getProperty("user.dir") + "/bin/Images/", selectedFile.getName());
|
|
|
- imagePath = "/Images/" + selectedFile.getName() ;
|
|
|
+ imagePath = "/Images/" + selectedFile.getName();
|
|
|
inStream = new FileInputStream(source);
|
|
|
outStream = new FileOutputStream(dest);
|
|
|
byte[] buffer = new byte[1024];
|
|
@@ -248,15 +248,16 @@ public class AddObjectPopUp extends JDialog {
|
|
|
e1.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public HolonObject getObject(){
|
|
|
+
|
|
|
+ public HolonObject getObject() {
|
|
|
return theObject;
|
|
|
}
|
|
|
-
|
|
|
- public void setController(Control controller){
|
|
|
+
|
|
|
+ public void setController(Control controller) {
|
|
|
this.controller = controller;
|
|
|
}
|
|
|
- public void setCategory(String cat){
|
|
|
+
|
|
|
+ public void setCategory(String cat) {
|
|
|
givenCategory = cat;
|
|
|
}
|
|
|
}
|