Example #1
0
  public boolean loadDocument(String fileName) {
    try {
      File file = new File(fileName);
      ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
      SavedDocument doc = (SavedDocument) in.readObject();

      document =
          new EditorDocument(
              doc.getTitle(), doc.getDescription(),
              doc.getText(), doc.getStartTime());
      paragraphs = new Paragraphs(document, doc.getParagraphsVector());
      clients = doc.getClients();
      Iterator i = clients.iterator();
      while (i.hasNext()) {
        EditorClient c = (EditorClient) i.next();
        c.setPresent(false);

        if (c.getIdNumber() > nextClientId) nextClientId = c.getIdNumber();
      }
      nextClientId++;

      lockManager = new LockManager(clients, document, paragraphs);
      highlights =
          new Highlights(lockManager, document, doc.getHighlightTypes(), doc.getHighlights());

      return true;
    } catch (Exception e) {
      System.out.println("EditorServer: loadDocument. error");
      e.printStackTrace();
      return false;
    }
  } // endof const WITH audio profile maker
Example #2
0
  // {{{ getPrintJob() method
  private static PrinterJob getPrintJob(String jobName) {
    job = PrinterJob.getPrinterJob();

    format = new HashPrintRequestAttributeSet();

    String settings = jEdit.getSettingsDirectory();
    if (settings != null) {
      String printSpecPath = MiscUtilities.constructPath(settings, "printspec");
      File filePrintSpec = new File(printSpecPath);

      if (filePrintSpec.exists()) {
        try {
          FileInputStream fileIn = new FileInputStream(filePrintSpec);
          ObjectInputStream obIn = new ObjectInputStream(fileIn);
          format = (HashPrintRequestAttributeSet) obIn.readObject();
        } catch (Exception e) {
          Log.log(Log.ERROR, BufferPrinter1_4.class, e);
        }
        // for backwards compatibility, the color variable is stored also as a property
        if (jEdit.getBooleanProperty("print.color")) format.add(Chromaticity.COLOR);
        else format.add(Chromaticity.MONOCHROME);

        // no need to always keep the same job name for every printout.
        format.add(new JobName(jobName, null));
      }
    }

    return job;
  } // }}}
Example #3
0
 // reads the configuration (breakpoints, window sizes and positions...) for the current index
 private void restoreConfig() {
   Breakpoints.reset();
   Properties.reset();
   try {
     ObjectInputStream in = new ObjectInputStream(new FileInputStream(idxName + ".config"));
     Breakpoints.restore(in);
     Properties.restore(in);
     in.close();
   } catch (IOException exc) {
     // something went wrong - there probably was no .config file
     // ignore it
   }
 }
 private Object loadObject(String fName) {
   Object obj = null;
   try {
     FileInputStream fis = new FileInputStream(fName);
     ObjectInputStream oin = new ObjectInputStream(fis);
     obj = oin.readObject();
   } catch (IOException ex) {
     JOptionPane.showMessageDialog(this, "Problemos skaitant Objektus");
     return null;
   } catch (ClassNotFoundException ex) {
     JOptionPane.showMessageDialog(this, "Nerasta objekto klasė");
     return null;
   }
   return obj;
 }
 /** Stop talking to the server */
 public void stop() {
   if (socket != null) {
     // Close all the streams and socket
     if (out != null) {
       try {
         out.close();
       } catch (IOException ioe) {
       }
       out = null;
     }
     if (in != null) {
       try {
         in.close();
       } catch (IOException ioe) {
       }
       in = null;
     }
     if (socket != null) {
       try {
         socket.close();
       } catch (IOException ioe) {
       }
       socket = null;
     }
   } else {
     // Already stopped
   }
   // Make sure the right buttons are enabled
   start_button.setEnabled(true);
   stop_button.setEnabled(false);
   setStatus(STATUS_STOPPED);
 }
 public void windowOpened(WindowEvent e) // read file on start
     {
   FileInputStream in = null;
   ObjectInputStream data = null;
   try {
     in = new FileInputStream(DB);
     data = new ObjectInputStream(in);
     p = (Person) data.readObject();
     while (p != null) {
       persons.add(p); // store Person object in ArrayList collection
       p = (Person) data.readObject(); // read the next record
     }
     data.close();
   } catch (Exception ex) {
     // IOException will always occur on the last read above
   } finally {
     if (persons.size() > 0) displayRecord();
   }
 }
Example #7
0
  private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {

    s.defaultReadObject();

    FigureEnumeration k = figures();
    while (k.hasMoreElements()) {
      Figure figure = k.nextFigure();
      figure.addToContainer(this);
    }
  }
  private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {

    s.defaultReadObject();

    fSelection = CollectionsFactory.current().createList(); // could use lazy initialization instead
    if (drawing() != null) {
      drawing().addDrawingChangeListener(this);
    }
    fSelectionListeners = CollectionsFactory.current().createList();
  }
  private void jMenuItemLoadProjectActionPerformed(
      java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemLoadProjectActionPerformed
      { // GEN-HEADEREND:event_jMenuItemLoadProjectActionPerformed
    JFileChooser jfc = new JFileChooser();
    if (lastPath != null) {
      jfc.setCurrentDirectory(lastPath);
    }
    int fileDialogReturnVal = jfc.showOpenDialog(this);

    if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) {
      try {
        File inputFile = jfc.getSelectedFile();
        FileInputStream fis = new FileInputStream(inputFile);
        ObjectInputStream ois = new ObjectInputStream(fis);

        this.theProject = (Project) ois.readObject();
        this.currentResults = (LSAResults) ois.readObject();

        lastPath = new File(jfc.getSelectedFile().getPath());
      } catch (IOException e) {
        if (this.theProject == null) {
          log.log(Log.ERROR, "Failed to load project");
        }
        if (this.currentResults == null) {
          log.log(Log.WARNING, "Failed to load results");
        }

        log.log(Log.WARNING, e.getMessage());
      } catch (ClassNotFoundException e) {
        log.log(Log.ERROR, "Class not found error, version mismatch");
      }
    }
    if (this.theProject != null) {
      jMenuItemViewDocuments.setEnabled(true);
      jMenuItemSaveProject.setEnabled(true);
      this.setTitle(theProject.getProjectName());
      log.log(Log.INFO, "Project Loaded");
    }
    if (this.currentResults != null) {
      log.log(Log.INFO, "Results loaded");
    }
  } // GEN-LAST:event_jMenuItemLoadProjectActionPerformed
Example #10
0
 private void load() {
   try {
     ObjectInputStream in = new ObjectInputStream(new FileInputStream("save.dat"));
     game.setScene(
         new MainScence(
             this.game,
             this.panel,
             (Snake) in.readObject(),
             (Apple) in.readObject(),
             (Delay) in.readObject(),
             (int) in.readObject(),
             (int) in.readObject(),
             (int) in.readObject(),
             (int) in.readObject()));
   } catch (IOException e) {
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   }
 }
Example #11
0
 // Close crap after chatting
 private void closeCrap() {
   showMessage("\n Closing connection... \n ");
   ableToType(false);
   try {
     output.close();
     input.close();
     connection.close();
   } catch (IOException ioException) {
     ioException.printStackTrace();
   }
 }
  private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {

    s.defaultReadObject();

    if (getStartConnector() != null) {
      connectStart(getStartConnector());
    }
    if (getEndConnector() != null) {
      connectEnd(getEndConnector());
    }
  }
  private void jMenuItemLoadLSAResultsActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemLoadLSAResultsActionPerformed
    JFileChooser jfc = new JFileChooser();
    int fileDialogReturnVal = jfc.showOpenDialog(this);

    if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) {
      try {
        File inputFile = jfc.getSelectedFile();
        FileInputStream fis = new FileInputStream(inputFile);
        ObjectInputStream ois = new ObjectInputStream(fis);

        this.currentResults = (LSAResults) ois.readObject();
      } catch (IOException e) {
        log.log(Log.ERROR, "Failed to load LSA results\n" + e.getMessage());
      } catch (ClassNotFoundException e) {
        log.log(Log.ERROR, "Class not found : Error loading LSA results due to version mismatch");
      }

      System.out.println(currentResults == null);
    }
  } // GEN-LAST:event_jMenuItemLoadLSAResultsActionPerformed
 private ConnectionData getConnectionData(Socket clientSocket, ObjectInputStream input) {
   ConnectionData res;
   try {
     Object o = input.readObject();
     res = (ConnectionData) o;
     return res;
   } catch (IOException | ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }
Example #15
0
 public void disconnect() {
   int cmdID = commID++;
   this.connected = false;
   try {
     out.println(cmdID + ";logout");
     out.flush();
     in.close();
     out.close();
     socket.close();
   } catch (IOException ex) {
     System.err.println("Server stop failed.");
   }
 }
Example #16
0
 // Fun chatting
 private void whileChatting() throws IOException {
   String message = " You are now connected! ";
   sendMessage(message);
   ableToType(true);
   do {
     // have conversation
     try {
       message = (String) input.readObject();
       showMessage("\n" + message);
     } catch (ClassNotFoundException classNotFoundException) {
       showMessage("\n idk wtf that user sent! \n");
     }
   } while (!message.equals("LEEPING: END"));
 }
Example #17
0
 /**
  * This methods loads the current state of MOCO from a serialized file
  *
  * @param loadFrom The name of the serialized file
  * @return The new state of MOCO
  */
 public Object openObject(String loadFrom) {
   File selected = new File(loadFrom);
   try {
     ObjectInputStream oi =
         new ObjectInputStream(new BufferedInputStream(new FileInputStream(selected)));
     Object obj = oi.readObject();
     oi.close();
     if (!(obj instanceof MOCCOState)) {
       throw new Exception("Object not of type MOCCOState");
     }
     return obj;
   } catch (Exception ex) {
     if (this.mainFrame != null) {
       JOptionPane.showMessageDialog(
           this.mainFrame,
           "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(),
           "Open object file",
           JOptionPane.ERROR_MESSAGE);
     } else {
       System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
     }
   }
   return null;
 }
Example #18
0
  public static void init(GameController gc, Registry r) {
    int version;

    registry = r;

    resolutions = new ArrayList();
    resolutions.add("800x600");
    resolutions.add("1024x768");
    resolutions.add("1152x864");
    resolutions.add("1280x720");
    resolutions.add("1280x768");
    resolutions.add("1280x800");
    resolutions.add("1280x960");
    resolutions.add("1280x1024");
    resolutions.add("1360x768");
    resolutions.add("1366x768");
    resolutions.add("1440x900");
    resolutions.add("1600x900");
    resolutions.add("1600x1024");
    resolutions.add("1680x1050");
    resolutions.add("1920x1080");
    resolutions.add("1920x1200");
    // resolutions.add("Full Screen");

    players = new ArrayList<Player>();
    blockManagers = new ArrayList<BlockManager>();
    placeableManagers = new ArrayList<PlaceableManager>();
    monsterManagers = new ArrayList<MonsterManager>();

    // try to load the settings file
    try {
      FileInputStream settingsFile = new FileInputStream("Settings.dat");
      ObjectInputStream settings = new ObjectInputStream(settingsFile);

      version = ((Integer) settings.readObject()).intValue();
      resolution = ((Integer) settings.readObject()).intValue();
      volumeMusic = ((Integer) settings.readObject()).intValue();
      volumeFX = ((Integer) settings.readObject()).intValue();
      buttonMoveRight = ((Integer) settings.readObject()).intValue();
      buttonMoveLeft = ((Integer) settings.readObject()).intValue();
      buttonJump = ((Integer) settings.readObject()).intValue();
      buttonAction = ((Integer) settings.readObject()).intValue();
      buttonRobot = ((Integer) settings.readObject()).intValue();
      buttonInventory = ((Integer) settings.readObject()).intValue();
      buttonPause = ((Integer) settings.readObject()).intValue();

      settings.close();
    } catch (Exception e) {
      EIError.debugMsg(e.getMessage(), EIError.ErrorLevel.Warning);
    }

    if (volumeMusic < -1 || volumeMusic > 10) {
      volumeMusic = 8;
    }
    if (volumeMusic == 0) {
      volumeMusic = 8;
    }
    if (volumeMusic == -1) {
      volumeMusic = 0;
    }

    if (volumeFX < -1 || volumeFX > 10) {
      volumeFX = 8;
    }
    if (volumeFX == 0) {
      volumeFX = 8;
    }
    if (volumeFX == -1) {
      volumeFX = 0;
    }

    if (buttonMoveRight == 0) {
      buttonMoveRight = KeyEvent.VK_D;
    }
    if (buttonMoveLeft == 0) {
      buttonMoveLeft = KeyEvent.VK_A;
    }
    if (buttonJump == 0) {
      buttonJump = KeyEvent.VK_SPACE;
    }
    if (buttonAction == 0) {
      buttonAction = KeyEvent.VK_E;
    }
    if (buttonRobot == 0) {
      buttonRobot = KeyEvent.VK_R;
    }
    if (buttonInventory == 0) {
      buttonInventory = KeyEvent.VK_I;
    }
    if (buttonPause == 0) {
      buttonPause = KeyEvent.VK_P;
    }

    // try to load the players
    for (int i = 1; i <= NUMBER_OF_PLAYER_SLOTS; i++) {
      try {
        FileInputStream playerFile = new FileInputStream("Player" + i + ".dat");
        ObjectInputStream playerInfo = new ObjectInputStream(playerFile);

        version = ((Integer) playerInfo.readObject()).intValue();
        players.add((Player) playerInfo.readObject());
        blockManagers.add((BlockManager) playerInfo.readObject());
        placeableManagers.add((PlaceableManager) playerInfo.readObject());

        MonsterManager mm = null;
        if (version >= 2) {
          mm = (MonsterManager) playerInfo.readObject();
        }
        if (mm == null) {
          mm = new MonsterManager(gc, r);
        }
        monsterManagers.add(mm);

        playerInfo.close();
        EIError.debugMsg("Added Player " + i);
      } catch (Exception e) {
        if (players.size() >= i) {
          players.set(i - 1, null);
        } else {
          players.add(null);
        }
        if (blockManagers.size() >= i) {
          blockManagers.set(i - 1, null);
        } else {
          blockManagers.add(null);
        }
        if (placeableManagers.size() >= i) {
          placeableManagers.set(i - 1, null);
        } else {
          placeableManagers.add(null);
        }
        if (monsterManagers.size() >= i) {
          monsterManagers.set(i - 1, null);
        } else {
          monsterManagers.add(null);
        }
        EIError.debugMsg(
            "Couldn't load Player " + i + " " + e.getMessage(), EIError.ErrorLevel.Error);
      }
    }
  }
Example #19
0
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == butConnect) {
      try {
        boolean ok = serverConnection();
        if (ok) {
          setInitPanel();
        } else {
          System.out.println("Le pseudo existe déjà, choisissez en un autre.");
        }
      } catch (IOException err) {
        System.err.println(
            "Problème de connection avec le serveur: " + err.getMessage() + "\n.Arrêt...");
        System.exit(1);
      }
    } else if (e.getSource() == butListParty) {
      try {
        // envoyer requête LIST PARTY
        oos.writeInt(JungleServer.REQ_LISTPARTY);
        oos.flush();

        // recevoir résultat et l'afficher dans textInfoInit
        System.out.println("flush");
        boolean pret = ois.readBoolean();
        System.out.println(pret);
        if (pret) {
          String nomParty = (String) ois.readObject();
          System.out.println("apres read");
          textInfoInit.append(nomParty + " ");
        }

      } catch (ClassNotFoundException err) {
      } catch (IOException err) {
        System.err.println(
            "Problème de connection avec le serveur: " + err.getMessage() + "\n.Arrêt...");
        System.exit(1);
      }

    } else if (e.getSource() == butCreateParty) {
      try {
        boolean ok;
        // envoyer requête CREATE PARTY (paramètres : nom partie et nb joueurs nécessaires)
        oos.writeInt(JungleServer.REQ_CREATEPARTY);
        oos.writeObject(textCreate.getText());
        int nbJoueurs = (Integer) spinNbPlayer.getValue();
        oos.writeInt(nbJoueurs);
        oos.flush();
        // recevoir résultat -> ok
        ok = ois.readBoolean();
        System.out.println(ok);
        // si ok == true :
        if (ok) {
          // mettre le panneau party au centre
          setPartyPanel();
          // afficher un message dans textInfoParty comme quoi il faut attendre le début de partie
          textInfoParty.append("Attendre le début de la partie");
          // créer un ThreadClient et lancer son exécution
          ThreadClient threadClient = new ThreadClient(this);
          threadClient.start();
        }
      } catch (IOException err) {
        System.err.println(
            "probleme de connection serveur : " + err.getMessage() + "\n.Aborting...");
        System.exit(1);
      }
    } else if (e.getSource() == butJoinParty) {

      try {
        int idPlayer;
        // envoyer requête JOIN PARTY (paramètres : numero partie)
        oos.writeInt(JungleServer.REQ_JOINPARTY);
        oos.flush();
        System.out.println("requete envoyée");
        int numPartie = Integer.parseInt(textJoin.getText());
        oos.writeInt(numPartie);
        oos.flush();
        System.out.println("numPartie flushé");
        // recevoir résultat -> idPlayer
        idPlayer = ois.readInt();
        System.out.println("idplayer reçu : " + idPlayer);
        // si idPlayer >= 1 :
        if (idPlayer >= 1) {
          // mettre le panneau party au centre
          setPartyPanel();
          // afficher un message dans textInfoParty comme quoi il faut attendre le début de partie
          textInfoParty.append("Attendre la début de la partie");
          // créer un ThreadClient et lancer son exécution
          System.out.println("avant démarrage du thread");
          ThreadClient threadClient = new ThreadClient(this);
          threadClient.start();
          System.out.println("Apres le thread");
        }
      } catch (IOException err) {
        System.err.println("Problème de connection serveur: " + err.getMessage() + "\n.Arrêt...");
        System.exit(1);
      }
    } else if (e.getSource() == butPlay) {
      try {
        // envoyer requête PLAY (paramètre : contenu de textPlay)
        oos.writeInt(JungleServer.REQ_PLAY);
        oos.writeObject(textPlay.getText());
        oos.flush();
        orderSent = true;
        butPlay.setEnabled(false);
        textPlay.setEnabled(false);

        // mettre orderSent à true
        // bloquer le bouton play et le textfiled associé
      } catch (IOException err) {
        System.err.println("Problème connection serveur: " + err.getMessage() + "\n.Arrêt...");
        System.exit(1);
      }
    } else if (e.getSource() == butQuit) {
      try {
        oos.close();
        ois.close();
        setConnectionPanel();
        comm = null;
      } catch (IOException err) {
        System.err.println("Problème connection serveur: " + err.getMessage() + "\n.Arrêt...");
        System.exit(1);
      }
    }
  }
 /** Прочитывает файл, который хранит долговременную информацию */
 public static void readData() throws IOException, ClassNotFoundException {
   ObjectInputStream ois =
       new ObjectInputStream(new FileInputStream(ApplicationProperties.BUY_FILE));
   instance = (ApplicationService) ois.readObject();
   if (instance.images == null) instance.images = new HashMap<>();
 }
Example #21
0
  public fileBackupProgram(JFrame frame) {
    super(new BorderLayout());
    this.frame = frame;

    errorDialog = new CustomDialog(frame, "Please enter a new name for the error log", this);
    errorDialog.pack();

    moveDialog = new CustomDialog(frame, "Please enter a new name for the move log", this);
    moveDialog.pack();

    printer = new FilePrinter();
    timers = new ArrayList<>();
    log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    JScrollPane logScrollPane = new JScrollPane(log);
    Object obj;
    copy = true;
    listModel = new DefaultListModel();
    // destListModel = new DefaultListModel();
    directoryList = new directoryStorage();

    // Create a file chooser
    fc = new JFileChooser();

    // Create the menu bar.
    menuBar = new JMenuBar();

    // Build the first menu.
    menu = new JMenu("File");
    menu.getAccessibleContext()
        .setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    editError = new JMenuItem("Save Error Log As...");
    editError
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the error log file");
    editError.addActionListener(new ErrorListener());
    menu.add(editError);

    editMove = new JMenuItem("Save Move Log As...");
    editMove
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the move log file");
    editMove.addActionListener(new MoveListener());
    menu.add(editMove);

    exit = new JMenuItem("Exit");
    exit.getAccessibleContext().setAccessibleDescription("Exit the Program");
    exit.addActionListener(new CloseListener());
    menu.add(exit);
    frame.setJMenuBar(menuBar);
    // Uncomment one of the following lines to try a different
    // file selection mode.  The first allows just directories
    // to be selected (and, at least in the Java look and feel,
    // shown).  The second allows both files and directories
    // to be selected.  If you leave these lines commented out,
    // then the default mode (FILES_ONLY) will be used.
    //
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    openButton = new JButton(openString);
    openButton.setActionCommand(openString);
    openButton.addActionListener(new OpenListener());

    destButton = new JButton(destString);
    destButton.setActionCommand(destString);
    destButton.addActionListener(new DestListener());

    // Create the save button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    saveButton = new JButton(saveString);
    saveButton.setActionCommand(saveString);
    saveButton.addActionListener(new SaveListener());

    URL imageURL = getClass().getResource(greenButtonIcon);
    ImageIcon greenSquare = new ImageIcon(imageURL);
    startButton = new JButton("Start", greenSquare);
    startButton.setSize(60, 20);
    startButton.setHorizontalTextPosition(AbstractButton.LEADING);
    startButton.setActionCommand("Start");
    startButton.addActionListener(new StartListener());

    imageURL = getClass().getResource(redButtonIcon);
    ImageIcon redSquare = new ImageIcon(imageURL);
    stopButton = new JButton("Stop", redSquare);
    stopButton.setSize(60, 20);
    stopButton.setHorizontalTextPosition(AbstractButton.LEADING);
    stopButton.setActionCommand("Stop");
    stopButton.addActionListener(new StopListener());

    copyButton = new JRadioButton("Copy");
    copyButton.setActionCommand("Copy");
    copyButton.setSelected(true);
    copyButton.addActionListener(new RadioListener());

    moveButton = new JRadioButton("Move");
    moveButton.setActionCommand("Move");
    moveButton.addActionListener(new RadioListener());

    ButtonGroup group = new ButtonGroup();
    group.add(copyButton);
    group.add(moveButton);

    // For layout purposes, put the buttons in a separate panel

    JPanel optionPanel = new JPanel();

    GroupLayout layout = new GroupLayout(optionPanel);
    optionPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout.createSequentialGroup().addComponent(copyButton).addComponent(moveButton));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(copyButton)
                    .addComponent(moveButton)));

    JPanel buttonPanel = new JPanel(); // use FlowLayout

    layout = new GroupLayout(buttonPanel);
    buttonPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(openButton)
                    .addComponent(optionPanel))
            .addComponent(destButton)
            .addComponent(startButton)
            .addComponent(stopButton)
        // .addComponent(saveButton)
        );
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(openButton)
                    .addComponent(destButton)
                    .addComponent(startButton)
                    .addComponent(stopButton)
                // .addComponent(saveButton)
                )
            .addComponent(optionPanel));

    buttonPanel.add(optionPanel);
    /*
    buttonPanel.add(openButton);
    buttonPanel.add(destButton);
    buttonPanel.add(startButton);
    buttonPanel.add(stopButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(listLabel);
    buttonPanel.add(copyButton);
    buttonPanel.add(moveButton);
    */
    destButton.setEnabled(false);
    startButton.setEnabled(false);
    stopButton.setEnabled(false);

    // Add the buttons and the log to this panel.

    // add(logScrollPane, BorderLayout.CENTER);

    JLabel listLabel = new JLabel("Monitored Directory:");
    listLabel.setLabelFor(list);

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(8);
    JScrollPane listScrollPane = new JScrollPane(list);
    JPanel listPane = new JPanel();
    listPane.setLayout(new BorderLayout());

    listPane.add(listLabel, BorderLayout.PAGE_START);
    listPane.add(listScrollPane, BorderLayout.CENTER);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    // monitored, destination, waitInt, check

    destination = new JLabel("Destination Directory: ");

    waitField = new JFormattedTextField();
    // waitField.setValue(240);
    waitField.setEditable(false);
    waitField.addPropertyChangeListener(new FormattedTextListener());

    waitInt = new JLabel("Wait Interval (in minutes)");
    // waitInt.setLabelFor(waitField);

    checkField = new JFormattedTextField();
    checkField.setSize(1, 10);
    // checkField.setValue(60);
    checkField.setEditable(false);
    checkField.addPropertyChangeListener(new FormattedTextListener());

    check = new JLabel("Check Interval (in minutes)");
    // check.setLabelFor(checkField);

    fireButton = new JButton(fireString);
    fireButton.setActionCommand(fireString);
    fireButton.addActionListener(new FireListener());

    JPanel fieldPane = new JPanel();
    // fieldPane.add(destField);
    layout = new GroupLayout(fieldPane);
    fieldPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitInt)
                    .addComponent(check))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitField, 60, 60, 60)
                    .addComponent(checkField, 60, 60, 60)));

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(waitInt)
                    .addComponent(waitField))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(check)
                    .addComponent(checkField)));

    JPanel labelPane = new JPanel();

    labelPane.setLayout(new BorderLayout());

    labelPane.add(destination, BorderLayout.PAGE_START);
    labelPane.add(fieldPane, BorderLayout.CENTER);

    layout = new GroupLayout(labelPane);
    labelPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(destination)
                    .addComponent(fieldPane)));

    layout.setVerticalGroup(
        layout.createSequentialGroup().addComponent(destination).addComponent(fieldPane));
    // labelPane.add(destination);
    // labelPane.add(fieldPane);

    try {
      // Read from disk using FileInputStream
      FileInputStream f_in = new FileInputStream(LOG_DIRECTORY + "\\save.data");

      // Read object using ObjectInputStream
      ObjectInputStream obj_in = new ObjectInputStream(f_in);

      // Read an object
      directoryList = (directoryStorage) obj_in.readObject();
      ERROR_LOG_NAME = (String) obj_in.readObject();
      MOVE_LOG_NAME = (String) obj_in.readObject();

      if (ERROR_LOG_NAME instanceof String) {
        printer.changeErrorLogName(ERROR_LOG_NAME);
      }

      if (MOVE_LOG_NAME instanceof String) {
        printer.changeMoveLogName(MOVE_LOG_NAME);
      }

      if (directoryList instanceof directoryStorage) {
        System.out.println("found object");
        // directoryList = (directoryStorage) obj;

        Iterator<Directory> directories = directoryList.getDirectories();
        Directory d;
        while (directories.hasNext()) {
          d = directories.next();

          try {
            listModel.addElement(d.getDirectory().toRealPath());
          } catch (IOException x) {
            printer.printError(x.toString());
          }

          int index = list.getSelectedIndex();
          if (index == -1) {
            list.setSelectedIndex(0);
          }

          index = list.getSelectedIndex();
          Directory dir = directoryList.getDirectory(index);

          destButton.setEnabled(true);
          checkField.setValue(dir.getInterval());
          waitField.setValue(dir.getWaitInterval());
          checkField.setEditable(true);
          waitField.setEditable(true);

          // directoryList.addNewDirectory(d);
          // try {
          // listModel.addElement(d.getDirectory().toString());
          // } catch (IOException x) {
          // printer.printError(x.toString());
          // }

          // timer = new Timer();
          // timer.schedule(new CopyTask(d.directory, d.destination, d.getWaitInterval(), printer,
          // d.copy), 0, d.getInterval());
        }

      } else {
        System.out.println("did not find object");
      }
      obj_in.close();
    } catch (ClassNotFoundException x) {
      printer.printError(x.getLocalizedMessage());
      System.err.format("Unable to read");
    } catch (IOException y) {
      printer.printError(y.getLocalizedMessage());
    }

    // Layout the text fields in a panel.

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(buttonPanel, BorderLayout.PAGE_START);
    add(listPane, BorderLayout.LINE_START);
    // add(destListScrollPane, BorderLayout.CENTER);

    add(fieldPane, BorderLayout.LINE_END);
    add(labelPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
  }
  /**
   * waitForConnection waits for incomming connections. There are two cases. If we receive a
   * JoinNetworkRequest it means that a new peer tries to get into the network. We lock the entire
   * system, and sends a ConnectionData object to the new peer, from which he can connect to every
   * other peer. We add this new peer to our data.
   *
   * <p>If we receive a NewPeerDataRequest, it means that a new peer has received ConnectionData
   * from another peer in the network, and he is now trying to connect to everyone, including me. We
   * then update our data with the new peer.
   */
  private void waitForConnection() {
    while (active) {
      Socket client = waitForConnectionFromClient();
      if (client != null) {
        try {
          ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
          ObjectInputStream input = new ObjectInputStream(client.getInputStream());
          Object o = input.readObject();

          if (o instanceof JoinNetworkRequest) {
            JoinNetworkRequest request = (JoinNetworkRequest) o;
            dec.sendObjectToAllPeers(new LockRequest(lc.getTimeStamp()));
            waitForAllToLock();
            setLocked(true);
            Thread.sleep(500);
            int id = getNewId();
            Peer p =
                new Peer(
                    editor,
                    er,
                    id,
                    client,
                    output,
                    input,
                    lc,
                    client.getInetAddress().getHostAddress(),
                    request.getPort());
            ConnectionData cd =
                new ConnectionData(
                    er.getEventHistory(),
                    er.getAcknowledgements(),
                    er.getCarets(),
                    id,
                    area1.getText(),
                    lc.getTimeStamp(),
                    lc.getID(),
                    dec.getPeers(),
                    serverSocket.getLocalPort());
            p.writeObjectToStream(cd);
            dec.addPeer(p);
            Thread t = new Thread(p);
            t.start();
            er.addCaretPos(id, 0);
          } else if (o instanceof NewPeerDataRequest) {
            NewPeerDataRequest request = (NewPeerDataRequest) o;
            Peer newPeer =
                new Peer(
                    editor,
                    er,
                    request.getId(),
                    client,
                    output,
                    input,
                    lc,
                    client.getInetAddress().getHostAddress(),
                    request.getPort());
            dec.addPeer(newPeer);
            er.addCaretPos(request.getId(), request.getCaretPos());
            newPeer.writeObjectToStream(new NewPeerDataAcknowledgement(lc.getTimeStamp()));
            Thread t = new Thread(newPeer);
            t.start();
          }
        } catch (IOException | ClassNotFoundException | InterruptedException e) {
          e.printStackTrace();
        }
      }
    }
  }
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == jbSaveLayer) {
      try {
        FileOutputStream fout = new FileOutputStream(jtfCengMing.getText() + ".wyf");
        ObjectOutputStream oout = new ObjectOutputStream(fout);
        oout.writeObject(itemArray);
        oout.close();
        fout.close();
      } catch (Exception ea) {
        ea.printStackTrace();
      }
    } else if (e.getSource() == jbLoadLayer) {
      try {
        FileInputStream fin = new FileInputStream(jtfCengMing.getText() + ".wyf");
        ObjectInputStream oin = new ObjectInputStream(fin);
        itemArray = (Item[][]) oin.readObject();

        oin.close();
        fin.close();
        this.flush();
      } catch (Exception ea) {
        ea.printStackTrace();
      }
      lvp.repaint();
    } else if (e.getSource() == jbLoadAll) { // 全部铺上当前选中

      for (int row = 0; row < 40; row++) {
        for (int col = 0; col < 60; col++) {
          Item item = ((Item) (jl.getSelectedValue())).clone();
          itemArray[row][col] = item;
          if (item != null) {
            item.setPosition(col, row);
          }
        }
      }

      lvp.repaint();
    } else if (e.getSource() == jbCreate) { // 生成源代码

      try {
        FileOutputStream fout = null;
        DataOutputStream dout = null;
        fout = new FileOutputStream("maps.so");
        dout = new DataOutputStream(fout);
        int totalBlocks = 0;

        for (int i = 0; i < 40; i++) {
          for (int j = 0; j < 60; j++) {
            Item item = itemArray[i][j];
            if (item != null) {
              totalBlocks++;
            }
          }
        }
        System.out.println("totalBlocks=" + totalBlocks);

        // 写入不空块的数量
        dout.writeInt(totalBlocks);

        for (int i = 0; i < 40; i++) {
          for (int j = 0; j < 60; j++) {
            Item item = itemArray[i][j];
            if (item != null) {
              int w = item.w; // 元素的图片宽度
              int h = item.h; // 元素的图片高度
              int col = item.col; // 元素的地图列
              int row = item.row; // 元素的地图行
              int pCol = item.pCol; // 元素的占位列
              int pRow = item.pRow; // 元素的占位行
              String leiMing = item.leiMing; // 类名

              int[][] notIn = item.notIn; // 不可通过
              int[][] keYu = item.keYu; // 可遇矩阵

              // 计算图片下标
              int outBitmapInxex = 0;
              if (leiMing.equals("Grass")) {
                outBitmapInxex = 0;
              } else if (leiMing.equals("XiaoHua1")) {
                outBitmapInxex = 1;
              } else if (leiMing.equals("MuZhuang")) {
                outBitmapInxex = 2;
              } else if (leiMing.equals("XiaoHua2")) {
                outBitmapInxex = 3;
              } else if (leiMing.equals("Road")) {
                outBitmapInxex = 4;
              } else if (leiMing.equals("Jing")) {
                outBitmapInxex = 5;
              }

              dout.writeByte(outBitmapInxex); // 记录图片下标
              dout.writeByte(0); // 记录可遇标志 0-不可遇 底层都不可遇
              dout.writeByte(w); // 图片宽度
              dout.writeByte(h); // 图片高度
              dout.writeByte(col); // 总列数
              dout.writeByte(row); // 总行数
              dout.writeByte(pCol); // 占位列
              dout.writeByte(pRow); // 占位行

              int bktgCount = notIn.length; // 不可通过点的数量
              dout.writeByte(bktgCount); // 写入不可通过点的数量

              for (int k = 0; k < bktgCount; k++) {
                dout.writeByte(notIn[k][0]);
                dout.writeByte(notIn[k][1]);
              }
            }
          }
        }

        dout.close();
        fout.close();

      } catch (Exception ea) {
        ea.printStackTrace();
      }
    }
  }
Example #24
0
  public void actionPerformed(ActionEvent e) {
    System.out.println("actionPerformed");
    if (e.getSource() == pen) // 画笔
    {
      System.out.println("pen");
      toolFlag = 0;
    }

    if (e.getSource() == eraser) // 橡皮
    {
      System.out.println("eraser");
      toolFlag = 1;
    }

    if (e.getSource() == clear) // 清除
    {
      System.out.println("clear");
      toolFlag = 2;
      paintInfo.removeAllElements();
      repaint();
    }

    if (e.getSource() == drLine) // 画线
    {
      System.out.println("drLine");
      toolFlag = 3;
    }

    if (e.getSource() == drCircle) // 画圆
    {
      System.out.println("drCircle");
      toolFlag = 4;
    }

    if (e.getSource() == drRect) // 画矩形
    {
      System.out.println("drRect");
      toolFlag = 5;
    }

    if (e.getSource() == colchooser) // 调色板
    {
      System.out.println("colchooser");
      Color newColor = JColorChooser.showDialog(this, "我的调色板", c);
      c = newColor;
    }

    if (e.getSource() == openPic) // 打开图画
    {

      openPicture.setVisible(true);

      if (openPicture.getFile() != null) {
        int tempflag;
        tempflag = toolFlag;
        toolFlag = 2;
        repaint();

        try {
          paintInfo.removeAllElements();
          File filein = new File(openPicture.getDirectory(), openPicture.getFile());
          picIn = new FileInputStream(filein);
          VIn = new ObjectInputStream(picIn);
          paintInfo = (Vector) VIn.readObject();
          VIn.close();
          repaint();
          toolFlag = tempflag;

        } catch (ClassNotFoundException IOe2) {
          repaint();
          toolFlag = tempflag;
          System.out.println("can not read object");
        } catch (IOException IOe) {
          repaint();
          toolFlag = tempflag;
          System.out.println("can not read file");
        }
      }
    }

    if (e.getSource() == savePic) // 保存图画
    {
      savePicture.setVisible(true);
      try {
        File fileout = new File(savePicture.getDirectory(), savePicture.getFile());
        picOut = new FileOutputStream(fileout);
        VOut = new ObjectOutputStream(picOut);
        VOut.writeObject(paintInfo);
        VOut.close();
      } catch (IOException IOe) {
        System.out.println("can not write object");
      }
    }
  }
Example #25
0
  /**
   * Class that contains the main function which creates the window for the game and implements the
   * server/client socket
   */
  @SuppressWarnings("deprecation")
  public static void main(String args[]) {
    int i = -1; // Variable to keep track of the result from the game

    do // Do-while loop
    {

      try {
        JFrame frame = getFrame(); // Create the frame

        // Dialog to get the name from the player as string, put the string in a label
        String sname = returnNameString();
        JLabel label = new JLabel(sname);

        // Create the status bar panel and shove it down the bottom of the frame
        JPanel statusPanel = new JPanel();
        statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
        statusPanel.setBackground(Color.red);
        frame.add(statusPanel, BorderLayout.SOUTH);

        // Create a label, placed at the bottom of the frame
        JLabel statusLabel = new JLabel();
        statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
        statusPanel.add(statusLabel);
        Button clearButton = new Button("Clear"); // Creating a "clear" button
        clearButton.setSize(new Dimension(10, 20));
        statusPanel.add(label);
        statusPanel.add(clearButton); // Adding the button to the panel

        statusPanel.add(getTime()); // Adding the clock to the status panel

        frame.setVisible(true);

        char ch;
        if (args.length == 0) ch = 'O';
        else ch = 'X';

        TicTacPanel ticTacPanel = new TicTacPanel(ch); // Create a panel for the game
        TicTacAction ticTacAction = new TicTacAction(ticTacPanel); // Handle actions in the game

        clearButton.addActionListener(ticTacAction);
        ticTacPanel.addMouseListener(ticTacAction);
        frame.add(ticTacPanel);
        frame.show();

        // Creating socket and I/O stream objects
        Socket s;
        ObjectOutputStream oops;
        ObjectInputStream oips;

        switch (ch) {
          case 'O':
            s = (new ServerSocket(7777)).accept();
            oops = new ObjectOutputStream(s.getOutputStream());
            oops.writeObject(ticTacPanel.ttt);
            ticTacAction.ready = false;
            break;
          case 'X':
          default:
            s = new Socket(args[0], 7777);
            ticTacAction.ready = true;
        }
        while (true) // Infinite loop
        {
          oips = new ObjectInputStream(s.getInputStream());
          ticTacPanel.ttt = (TicTacGame) (oips.readObject());
          ticTacPanel.paint(ticTacPanel.getGraphics());
          ticTacAction.ready = true;
          while (ticTacAction.ready) {
            Thread.sleep(100);
          }
          oops = new ObjectOutputStream(s.getOutputStream());
          oops.writeObject(ticTacPanel.ttt);

          i = ticTacPanel.ttt.checkWin(); // Check if there's a winner
          if (i == 1) // A winner is declared
          {
            TicTacPanel.infoBox("The winner is " + sname + "!", "Game Over");
            ticTacPanel.ttt.clearAll();
            ticTacPanel.paint(ticTacPanel.getGraphics());
          } else if (i == 0) // No winner, but every square is covered so the game is done
          {
            TicTacPanel.infoBox("We have a tie!", "Game Over");
            ticTacPanel.ttt.clearAll();
            ticTacPanel.paint(ticTacPanel.getGraphics());
          }
        }
      } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        System.exit(1);
      }
    } while (i == -1); // End of do-while loop
  }
Example #26
0
 public void run() {
   while (connected) {
     try {
       Object obj = in.readObject();
       if (obj.toString().equals("-101")) {
         connected = false;
         in.close();
         out.close();
         socket.close();
         SwingUtilities.invokeLater(
             new Runnable() {
               public void run() {
                 Cashier.closee = true;
                 JOptionPane.showMessageDialog(
                     null,
                     "Disconnected from server. Please Restart",
                     "Error:",
                     JOptionPane.PLAIN_MESSAGE);
                 try {
                   m.stop();
                 } catch (Exception w) {
                 }
               }
             });
       } else if (obj.toString().split("::")[0].equals("broadcast")) {
         // System.out.println("braodcast received");
         bc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else if (obj.toString().split("::")[0].equals("chat")) {
         // System.out.println("chat received:
         // "+obj.toString().substring(obj.toString().indexOf("::")+2));
         cc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else if (obj.toString().split("::")[0].equals("rankings")) {
         String hhh = obj.toString().split("::")[1];
         final JDialog jd = new JDialog();
         jd.setUndecorated(false);
         JPanel pan = new JPanel(new BorderLayout());
         JLabel ppp = new JLabel();
         ppp.setFont(new Font("Arial", Font.BOLD, 20));
         ppp.setText(
             "<html><pre>Thanks for playing !!!<br/>1st: "
                 + hhh.split(":")[0]
                 + "<br/>2nd: "
                 + hhh.split(":")[1]
                 + "<br/>3rd: "
                 + hhh.split(":")[2]
                 + "</pre></html>");
         pan.add(ppp, BorderLayout.CENTER);
         JButton ok = new JButton("Ok");
         ok.addActionListener(
             new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                 jd.setVisible(false);
                 try {
                   m.stop();
                 } catch (Exception w) {
                 }
               }
             });
         pan.add(ok, BorderLayout.SOUTH);
         jd.setContentPane(pan);
         jd.setModalityType(JDialog.ModalityType.APPLICATION_MODAL);
         jd.pack();
         jd.setLocationRelativeTo(null);
         jd.setVisible(true);
       } else if (obj.toString().split("::")[0].equals("rank")) {
         rc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else {
         User hhh = null;
         try {
           hhh = (User) obj;
           /*if(usrD==1)
           {
               reply=obj;
               ccl.interrupt();
           }
           else*/
           {
             try {
               m.ur.changeData((User) obj);
             } catch (Exception w) {
               try {
                 maain.ur.changeData((User) obj);
               } catch (Exception ppp) {
                 ppp.printStackTrace();
               }
             }
           }
         } catch (Exception p) {
           int iid = -1;
           try {
             iid = Integer.parseInt(obj.toString());
             obj = in.readObject();
             if (obj.toString().equals("-102")) {
               // ccl.interrupt();
               SwingUtilities.invokeLater(
                   new Runnable() {
                     public void run() {
                       Cashier.closee = true;
                       JOptionPane.showMessageDialog(
                           null, "Server Not Running.", "Error:", JOptionPane.PLAIN_MESSAGE);
                     }
                   });
             }
             // Thread th = ((Thread)rev.remove(iid));
             rev2.put(iid, obj);
             // System.out.println("Put: "+iid+"   :   "+obj.toString()+"   :
             // "+Thread.currentThread());
             // th.interrupt();
             // ccl.interrupt();
           } catch (Exception ppp) {
               /*ppp.printStackTrace();*/
             System.out.println(
                 "Shit: "
                     + iid
                     + "   :   "
                     + obj.toString()
                     + "   :   "
                     + Thread.currentThread());
           }
         }
       }
       try {
         Thread.sleep(500);
       } catch (Exception n) {
       }
     } catch (Exception m) {
     }
   }
 }
 private void readObject(ObjectInputStream aInputStream) throws Exception {
   aInputStream.defaultReadObject();
 }
    /** Background thread used to receive data from the server. */
    public void run() {
      Long id;
      Integer message_type;
      String target;
      String soap;
      SOAPMonitorData data;
      int selected;
      int row;
      boolean update_needed;
      while (socket != null) {
        try {
          // Get the data from the server
          message_type = (Integer) in.readObject();
          // Process the data depending on its type
          switch (message_type.intValue()) {
            case SOAPMonitorConstants.SOAP_MONITOR_REQUEST:
              // Get the id, target and soap info
              id = (Long) in.readObject();
              target = (String) in.readObject();
              soap = (String) in.readObject();
              // Add new request data to the table
              data = new SOAPMonitorData(id, target, soap);
              model.addData(data);
              // If "most recent" selected then update
              // the details area if needed
              selected = table.getSelectedRow();
              if ((selected == 0) && model.filterMatch(data)) {
                valueChanged(null);
              }
              break;
            case SOAPMonitorConstants.SOAP_MONITOR_RESPONSE:
              // Get the id and soap info
              id = (Long) in.readObject();
              soap = (String) in.readObject();
              data = model.findData(id);
              if (data != null) {
                update_needed = false;
                // Get the selected row
                selected = table.getSelectedRow();
                // If "most recent", then always
                // update details area
                if (selected == 0) {
                  update_needed = true;
                }
                // If the data being updated is
                // selected then update details
                row = model.findRow(data);
                if ((row != -1) && (row == selected)) {
                  update_needed = true;
                }
                // Set the response and update table
                data.setSOAPResponse(soap);
                model.updateData(data);
                // Refresh details area (if needed)
                if (update_needed) {
                  valueChanged(null);
                }
              }
              break;
          }

        } catch (Exception e) {
          // Exceptions are expected here when the
          // server communication has been terminated.
          if (stop_button.isEnabled()) {
            stop();
            setErrorStatus(STATUS_CLOSED);
          }
        }
      }
    }
 /** Restores a serialized object. */
 private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
   s.defaultReadObject();
   valueDrawer = defaultValueDrawer;
 }