Library inserts element if it is imported, added icons

This commit is contained in:
hneemann 2016-04-01 17:40:11 +02:00
parent b858d72fd5
commit 802d5c83a6
2 changed files with 7 additions and 3 deletions

View File

@ -54,7 +54,11 @@ public class LibrarySelector implements ElementNotFoundNotification {
JFileChooser fc = new JFileChooser(filePath);
fc.addChoosableFileFilter(new FileNameExtensionFilter("Circuit", "dig"));
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
importElement(fc.getSelectedFile());
ElementTypeDescription des = importElement(fc.getSelectedFile());
if (des != null) {
VisualElement visualElement = new VisualElement(des.getName()).setPos(new Vector(10, 10)).setShapeFactory(shapeFactory);
circuitComponent.setPartToDrag(visualElement);
}
}
}
}.setToolTip(Lang.get("menu_import_tt")));

View File

@ -67,8 +67,9 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
public Main(Component parent, File fileToOpen, SavedListener savedListener) {
super(Lang.get("digital"));
this.savedListener = savedListener;
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setIconImages(IconCreator.createImages("icon32.png", "icon64.png", "icon128.png"));
this.savedListener = savedListener;
library = new ElementLibrary();
shapeFactory = new ShapeFactory(library);
@ -103,7 +104,6 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
JMenuBar bar = new JMenuBar();
ToolTipAction newFile = new ToolTipAction(Lang.get("menu_new"), iconNew) {
@Override
public void actionPerformed(ActionEvent e) {