Ejemplo n.º 1
0
  public static VehicleType showVehicleDialog(
      Vector<VehicleType> forbiddenVehicles,
      VehicleType initialSelection,
      Component parentComponent) {
    List<String> vehicles = new ArrayList<>();
    if (forbiddenVehicles == null) forbiddenVehicles = new Vector<>();

    for (Entry<String, VehicleType> entry : VehiclesHolder.getVehiclesList().entrySet()) {
      if (!forbiddenVehicles.contains(entry.getValue())) vehicles.add(entry.getKey());
    }

    if (vehicles.isEmpty()) return null;

    Collections.sort(vehicles);
    Object ret =
        JOptionPane.showInputDialog(
            parentComponent,
            I18n.text("Select vehicle"),
            I18n.text("Select vehicle"),
            JOptionPane.QUESTION_MESSAGE,
            null,
            vehicles.toArray(new String[0]),
            initialSelection != null ? initialSelection.getId() : vehicles.iterator().next());
    if (ret == null) return null;
    return VehiclesHolder.getVehicleById("" + ret);
  }
Ejemplo n.º 2
0
  @Override
  public JFreeChart createChart() {

    LinkedHashMap<String, TimeSeriesCollection> timeSeriesCollections = new LinkedHashMap<>();
    combinedPlot = new CombinedDomainXYPlot(new DateAxis(I18n.text("Time Of Day")));

    for (String seriesName : series.keySet()) {
      if (forbiddenSeries.contains(seriesName)) continue;
      String plot = seriesName.split("\\.")[0];
      if (!timeSeriesCollections.containsKey(plot))
        timeSeriesCollections.put(plot, new TimeSeriesCollection());
      timeSeriesCollections.get(plot).addSeries(series.get(seriesName));
    }

    for (String plotName : timeSeriesCollections.keySet()) {
      combinedPlot.add(
          ChartFactory.createTimeSeriesChart(
                  plotName,
                  I18n.text("Time Of Day"),
                  plotName,
                  timeSeriesCollections.get(plotName),
                  true,
                  true,
                  false)
              .getXYPlot());
    }

    // Do this here to make sure we have a built chart.. //FIXME FIXME FIXME
    for (LogMarker marker : mraPanel.getMarkers()) {
      addLogMarker(marker);
    }

    return new JFreeChart(combinedPlot);
  }
Ejemplo n.º 3
0
  @Override
  public JComponent getVisualization(IMraLogGroup source, double timestep) {
    try {
      if (index == null)
        index =
            new LsfIndex(
                source.getFile("Data.lsf"),
                new IMCDefinition(new FileInputStream(source.getFile("IMC.xml"))));

      try {

        IMCGraph graph = new IMCGraph(index);
        BufferedImage img = graph.generateSystemsGraph().generateImage();

        label.setIcon(new ImageIcon(img));

      } catch (Exception e) {
        e.printStackTrace();
        label.setText(I18n.text("Your system doesn't have dot support"));
      }

      return new JScrollPane(label);
    } catch (Exception e) {
      return new JLabel(I18n.text("ERROR") + ": " + e.getMessage());
    }
  }
Ejemplo n.º 4
0
 private void printErrors(String[] errors) {
   String errorsString = "<html>" + I18n.text("The following errors were found") + ":<br>";
   int i = 1;
   for (String error : errors) {
     errorsString = errorsString + "<br> &nbsp;" + (i++) + ") " + error;
   }
   errorsString = errorsString + "</html>";
   GuiUtils.errorMessage(
       new JFrame(I18n.text("Error")), I18n.text("Invalid properties"), errorsString);
 }
Ejemplo n.º 5
0
  public void selectFile() {
    final JFileChooser chooser = new JFileChooser(overlays.defaultDirectory);
    chooser.setFileFilter(
        GuiUtils.getCustomFileFilter(I18n.text("LSF log files"), new String[] {"lsf", "lsf.gz"}));
    chooser.setApproveButtonText(I18n.text("Open Log"));

    int option = chooser.showOpenDialog(overlays.getConsole());
    if (option != JFileChooser.APPROVE_OPTION) return;
    else {
      Thread logLoading =
          new Thread(
              new Runnable() {

                @Override
                public void run() {
                  final ProgressMonitor monitor =
                      new ProgressMonitor(
                          overlays.getConsole(),
                          I18n.text("Opening LSF log"),
                          I18n.text("Opening LSF log"),
                          0,
                          100);
                  try {
                    clearOverlays();
                    fileLabel.setText("loading...");
                    logFile = chooser.getSelectedFile();
                    LsfLogSource source =
                        new LsfLogSource(
                            chooser.getSelectedFile(),
                            new LsfIndexListener() {
                              @Override
                              public void updateStatus(String messageToDisplay) {
                                monitor.setNote(messageToDisplay);
                              }
                            });
                    logSource = source;
                    loadOverlays(source);
                  } catch (Exception e) {
                    GuiUtils.errorMessage(overlays.getConsole(), e);
                  }
                  SwingUtilities.invokeLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          fileLabel.setText(chooser.getSelectedFile().getParentFile().getName());
                        }
                      });
                  monitor.close();
                  overlays.defaultDirectory = chooser.getSelectedFile().getParent();
                }
              });
      logLoading.start();
    }
  }
  @Override
  public void initSubPanel() {

    if (initCalled) return;
    initCalled = true;

    addMenuItem(
        I18n.text("Settings") + ">" + I18n.text("Coverage Planner Settings"),
        null,
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            PropertiesEditor.editProperties(AreaCoveragePlanner.this, getConsole(), true);
          }
        });
  };
Ejemplo n.º 7
0
 /* (non-Javadoc)
  * @see pt.lsts.neptus.plugins.web.IConsoleMenuItemServlet#informCreatedConsoleMenuItem(java.util.Hashtable)
  */
 @Override
 public void informCreatedConsoleMenuItem(Hashtable<String, JMenuItem> consoleMenuItems) {
   for (String path : consoleMenuItems.keySet()) {
     if (I18n.text("Allow console exposure to the outside").equalsIgnoreCase(path))
       exposuredMenuItem = consoleMenuItems.get(path);
   }
 }
Ejemplo n.º 8
0
  private void initialize() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    fileLabel = new JLabel(I18n.text("(no log loaded)"));
    fileLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    fileLabel.setBackground(Color.white);
    fileLabel.setOpaque(true);
    filePanel.add(fileLabel, BorderLayout.CENTER);
    fileSelection = new JButton("...");
    fileSelection.setMargin(new Insets(1, 1, 1, 1));
    fileSelection.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            selectFile();
          }
        });
    filePanel.add(fileSelection, BorderLayout.EAST);
    filePanel.setMaximumSize(new Dimension(200, 25));
    add(filePanel);
    overlaysPanel = new JPanel();
    overlaysPanel.setLayout(new BoxLayout(overlaysPanel, BoxLayout.PAGE_AXIS));
    add(new JScrollPane(overlaysPanel));
  }
  public RunChecklistConsoleAction(final ConsoleLayout console) {
    super(
        I18n.text("Run CheckList"),
        new ImageIcon(ImageUtils.getImage("images/buttons/checklist.png")));
    this.console = console;
    console.addMissionListener(
        new MissionChangeListener() {

          @Override
          public void missionUpdated(MissionType mission) {
            updateStatus(console);
          }

          private void updateStatus(final ConsoleLayout console) {
            if (console.getMission() != null
                && console.getMission().getChecklistsList().size() > 0) {
              setEnabled(true);
            } else {
              setEnabled(false);
            }
          }

          @Override
          public void missionReplaced(MissionType mission) {
            updateStatus(console);
          }
        });
  }
Ejemplo n.º 10
0
  public enum CATEGORY {
    PLANNING(I18n.text("Planning")),
    WEB_PUBLISHING(I18n.text("Web Publishing")),
    INTERFACE(I18n.text("Interface")),
    COMMUNICATIONS(I18n.text("Communications")),
    UNSORTED(I18n.text("Neptus Plug-ins"));
    private String name;

    private CATEGORY(String name) {
      this.name = name;
    }

    @Override
    public String toString() {
      return name;
    }
  }
Ejemplo n.º 11
0
 public void addMarker(LogMarker marker) {
   if (markersNode == null) {
     markersNode = new DefaultMutableTreeNode(I18n.text("Markers"));
     root.add(markersNode);
   }
   markersNode.add(new DefaultMutableTreeNode(marker));
   treeModel.nodeStructureChanged(root);
   expandAllTree();
 }
Ejemplo n.º 12
0
  public void createtoolBar() {
    setOrientation(JToolBar.VERTICAL);
    setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createRaisedBevelBorder(), BorderFactory.createEmptyBorder()));

    setRhodToggle(new JToggleButton());
    getRhodToggle().setToolTipText(I18n.text("See Rhodamine Dye data color map") + ".");
    getRhodToggle().setIcon(ICON_RHOD);
    getRhodToggle().addActionListener(rhodamineDyeToggleAction);

    setPredToggle(new JToggleButton());
    getPredToggle().setToolTipText(I18n.text("See Prediction data color map") + ".");
    getPredToggle().setIcon(ICON_PRED);
    getPredToggle().addActionListener(predictionToggleAction);

    //        ButtonGroup groupToggles = new ButtonGroup();
    //        groupToggles.add(getRhodToggle());
    //        groupToggles.add(getPredToggle());

    setZexaggerToggle(new JToggleButton());
    getZexaggerToggle().setToolTipText(I18n.text("Enable/Disable Z Exaggeration") + ".");
    getZexaggerToggle().setIcon(ICON_Z);
    getZexaggerToggle().addActionListener(zexaggerToggleAction);

    resetViewportButton = new JButton();
    resetViewportButton.setToolTipText(I18n.text("Reset Viewport") + ".");
    resetViewportButton.setIcon(ICON_RESETVIEWPORT);
    resetViewportButton.addActionListener(resetViewportAction);

    add(getRhodToggle());
    add(getPredToggle());

    addSeparator();

    add(getZexaggerToggle());

    addSeparator();

    add(resetViewportButton);
  }
  public void loadFile() {
    if (file == null) {
      id.setText("");
      return;
    }
    try {
      if (file.exists()) {
        LinkedHashMap<String, String> header = loadHeader(file);
        if (header.values().size() != 2) {
          id.setText(
              "<html><font color='red'>" + I18n.text("Not a valid checklist") + "</font></html>");
        } else {
          id.setText(
              "<html><font color='blue'>"
                  + I18n.text("Name")
                  + ": </font>"
                  + header.get("name")
                  + "<hr><font color='blue'>"
                  + I18n.text("Description")
                  + ":</font><br>"
                  + header.get("description")
                  + "</html>");
        }

        /*
         * ChecklistType cl = new ChecklistType(file.getAbsolutePath());
         * // cl.load(file.getAbsolutePath()); if
         * (!cl.getName().equalsIgnoreCase("")) {
         * id.setText("<html> <b>Checklist name:</b><br>" + " <i>" +
         * cl.getName() + "</i></html>"); } else { id.setText(" "); }
         */
      } else {
        id.setText(" ");
      }
    } catch (Exception e) {
      id.setText(
          "<html><font color='red'>" + I18n.text("Not a valid checklist") + "</font></html>");
    }
  }
Ejemplo n.º 14
0
  /**
   * Initializes a menu containing actions applicable to log markers.
   *
   * @param menu menu object.
   * @return true if menu is applicable to current selection and was initialized, false otherwise.
   */
  private boolean initializeLogMarkerNodeMenu(final JPopupMenu menu) {
    TreePath[] paths = getSelectionsFiltered(this::nodeIsLogMarker);
    if (paths.length == 0) return false;

    menu.add(
        new AbstractAction(I18n.text("Remove")) {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (LsfReportProperties.generatingReport) {
              GuiUtils.infoMessage(
                  panel.getRootPane(),
                  I18n.text("Can not remove Marks"),
                  I18n.text("Can not remove Marks - Generating Report."));
              return;
            }

            for (TreePath path : paths) {
              final DefaultMutableTreeNode node =
                  (DefaultMutableTreeNode) path.getLastPathComponent();
              panel.removeMarker((LogMarker) node.getUserObject());
            }
          }
        });

    menu.add(
        new AbstractAction(I18n.text("GoTo")) {
          @Override
          public void actionPerformed(ActionEvent e) {
            final DefaultMutableTreeNode node =
                (DefaultMutableTreeNode) paths[0].getLastPathComponent();
            panel.synchVisualizations((LogMarker) node.getUserObject());
          }
        });

    return true;
  }
Ejemplo n.º 15
0
  @Override
  protected ArrayList<JComponent> getAdditionalComponentsForButtonsPanel() {
    ArrayList<JComponent> ret = new ArrayList<>();

    testButton = new JButton(I18n.text("Test"));
    testButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            String tmpStr = editorPane.getText();
            NeptusEvents.post(new NeptusEventLayoutChanged(tmpStr));
          }
        });
    ret.add(testButton);

    return ret;
  }
Ejemplo n.º 16
0
  /**
   * Initializes a menu containing actions applicable to user items.
   *
   * @param menu menu object.
   * @return true if menu is applicable to current selection and was initialized, false otherwise.
   */
  private boolean initializeDynamicViewNodeMenu(final JPopupMenu menu) {
    TreePath[] paths = getSelectionsFiltered(this::nodeIsDynamicView);
    if (paths.length == 0) return false;

    menu.add(
        new AbstractAction(I18n.text("Remove")) {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (TreePath path : paths) {
              final DefaultMutableTreeNode node =
                  (DefaultMutableTreeNode) path.getLastPathComponent();
              panel.removeTreeObject(node.getUserObject());
            }
          }
        });

    return true;
  }
Ejemplo n.º 17
0
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
      Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
      if (userObject instanceof ClassPropertiesInfo) {
        setIcon(((ClassPropertiesInfo) userObject).getIcon());
        setText(I18n.text(((ClassPropertiesInfo) userObject).getName()));
      }

      return this;
    }
Ejemplo n.º 18
0
 /**
  * Searches in the subPanels and the GeneralPreferences for settings and builds a tree with a node
  * for each plugin with settings for current permission level and type of console.
  *
  * @return a JTree with one node for each functionality with properties.
  */
 private JTree buildAndSetupTree() {
   final JTree tree = new JTree();
   // Setup tree options
   tree.setCellRenderer(new IconRenderer());
   tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
   tree.expandRow(0);
   tree.setRootVisible(false);
   tree.setShowsRootHandles(true);
   // setup interaction with right pane
   final JPanel holderPropertiesPanel = (JPanel) splitPane.getRightComponent();
   if (tree.getModel().getChildCount(tree.getModel().getRoot()) == 0) {
     holderPropertiesPanel.add(new JLabel(I18n.text("There are no settings to display")));
   } else {
     tree.addTreeSelectionListener(
         new TreeSelectionListener() {
           @Override
           public void valueChanged(TreeSelectionEvent e) {
             TreePath path = e.getNewLeadSelectionPath();
             holderPropertiesPanel.removeAll();
             if (path != null) {
               PropertySheetPanel propertiesPanel;
               // called due to selecting a different node
               DefaultMutableTreeNode defaultMutableTreeNode =
                   (DefaultMutableTreeNode) path.getLastPathComponent();
               ClassPropertiesInfo userObject =
                   (ClassPropertiesInfo) defaultMutableTreeNode.getUserObject();
               propertiesPanel = userObject.getPropertiesPanel();
               // if there is no built panel fetch values
               if (propertiesPanel == null) {
                 propertiesPanel = createPropertiesPanelForClass(userObject.getClassInstance());
                 userObject.setPropertiesPanel(propertiesPanel);
               }
               holderPropertiesPanel.add(propertiesPanel, "w 100%, h 100%");
             }
             revalidate();
           }
         });
   }
   return tree;
 }
Ejemplo n.º 19
0
 /* (non-Javadoc)
  * @see pt.lsts.neptus.plugins.web.IConsoleMenuItemServlet#getConsoleMenuItems()
  */
 @Override
 public ConsoleMenuItem[] getConsoleMenuItems() {
   return new ConsoleMenuItem[] {
     new ConsoleMenuItem(
         I18n.text("Allow console exposure to the outside"),
         null,
         new ActionListener() {
           @Override
           public void actionPerformed(ActionEvent e) {
             if (exposuredMenuItem
                 .getText()
                 .equals(I18n.text("Allow console exposure to the outside"))) {
               allowConsoleExposure = true;
               exposuredMenuItem.setText(I18n.text("Disallow console exposure to the outside"));
             } else {
               allowConsoleExposure = false;
               exposuredMenuItem.setText(I18n.text("Allow console exposure to the outside"));
             }
           }
         })
   };
 }
  @Override
  protected boolean processMsgLocally(MessageInfo info, IMCMessage msg) {
    // msg.dump(System.out);
    // System.out.flush();

    ImcSystem resSys = ImcSystemsHolder.lookupSystem(systemCommId);

    if (resSys != null) {
      if (resSys.getAuthorityState() == ImcSystem.IMCAuthorityState.OFF) return false;
    }

    logMessage(info, msg);

    try {
      if (bus != null) bus.post(msg);
    } catch (Exception e1) {
      e1.printStackTrace();
    } catch (Error e1) {
      e1.printStackTrace();
    }

    imcState.setMessage(msg);

    if (resSys == null) return true;

    switch (msg.getMgid()) {
      case VehicleState.ID_STATIC:
        try {
          int errorCount = msg.getInteger("error_count");
          if (errorCount > 0) resSys.setOnErrorState(true);
          else resSys.setOnErrorState(false);

          Object errEntStr = msg.getValue("error_ents");
          if (errEntStr != null) resSys.setOnErrorStateStr(errEntStr.toString());
          else resSys.setOnErrorStateStr("");
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case PlanControlState.ID_STATIC:
        try {
          String planId = msg.getString("plan_id");
          String maneuver = msg.getString("man_id");
          String state = msg.getString("state");
          PlanType plan = new PlanType(null);
          plan.setId(planId + "|" + I18n.textc("Man", "Maneuver (short form)") + ":" + maneuver);
          if ("EXECUTING".equalsIgnoreCase(state)) resSys.setActivePlan(plan);
          else resSys.setActivePlan(null);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case EmergencyControlState.ID_STATIC:
        try {
          String planId;
          planId = msg.getString("plan_id");

          if (planId == null) planId = msg.getString("mission_id");

          String state = msg.getString("state");
          resSys.setEmergencyPlanId(planId);
          resSys.setEmergencyStatusStr(state);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case EstimatedState.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();

          double lat = msg.getDouble("lat");
          double lon = msg.getDouble("lon");
          double height = msg.getDouble("height");
          msg.getDouble("depth");
          msg.getDouble("altitude");
          double x = msg.getDouble("x");
          double y = msg.getDouble("y");
          double z = msg.getDouble("z");
          double phi = msg.getDouble("phi");
          double theta = msg.getDouble("theta");
          double psi = msg.getDouble("psi");

          LocationType loc = new LocationType();
          loc.setLatitudeRads(lat);
          loc.setLongitudeRads(lon);
          loc.setHeight(height);
          loc.setOffsetNorth(x);
          loc.setOffsetEast(y);
          loc.setOffsetDown(z);
          loc.convertToAbsoluteLatLonDepth();

          if (loc != null) {
            resSys.setLocation(loc, timeMillis);
          }

          resSys.setAttitudeDegrees(
              Math.toDegrees(phi), Math.toDegrees(theta), Math.toDegrees(psi), timeMillis);

          // double u = msg.getDouble("u");
          // double v = msg.getDouble("v");
          // double w = msg.getDouble("w");
          double vx = msg.getDouble("vx");
          double vy = msg.getDouble("vy");
          double vz = msg.getDouble("vz");

          double courseRad = AngleCalc.calcAngle(0, 0, vy, vx);
          double groundSpeed = Math.sqrt(vx * vx + vy * vy);
          double verticalSpeed = vz;

          resSys.storeData(
              ImcSystem.COURSE_KEY,
              (int)
                  AngleCalc.nomalizeAngleDegrees360(
                      MathMiscUtils.round(Math.toDegrees(courseRad), 0)),
              timeMillis,
              true);
          resSys.storeData(ImcSystem.GROUND_SPEED_KEY, groundSpeed, timeMillis, true);
          resSys.storeData(ImcSystem.VERTICAL_SPEED_KEY, verticalSpeed, timeMillis, true);

          double headingRad = msg.getDouble("psi");
          resSys.storeData(
              ImcSystem.HEADING_KEY,
              (int)
                  AngleCalc.nomalizeAngleDegrees360(
                      MathMiscUtils.round(Math.toDegrees(headingRad), 0)),
              timeMillis,
              true);

        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case SimulatedState.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();
          resSys.storeData(msg.getAbbrev(), msg, timeMillis, true);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case OperationalLimits.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();
          resSys.storeData(msg.getAbbrev(), msg, timeMillis, true);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case IndicatedSpeed.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();
          double value = msg.getDouble("value");
          resSys.storeData(ImcSystem.INDICATED_SPEED_KEY, value, timeMillis, true);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case TrueSpeed.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();
          double value = msg.getDouble("value");
          resSys.storeData(ImcSystem.TRUE_SPEED_KEY, value, timeMillis, true);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case PlanDB.ID_STATIC:
        try {
          resSys.getPlanDBControl().onMessage(info, msg);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case Rpm.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();
          int entityId = (Integer) msg.getHeaderValue("src_ent");
          final int value = msg.getInteger("value");
          if (entityId == 0xFF) {
            resSys.storeData(ImcSystem.RPM_MAP_ENTITY_KEY, value, timeMillis, true);
          } else {
            final String entityName = EntitiesResolver.resolveName(resSys.getName(), entityId);
            if (entityName != null) {
              Object obj = resSys.retrieveData(ImcSystem.RPM_MAP_ENTITY_KEY);
              if (obj == null) {
                Map<String, Integer> map =
                    (Map<String, Integer>)
                        Collections.synchronizedMap(new HashMap<String, Integer>());
                map.put(entityName, value);
                resSys.storeData(ImcSystem.RPM_MAP_ENTITY_KEY, map, timeMillis, true);
              } else {
                @SuppressWarnings("unchecked")
                Map<String, Integer> rpms =
                    (Map<String, Integer>) resSys.retrieveData(ImcSystem.RPM_MAP_ENTITY_KEY);
                rpms.put(entityName, value);
                resSys.storeData(ImcSystem.RPM_MAP_ENTITY_KEY, rpms, timeMillis, false);
              }
            }
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case FuelLevel.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();
          FuelLevel fuelLevelMsg = (FuelLevel) msg;
          resSys.storeData(ImcSystem.FUEL_LEVEL_KEY, fuelLevelMsg, timeMillis, true);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case LblConfig.ID_STATIC:
        try {
          if (((LblConfig) msg).getOp() == OP.CUR_CFG)
            resSys.storeData(
                ImcSystem.LBL_CONFIG_KEY, (LblConfig) msg, msg.getTimestampMillis(), true);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case AcousticSystems.ID_STATIC:
        try {
          long timeMillis = msg.getTimestampMillis();
          AcousticSystems acousticSystemsMsg = (AcousticSystems) msg;
          resSys.storeData(ImcSystem.ACOUSTIC_SYSTEMS, acousticSystemsMsg, timeMillis, true);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;
      default:
        break;
    }

    return true;
  }
Ejemplo n.º 21
0
/** @author jqcorreia */
@SuppressWarnings("serial")
public class LogTree extends JTree {
  private final MRAPanel panel;

  // Root node
  private final DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");

  // Top level nodes
  private final DefaultMutableTreeNode visualizationsNode =
      new DefaultMutableTreeNode(I18n.text("Visualizations"));
  private final DefaultMutableTreeNode tablesNode = new DefaultMutableTreeNode(I18n.text("Tables"));
  private final DefaultMutableTreeNode chartsNode = new DefaultMutableTreeNode(I18n.text("Charts"));
  private DefaultMutableTreeNode markersNode;

  private final DefaultTreeModel treeModel = new DefaultTreeModel(root);

  public LogTree(IMraLogGroup source, MRAPanel panel) {
    this.panel = panel;

    setModel(treeModel);
    initializeTreeRenderer();

    setRootVisible(false);
    setShowsRootHandles(true);

    initializeMouseAdapter();

    loadDefaultNodes();
    treeModel.nodeStructureChanged(root);

    // Multiple selections may only contains items of the same compatible type.
    addTreeSelectionListener((e) -> setSelectionPaths(getSelectionsFiltered(null)));
  }

  private void initializeTreeRenderer() {
    DefaultTreeCellRenderer treeRenderer =
        new DefaultTreeCellRenderer() {
          private final LinkedHashMap<Object, ImageIcon> iconCache = new LinkedHashMap<>();

          @Override
          public Component getTreeCellRendererComponent(
              JTree tree,
              Object value,
              boolean selected,
              boolean expanded,
              boolean leaf,
              int row,
              boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            super.getTreeCellRendererComponent(
                tree, value, selected, expanded, leaf, row, hasFocus);

            if (node.getUserObject() instanceof MRAVisualization) {
              MRAVisualization viz = (MRAVisualization) node.getUserObject();
              setText(viz.getName());
              if (!iconCache.containsKey(viz)) iconCache.put(viz, viz.getIcon());
              setIcon(iconCache.get(viz));
            }

            if (node.getUserObject() instanceof LogMarker) {
              LogMarker mark = (LogMarker) node.getUserObject();
              setText(mark.getLabel());
              if (!iconCache.containsKey("markers"))
                iconCache.put("markers", ImageUtils.getIcon("images/menus/marker.png"));
              setIcon(iconCache.get("markers"));
            }

            return this;
          }
        };

    setCellRenderer(treeRenderer);
  }

  private void initializeMouseAdapter() {
    MouseAdapter mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            final TreePath path = getPathForLocation(e.getX(), e.getY());

            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getClickCount() == 2) {
                // This takes care of clicking outside item area
                if (path != null) {
                  DefaultMutableTreeNode n = (DefaultMutableTreeNode) path.getLastPathComponent();

                  // MRAVisualization case
                  if (n.getUserObject() instanceof MRAVisualization) {
                    panel.openVisualization(((MRAVisualization) n.getUserObject()));
                  }

                  // Log marker case.
                  if (n.getUserObject() instanceof LogMarker) {
                    panel.synchVisualizations((LogMarker) n.getUserObject());
                  }
                }
              }
            }

            if (e.getButton() == MouseEvent.BUTTON3) {
              // This takes care of clicking outside item area
              if (path != null) {
                final JPopupMenu menu = new JPopupMenu();
                if (initializeLogMarkerNodeMenu(menu) || initializeDynamicViewNodeMenu(menu))
                  menu.show(LogTree.this, e.getX(), e.getY());
              }
            }

            // Let the original event go the UI Thread
            super.mouseClicked(e);
          }
        };

    addMouseListener(mouseAdapter);
  }

  /**
   * Tests if a tree node is a log marker.
   *
   * @param node tree node
   * @return true if node is a log marker, false otherwise.
   */
  private Boolean nodeIsLogMarker(final DefaultMutableTreeNode node) {
    return node.getUserObject() instanceof LogMarker;
  }

  /**
   * Tests if a tree node is a dynamic view (i.e., not a builtin/predefined).
   *
   * @param node tree node
   * @return true if node is a user item, false otherwise.
   */
  private Boolean nodeIsDynamicView(final DefaultMutableTreeNode node) {
    Object userObject = node.getUserObject();
    return userObject instanceof LogTableVisualization
        || userObject instanceof GenericPlot
        || userObject instanceof MessageHtmlVisualization;
  }

  /**
   * Retrieves an array of the current selected tree items. This selection shall contain only items
   * of the same compatible type.
   *
   * @param filter optional node filter.
   * @return array of tree paths.
   * @see #nodeTypeIsCompatible
   */
  private TreePath[] getSelectionsFiltered(Function<DefaultMutableTreeNode, Boolean> filter) {
    TreePath[] paths = getSelectionPaths();
    if (paths == null) return new TreePath[] {};

    final ArrayList<TreePath> list = new ArrayList<>();
    Object firstUserObject = null;

    for (TreePath path : paths) {
      final Object node = path.getLastPathComponent();
      final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
      final Object userObject = treeNode.getUserObject();

      if (firstUserObject == null) {
        firstUserObject = userObject;
      }

      if (!nodeTypeIsCompatible(firstUserObject, userObject)
          || (filter != null && !filter.apply(treeNode))) break;

      list.add(path);
    }

    return list.toArray(new TreePath[list.size()]);
  }

  /**
   * Tests if two objects have compatible types (i.e., are used in similar ways, have the same
   * menu).
   *
   * @param a first object.
   * @param b second object.
   * @return true if nodes are compatible, false otherwise.
   */
  private boolean nodeTypeIsCompatible(Object a, Object b) {
    return a.getClass().isInstance(b) || b.getClass().isInstance(a);
  }

  /**
   * Initializes a menu containing actions applicable to log markers.
   *
   * @param menu menu object.
   * @return true if menu is applicable to current selection and was initialized, false otherwise.
   */
  private boolean initializeLogMarkerNodeMenu(final JPopupMenu menu) {
    TreePath[] paths = getSelectionsFiltered(this::nodeIsLogMarker);
    if (paths.length == 0) return false;

    menu.add(
        new AbstractAction(I18n.text("Remove")) {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (LsfReportProperties.generatingReport) {
              GuiUtils.infoMessage(
                  panel.getRootPane(),
                  I18n.text("Can not remove Marks"),
                  I18n.text("Can not remove Marks - Generating Report."));
              return;
            }

            for (TreePath path : paths) {
              final DefaultMutableTreeNode node =
                  (DefaultMutableTreeNode) path.getLastPathComponent();
              panel.removeMarker((LogMarker) node.getUserObject());
            }
          }
        });

    menu.add(
        new AbstractAction(I18n.text("GoTo")) {
          @Override
          public void actionPerformed(ActionEvent e) {
            final DefaultMutableTreeNode node =
                (DefaultMutableTreeNode) paths[0].getLastPathComponent();
            panel.synchVisualizations((LogMarker) node.getUserObject());
          }
        });

    return true;
  }

  /**
   * Initializes a menu containing actions applicable to user items.
   *
   * @param menu menu object.
   * @return true if menu is applicable to current selection and was initialized, false otherwise.
   */
  private boolean initializeDynamicViewNodeMenu(final JPopupMenu menu) {
    TreePath[] paths = getSelectionsFiltered(this::nodeIsDynamicView);
    if (paths.length == 0) return false;

    menu.add(
        new AbstractAction(I18n.text("Remove")) {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (TreePath path : paths) {
              final DefaultMutableTreeNode node =
                  (DefaultMutableTreeNode) path.getLastPathComponent();
              panel.removeTreeObject(node.getUserObject());
            }
          }
        });

    return true;
  }

  private void loadDefaultNodes() {
    root.add(visualizationsNode);
    root.add(chartsNode);
    root.add(tablesNode);
  }

  public void addVisualization(MRAVisualization vis) {
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(vis);

    // Choose parent node based on visualization type
    switch (vis.getType()) {
      case VISUALIZATION:
        parent = visualizationsNode;
        break;
      case CHART:
        parent = chartsNode;
        break;
      case TABLE:
        parent = tablesNode;
        break;
      default:
        parent = visualizationsNode;
    }
    parent.add(node);
    treeModel.nodeStructureChanged(root);
    expandAllTree();
  }

  /**
   * Retrieves the tree node that contains charts.
   *
   * @return chart tree node.
   */
  DefaultMutableTreeNode getChartsNode() {
    return chartsNode;
  }

  private void remove(Object obj, DefaultMutableTreeNode parent) {
    for (int i = 0; i < parent.getChildCount(); i++) {
      if (!(parent.getChildAt(i) instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent.getChildAt(i);

      if (!node.isLeaf()) remove(obj, node);
      else if (node.isLeaf()) {
        if (node.getUserObject().equals(obj)) {
          parent.remove(node);
          if (parent.getChildCount() == 0 && parent.getParent() instanceof DefaultMutableTreeNode) {
            ((DefaultMutableTreeNode) parent.getParent()).remove(parent);
          }

          treeModel.nodeStructureChanged(root);
          expandAllTree();
          return;
        }
      }
    }
  }

  public void remove(Object obj) {
    remove(obj, root);
  }

  public void addMarker(LogMarker marker) {
    if (markersNode == null) {
      markersNode = new DefaultMutableTreeNode(I18n.text("Markers"));
      root.add(markersNode);
    }
    markersNode.add(new DefaultMutableTreeNode(marker));
    treeModel.nodeStructureChanged(root);
    expandAllTree();
  }

  public void removeMarker(LogMarker marker) {
    DefaultMutableTreeNode node;
    for (int i = 0; i < markersNode.getChildCount(); i++) {
      node = (DefaultMutableTreeNode) markersNode.getChildAt(i);
      if (node.getUserObject() == marker) {
        markersNode.remove(node);
      }
    }
    if (markersNode.getChildCount() == 0) {
      root.remove(markersNode);
      markersNode = null;
    }

    treeModel.nodeStructureChanged(root);
    expandAllTree();
  }

  // Util methods
  private void expandAllTree() {
    for (int i = 0; i < getRowCount(); i++) {
      expandRow(i);
    }
  }
}
Ejemplo n.º 22
0
 @Override
 public String getName() {
   return I18n.textf("%1 Colormap", messageName + "." + varName);
 }
Ejemplo n.º 23
0
  @SuppressWarnings("unchecked")
  private <T> PluginProperty extractPluginProperty(Field f, T class1) {
    NeptusProperty neptusProperty = f.getAnnotation(NeptusProperty.class);
    Object fieldValue = null;
    try {
      fieldValue = f.get(class1);
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }

    // Name
    String nameRaw = neptusProperty.name();
    String displayName;
    if (nameRaw == null || nameRaw.length() == 0) {
      nameRaw = f.getName();
      char firstLetter = Character.toUpperCase(nameRaw.charAt(0));
      displayName = firstLetter + nameRaw.substring(1);
    } else {
      displayName = nameRaw;
    }
    // Type
    Class<?> type = f.getType();

    PluginProperty pp = new PluginProperty(nameRaw, type, fieldValue);
    pp.setValue(fieldValue);

    // Editable
    if (neptusProperty.editable() == false) {
      pp.setEditable(false);
    } else {
      pp.setEditable(true);
    }
    // Display name
    // signal the scope is the whole Neptus
    if (class1.getClass().equals(GeneralPreferences.class))
      displayName = "* " + I18n.text(displayName);
    else displayName = I18n.text(displayName);
    pp.setDisplayName(displayName);
    // Category
    if (neptusProperty.category() != null) {
      pp.setCategory(I18n.text(neptusProperty.category()));
    }
    // Short description
    Map<String, PluginProperty> hashMap = PluginUtils.getDefaultsValues(class1);
    StringBuilder description = new StringBuilder();
    description.append(I18n.text(neptusProperty.description()));
    String defaultValue;
    if (hashMap == null) {
      // no value!
      defaultValue =
          I18n.textf("No default found for class %className", class1.getClass().getSimpleName());
    } else {
      PluginProperty pluginProperty = hashMap.get(f.getName());
      if (pluginProperty == null) {
        // no value!
        defaultValue = I18n.textf("No default found for field %fieldName", f.getName());
      } else {
        Object defaultPropValue = pluginProperty.getValue();
        defaultValue =
            (defaultPropValue == null
                ? I18n.text("Absence of value")
                : ((f.getType().getEnumConstants() != null
                    ? I18n.text(defaultPropValue.toString())
                    : defaultPropValue.toString())));
      }
    }
    description.append(" (");
    description.append(I18n.text("Default value"));
    description.append(": ");
    description.append(defaultValue);
    description.append(")");
    pp.setShortDescription(description.toString());

    // Editor class - ATTENTION must be the last or wont work!
    Class<? extends PropertyEditor> editClass = null;
    if (neptusProperty.editorClass() != PropertyEditor.class) {
      editClass = neptusProperty.editorClass();
    }
    if (editClass != null) {
      pEditorRegistry.registerEditor(pp, editClass);
    } else {
      if (ReflectionUtil.hasInterface(f.getType(), PropertyType.class)) {
        PropertyType pt = (PropertyType) fieldValue;
        pEditorRegistry.registerEditor(pp, pt.getPropertyEditor());
      }
      if (f.getType().getEnumConstants() != null) {
        if (fieldValue != null) {
          pEditorRegistry.registerEditor(
              pp, new EnumEditor((Class<? extends Enum<?>>) fieldValue.getClass()));
        }
      }
    }
    return pp;
  }
Ejemplo n.º 24
0
  public MiGLayoutXmlPropertyEditor() {
    super();
    rootElement = "";
    xmlSchemaName = "MiGLayoutContainer";
    title = I18n.text("Layout for: MiGLayout Layout XML");
    smallMsg = ""; // I18n.text("This follows the MiGLayout");
    contentType = "text/html";
    helpText = I18n.text("Container using MigLayout") + "<br/>";
    helpText +=
        I18n.textf(
                "(see %url)",
                "'http://www.migcalendar.com/miglayout/mavensite/docs/cheatsheet.html'")
            + "<br/>";
    helpText +=
        I18n.text("For reference duplicated components use <Component Name>_N where N=1,2,3...\n");
    helpText += "<br/>";
    helpText += I18n.text("Example of a basic profile:") + "<br/>";
    helpText += "================<br/>";
    helpText += "<br/>";
    helpText += "&lt;profiles&gt;<br/>";
    helpText += "&nbsp;&nbsp;&lt;profile name=\"Normal\"&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&lt;container layoutparam=\"ins 0\" param=\"w 100%, h 100%\"&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;child name=\"Map Panel\" param=\"w 100%, h 100%\"/&gt;<br/>";
    helpText += "&nbsp;&nbsp;&nbsp;&nbsp;&lt;/container&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&lt;container layoutparam=\"ins 3\" param=\"w 300px!, h 100%\"&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container layoutparam=\"ins 0, filly\" param=\"w 100%, h 100%\"&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;child name=\"Plan Control\" param=\"w 80%, h 50px!\"/&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;child name=\"Abort Button\" param=\"w 20%, h 50px!, wrap\"/&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;child name=\"Plan Control State\" param=\"w 100%!, h 100px!, span, wrap\"/&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;child name=\"Mission Tree\" param=\"w 100%, h 100%, span\"/&gt;<br/>";
    helpText += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/container&gt;<br/>";
    helpText += "&nbsp;&nbsp;&nbsp;&nbsp;&lt;/container&gt;<br/>";
    helpText += "&nbsp;&nbsp;&lt;/profile&gt;<br/>";
    helpText += "&nbsp;&nbsp;&lt;profile name=\"Map\"&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&lt;container layoutparam=\"ins 0\" param=\"w 100%, h 100%\"&gt;<br/>";
    helpText +=
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;child name=\"Map Panel\" param=\"w 100%, h 100%\"/&gt;<br/>";
    helpText += "&nbsp;&nbsp;&nbsp;&nbsp;&lt;/container&gt;<br/>";
    helpText += "&nbsp;&nbsp;&lt;/profile&gt;<br/>";
    helpText += "&lt;/profiles&gt;<br/>";

    helpText += "<br/>";
    helpText += "<br/>";

    helpText += "&lt;!--profiles DTD--&gt;<br/>";
    helpText += "&lt;!ELEMENT profiles (profile)+&gt;<br/>";
    helpText += "&lt;!ELEMENT profile (container | child)*&gt;<br/>";
    helpText += "&lt;!ATTLIST profile<br/>";
    helpText += "&nbsp;&nbsp;name CDATA #REQUIRED<br/>";
    helpText += "&gt;<br/>";
    helpText += "&lt;!ELEMENT container ((container | child)* | (tab*)*)&gt;<br/>";
    helpText += "&lt;!ATTLIST container<br/>";
    helpText += "&nbsp;&nbsp;layoutparam CDATA #IMPLIED<br/>";
    helpText += "&nbsp;&nbsp;colparam CDATA #IMPLIED<br/>";
    helpText += "&nbsp;&nbsp;rowparam CDATA #IMPLIED<br/>";
    helpText += "&nbsp;&nbsp;param CDATA #IMPLIED<br/>";
    helpText += "&gt;<br/>";
    helpText += "&lt;!ELEMENT child EMPTY&gt;<br/>";
    helpText += "&lt;!ATTLIST child<br/>";
    helpText += "&nbsp;&nbsp;name CDATA #REQUIRED<br/>";
    helpText += "&nbsp;&nbsp;param CDATA #IMPLIED<br/>";
    helpText += "&gt;<br/>";
    helpText += "&lt;!ELEMENT tab (container | child)*&gt;<br/>";
    helpText += "&lt;!ATTLIST tab<br/>";
    helpText += "&nbsp;&nbsp;tabname CDATA #REQUIRED<br/>";
    helpText += "&nbsp;&nbsp;layoutparam CDATA #IMPLIED<br/>";
    helpText += "&nbsp;&nbsp;colparam CDATA #IMPLIED<br/>";
    helpText += "&nbsp;&nbsp;rowparam CDATA #IMPLIED<br/>";
    helpText += "&gt;<br/>";
  }
 public static File showSaveDialog(Component parent, File basedir) {
   return showOpenDialog(parent, I18n.text("Save Checklist"), basedir);
 }
 /** @return */
 public static File showSaveDialog(File basedir) {
   return showOpenDialog(null, I18n.text("Save Checklist"), basedir);
 }
Ejemplo n.º 27
0
 @Override
 public String getName() {
   return I18n.text("Statistics");
 }
Ejemplo n.º 28
0
  @Override
  public void mouseClicked(MouseEvent e) {
    TreePath[] path = tree.getSelectionPaths();
    if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
      if (path == null) return;
      if (path.length == 1 && path[0].getPath().length == 2) {
        final String fileToOpen = path[0].getPath()[1].toString();
        IMraLog log = source.getLog(fileToOpen);
        panel.loadVisualization(new LogTableVisualization(log, panel), true);
      }
    }
    if (e.getButton() == MouseEvent.BUTTON3) {
      if (path == null) return;

      if (path.length == 1 && path[0].getPath().length == 2) {
        final String fileToOpen = path[0].getPath()[1].toString();
        JPopupMenu popup = new JPopupMenu();

        String text = I18n.textf("Show %log data", fileToOpen);

        popup
            .add(text)
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(java.awt.event.ActionEvent e) {
                    IMraLog log = source.getLog(fileToOpen);
                    panel.loadVisualization(new LogTableVisualization(log, panel), true);
                  }
                });

        popup.show(tree, e.getX(), e.getY());
        return;
      }

      final Vector<String> fieldsToPlot = new Vector<String>();
      int count = 0;

      for (int i = 0; i < path.length; i++) {
        if (path[i].getPath().length == 3) {
          count++;
          String message = path[i].getPath()[1].toString();
          String field = path[i].getPath()[2].toString();

          fieldsToPlot.add(message + "." + field);
        }
      }

      if (count == 0) return;

      JPopupMenu popup = new JPopupMenu();

      popup
          .add(I18n.text("Plot data"))
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {
                  panel.loadVisualization(
                      new GenericPlot(fieldsToPlot.toArray(new String[0]), panel), true);
                }
              });

      popup
          .add(I18n.text("Timeline Plot"))
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {
                  panel.loadVisualization(
                      new ReplayPlot(panel, fieldsToPlot.toArray(new String[0])), true);
                }
              });

      popup
          .add(I18n.text("Plot data on new window"))
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {

                  LLFChart chart = new GenericPlot(fieldsToPlot.toArray(new String[0]), panel);
                  MRAChartPanel fcp = new MRAChartPanel(chart, source, panel);
                  JDialog dialog = new JDialog(ConfigFetch.getSuperParentAsFrame());
                  dialog.setTitle("[MRA] " + chart.getName());
                  dialog.setIconImage(ImageUtils.getScaledImage("images/menus/graph.png", 16, 16));
                  dialog.add(fcp);
                  dialog.setSize(640, 480);
                  dialog.setResizable(true);
                  dialog.setVisible(true);
                  fcp.regeneratePanel();
                }
              });
      if (count == 1) {
        popup
            .add(I18n.text("Plot ColorMap"))
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(java.awt.event.ActionEvent e) {
                    NeptusLog.pub().info("<###> " + fieldsToPlot);
                    panel.loadVisualization(
                        new ColorMapVisualization(panel, "ALL", fieldsToPlot.get(0)), true);
                  }
                });
      }
      popup.show(tree, e.getX(), e.getY());
    }
  }
 public static File showSaveDialog() {
   return showOpenDialog(null, I18n.text("Save Checklist"), null);
 }
Ejemplo n.º 30
0
  public OperationLimitsPanel(MissionType mt, boolean editArea) {
    this.mt = mt;
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    maxDepthCheck = new JCheckBox(I18n.text("Maximum Depth (m)"));
    minAltitudeCheck = new JCheckBox(I18n.text("Minimum Altitude (m)"));
    maxAltitudeCheck = new JCheckBox(I18n.text("Maximum Altitude (m)"));
    minSpeedCheck = new JCheckBox(I18n.text("Minimum Speed (m/s)"));
    maxSpeedCheck = new JCheckBox(I18n.text("Maximum Speed (m/s)"));
    areaCheck = new JCheckBox(I18n.text("Area Limits"));
    maxVRateCheck = new JCheckBox(I18n.text("Maximum Vertical Rate (m/s)"));

    maxDepthField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    maxAltitudeField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    minAltitudeField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    maxSpeedField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    minSpeedField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    maxVRateField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);

    JPanel tmp = new JPanel(new GridLayout(0, 2, 2, 10));
    tmp.add(maxDepthCheck);
    tmp.add(maxDepthField);

    tmp.add(maxAltitudeCheck);
    tmp.add(maxAltitudeField);

    tmp.add(minAltitudeCheck);
    tmp.add(minAltitudeField);

    tmp.add(maxSpeedCheck);
    tmp.add(maxSpeedField);

    tmp.add(minSpeedCheck);
    tmp.add(minSpeedField);

    tmp.add(maxVRateCheck);
    tmp.add(maxVRateField);

    tmp.add(areaCheck);

    JButton b = new JButton(I18n.text("Select..."));
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            RectangleEditor editor = new RectangleEditor(OperationLimitsPanel.this.mt);
            if (limits.getOpAreaLat() != null) {
              editor.pp =
                  new ParallelepipedElement(
                      MapGroup.getMapGroupInstance(OperationLimitsPanel.this.mt), null);
              editor.pp.setWidth(limits.getOpAreaWidth());
              editor.pp.setLength(limits.getOpAreaLength());
              editor.pp.setYawDeg(Math.toDegrees(limits.getOpRotationRads()));
              LocationType lt = new LocationType();
              lt.setLatitudeDegs(limits.getOpAreaLat());
              lt.setLongitudeDegs(limits.getOpAreaLon());
              editor.pp.setCenterLocation(lt);
              editor.pp.setMyColor(Color.red);
              editor.btnOk.setEnabled(true);
            }
            ParallelepipedElement rectangle = editor.showDialog(OperationLimitsPanel.this);
            if (rectangle != null) {
              double lld[] = rectangle.getCenterLocation().getAbsoluteLatLonDepth();
              limits.setOpAreaLat(lld[0]);
              limits.setOpAreaLon(lld[1]);
              limits.setOpAreaLength(rectangle.getLength());
              limits.setOpAreaWidth(rectangle.getWidth());
              limits.setOpRotationRads(rectangle.getYawRad());
            }
          }
        });
    tmp.add(b);
    if (!editArea) b.setEnabled(false);
    add(tmp);
  }