mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 07:28:20 -04:00
fixed a bug in the insert history
This commit is contained in:
parent
6f0fd2bd38
commit
2262f8863f
@ -62,6 +62,13 @@ public final class InsertAction extends ToolTipAction {
|
|||||||
return node.getDescriptionOrNull() instanceof ElementLibrary.ElementTypeDescriptionCustom;
|
return node.getDescriptionOrNull() instanceof ElementLibrary.ElementTypeDescriptionCustom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the node to insert
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return node.getName();
|
||||||
|
}
|
||||||
|
|
||||||
private static ImageIcon createIcon(LibraryNode node, ShapeFactory shapeFactory) {
|
private static ImageIcon createIcon(LibraryNode node, ShapeFactory shapeFactory) {
|
||||||
// doesn't load the description if only the icon is needed
|
// doesn't load the description if only the icon is needed
|
||||||
// create action without an icon instead
|
// create action without an icon instead
|
||||||
|
@ -35,7 +35,7 @@ public class InsertHistory {
|
|||||||
*
|
*
|
||||||
* @param action the action
|
* @param action the action
|
||||||
*/
|
*/
|
||||||
public void add(AbstractAction action) {
|
public void add(InsertAction action) {
|
||||||
if (!contains(action)) {
|
if (!contains(action)) {
|
||||||
WrapperAction wrapper = new WrapperAction(action, bar.getComponentCount());
|
WrapperAction wrapper = new WrapperAction(action, bar.getComponentCount());
|
||||||
wrappers.add(wrapper);
|
wrappers.add(wrapper);
|
||||||
@ -69,9 +69,9 @@ public class InsertHistory {
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contains(AbstractAction action) {
|
private boolean contains(InsertAction action) {
|
||||||
for (WrapperAction wrapper : wrappers)
|
for (WrapperAction wrapper : wrappers)
|
||||||
if (wrapper.action == action)
|
if (wrapper.action.getName().equals(action.getName()))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -83,22 +83,20 @@ public class InsertHistory {
|
|||||||
Iterator<WrapperAction> it = wrappers.iterator();
|
Iterator<WrapperAction> it = wrappers.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
WrapperAction w = it.next();
|
WrapperAction w = it.next();
|
||||||
if (w.action instanceof InsertAction) {
|
if (w.action.isCustom()) {
|
||||||
if (((InsertAction) w.action).isCustom()) {
|
|
||||||
removeWrapperFromBar(w);
|
removeWrapperFromBar(w);
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
bar.revalidate();
|
bar.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class WrapperAction extends AbstractAction {
|
private final class WrapperAction extends AbstractAction {
|
||||||
private final AbstractAction action;
|
private final InsertAction action;
|
||||||
private int componentPosition;
|
private int componentPosition;
|
||||||
private int time;
|
private int time;
|
||||||
|
|
||||||
private WrapperAction(AbstractAction action, int componentPosition) {
|
private WrapperAction(InsertAction action, int componentPosition) {
|
||||||
super(action.getValue(Action.NAME).toString(), (Icon) action.getValue(Action.SMALL_ICON));
|
super(action.getValue(Action.NAME).toString(), (Icon) action.getValue(Action.SMALL_ICON));
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.componentPosition = componentPosition;
|
this.componentPosition = componentPosition;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user