All Downloads are FREE. Search and download functionalities are using the official Maven repository.

us.ihmc.simulationconstructionset.gui.actions.HideShowViewportAction Maven / Gradle / Ivy

There is a newer version: 0.25.2
Show newest version
package us.ihmc.simulationconstructionset.gui.actions;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import us.ihmc.simulationconstructionset.commands.ViewportSelectorCommandExecutor;
import us.ihmc.simulationconstructionset.commands.ViewportSelectorCommandListener;

public class HideShowViewportAction extends AbstractAction implements ViewportSelectorCommandListener
{
   private static final long serialVersionUID = 1774088226210361744L;
   private ViewportSelectorCommandExecutor viewportSelector;

   public HideShowViewportAction(ViewportSelectorCommandExecutor viewportSelector)
   {
      super("Hide Viewport");
      this.viewportSelector = viewportSelector;

      putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_V));
      putValue(Action.LONG_DESCRIPTION, "Long Description");
      putValue(Action.SHORT_DESCRIPTION, "Short Description");

      viewportSelector.registerViewportSelectorCommandListener(this);
   }

   @Override
   public void actionPerformed(ActionEvent e)
   {
      if (viewportSelector.isViewportHidden())
      {
         viewportSelector.showViewport();
      }
      else
      {
         viewportSelector.hideViewport();
      }
   }

   @Override
   public void updateViewportStatus()
   {
      if (viewportSelector.isViewportHidden())
      {
         putValue(NAME, "Show Viewport");
      }
      else
      {
         putValue(NAME, "Hide Viewport");
      }
   }

   @Override
   public void closeAndDispose()
   {
      if (viewportSelector != null)
         viewportSelector.closeAndDispose();
      viewportSelector = null;
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy