public void setSwingDataCollection(Collection<ICFSecurityISOCountryObj> value) {
   final String S_ProcName = "setSwingDataCollection";
   swingDataCollection = value;
   if (swingDataCollection == null) {
     arrayOfISOCountry = new ICFSecurityISOCountryObj[0];
   } else {
     int len = value.size();
     arrayOfISOCountry = new ICFSecurityISOCountryObj[len];
     Iterator<ICFSecurityISOCountryObj> iter = swingDataCollection.iterator();
     int idx = 0;
     while (iter.hasNext() && (idx < len)) {
       arrayOfISOCountry[idx++] = iter.next();
     }
     if (idx < len) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator did not fully populate the array copy");
     }
     if (iter.hasNext()) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator had left over items when done populating array copy");
     }
     Arrays.sort(arrayOfISOCountry, compareISOCountryByQualName);
   }
   PickerTableModel tblDataModel = getDataModel();
   if (tblDataModel != null) {
     tblDataModel.fireTableDataChanged();
   }
 }
  protected void modelChanged() {
    super.modelChanged();
    MComponentInstance coi = (MComponentInstance) getOwner();
    if (coi == null) return;
    String nameStr = "";
    if (coi.getName() != null) {
      nameStr = coi.getName().trim();
    }

    // construct bases string (comma separated)
    String baseStr = "";
    Collection col = coi.getClassifiers();
    if (col != null && col.size() > 0) {
      Iterator it = col.iterator();
      baseStr = ((MClassifier) it.next()).getName();
      while (it.hasNext()) {
        baseStr += ", " + ((MClassifier) it.next()).getName();
      }
    }
    if (_readyToEdit) {
      if (nameStr == "" && baseStr == "") _name.setText("");
      else _name.setText(nameStr.trim() + " : " + baseStr);
    }
    Dimension nameMin = _name.getMinimumSize();
    Rectangle r = getBounds();
    setBounds(r.x, r.y, r.width, r.height);

    updateStereotypeText();
  }
  /**
   * Initializes custom contact action buttons.
   *
   * @param contactActionButtons the list of buttons to initialize
   * @param gridX the X grid of the first button
   * @param xBounds the x bounds of the first button
   * @return the new grid X coordinate after adding all the buttons
   */
  private int initGroupActionButtons(
      Collection<SIPCommButton> contactActionButtons, int gridX, int xBounds) {
    // Reinit the labels to take the whole horizontal space.
    addLabels(gridX + contactActionButtons.size());

    Iterator<SIPCommButton> actionsIter = contactActionButtons.iterator();
    while (actionsIter.hasNext()) {
      final SIPCommButton actionButton = actionsIter.next();

      // We need to explicitly remove the buttons from the tooltip manager,
      // because we're going to manager the tooltip ourselves in the
      // DefaultTreeContactList class. We need to do this in order to have
      // a different tooltip for every button and for non button area.
      ToolTipManager.sharedInstance().unregisterComponent(actionButton);

      if (customActionButtonsUIGroup == null)
        customActionButtonsUIGroup = new LinkedList<JButton>();

      customActionButtonsUIGroup.add(actionButton);

      xBounds += addButton(actionButton, ++gridX, xBounds, false);
    }

    return gridX;
  }
Ejemplo n.º 4
0
  // Return a collection of common actions.
  // Each action in the collection is a compound
  // action. There is one compound action in the collection
  // for each action which is common to all viewlets in the selection.
  public Collection getCommonActions() {
    Collection commonActions = new LinkedList();
    Collection firstViewletsActions;
    ViewletAction currentAction;
    Iterator viewletsIterator;
    Iterator firstViewletsActionsIterator;
    Viewlet firstViewlet, currentViewlet;
    List currentViewletActions;
    boolean allContainAction;

    if (isEmpty()) {
      return (Collections.EMPTY_SET);
    }
    firstViewlet = (Viewlet) (iterator().next());
    firstViewletsActions = firstViewlet.getActions();
    firstViewletsActionsIterator = firstViewletsActions.iterator();

    // for each currentAction in the first viewlet's actions
    while (firstViewletsActionsIterator.hasNext()) {
      currentAction = (ViewletAction) firstViewletsActionsIterator.next();
      viewletsIterator = iterator();
      allContainAction = true;
      // test whether each viewlet has an action equals() to currentAction
      while (viewletsIterator.hasNext() && allContainAction) {
        currentViewlet = (Viewlet) viewletsIterator.next();
        if (!currentViewlet.getActions().contains(currentAction)) {
          allContainAction = false;
        }
      }
      if (allContainAction) {
        commonActions.add(currentAction.createCompoundAction(this));
      }
    }
    return (commonActions);
  }
Ejemplo n.º 5
0
 public void startServer() throws Exception {
   while (true) {
     Socket s = server.accept();
     cClient.add(new ClientConn(s));
     ta.append("NEW-CLIENT " + s.getInetAddress() + ":" + s.getPort());
     ta.append("\n" + "CLIENTS-COUNT: " + cClient.size() + "\n\n");
   }
 }
Ejemplo n.º 6
0
 public void actionPerformed(ActionEvent e) {
   if (_widget.isEditable()) {
     Collection selections =
         DisplayUtilities.pickInstances(
             (Component) _widget, _widget.getAllowedClses(), _dialogTitle);
     if ((null != selections) && (selections.size() != 0)) {
       _widget.addValues(selections);
     }
   }
 }
Ejemplo n.º 7
0
  private Set<String> getLoadedPaths() {

    if (!IGV.hasInstance()) return new HashSet<String>();

    Collection<ResourceLocator> locators = IGV.getInstance().getDataResourceLocators();
    HashSet<String> loadedPaths = new HashSet<String>(locators.size());
    for (ResourceLocator locator : locators) {
      loadedPaths.add(locator.getPath());
    }
    return loadedPaths;
  }
Ejemplo n.º 8
0
  private boolean containInstance(Instance sel, Slot slot, Instance instance) {
    if (itsInstance == null) return false;
    Collection instances = sel.getOwnSlotValues(slot);
    Iterator i = instances.iterator();
    while (i.hasNext()) {

      Instance tmpInstance = (Instance) i.next();
      if (tmpInstance.equals(instance)) return true;
    }
    return false;
  }
Ejemplo n.º 9
0
  public Collection search() {
    if (specification.getType() == null) return null;
    String slotType = specification.getType();
    if (!slotType.toLowerCase().equals("cls")) return null;

    // Here we first test the function based on the simplest Instance cases
    ArrayList resultInstances = new ArrayList();
    Collection instances = itsInstances;
    Iterator i = instances.iterator();
    Slot slot = itsWidget.getKB().getSlot(specification.getName());
    while (i.hasNext()) {
      Instance instance = (Instance) i.next();
      if (testInstance(getTestIndex(specification.getConstraint()), instance, slot))
        resultInstances.add(instance);
    }
    return resultInstances;
  }
Ejemplo n.º 10
0
  private TreeModel buildModel(Object[] resolvers) {
    TreeModel fullModel = null;
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(Tr.t("root"));

    try {
      cpos = null;
      for (Object resolver : resolvers) {
        if (resolver instanceof ColorPository) {
          cpos = (ColorPository) resolver;
          GraphCellRenderer graphCellRenderer = new GraphCellRenderer(cpos);
          colors.setCellRenderer(graphCellRenderer);
          break;
        }
      }
      Collection<ColorPository.ClassRecord> classes = cpos.getClasses();
      String[] classNames = new String[classes.size()];
      Iterator<ColorPository.ClassRecord> it = classes.iterator();
      int count = 0;
      while (it.hasNext()) {
        classNames[count] = it.next().name;
        count++;
      }
      Arrays.sort(classNames);

      for (String className : classNames) {
        ColorPository.ColorRecord[] colors = cpos.enumerateColors(className);
        String[] colorNames = new String[colors.length];
        for (int a = 0; a < colorNames.length; a++) {
          colorNames[a] = colors[a].name;
        }
        Arrays.sort(colorNames);

        DefaultMutableTreeNode tn = new DefaultMutableTreeNode(className);
        top.add(tn);
        for (String colorName : colorNames) {
          tn.add(new DefaultMutableTreeNode(colorName));
        }
      }

      fullModel = new DefaultTreeModel(top);
    } catch (Exception e) {
      fullModel = new DefaultTreeModel(new DefaultMutableTreeNode(Tr.t("root.failed")));
      // e.printStackTrace();
    }
    return fullModel;
  }
Ejemplo n.º 11
0
 // This is used for Query test
 public Collection search(Collection instances, Slot slot, String operation, Object obj) {
   ArrayList resultInstances = new ArrayList();
   Iterator i = instances.iterator();
   String value = (String) (((Instance) obj).getBrowserText());
   while (i.hasNext()) {
     Instance instance = (Instance) i.next();
     if (testInstance(getTestIndex(operation), instance, slot, value))
       resultInstances.add(instance);
   }
   return resultInstances;
 }
  public Object getChild(Object parent, int index) {
    Collection c = null;

    if (parent instanceof IProject) {
      if (activeOnly()) c = CurrentProject.getTaskList().getActiveSubTasks(null, CurrentDate.get());
      else c = CurrentProject.getTaskList().getTopLevelTasks();
    } else {
      ITask t = (ITask) parent;
      if (activeOnly())
        c = CurrentProject.getTaskList().getActiveSubTasks(t.getID(), CurrentDate.get());
      else c = t.getSubTasks();
    }

    Object array[] = c.toArray();
    Arrays.sort(array, comparator);
    if (opposite) {
      return array[array.length - index - 1];
    }
    return array[index];
  }
Ejemplo n.º 13
0
  /**
   * Checks if title is valid.
   *
   * @return error message or NULL.
   */
  protected String validateTitle() {
    String message = null;

    final String title = tfTitle.getText();
    if (title == null || title.trim().length() == 0) {
      message = Strings.message("guide.dialog.validation.empty.title");
    } else if (CommonUtils.areDifferent(originalTitle, title) && presentTitles.contains(title)) {
      message = Strings.message("guide.dialog.validation.already.present");
    }
    return message;
  }
  /**
   * Initializes buttons panel.
   *
   * @param uiGroup the <tt>UIGroup</tt> for which we initialize the button panel
   */
  private void initButtonsPanel(UIGroup uiGroup) {
    if (!isSelected) return;

    int x = (statusIcon == null ? 0 : statusIcon.getIconWidth()) + LEFT_BORDER + H_GAP;
    int gridX = 0;

    // The list of the actions
    // we will create a button for every action
    Collection<SIPCommButton> contactActions = uiGroup.getCustomActionButtons();

    int lastGridX = gridX;
    if (contactActions != null && contactActions.size() > 0) {
      lastGridX = initGroupActionButtons(contactActions, gridX, x);
    } else {
      addLabels(gridX);
    }

    if (lastAddedButton != null) setButtonBg(lastAddedButton, lastGridX, true);

    this.setBounds(0, 0, treeContactList.getWidth(), getPreferredSize().height);
  }
Ejemplo n.º 15
0
 /**
  * Check if the given element denotes a supported array-friendly data structure, i.e. a data
  * structure jconsole can render as an array.
  */
 public static boolean canBeRenderedAsArray(Object elem) {
   if (isSupportedArray(elem)) return true;
   if (elem instanceof Collection) {
     Collection<?> c = (Collection<?>) elem;
     if (c.isEmpty()) {
       // Empty collections of any Java type are not handled as arrays
       //
       return false;
     } else {
       // - Collections of CompositeData/TabularData are not handled
       //   as arrays
       // - Collections of other Java types are handled as arrays
       //
       return !isUniformCollection(c, CompositeData.class)
           && !isUniformCollection(c, TabularData.class);
     }
   }
   if (elem instanceof Map) {
     return !(elem instanceof TabularData);
   }
   return false;
 }
Ejemplo n.º 16
0
  // Works the exact same way as rangeSize(). Simply checks if sub-tree possibly contains points in
  // query
  private void rangeQuery(Point sw, Point ne, Collection<Point> result, TreeNode t) {
    if (t == null) return;

    if (subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minY.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxY.p)) {
      rangeQuery(sw, ne, result, t.left);
      rangeQuery(sw, ne, result, t.right);
    } else return;

    if (inRange(sw, ne, t.p)) result.add(t.p);
  }
Ejemplo n.º 17
0
  /**
   * loads a pluginSet xml file and updates the model to reflect certain checked selections
   *
   * @since jEdit 4.3pre10
   * @author Alan Ezust
   */
  boolean loadPluginSet(String path) {
    pluginSet.clear();
    pluginModel.restoreSelection(new HashSet<String>(), new HashSet<String>());

    VFS vfs = VFSManager.getVFSForPath(path);
    Object session = vfs.createVFSSession(path, InstallPanel.this);
    try {
      InputStream is = vfs._createInputStream(session, path, false, InstallPanel.this);
      XMLUtilities.parseXML(is, new StringMapHandler());
    } catch (Exception e) {
      Log.log(Log.WARNING, this, "Loading Pluginset failed:" + e.getMessage());
      return false;
    }
    pluginModel.update();
    return true;
  } // }}}
Ejemplo n.º 18
0
 /** Check if the given collection is a uniform collection of the given type. */
 public static boolean isUniformCollection(Collection<?> c, Class<?> e) {
   if (e == null) {
     throw new IllegalArgumentException("Null reference type");
   }
   if (c == null) {
     throw new IllegalArgumentException("Null collection");
   }
   if (c.isEmpty()) {
     return false;
   }
   for (Object o : c) {
     if (o == null || !e.isAssignableFrom(o.getClass())) {
       return false;
     }
   }
   return true;
 }
 private void captureUsagesExpandState(TreePath pathFrom, final Collection<UsageState> states) {
   if (!myTree.isExpanded(pathFrom)) {
     return;
   }
   final DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathFrom.getLastPathComponent();
   final int childCount = node.getChildCount();
   for (int idx = 0; idx < childCount; idx++) {
     final TreeNode child = node.getChildAt(idx);
     if (child instanceof UsageNode) {
       final Usage usage = ((UsageNode) child).getUsage();
       states.add(
           new UsageState(
               usage,
               myTree.getSelectionModel().isPathSelected(pathFrom.pathByAddingChild(child))));
     } else {
       captureUsagesExpandState(pathFrom.pathByAddingChild(child), states);
     }
   }
 }
Ejemplo n.º 20
0
    protected void loadAirspacesFromPath(String path, Collection<Airspace> airspaces) {
      File file = ExampleUtil.saveResourceToTempFile(path, ".zip");
      if (file == null) return;

      try {
        ZipFile zipFile = new ZipFile(file);

        ZipEntry entry = null;
        for (Enumeration<? extends ZipEntry> e = zipFile.entries();
            e.hasMoreElements();
            entry = e.nextElement()) {
          if (entry == null) continue;

          String name = WWIO.getFilename(entry.getName());

          if (!(name.startsWith("gov.nasa.worldwind.render.airspaces") && name.endsWith(".xml")))
            continue;

          String[] tokens = name.split("-");

          try {
            Class c = Class.forName(tokens[0]);
            Airspace airspace = (Airspace) c.newInstance();
            BufferedReader input =
                new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry)));
            String s = input.readLine();
            airspace.restoreState(s);
            airspaces.add(airspace);

            if (tokens.length >= 2) {
              airspace.setValue(AVKey.DISPLAY_NAME, tokens[1]);
            }
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
Ejemplo n.º 21
0
 /**
  * Adds the given <tt>TextFieldChangeListener</tt> to the list of listeners notified on changes of
  * the text contained in this field.
  *
  * @param l the <tt>TextFieldChangeListener</tt> to add
  */
 public void addTextChangeListener(TextFieldChangeListener l) {
   synchronized (changeListeners) {
     changeListeners.add(l);
   }
 }
Ejemplo n.º 22
0
 /**
  * Removes the given <tt>TextFieldChangeListener</tt> from the list of listeners notified on
  * changes of the text contained in this field.
  *
  * @param l the <tt>TextFieldChangeListener</tt> to add
  */
 public void removeTextChangeListener(TextFieldChangeListener l) {
   synchronized (changeListeners) {
     changeListeners.remove(l);
   }
 }
  /**
   * Initializes buttons panel.
   *
   * @param uiContact the <tt>UIContact</tt> for which we initialize the button panel
   */
  private void initButtonsPanel(UIContact uiContact) {
    this.remove(chatButton);
    this.remove(callButton);
    this.remove(callVideoButton);
    this.remove(desktopSharingButton);
    this.remove(addContactButton);

    clearCustomActionButtons();

    if (!isSelected) return;

    UIContactDetail imContact = null;
    // For now we support instance messaging only for contacts in our
    // contact list until it's implemented for external source contacts.
    if (uiContact.getDescriptor() instanceof MetaContact)
      imContact = uiContact.getDefaultContactDetail(OperationSetBasicInstantMessaging.class);

    int x = (statusIcon == null ? 0 : statusIcon.getIconWidth()) + LEFT_BORDER + H_GAP;

    // Re-initialize the x grid.
    constraints.gridx = 0;
    int gridX = 0;

    if (imContact != null) {
      x += addButton(chatButton, ++gridX, x, false);
    }

    UIContactDetail telephonyContact =
        uiContact.getDefaultContactDetail(OperationSetBasicTelephony.class);

    // Check if contact has additional phone numbers, if yes show the
    // call button
    ContactPhoneUtil contactPhoneUtil = null;

    // check for phone stored in contact info only
    // if telephony contact is missing
    if (uiContact.getDescriptor() != null
        && uiContact.getDescriptor() instanceof MetaContact
        && telephonyContact == null) {
      contactPhoneUtil = ContactPhoneUtil.getPhoneUtil((MetaContact) uiContact.getDescriptor());

      MetaContact metaContact = (MetaContact) uiContact.getDescriptor();
      Iterator<Contact> contacts = metaContact.getContacts();

      while (contacts.hasNext()) // && !hasPhone)
      {
        Contact contact = contacts.next();

        if (!contact.getProtocolProvider().isRegistered()) continue;

        contactPhoneUtil.addDetailsResponseListener(
            contact, new DetailsListener(treeNode, callButton, uiContact));
      }
    }

    // for SourceContact in history that do not support telephony, we
    // show the button but disabled
    List<ProtocolProviderService> providers =
        AccountUtils.getOpSetRegisteredProviders(OperationSetBasicTelephony.class, null, null);

    if ((telephonyContact != null && telephonyContact.getAddress() != null)
        || (contactPhoneUtil != null && contactPhoneUtil.isCallEnabled() && providers.size() > 0)) {
      x += addButton(callButton, ++gridX, x, false);
    }

    UIContactDetail videoContact =
        uiContact.getDefaultContactDetail(OperationSetVideoTelephony.class);

    if (videoContact != null
        || (contactPhoneUtil != null && contactPhoneUtil.isVideoCallEnabled())) {
      x += addButton(callVideoButton, ++gridX, x, false);
    }

    UIContactDetail desktopContact =
        uiContact.getDefaultContactDetail(OperationSetDesktopSharingServer.class);

    if (desktopContact != null
        || (contactPhoneUtil != null && contactPhoneUtil.isDesktopSharingEnabled())) {
      x += addButton(desktopSharingButton, ++gridX, x, false);
    }

    // enable add contact button if contact source has indicated
    // that this is possible
    if (uiContact.getDescriptor() instanceof SourceContact
        && uiContact.getDefaultContactDetail(OperationSetPersistentPresence.class) != null
        && AccountUtils.getOpSetRegisteredProviders(
                    OperationSetPersistentPresence.class, null, null)
                .size()
            > 0
        && !ConfigurationUtils.isAddContactDisabled()) {
      x += addButton(addContactButton, ++gridX, x, false);
    }

    // The list of the contact actions
    // we will create a button for every action
    Collection<SIPCommButton> contactActions = uiContact.getContactCustomActionButtons();

    int lastGridX = gridX;
    if (contactActions != null && contactActions.size() > 0) {
      lastGridX = initContactActionButtons(contactActions, gridX, x);
    } else {
      addLabels(gridX);
    }

    if (lastAddedButton != null) setButtonBg(lastAddedButton, lastGridX, true);

    this.setBounds(0, 0, treeContactList.getWidth(), getPreferredSize().height);
  }