/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
  /**
   * remove member from the game. Also updates game's client version range, with remaining connected
   * members. Please call {@link #takeMonitorForGame(String)} before calling this.
   *
   * @param gaName the name of the game
   * @param conn the member's connection
   */
  public synchronized void removeMember(StringConnection conn, String gaName) {
    System.err.println("L139: game " + gaName + " remove " + conn); // JM TEMP
    Vector members = getMembers(gaName);

    if ((members != null)) {
      members.removeElement(conn);

      // Check version of remaining members
      if (!members.isEmpty()) {
        StringConnection c = (StringConnection) members.firstElement();
        int lowVers = c.getVersion();
        int highVers = lowVers;
        for (int i = members.size() - 1; i > 1; --i) {
          c = (StringConnection) members.elementAt(i);
          int v = c.getVersion();
          if (v < lowVers) lowVers = v;
          if (v > highVers) highVers = v;
        }
        SOCGame ga = getGameData(gaName);
        ga.clientVersionLowest = lowVers;
        ga.clientVersionHighest = highVers;
        ga.hasOldClients = (lowVers < Version.versionNumber());
      }
    }
  }
Esempio n. 3
1
 public void undo() {
   if (moveHistory.size() > 0) {
     unmove((Move) moveHistory.lastElement());
     moveHistory.removeElement(moveHistory.lastElement());
   } else {
     controller.alert("You haven't made any moves yet!");
   }
 }
  /** Close an audio channel. */
  public synchronized void closeChannel(InputStream in) {

    if (DEBUG) {
      System.out.println("AudioDevice.closeChannel");
    }

    if (in == null) return; // can't go anywhere here!

    Info info;

    for (int i = 0; i < infos.size(); i++) {

      info = (AudioDevice.Info) infos.elementAt(i);

      if (info.in == in) {

        if (info.sequencer != null) {

          info.sequencer.stop();
          // info.sequencer.close();
          infos.removeElement(info);

        } else if (info.datapusher != null) {

          info.datapusher.stop();
          infos.removeElement(info);
        }
      }
    }
    notify();
  }
  /** Close streams */
  public synchronized void closeStreams() {

    Info info;

    for (int i = 0; i < infos.size(); i++) {

      info = (AudioDevice.Info) infos.elementAt(i);

      if (info.sequencer != null) {

        info.sequencer.stop();
        info.sequencer.close();
        infos.removeElement(info);

      } else if (info.datapusher != null) {

        info.datapusher.stop();
        infos.removeElement(info);
      }
    }

    if (DEBUG) {
      System.err.println("Audio Device: Streams all closed.");
    }
    // Empty the hash table.
    clipStreams = new Hashtable();
    infos = new Vector();
  }
Esempio n. 6
0
  /**
   * Tries to add a reuseable connection to the connection pool. Replace any not in use connections
   * to the same host and port. Will not add to the same host and port in use. Will replace oldest
   * not in use element (if any) if the pool is full.
   *
   * @param p_protocol The protocol for the connection
   * @param p_host The Hostname for the connection
   * @param p_port The port number for the connection
   * @param sc The base stream connection
   * @param dos The data output stream from the base connection
   * @param dis The data input stream from the base connection
   * @return true if the connection was added, otherwise false
   */
  synchronized boolean add(
      String p_protocol,
      String p_host,
      int p_port,
      StreamConnection sc,
      DataOutputStream dos,
      DataInputStream dis) {

    StreamConnectionElement oldestNotInUse = null;

    // find the last unused element
    Enumeration cons = m_connections.elements();
    while (cons.hasMoreElements()) {
      StreamConnectionElement sce = (StreamConnectionElement) cons.nextElement();

      if (sce.m_in_use) {
        if (p_host.equals(sce.m_host) && p_port == sce.m_port) {
          return false;
        }

        continue;
      }

      // if the connection is a duplicate, delete it
      if (p_host.equals(sce.m_host) && p_port == sce.m_port) {
        // no protocol duplicates on host and port
        sce.close();
        m_connections.removeElement(sce);
        break;
      } else {
        if (oldestNotInUse == null || sce.m_time < oldestNotInUse.m_time) {
          // save the oldest not in use, it may be removed later
          oldestNotInUse = sce;
        }
      }
    }

    /*
     * first check and see if the maximum number of connections
     * has been reached - if so delete the first one in the list (FIFO)
     *   or
     * if this port and host are already in the pool.
     */
    if (m_connections.size() >= m_max_connections) {
      if (oldestNotInUse == null) {
        return false;
      }

      oldestNotInUse.close();
      m_connections.removeElement(oldestNotInUse);
    }

    m_connections.addElement(new StreamConnectionElement(p_protocol, p_host, p_port, sc, dos, dis));
    return true;
  }
Esempio n. 7
0
 public void removeUserAction(UserAction action) {
   Vector userEvents = action.getUserEvents();
   for (Iterator iterator = userEvents.iterator(); iterator.hasNext(); ) {
     UserEvent userEvent = (UserEvent) iterator.next();
     if (action.mustStartAndStop()) {
       if (userEvent.isMouseActivated()) {
         if (userEvent.isMouseWheelEvent()) {
           mouseWheelEvents.removeElement(userEvent);
         } else {
           mousePressedEvents.removeElement(userEvent);
           mouseReleasedEvents.removeElement(userEvent);
         }
       } else {
         keyPressedEvents.removeElement(userEvent);
         keyReleasedEvents.removeElement(userEvent);
       }
     } else {
       if (userEvent.isMouseActivated()) {
         if (userEvent.isMouseWheelEvent()) {
           mouseWheelEvents.removeElement(userEvent);
         } else {
           mousePressedEvents.removeElement(userEvent);
         }
       } else {
         keyPressedEvents.removeElement(userEvent);
       }
     }
   }
 }
 public ChargeResultInfo getElement(int index) {
   synchronized (queue) {
     ChargeResultInfo item = queue.get(index);
     queue.removeElement(item);
     return item;
   }
 }
Esempio n. 9
0
 private boolean isChecked(String uin) {
   if (validUins.contains(uin)) {
     validUins.removeElement(uin);
     return true;
   }
   return false;
 }
Esempio n. 10
0
 /**
  * Removes display object from the container by Id.
  *
  * @param displayId ID of the display
  * @return true if display has been succcessfully removed, false, if display object has not been
  *     found in the container.
  */
 public synchronized boolean removeDisplayById(int displayId) {
   DisplayAccess da = findDisplayById(displayId);
   if (da != null) {
     return displays.removeElement(da);
   }
   return false;
 }
Esempio n. 11
0
 /**
  * Remove changelistener.
  *
  * @param l changelistener
  */
 public synchronized void removeChangeListener(ChangeListener l) {
   if (changeListeners != null && changeListeners.contains(l)) {
     Vector v = (Vector) changeListeners.clone();
     v.removeElement(l);
     changeListeners = v;
   }
 }
Esempio n. 12
0
 /**
  * Removes a figure from the composite.
  *
  * @see #removeAll
  */
 public Figure remove(Figure figure) {
   if (fFigures.contains(figure)) {
     figure.removeFromContainer(this);
     fFigures.removeElement(figure);
   }
   return figure;
 }
  public Vector put(Range holder, Object value) {
    int pos = VectorUtil.binarySearch(ranges, holder, rangeComparator, true);
    if (pos == -1) {
      pos = 0;
    }
    Vector output = new Vector();

    int posHigh =
        VectorUtil.binarySearch(
            ranges, new RangeHolder(holder.getHigh(), holder.getHigh()), rangeComparator, true);

    Vector purged = new Vector();
    boolean positionRemoved = false;
    for (int i = (pos - 1 >= 0 ? pos - 1 : 0); i < posHigh && i < ranges.size(); i++) {
      Range clobberMe = (Range) ranges.elementAt(i);
      if (overlaps(clobberMe, holder)) {
        if (i == pos - 1) positionRemoved = true;
        output.addElement(data.remove(clobberMe));
        purged.addElement(clobberMe);
      }
    }
    for (int i = 0; i < purged.size(); i++) ranges.removeElement(purged.elementAt(i));

    if (positionRemoved) pos = pos - 1;

    ranges.insertElementAt(holder, pos);
    data.put(holder, value);
    return output;
  }
Esempio n. 14
0
 /**
  * Return a copy of the current membership minus the suspected members: FLUSH request is not sent
  * to suspected members (because they won't respond, and not to joining members either. It IS sent
  * to leaving members (before they are allowed to leave).
  */
 Vector computeFlushDestination(Vector suspected_mbrs) {
   Vector ret = members.getMembers(); // *copy* of current membership
   if (suspected_mbrs != null && suspected_mbrs.size() > 0)
     for (int i = 0; i < suspected_mbrs.size(); i++)
       ret.removeElement(suspected_mbrs.elementAt(i));
   return ret;
 }
  /** @param container */
  public void closeContainer(SshToolsApplicationContainer container) {
    if (log.isDebugEnabled()) {
      log.debug("Asking " + container + " if it can close");
    }

    if (container.getApplicationPanel().canClose()) {
      if (log.isDebugEnabled()) {
        log.debug("Closing");

        for (Iterator i = containers.iterator(); i.hasNext(); ) {
          log.debug(i.next() + " is currently open");
        }
      }

      container.getApplicationPanel().close();
      container.closeContainer();
      containers.removeElement(container);

      if (containers.size() == 0) {
        exit(true);
      } else {
        log.debug("Not closing completely because there are containers still open");

        for (Iterator i = containers.iterator(); i.hasNext(); ) {
          log.debug(i.next() + " is still open");
        }
      }
    }
  }
Esempio n. 16
0
 /** Brings a figure to the front. */
 public synchronized void bringToFront(Figure figure) {
   if (fFigures.contains(figure)) {
     fFigures.removeElement(figure);
     fFigures.addElement(figure);
     figure.changed();
   }
 }
Esempio n. 17
0
 public void checkAllPorters() {
   for (int i = 0; i < m_porters.size(); i++) {
     CMPPXMLPorter porter = (CMPPXMLPorter) m_porters.elementAt(i);
     if (!porter.isRunning()) m_porters.removeElement(porter);
     else porter.checkTimeout();
   }
 }
Esempio n. 18
0
  /**
   * Handle the closing of a tag.
   *
   * @param g Graphics used to retrieve the font metrics.
   * @param tag The closing tag without '</' and '>'.
   * @return A new TextToken corresponding to the new state.
   */
  private TextToken closeTag(Graphics g, String tag) {
    TextToken textTok = new TextToken();
    int i = m_heap.size() - 1;
    char c = tag.charAt(0);
    String prevTag;

    m_heap.removeElement(tag);

    if (c == 'b') m_style &= ~Font.BOLD;
    else if (c == 'i') m_style &= ~Font.ITALIC;

    if (isGfx(c)) {
      while (i-- > 0) { // find previous Tag of the same type in the heap
        prevTag = (String) m_heap.elementAt(i);

        if (prevTag.charAt(0) == c) {
          return updateGfx(g, prevTag);
        }
      }
    }
    textTok.m_font = new Font(m_name, m_style, m_size);
    g.setFont(textTok.m_font);

    return textTok;
  }
Esempio n. 19
0
 /** Sends a figure to the back of the drawing. */
 public synchronized void sendToBack(Figure figure) {
   if (fFigures.contains(figure)) {
     fFigures.removeElement(figure);
     fFigures.insertElementAt(figure, 0);
     figure.changed();
   }
 }
Esempio n. 20
0
  // JAVADOC COMMENT ELIDED
  public static boolean removeFileSystemListener(FileSystemListener listener) {
    if (listener == null) {
      throw new NullPointerException();
    }

    return fileSystemListeners.removeElement(listener);
  }
Esempio n. 21
0
 public Vector<String> getOptionalSuts() {
   File path = getSutDirectory();
   File[] list = path.listFiles();
   if (list != null && list.length > 0) {
     Arrays.sort(list);
   }
   Vector<String> sutsVector = new Vector<String>();
   try {
     if (list == null) {
       return sutsVector;
     }
     for (int i = 0; i < list.length; i++) {
       if (list[i].getName().toLowerCase().endsWith(".xml")) {
         sutsVector.removeElement(list[i].getName());
         sutsVector.addElement(list[i].getName());
       }
     }
     return sutsVector;
   } finally {
     // add create new sut file menu item in the end of the list.
     if (!"false"
         .equals(JSystemProperties.getInstance().getPreference(FrameworkOptions.SUT_PLANNER))) {
       sutsVector.addElement(CREATE_A_NEW_SUT_FILE);
     }
   }
 }
Esempio n. 22
0
 /**
  * Detach the DataSet from the class. Data associated with the DataSet will nolonger be plotted.
  *
  * @param d The DataSet to detach.
  */
 public void detachDataSet(DataSet d) {
   if (d != null) {
     if (d.xaxis != null) d.xaxis.detachDataSet(d);
     if (d.yaxis != null) d.yaxis.detachDataSet(d);
     dataset.removeElement(d);
   }
 }
Esempio n. 23
0
  /**
   * Check to see if a resource is currently write locked.
   *
   * @param path Path of the resource
   * @param ifHeader "If" HTTP header which was included in the request
   * @return boolean true if the resource is locked (and no appropriate lock token has been found
   *     for at least one of the non-shared locks which are present on the resource).
   */
  public boolean isLocked(WebResource resource, String ifHeader, Identity identity) {
    // Checking resource locks
    String path = resource.getPath();

    // check if someone else as not set a lock on the resource
    if (resource instanceof VFSResource) {
      VFSResource vfsResource = (VFSResource) resource;
      Long lockedBy = getMetaLockedBy(vfsResource.getItem());
      if (lockedBy != null && !lockedBy.equals(identity.getKey())) {
        return true;
      }
    }

    File file = extractFile(resource);
    if (file == null) {
      return false; // lock only file
    }

    LockInfo lock = fileLocks.get(file);
    if (lock != null && lock.hasExpired()) {
      fileLocks.remove(file);
    } else if (lock != null) {
      // At least one of the tokens of the locks must have been given
      Iterator<String> tokenList = lock.tokens();
      boolean tokenMatch = false;
      while (tokenList.hasNext()) {
        String token = tokenList.next();
        if (ifHeader.indexOf(token) != -1) {
          tokenMatch = true;
          break;
        }
      }
      if (!tokenMatch) return true;
    }

    // Checking inheritable collection locks

    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();
    while (collectionLocksList.hasMoreElements()) {
      lock = collectionLocksList.nextElement();
      if (lock.hasExpired()) {
        collectionLocks.removeElement(lock);
      } else if (path.startsWith(lock.getWebPath())) {

        Iterator<String> tokenList = lock.tokens();
        boolean tokenMatch = false;
        while (tokenList.hasNext()) {
          String token = tokenList.next();
          if (ifHeader.indexOf(token) != -1) {
            tokenMatch = true;
            break;
          }
        }
        if (!tokenMatch) return true;
      }
    }

    return false;
  }
 /**
  * Removes the first (lowest-indexed) occurrence of the argument from this list.
  *
  * @param obj the component to be removed
  * @return <code>true</code> if the argument was a component of this list; <code>false</code>
  *     otherwise
  * @see Vector#removeElement(Object)
  */
 public boolean removeElement(Object obj) {
   int index = indexOf(obj);
   boolean rv = delegate.removeElement(obj);
   if (index >= 0) {
     fireIntervalRemoved(this, index, index);
   }
   return rv;
 }
Esempio n. 25
0
 synchronized void remove(Identity identity) {
   if (identities.contains(identity)) {
     identities.removeElement(identity);
     identity.clear();
   } else {
     remove(identity.getPublicKeyBlob());
   }
 }
Esempio n. 26
0
 /**
  * Removes the specified {@code Certificate} from this {@code Identity}.
  *
  * @param certificate the {@code Certificate} to be removed.
  * @throws KeyManagementException if the certificate is not found.
  */
 public void removeCertificate(Certificate certificate) throws KeyManagementException {
   if (certificates != null) {
     if (!certificates.contains(certificate)) {
       throw new KeyManagementException("Certificate not found");
     }
     certificates.removeElement(certificate);
   }
 }
Esempio n. 27
0
  /**
   * Detach a previously attached Axis.
   *
   * @param the Axis to dettach.
   */
  public void detachAxis(Axis a) {

    if (a != null) {
      a.detachAll();
      a.g2d = null;
      axis.removeElement(a);
    }
  }
Esempio n. 28
0
 private void sendHelloMessage(Protocol protocol, Contact contact) {
   validUins.addElement(contact.getUserId());
   uncheckedUins.removeElement(contact.getUserId());
   if (protocol.isMeVisible(contact)) {
     protocol.sendMessage(
         contact, Options.getString(JLocale.getString(R.string.pref_antispam_hello)), false);
   }
 }
  public void removeListener(ServiceContextListener listener) throws IllegalStateException {
    if (getState() == CLOSED)
      throw new IllegalStateException("Cannot remove listener on closed Service Context.");

    if (listener == null || _serviceContextListener.contains(listener)) return;

    _serviceContextListener.removeElement(listener);
  }
 /**
  * Handles click on checkbox for a list item.
  *
  * @param chkBox Checkbox view
  * @param id Id assigned to the list item
  */
 protected void toggleCheck(CheckBox chkBox, int id) {
   if (mSelectedItems.contains(id)) {
     mSelectedItems.removeElement(id);
   } else {
     mSelectedItems.add(id);
   }
   chkBox.setChecked(mSelectedItems.contains(id));
 }