Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit f1738014 authored by JxDannyxJ's avatar JxDannyxJ
Browse files

Created a new action deselect class which accepts an action mouse mode

for switching back after hitting the esc key.
The Action might be initialized on two different spots. Thus in the PostvisualizationWindow
and the TopographyWindow the initialization is defined.
parent f67c675c
......@@ -3,8 +3,6 @@ package org.vadere.gui.postvisualization.view;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import javax.swing.*;
import org.vadere.gui.components.control.IViewportChangeListener;
import org.vadere.gui.components.control.JViewportChangeListener;
import org.vadere.gui.components.control.PanelResizeListener;
......@@ -14,7 +12,18 @@ import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.components.utils.SwingUtils;
import org.vadere.gui.components.view.ScenarioElementView;
import org.vadere.gui.postvisualization.PostVisualisation;
import org.vadere.gui.postvisualization.control.*;
import org.vadere.gui.postvisualization.control.ActionGeneratePNG;
import org.vadere.gui.postvisualization.control.ActionGenerateSVG;
import org.vadere.gui.postvisualization.control.ActionOpenFile;
import org.vadere.gui.postvisualization.control.ActionPause;
import org.vadere.gui.postvisualization.control.ActionPlay;
import org.vadere.gui.postvisualization.control.ActionRecording;
import org.vadere.gui.postvisualization.control.ActionRemoveFloorFieldFile;
import org.vadere.gui.postvisualization.control.ActionShowPotentialField;
import org.vadere.gui.postvisualization.control.ActionStop;
import org.vadere.gui.postvisualization.control.ActionSwapSelectionMode;
import org.vadere.gui.postvisualization.control.ActionVisualization;
import org.vadere.gui.postvisualization.control.Player;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.gui.projectview.control.ActionDeselect;
import org.vadere.simulator.projects.Scenario;
......@@ -31,6 +40,8 @@ import java.text.MessageFormat;
import java.util.Observer;
import java.util.prefs.Preferences;
import javax.swing.*;
/**
* Main Window of the new post visualization.
*
......@@ -319,7 +330,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
// deselect selected element on esc
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "deselect");
getActionMap().put("deselect", new ActionDeselect(model, this));
getActionMap().put("deselect", new ActionDeselect(model, this, null));
}
public JMenuBar getMenu() {
......
package org.vadere.gui.projectview.control;
import javax.swing.*;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class ActionDeselect extends AbstractAction {
private static final long serialVersionUID = 1L;
private final IDefaultModel panelModel;
private JPanel jpanel;
private ActionSelectSelectShape selectSelectShape;
public ActionDeselect(final IDefaultModel panelModel, JPanel jpanel) {
public ActionDeselect(final IDefaultModel panelModel, JPanel jpanel, ActionSelectSelectShape selectSelectShape) {
this.panelModel = panelModel;
this.jpanel = jpanel;
this.selectSelectShape = selectSelectShape;
}
@Override
public void actionPerformed(ActionEvent e) {
panelModel.deselectSelectedElement();
//Reset to select mode
if (selectSelectShape != null) {
selectSelectShape.actionPerformed(e);
}
jpanel.repaint();
}
}
package org.vadere.gui.topographycreator.view;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.beans.IntrospectionException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.undo.UndoManager;
import javax.swing.undo.UndoableEditSupport;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import org.vadere.gui.components.control.IViewportChangeListener;
import org.vadere.gui.components.control.JViewportChangeListener;
......@@ -64,8 +42,16 @@ import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.simulator.projects.Scenario;
import org.vadere.state.types.ScenarioElementType;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.beans.IntrospectionException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.undo.UndoManager;
import javax.swing.undo.UndoableEditSupport;
public class TopographyWindow extends JPanel {
private static Resources resources = Resources.getInstance("topographycreator");
......@@ -295,7 +281,7 @@ public class TopographyWindow extends JPanel {
/* pedestrians */
TopographyAction switchToPedestrianAction = new ActionSwitchCategory("switch to pedestrian", panelModel,
ScenarioElementType.PEDESTRIAN, selectDotModeAction);
TopographyAction closeDialogAction = new ActionCloseDrawOptionPanel("Pedestrain", new ImageIcon(
TopographyAction closeDialogAction = new ActionCloseDrawOptionPanel("Pedestrian", new ImageIcon(
Resources.class.getResource("/icons/pedestrians_icon.png")), panelModel,
switchToPedestrianAction);
......@@ -309,9 +295,10 @@ public class TopographyWindow extends JPanel {
.getResource("/icons/source_icon.png")), panelModel, switchToSourceAction, sourceButton,
sourceDrawModes);
addActionToToolbar(toolbar, new ActionSelectSelectShape("select shape mode", new ImageIcon(
Resources.class.getResource("/icons/select_shapes_icon.png")), panelModel, undoSupport),
"select_shape_tooltip");
ActionSelectSelectShape selectShape = new ActionSelectSelectShape("select shape mode", new ImageIcon(
Resources.class.getResource("/icons/select_shapes_icon.png")), panelModel, undoSupport);
addActionToToolbar(toolbar, selectShape,"select_shape_tooltip");
addActionToToolbar(
toolbar,
new ActionSwitchSelectionMode("erase mode", new ImageIcon(Resources.class
......@@ -386,7 +373,7 @@ public class TopographyWindow extends JPanel {
// deselect selected element on esc
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "deselect");
getActionMap().put("deselect", new ActionDeselect(panelModel, thisPanel));
getActionMap().put("deselect", new ActionDeselect(panelModel, thisPanel, selectShape));
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment