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(); } }
// 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); }
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; }
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; }
// 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; }
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; }
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; }