public RemoveServiceItem(MainWindow window, Gui gui) {
    // TODO: logger.setLevel(Level.OFF);

    this.window = window;
    this.gui = gui;

    addActionListener(window.getActionListener());
  }
  @Override
  public void actionPerformed(ActionEvent e) {
    boolean refreshTabs = false;
    if (e.getSource() == btnGetT0) {
      MainWindow.updateManager.updateT0(sat);
      updateTimeSeries();
    }
    if (e.getSource() == btnCancel) {
      this.dispose();
    }
    if (e.getSource() == btnSave) {
      try {
        try {
          sat.telemetryDownlinkFreqkHz = Integer.parseInt(telemetryDownlinkFreqkHz.getText());
          sat.minFreqBoundkHz = Integer.parseInt(minFreqBoundkHz.getText());
          sat.maxFreqBoundkHz = Integer.parseInt(maxFreqBoundkHz.getText());
        } catch (NumberFormatException ex) {
          throw new Exception("The Frequency fields must contain a valid number");
        }
        if (sat.rssiLookUpTableFileName != rssiLookUpTableFileName.getText()) {
          sat.rssiLookUpTableFileName = rssiLookUpTableFileName.getText();
          refreshTabs = true;
        }
        if (sat.ihuTempLookUpTableFileName != ihuTempLookUpTableFileName.getText()) {
          sat.ihuTempLookUpTableFileName = ihuTempLookUpTableFileName.getText();
          refreshTabs = true;
        }
        if (sat.ihuVBattLookUpTableFileName != ihuVBattLookUpTableFileName.getText()) {
          sat.ihuVBattLookUpTableFileName = ihuVBattLookUpTableFileName.getText();
          refreshTabs = true;
        }

        if (sat.BATTERY_CURRENT_ZERO != Double.parseDouble(BATTERY_CURRENT_ZERO.getText())) {
          sat.BATTERY_CURRENT_ZERO = Double.parseDouble(BATTERY_CURRENT_ZERO.getText());
          refreshTabs = true;
        }

        if (sat.useIHUVBatt != useIHUVBatt.isSelected()) {
          sat.useIHUVBatt = useIHUVBatt.isSelected();
          refreshTabs = true;
        }
        sat.track = track.isSelected();

        if (refreshTabs) MainWindow.refreshTabs(false);
        sat.save();
        this.dispose();
      } catch (Exception Ex) {
        Log.errorDialog("Invalid Paramaters", Ex.getMessage());
      }
    }
  }
  public void mouseClicked(MouseEvent e) {
    if (cm != null) {
      if (cm.getMapSize() == 2 && e.getClickCount() == 1) {
        // invert color
        color = (color == 1) ? 0 : 1;
        chooser.setCurrentColor(color);
        mainWindow.setActiveEditorColor(color);

        if (chooser.isVisible()) {
          chooser.repaint();
        }
        this.repaint();
      } else if (e.getClickCount() % 2 == 0) {
        chooser.setVisible(true);
      }
    }
  }
  /**
   * Replaces the current PetrinetViewer so the new Petrinet is displayed. All Listeners are
   * attacked to the new Petrinet
   */
  public void displayPetrinet(int petrinetId, String title) {

    if (title != null) {
      setBorderTitle(title);
    }

    try {
      Layout<INode, IArc> layout =
          EngineAdapter.getPetrinetManipulation().getJungLayout(petrinetId);
      if (petrinetViewer != null) {
        petrinetViewer.removeFrom(petrinetPanel);
      }
      petrinetViewer = new PetrinetViewer(layout, petrinetId, null);
      double nodeSize = EngineAdapter.getPetrinetManipulation().getNodeSize(petrinetId);
      petrinetViewer.setNodeSize(nodeSize);
      petrinetViewer.addTo(petrinetPanel);
      MainWindow.getInstance().repaint();
      SimulationPane.getInstance().setSimulationPaneEnable();
    } catch (EngineException e) {
    }
  }
Exemple #5
0
  @Override
  public void actionPerformed(ActionEvent e) {
    MainWindow w = MainWindowSingleton.getInstance();
    String event = e.getActionCommand();

    if ("colour".equals(event)) {

      // TODO fail due to old substance API / Bug in API
      Color newColor = JColorChooser.showDialog(w, "Choose Element Colour", getElementColor());
      JButton b = ((JButton) e.getSource());
      b.setBackground(newColor);

      ab.setColor(newColor);
      ab.setReference(false);
      ab.setHidden(false);
      ab.setVisible(true);
      // reference.setSelected(false);
      // updateReferences(false);

    } else if ("reference".equals(event)) {
      // TODO calculate References properly
      ab.setReference(reference.isSelected());
      if (reference.isSelected()) {
        ab.setHidden(true);
        updateReferences(true);
      } else {
        ab.setHidden(false);
        updateReferences(false);
      }
      colorButton.setBackground(ab.getColor());
    } else if ("pathwayLink".equals(event)) {
      if (JOptionPane.showConfirmDialog(
                  w,
                  "If you delete the PathwayLink the Sub-Pathway (with all eventually made changes within it) will be lost. Do you want to do this?",
                  "Delete the Sub-Pathway...",
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.QUESTION_MESSAGE)
              == JOptionPane.YES_OPTION
          && ab instanceof PathwayMap) {
        ((PathwayMap) ab).setPathwayLink(null);
        w.updateElementTree();
        w.updatePathwayTree();
        ab.setColor(Color.white);
      }
      w.updateElementProperties();
    } else if (("hideNeighbours".equals(event) || ("showNeighbours".equals(event)))
        && ab instanceof BiologicalNodeAbstract) {
      // TODO visible wird noch nicht gehandelt in transformators
      Pathway pw = graphInstance.getPathway();
      boolean hide = "hideNeighbours".equals(event);
      BiologicalNodeAbstract bna = (BiologicalNodeAbstract) ab;

      Iterator<BiologicalEdgeAbstract> it =
          pw.getGraph().getJungGraph().getIncidentEdges(bna).iterator();
      BiologicalEdgeAbstract bea;

      while (it.hasNext()) {
        // System.out.println(!hide);
        bea = it.next();
        bea.setVisible(!hide);
        // bea.setLabel(!hide+"");
      }

      Iterator<BiologicalNodeAbstract> it2 =
          pw.getGraph().getJungGraph().getNeighbors(bna).iterator();

      BiologicalNodeAbstract node;
      while (it2.hasNext()) {
        // System.out.println("drin");
        node = it2.next();
        node.setVisible(!hide);
        node.setHidden(hide);
      }

    } else if ("dirChanger".equals(event) && ab.isEdge()) {
      Pathway pw = graphInstance.getPathway();
      PNEdge edge = (PNEdge) ab;

      PNEdge newEdge =
          new PNEdge(
              edge.getTo(),
              edge.getFrom(),
              edge.getLabel(),
              edge.getName(),
              edge.getBiologicalElement(),
              edge.getFunction());
      newEdge.setUpperBoundary(edge.getUpperBoundary());
      newEdge.setLowerBoundary(edge.getLowerBoundary());
      newEdge.setActivationProbability(edge.getActivationProbability());
      newEdge.setDirected(true);
      // pw = graphInstance.getPathway();
      MyGraph g = pw.getGraph();
      g.getJungGraph().removeEdge(edge);
      // g.getEdgeStringer().removeEdge(edge.getEdge());
      pw.removeElement(edge);
      pw.addEdge(newEdge);
      // g.getVisualizationViewer().getPickedState().clearPickedEdges();
      graphInstance.setSelectedObject(newEdge);

      ab = newEdge;
    } else if ("chooseRef".equals(event)) {
      BiologicalNodeAbstract bna = (BiologicalNodeAbstract) original;
      ReferenceDialog dialog = new ReferenceDialog(bna);
      BiologicalNodeAbstract node = dialog.getAnswer();
      if (node != null) {
        bna.setRef(node);
        this.revalidateView();
        w.updateElementTree();
        // System.out.println("node: "+node.getID());
      }
    } else if ("deleteRef".equals(event)) {
      BiologicalNodeAbstract bna = (BiologicalNodeAbstract) original;
      bna.deleteRef();

      this.revalidateView();
      w.updateElementTree();

    } else if ("pickOrigin".equals(event)) {
      BiologicalNodeAbstract bna = (BiologicalNodeAbstract) original;

      Pathway pw = graphInstance.getPathway();
      pw = graphInstance.getPathway();
      MyGraph g = pw.getGraph();
      g.getVisualizationViewer().getPickedVertexState().pick(bna.getRef(), true);

      this.revalidateView();

    } else if ("pickRefs".equals(event)) {
      BiologicalNodeAbstract bna = (BiologicalNodeAbstract) original;

      Pathway pw = graphInstance.getPathway();
      pw = graphInstance.getPathway();
      MyGraph g = pw.getGraph();
      // System.out.println("c: "+g.getJungGraph().getVertexCount());
      BiologicalNodeAbstract pick;
      Iterator<BiologicalNodeAbstract> it = bna.getRefs().iterator();
      // System.out.println("size: "+bna.getRefs().size());
      while (it.hasNext()) {
        pick = it.next();
        // System.out.println(pick.getLabel());
        // System.out.println(pick);
        g.getVisualizationViewer().getPickedVertexState().pick(pick, true);
      }
      // System.out.println(g.getVisualizationViewer().getPickedVertexState().getPicked().size());
      this.revalidateView();
    } else if ("showParameters".equals(event)) {
      // System.out.println("show parameters");
      new ParameterWindow(ab);
      this.updateWindow(ab);
      p.revalidate();
    } else if ("showLabels".equals(event)) {
      // System.out.println("click");
      new LabelsWindow(ab);
    } else if ("knockedOut".equals(event)) {

      ((Transition) ab).setKnockedOut(knockedOut.isSelected());
      this.updateWindow(ab);
      p.revalidate();
      // p.repaint();
      Pathway pw = new GraphInstance().getPathway();
      pw.handleChangeFlags(ChangedFlags.PNPROPERTIES_CHANGED);

      // System.out.println("knocked out");
    } else if ("constCheck".equals(event)) {
      if (ab instanceof BiologicalNodeAbstract) {
        BiologicalNodeAbstract bna = (BiologicalNodeAbstract) ab;
        if (constCheck.isSelected()) {
          this.tokenMin.setEnabled(false);
          this.tokenMax.setEnabled(false);
          bna.setConstant(true);
        } else {
          this.tokenMin.setEnabled(true);
          this.tokenMax.setEnabled(true);
          bna.setConstant(false);
        }
        Pathway pw = new GraphInstance().getPathway();
        pw.handleChangeFlags(ChangedFlags.EDGEWEIGHT_CHANGED);
      }
      // System.out.println(this.constCheck.isSelected());

    }

    GraphInstance.getMyGraph().updateGraph();
  }
  @SuppressWarnings("unchecked")
  public Iruzkindu(final Erabiltzailea er) {

    setTitle("Iruzkindu");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblEtxea = new JLabel("Etxea:");
    lblEtxea.setBounds(33, 30, 46, 14);
    contentPane.add(lblEtxea);

    MainWindow.setBussinessLogic(MainWindow.getBusinessLogic());
    ApplicationFacadeInterface facade = MainWindow.getBusinessLogic();

    JLabel lblPuntuazioa = new JLabel("Puntuazioa:");
    lblPuntuazioa.setBounds(33, 81, 66, 14);
    contentPane.add(lblPuntuazioa);

    final JComboBox<Integer> comboBoxPunt = new JComboBox<Integer>();
    comboBoxPunt.setBounds(102, 78, 46, 20);
    contentPane.add(comboBoxPunt);
    comboBoxPunt.addItem(1);
    comboBoxPunt.addItem(2);
    comboBoxPunt.addItem(3);
    comboBoxPunt.addItem(4);
    comboBoxPunt.addItem(5);

    JLabel lblKomentarioa = new JLabel("Komentarioa:");
    lblKomentarioa.setBounds(33, 127, 66, 14);
    contentPane.add(lblKomentarioa);

    textFieldKom = new JTextField();
    textFieldKom.setBounds(105, 127, 283, 83);
    contentPane.add(textFieldKom);
    textFieldKom.setColumns(10);

    Vector<RuralHouse> v = null;
    try {
      v = facade.getAllRuralHouses();
    } catch (RemoteException e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    } catch (Exception e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }
    Vector<String> b = new Vector();
    for (int i = 0; i < v.size(); i++) {
      b.addElement(v.get(i).getCity());
    }

    final JComboBox<String> comboBoxEtxe = new JComboBox(b);
    comboBoxEtxe.setBounds(74, 27, 122, 20);
    contentPane.add(comboBoxEtxe);

    JButton btnAtzera = new JButton("Atzera");
    btnAtzera.setBounds(345, 0, 89, 28);
    contentPane.add(btnAtzera);
    btnAtzera.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            btnAtzera_actionPerformed(e);
          }
        });

    final JTextArea textArea = new JTextArea();
    textArea.setBounds(266, 40, 141, 55);
    contentPane.add(textArea);

    JButton btnIruzkindu = new JButton("Iruzkindu");
    btnIruzkindu.setBounds(184, 221, 89, 30);
    btnIruzkindu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!textFieldKom.getText().isEmpty()) {

              MainWindow.setBussinessLogic(MainWindow.getBusinessLogic());
              ApplicationFacadeInterface facade = MainWindow.getBusinessLogic();
              textArea.setText(" ");

              Vector<RuralHouse> etxe = new Vector();
              try {
                etxe = facade.getAllRuralHouses();
              } catch (RemoteException e2) {
                // TODO Auto-generated catch block
                e2.printStackTrace();
              } catch (Exception e2) {
                // TODO Auto-generated catch block
                e2.printStackTrace();
              }
              RuralHouse r = new RuralHouse();
              for (int i = 0; i < etxe.size(); i++) {
                if (comboBoxEtxe.getSelectedItem().equals((etxe.get(i)).getCity())) {
                  r = etxe.get(i);
                }
              }
              String k = textFieldKom.getText();
              int p = (Integer) comboBoxPunt.getSelectedItem();
              java.util.Date d = new Date();
              try {
                facade.createIruzkina(r, er, d, p, k);
                System.out.println("iruzkina gehitu da");
              } catch (RemoteException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }

              JFrame sw = new MainWindow(er);
              sw.setVisible(true);
              ((MainWindow) sw).getBoton2().setEnabled(false);
              ((MainWindow) sw).getbtnAddRH().setEnabled(false);
              ((MainWindow) sw).btnIruzkindu().setEnabled(true);
              ((MainWindow) sw).btnTxangoApDes().setEnabled(true);
              ((MainWindow) sw).btnManageTxangoa().setEnabled(false);

            } else {
              textArea.setText("Informazioa sartu");
            }
          }
        });
    contentPane.add(btnIruzkindu);

    JButton btnEzabatu = new JButton("Iruzkina ezabatu");
    btnEzabatu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            JFrame s = new IruzkinaEzabatu(er);
            s.setVisible(true);
          }
        });
    btnEzabatu.setBounds(0, 225, 113, 37);
    contentPane.add(btnEzabatu);
  }
 public void setChoosedColor(int color) {
   this.color = color;
   mainWindow.setActiveEditorColor(color);
   repaint();
 }