/**
   * Eventhandling des Registriere Agent ohne Visualisierungs-Button.
   *
   * @param ActionEvent e
   */
  void m_roVButton_actionPerformed(ActionEvent e) {
    try {
      if (m_coordinator.isGameRegisteredAndOpen(m_gameId)) {
        m_parent.writeStatusMessage(
            "Registriere den Agenten "
                + m_agentTF.getText()
                + " beim Spiel "
                + m_coordinator.getGameName(m_gameId));
        /*
         * Erstelle kompletten Pfad der Agentenklasse
         */
        if (m_parameter.containsKey("ScenarioName")) {
          m_scenarioName = (String) m_parameter.get("ScenarioName");
          System.out.println("Parameter ScenarioName vorhanden: " + m_scenarioName);
        } else {
          m_scenarioName = "island";
        }
        String agentClass =
            "scenario."
                + m_scenarioName
                + "."
                + AGENTENORDNER
                + "."
                + (String) m_agentClassCombo.getSelectedItem();
        // + ".class";
        System.out.println("Agent name and location: " + agentClass);

        m_coordinator.registerAgent(
            m_gameId, m_agentTF.getText(), agentClass, m_serverTF.getText());

        m_parent.writeStatusMessage(
            "Registrierung von Agent " + m_agentTF.getText() + " erfolgreich ausgeführt.");
        if ((m_gpp != null) && !m_coordinator.isGameRegisteredAndOpen(m_gameId))
          m_gpp.setAgentRegisterButtonVisible(false);

      } else {
        MessageDialog md =
            new MessageDialog(
                "Agentenregistrierung",
                "Der Agent kann nicht registriert werden, "
                    + "da das Spiel schon geschlossen ist.");
        md.show();
      }
    } catch (Exception ex) {
      MessageDialog md =
          new MessageDialog(
              "Agentenregistrierung",
              "Der Agent konnte nicht registriert werden, "
                  + "bitte beachten sie die Statusmeldung im Hauptfenster.");
      md.show();
      m_parent.writeStatusMessage("Der Agent konnte nicht registriert werden.");
      System.out.println("Der Agent konnte nicht registriert werden.");
      ex.printStackTrace(System.out);
    }
    this.setVisible(false);
    this.dispose();
    //    boolean tesss=m_coordinator.isGameRegisteredAndOpen(m_gameId);
    m_parent.repaintApplication();
  }
Exemplo n.º 2
0
 public MessageDialog getMessageDialogByTarget(String target) {
   for (MessageDialog m : messages) {
     if (m.getTarget().equalsIgnoreCase(target)) {
       return m;
     }
   }
   return null;
 }
Exemplo n.º 3
0
 public boolean hasMessage(String target) {
   for (MessageDialog m : messages) {
     if (m.getTarget().equalsIgnoreCase(target)) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 4
0
 @Override
 protected boolean validate(String input) {
   if (input.length() == 0) {
     MessageDialog dialog =
         new MessageDialog(MessageDialog.ERROR, "Error", "You must enter a value.");
     dialog.addButton("OK", (Operation) null, true, true);
     dialog.showModal();
     textBox_.setFocus(true);
     return false;
   } else {
     return true;
   }
 }
Exemplo n.º 5
0
  // exit button listener;
  public void logoutMaintainer() {

    MachineryController machctrl = mCtrl.getMachineryController();

    boolean ds = machctrl.isDoorClosed();

    if (ds == false) {
      MessageDialog msg = new MessageDialog(mpanel, "Please Lock the Door before You Leave");
      msg.setLocation(500, 500);
      return;
    }

    mpanel.setActive(MaintenancePanel.DIALOG, true);
  }
Exemplo n.º 6
0
 private void showMessageDialogConfirm() {
   String title = "Confirmation";
   String mesg = "Nothing will be done. Ok?";
   boolean result = MessageDialog.openConfirm(getShell(), title, mesg);
   messageDlgResLabel.setText("Result: " + result);
   messageDlgResLabel.pack();
 }
Exemplo n.º 7
0
 private void showMessageDialogError() {
   String title = "Error";
   String mesg = "An everyday error occured.\n " + "Nothing to get worried.";
   MessageDialog.openError(getShell(), title, mesg);
   messageDlgResLabel.setText("Result: none");
   messageDlgResLabel.pack();
 }
Exemplo n.º 8
0
 private void showMessageDialogInfo() {
   String title = "Information";
   String mesg = "RAP rocks!";
   MessageDialog.openInformation(getShell(), title, mesg);
   messageDlgResLabel.setText("Result: none");
   messageDlgResLabel.pack();
 }
Exemplo n.º 9
0
 private void showMessageDialogWarning() {
   String title = "Warning";
   String mesg = "You have been warned.";
   MessageDialog.openWarning(getShell(), title, mesg);
   messageDlgResLabel.setText("Result: none");
   messageDlgResLabel.pack();
 }
Exemplo n.º 10
0
 /**
  * This method is called when 'Finish' button is pressed in the wizard. We will create an
  * operation and run it using wizard as execution context.
  */
 public boolean performFinish() {
   final String containerName = page.getContainerName();
   final String fileName = page.getFileName();
   IRunnableWithProgress op =
       new IRunnableWithProgress() {
         public void run(IProgressMonitor monitor) throws InvocationTargetException {
           try {
             doFinish(containerName, fileName, monitor);
           } catch (CoreException e) {
             throw new InvocationTargetException(e);
           } finally {
             monitor.done();
           }
         }
       };
   try {
     getContainer().run(true, false, op);
   } catch (InterruptedException e) {
     return false;
   } catch (InvocationTargetException e) {
     Throwable realException = e.getTargetException();
     MessageDialog.openError(getShell(), "Error", realException.getMessage());
     return false;
   }
   return true;
 }
Exemplo n.º 11
0
 @Override
 public void run() {
   if (!fileBox.getText().isEmpty()) {
     selectedFile = new File(directory, fileBox.getText());
     close();
   } else {
     MessageDialog.showMessageDialog(
         getTextGUI(), "Error", "Please select a valid file name", MessageDialogButton.OK);
   }
 }
Exemplo n.º 12
0
 private void showMessageDialogQuestion() {
   String title = "Question";
   String mesg =
       "Do you like the RAP technology?\n\n"
           + "Note that you can also press <Return> here. "
           + "The correct answer is automatically selected.";
   boolean result = MessageDialog.openQuestion(getShell(), title, mesg);
   messageDlgResLabel.setText("Result: " + result);
   messageDlgResLabel.pack();
 }
Exemplo n.º 13
0
 public static void selectToMarker(String s) {
   if (s == null) return;
   s = s.trim();
   if (s.length() == 0) return;
   final Editor editor = Editor.currentEditor();
   Marker m = null;
   try {
     final int index = Integer.parseInt(s);
     final Marker[] bookmarks = Editor.getBookmarks();
     if (index >= 0 && index < bookmarks.length) m = bookmarks[index];
   } catch (NumberFormatException e) {
   }
   if (m == null) {
     MessageDialog.showMessageDialog(editor, "No such marker", "Select To Marker");
     return;
   }
   m.selectToMarker(editor);
 }
Exemplo n.º 14
0
  public Fifteen() {
    // создание поля
    mBoard = new Board(SIDE_SIZE);
    mBoard.createRandomArray();
    // создание объекта, выполняющего поиск решения
    mCalc = new Calc(mBoard);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setResizable(false);
    setTitle("Решатель пятнашек");

    mMainPanel = new JPanel();
    mMainPanel.setLayout(new BorderLayout());
    add(mMainPanel);

    mGamePanel = new JPanel();
    mGamePanel.setLayout(null);
    mGamePanel.setPreferredSize(new Dimension(CELL_SIZE * SIDE_SIZE, CELL_SIZE * SIDE_SIZE));
    mGamePanel.setBackground(Color.WHITE);
    mMainPanel.add(mGamePanel);

    mLabels = new Label[SIDE_SIZE][SIDE_SIZE];
    createField();

    mStatusLabel = new JLabel("Состояние: готов.");
    mMainPanel.add(mStatusLabel, BorderLayout.SOUTH);

    mMessageDialog = new MessageDialog(mBoard, this);
    mFifteenThread = new FifteenThread(mStatusLabel, mMessageDialog, mCalc, mLabels);
    mMessageDialog.setThread(mFifteenThread);

    startButton = new JButton("Решить задачу");
    mMainPanel.add(startButton, BorderLayout.NORTH);
    // событие нажатия на кнопку старта
    startButton.addActionListener(
        action -> {
          mFifteenThread.calcAndShow();
        });

    setVisible(true);
    pack();
    setLocationRelativeTo(null);
  }
Exemplo n.º 15
0
 private void showProgressDialog() {
   ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
   try {
     dialog.run(
         true,
         true,
         new IRunnableWithProgress() {
           public void run(final IProgressMonitor monitor)
               throws InvocationTargetException, InterruptedException {
             monitor.beginTask("Counting from one to 20...", 20);
             for (int i = 1; !monitor.isCanceled() && i <= 20; i++) {
               monitor.worked(1);
               Thread.sleep(1000);
             }
             monitor.done();
           }
         });
   } catch (Exception e) {
     MessageDialog.openError(getShell(), "Error", e.getMessage());
   }
 }
Exemplo n.º 16
0
 private void selectToMarker(Editor editor) {
   if (buffer == editor.getBuffer()
       || (file != null && file.equals(editor.getBuffer().getFile()))) {
     // Marker is in current buffer.
     editor.addUndo(SimpleEdit.MOVE);
     editor.unmark();
     editor.setMarkAtDot();
     editor.updateDotLine();
     if (pos != null && editor.getBuffer().contains(pos.getLine())) {
       editor.getDot().moveTo(pos);
     } else {
       editor.gotoline(lineNumber);
       editor.getDot().setOffset(offset);
     }
     if (editor.getDotOffset() > editor.getDotLine().length())
       editor.getDot().setOffset(editor.getDotLine().length());
     editor.moveCaretToDotCol();
     editor.updateDotLine();
     editor.setUpdateFlag(REFRAME | REPAINT);
   } else {
     // Marker is not in current buffer.
     MessageDialog.showMessageDialog(editor, "Marker is not in this buffer.", "Select To Marker");
   }
 }
Exemplo n.º 17
0
 public void actionPerformed(ActionEvent event) {
   MessageDialog.show(PMDViewer.getViewer(), "Online Help not available yet.");
 }
Exemplo n.º 18
0
 /**
  * Called whenever the part throws an exception.
  *
  * @param exception java.lang.Throwable
  */
 private void handleException(Throwable exception) {
   MessageDialog.displayException(exception, this);
 }
 private void markerDownloadWithError() {
   // hideProgressControls();
   MessageDialog.showMessage(R.string.downloadErrorMsg, this);
 }
Exemplo n.º 20
0
  public void render() {
    this.map.update();
    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();

    this.mapInputListener.update();

    while (Client.getCurrentState() == this) {
      TopPacket packet = Network.getInstance().pollPacket();
      if (packet == null) break;

      if (packet.getType() == TopPacket.CHARACTER) {
        if (((CharacterPacket) packet).getType2() == CharacterPacket.Add) {
          Character entity = new Character(this, (CharacterPacket) packet);
          this.map.addEntity(entity);
        } else if (((CharacterPacket) packet).getType2() == CharacterPacket.Del) {
          Entity entity = getEntityByEntityId(((CharacterPacket) packet).getEntityId());
          this.map.removeEntity(entity);
        }
      } else if (packet.getType() == TopPacket.MONSTER) {
        if (((MonsterPacket) packet).getType2() == MonsterPacket.Add) {
          Monster monster = new Monster(this, (MonsterPacket) packet);
          this.map.addEntity(monster);
        } else if (((MonsterPacket) packet).getType2() == MonsterPacket.Del) {
          Entity entity = getEntityByEntityId(((MonsterPacket) packet).getEntityId());
          this.map.removeEntity(entity);
        }
      } else if (packet.getType() == TopPacket.MOVE) {
        Entity target = getEntityByEntityId(((MovePacket) packet).getEntityId());
        if (target == null) break;

        int src_x = ((MovePacket) packet).getSx();
        int src_y = ((MovePacket) packet).getSy();
        int dest_x = ((MovePacket) packet).getDx();
        int dest_y = ((MovePacket) packet).getDy();

        target.move(src_x, src_y, dest_x, dest_y);
      } else if (packet.getType() == TopPacket.UPDATE) {
        Entity target = getEntityByEntityId(((UpdatePacket) packet).getEntityId());
        if (target == null) break;

        target.update((UpdatePacket) packet);
      } else if (packet.getType() == TopPacket.CHAT) {
        chattingDialog.append((ChatPacket) packet);
      } else if (packet.getType() == TopPacket.PARTY) {
        PartyPacket p = (PartyPacket) packet;
        if (p.getType2() == PartyPacket.info) {
          centerCharacterParty = new Party();
          int[] entityIds = p.getPartyMemberEntityIds();
          for (int i = 0; i < p.getPartyNumber(); i++) {
            Character c = (Character) getEntityByEntityId(entityIds[i]);
            centerCharacterParty.addMember(c);
          }
        } else if (p.getType2() == PartyPacket.withdraw) {
          centerCharacterParty = null;
        } else if (p.getType2() == PartyPacket.add) {
          centerCharacterParty.addMember((Character) getEntityByEntityId(p.getTargetEntityId()));
        } else if (p.getType2() == PartyPacket.del) {
          centerCharacterParty.removeMember(p.getTargetEntityId());
        } else if (p.getType2() == PartyPacket.invite) {
          stage.addActor(new ServerMsgDialog("", skin, p));
        }
      } else if (packet.getType() == TopPacket.MESSAGE) {
        MessagePacket p = (MessagePacket) packet;
        MessageDialog m = getMessageDialogByTarget(p.getName());
        if (m == null) {
          m = new MessageDialog("", skin, p.getName());
          messages.add(m);
          stage.addActor(m);
        }
        m.append(p);
      } else if (packet.getType() == TopPacket.SERVER) {
        SystemMessage.getInstance()
            .show(((ServerMsg) packet).getMsg(), 2000, 1.0f, 1.0f, 1.0f, 1.0f);
      }
    }
  }
  /**
   * Eventhandling des Registriere Agent mit Visualisierungs-Button.
   *
   * @param ActionEvent e
   */
  void m_rwVAgentButton_actionPerformed(ActionEvent e) {
    try {
      /*
       * Check, ob Spiel überhaupt noch offen ist.
       */
      if (m_coordinator.isGameRegisteredAndOpen(m_gameId)) {
        m_parent.writeStatusMessage(
            "Registriere den Agenten "
                + m_agentTF.getText()
                + " beim Spiel "
                + m_coordinator.getGameName(m_gameId));
        /*
         * Delegate für Visualisierungskomponente erstellen
         */
        VisualisationDelegate delegate = null;
        delegate =
            new VisualisationDelegate(
                m_parameter, AgentVisualisation.class, "Agent " + m_agentTF.getText());
        System.out.println(
            "MultiagentSimulatorClient: " + "	Visualisation wird versucht zu registrieren.");

        /*
         * Erstelle kompletten Pfad der Agentenklasse
         */
        if (m_parameter.containsKey("ScenarioName")) {
          m_scenarioName = (String) m_parameter.get("ScenarioName");
        } else {
          m_scenarioName = "islandParallel";
        }

        /*
         * Agent und Visualisierung registrieren
         */
        String agentClass =
            "scenario."
                + m_scenarioName
                + "."
                + AGENTENORDNER
                + "."
                + (String) m_agentClassCombo.getSelectedItem();
        // + ".class";
        m_coordinator.registerAgent(
            m_gameId, m_agentTF.getText(), agentClass, m_serverTF.getText(), delegate);

        /*
         * Visualisierung starten
         */
        if ((m_gpp != null) && !m_coordinator.isGameRegisteredAndOpen(m_gameId))
          m_gpp.setAgentRegisterButtonVisible(false);

        delegate.show();
      } else {
        /*
         * MElde das dem User.
         */
        MessageDialog md =
            new MessageDialog(
                "Agentenregistrierung",
                "Der Agent kann nicht registriert werden, "
                    + "da das Spiel schon geschlossen ist.");
        md.show();
      }
    } catch (Exception ex) {
      MessageDialog md =
          new MessageDialog(
              "Agentenregistrierung",
              "Der Agent konnte nicht registriert werden, "
                  + "bitte beachten sie die Statusmeldung im Hauptfenster.");
      md.show();
      m_parent.writeStatusMessage("Der Agent konnte nicht registriert werden.");
      System.out.println("Der Agent konnte nicht registriert werden.");
      ex.printStackTrace(System.out);
    }
    m_parent.writeStatusMessage(
        "Registrierung von Agent " + m_agentTF.getText() + " erfolgreich ausgeführt.");
    this.setVisible(false);
    this.dispose();
    m_parent.repaintApplication();
  }
Exemplo n.º 22
0
 public static void alert(String text) {
   MessageDialog.alert(text);
 }