mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-09 12:56:02 -04:00
library is cleared if new file is opened
This commit is contained in:
parent
288b01388f
commit
edd1b8e4cc
@ -89,10 +89,7 @@ public class LibrarySelector implements ElementNotFoundNotification {
|
||||
customMenu.add(new ToolTipAction(Lang.get("menu_refresh")) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
for (ImportedItem item : importedElements) {
|
||||
library.removeElement(item.file);
|
||||
customMenu.remove(item.menuEntry);
|
||||
}
|
||||
removeCustomElements();
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_refresh_tt")).createJMenuItem());
|
||||
|
||||
@ -114,6 +111,16 @@ public class LibrarySelector implements ElementNotFoundNotification {
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes all custom elements
|
||||
*/
|
||||
public void removeCustomElements() {
|
||||
for (ImportedItem item : importedElements) {
|
||||
library.removeElement(item.file);
|
||||
customMenu.remove(item.menuEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private String createToolTipText(String elementName) {
|
||||
String toolTipText = Lang.getNull("elem_" + elementName + "_tt");
|
||||
if (toolTipText == null)
|
||||
|
@ -279,6 +279,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
setFilename(null, true);
|
||||
circuitComponent.setCircuit(new Circuit());
|
||||
windowPosManager.closeAll();
|
||||
librarySelector.removeCustomElements();
|
||||
}
|
||||
}
|
||||
}.setActive(normalMode);
|
||||
@ -289,6 +290,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
if (ClosingWindowListener.checkForSave(Main.this, Main.this)) {
|
||||
JFileChooser fc = getJFileChooser(lastFilename);
|
||||
if (fc.showOpenDialog(Main.this) == JFileChooser.APPROVE_OPTION) {
|
||||
librarySelector.removeCustomElements();
|
||||
loadFile(fc.getSelectedFile(), true);
|
||||
}
|
||||
}
|
||||
@ -776,6 +778,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
|
||||
@Override
|
||||
public void open(File file) {
|
||||
librarySelector.removeCustomElements();
|
||||
loadFile(file, true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user