Package java.util

Examples of java.util.LinkedHashMap$ValueIterator


                //   model elements and place them into the template context
                //   by their variable names.
                if (template.isOutputToSingleFile() &&
                    (template.isOutputOnEmptyElements() || !allMetafacades.isEmpty()))
                {
                    final Map templateContext = new LinkedHashMap();

                    // - first place all relevant model elements by the
                    //   <modelElements/> variable name. If the variable
                    //   isn't defined (which is possible), ignore.
                    final String modelElementsVariable = modelElements.getVariable();
                    if (modelElementsVariable != null && modelElementsVariable.trim().length() > 0)
                    {
                        templateContext.put(
                            modelElements.getVariable(),
                            allMetafacades);
                    }

                    // - now place the collections of elements by the given variable names.
                    //   (skip if the variable is NOT defined)
                    for (final Iterator iterator = modelElements.getModelElements().iterator(); iterator.hasNext();)
                    {
                        final ModelElement modelElement = (ModelElement)iterator.next();
                        final String modelElementVariable = modelElement.getVariable();
                        if (modelElementVariable != null && modelElementVariable.trim().length() > 0)
                        {
                            // - if a modelElement has the same variable defined
                            //   more than one time, then get the existing
                            //   model elements added from the last iteration
                            //   and add the new ones to that collection
                            Collection metafacades = (Collection)templateContext.get(modelElementVariable);
                            if (metafacades != null)
                            {
                                metafacades.addAll(modelElement.getMetafacades());
                            }
                            else
                            {
                                metafacades = modelElement.getMetafacades();
                                templateContext.put(
                                    modelElementVariable,
                                    new LinkedHashSet(metafacades));
                            }
                        }
                    }
                    this.processWithTemplate(
                        template,
                        templateContext,
                        null,
                        null);
                }
                else
                {
                    // - if outputToSingleFile isn't true, then
                    //   we just place the model element with the default
                    //   variable defined on the <modelElements/> into the
                    //   template.
                    for (final Iterator iterator = allMetafacades.iterator(); iterator.hasNext();)
                    {
                        final Map templateContext = new LinkedHashMap();
                        final Object metafacade = iterator.next();
                        final ModelAccessFacade model = factory.getModel();
                        for (final Iterator elements = modelElements.getModelElements().iterator(); elements.hasNext();)
                        {
                            final ModelElement modelElement = (ModelElement)elements.next();
                            String variable = modelElement.getVariable();

                            // - if the variable isn't defined on the <modelElement/>, try
                            //   the <modelElements/>
                            if (variable == null || variable.trim().length() == 0)
                            {
                                variable = modelElements.getVariable();
                            }

                            // - only add the metafacade to the template context if the variable
                            //   is defined (which is possible)
                            if (variable != null && variable.trim().length() > 0)
                            {
                                templateContext.put(
                                    variable,
                                    metafacade);
                            }

                            // - now we process any property templates (if any 'variable' attributes are defined on one or
View Full Code Here


    /* (non-Javadoc)
     * @see jsynoptic.base.SelectionContextualActionProvider#getCollectiveActions()
     */
    public LinkedHashMap getCollectiveActions(DiagramSelection sel, double x, double y, Object o, int context) {
        LinkedHashMap res=new LinkedHashMap();
        if (((primaryCurves!=null) && (primaryCurves.size()!=0))
                || ((secondaryCurves!=null) && (secondaryCurves.size()!=0))) {       // do both primary and secondary
            res.put(resources.getStringValue("autoscale"), null);
            res.put(resources.getStringValue("autoscaleOnY"), null);

            res.put(resources.getStringValue("adjustOnX") + ";" +  resources.getStringValue("union"), null);
            res.put(resources.getStringValue("adjustOnX") + ";" +  resources.getStringValue("intersection"), null);
            res.put(resources.getStringValue("adjustOnX") + ";" +  resources.getStringValue("firstPlotSelected"), null);

        }

        return res;
    }
View Full Code Here

        {
            messages = Collections.EMPTY_MAP;
        }
        else
        {
            messages = new LinkedHashMap(); // we want to keep the order

            for (final Iterator iterator = taggedValues.iterator(); iterator.hasNext();)
            {
                final String value = (String)iterator.next();
                messages.put(StringUtilsHelper.toResourceMessageKey(value), value);
View Full Code Here

    {
        final Collection tableColumns = super.getTableColumns();
        if (tableColumns.isEmpty())
        {
            // try to preserve the order of the elements encountered
            final Map tableColumnsMap = new LinkedHashMap();

            // order is important
            final List actions = new ArrayList();

            // all table actions need the exact same parameters, just not always all of them
            actions.addAll(this.getTableFormActions());

            // if there are any actions that are hyperlinks then their parameters get priority
            // the user should not have modeled it that way (constraints will warn him/her)
            actions.addAll(this.getTableHyperlinkActions());

            for (final Iterator actionIterator = actions.iterator(); actionIterator.hasNext();)
            {
                final JSFAction action = (JSFAction)actionIterator.next();
                final Collection actionParameters = action.getParameters();
                for (final Iterator parameterIterator = actionParameters.iterator(); parameterIterator.hasNext();)
                {
                    final Object object = parameterIterator.next();
                    if (object instanceof JSFParameter)
                    {
                        final JSFParameter parameter = (JSFParameter)object;
                        final String parameterName = parameter.getName();
                        if (parameterName != null)
                        {
                            // never overwrite column specific table links
                            // the hyperlink table links working on a real column get priority
                            final Object existingObject = tableColumnsMap.get(parameterName);
                            if (existingObject instanceof JSFParameter)
                            {
                                final JSFParameter existingParameter = (JSFParameter)existingObject;
                                if (existingParameter == null ||
                                    (action.isHyperlink() && parameterName.equals(action.getTableLinkColumnName())))
                                {
                                    tableColumnsMap.put(
                                        parameterName,
                                        parameter);
                                }
                            }
                        }
                    }
                }
            }

            // for any missing parameters we just add the name of the column
            final Collection columnNames = this.getTableColumnNames();
            for (final Iterator columnNameIterator = columnNames.iterator(); columnNameIterator.hasNext();)
            {
                final String columnName = (String)columnNameIterator.next();
                if (!tableColumnsMap.containsKey(columnName))
                {
                    tableColumnsMap.put(
                        columnName,
                        columnName);
                }
            }

            // return everything in the same order as it has been modeled (using the table tagged value)
            for (final Iterator columnNameIterator = columnNames.iterator(); columnNameIterator.hasNext();)
            {
                final Object columnObject = columnNameIterator.next();
                tableColumns.add(tableColumnsMap.get(columnObject));
            }
        }
        return tableColumns;
    }
View Full Code Here

    public static class ChangedProperties implements NamedProperties{

        private LinkedHashMap changes;

        public ChangedProperties(){
            changes = new LinkedHashMap();
        }
View Full Code Here

      }
      return new ActionPopup(this, selX, selY, getSelectedSource(), context);
    }
   
    protected boolean addCollectiveActions(JPopupMenu menu, int x, int y, int context){
      LinkedHashMap pactions=null;
      for(int i=0;i<getElementContainer().getSelection().getSelectedElements().size();i++){
        Object o=getElementContainer().getSelection().getSelectedElements().get(i);
        if (o instanceof SelectionContextualActionProvider) {
          SelectionContextualActionProvider provider = (SelectionContextualActionProvider)o;
          boolean locked = JSynoptic.gui==null ? false : JSynoptic.gui.getLockedShapes().contains(provider);
          if(locked){
            continue;
          }
          LinkedHashMap cactions = provider.getCollectiveActions(getElementContainer().getSelection(), x, y, getSelectedSource(), context);
          if (cactions != null){
                       if(pactions==null){
                            pactions=cactions;
                       
                        } else{
                            HashSet h=new HashSet(cactions.keySet());
                            h.retainAll(pactions.keySet());
                            Iterator it=pactions.keySet().iterator();
                            while(it.hasNext()){
                                if(!h.contains(it.next())){
                                    it.remove();
                                }
                            }
                        }
          }
        } else{
          // one element in the selection does
          // not provide collective actions
          return false;
        }
      }
      if(pactions==null || pactions.isEmpty()){
        // no common actions
        return false;
      }
      final LinkedHashMap commonActions=pactions;
      Iterator it=commonActions.keySet().iterator();
      while(it.hasNext()){
        final String actionName =(String)it.next();
        Icon icon =(commonActions.get(actionName) instanceof Icon)(Icon)commonActions.get(actionName) : null;
        JMenuItem jmi = ActionPopup.createMenuItem(menu, actionName, icon);
        jmi.addActionListener(new CollectiveActionListener(x, y, getSelectedSource(), actionName))
      }
      return true;
    }
View Full Code Here

    protected void processTemplateWithoutMetafacades(final Template template)
    {
        ExceptionUtils.checkNull(
            "template",
            template);
        final Map templateContext = new LinkedHashMap();
        this.processWithTemplate(
            template,
            templateContext,
            null,
            null);
View Full Code Here

                    resourceUri.substring(
                        resourceUri.lastIndexOf(FORWARD_SLASH),
                        resourceUri.length());
            }

            final Map templateContext = new LinkedHashMap();
            this.populateTemplateContext(templateContext);
           
            // - if we have an outputCondition defined make sure it evaluates to true before continuing
            if (this.isValidOutputCondition(resource.getOutputCondition(), templateContext))
            {
View Full Code Here

        // is used
        // the event parameters have priority to be included in the collection because
        // they contain additional information such as validation constraint and widget type, ...

        // try to preserve the order of the elements encountered
        final Map tableColumnsMap = new LinkedHashMap();

        // order is important
        final List actions = new ArrayList();

        // all table actions need the exact same parameters, just not always all of them
        actions.addAll(this.getTableFormActions());
        // if there are any actions that are hyperlinks then their parameters get priority
        // the user should not have modeled it that way (constraints will warn him/her)
        actions.addAll(this.getTableHyperlinkActions());

        for (final Iterator actionIterator = actions.iterator(); actionIterator.hasNext();)
        {
            final StrutsAction action = (StrutsAction)actionIterator.next();
            final Collection actionParameters = action.getActionParameters();
            for (final Iterator parameterIterator = actionParameters.iterator(); parameterIterator.hasNext();)
            {
                final StrutsParameter parameter = (StrutsParameter)parameterIterator.next();
                final String parameterName = parameter.getName();
                if (parameterName != null)
                {
                    // never overwrite column specific table links
                    // the hyperlink table links working on a real column get priority
                    final StrutsParameter existingParameter = (StrutsParameter)tableColumnsMap.get(parameterName);
                    if (existingParameter == null ||
                        (action.isHyperlink() && parameterName.equals(action.getTableLinkColumnName())))
                    {
                        tableColumnsMap.put(parameterName, parameter);
                    }
                }
            }
        }

        final Collection columnNames = this.getTableColumnNames();

        // in case of a custom array just add the attributes
        if (this.isCustomArrayTable())
        {
            final Collection attributes = this.getType().getNonArray().getAttributes(true);
            for (final Iterator attributeIterator = attributes.iterator(); attributeIterator.hasNext();)
            {
                final ModelElementFacade attribute = (ModelElementFacade)attributeIterator.next();
                // don't override
                if (!tableColumnsMap.containsKey(attribute.getName()))
                {
                    tableColumnsMap.put(attribute.getName(), attribute);
                }
            }
        }
        else
        {
            for (final Iterator columnNameIterator = columnNames.iterator(); columnNameIterator.hasNext();)
            {
                final String columnName = (String)columnNameIterator.next();
                // don't override
                if (!tableColumnsMap.containsKey(columnName))
                {
                    tableColumnsMap.put(columnName, columnName);
                }
            }
        }

        // return everything in the same order as it has been modeled (using the table tagged value)
        // note that only those columns mentioned in the tagged value are returned
        final Collection tableColumns = new ArrayList();
        for (final Iterator columnNameIterator = columnNames.iterator(); columnNameIterator.hasNext();)
        {
            final Object columnObject = columnNameIterator.next();
            tableColumns.add(tableColumnsMap.get(columnObject));
        }
        return tableColumns;
    }
View Full Code Here

    /**
     * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getValidatorVars()
     */
    protected java.util.Collection handleGetValidatorVars()
    {
        final Map vars = new LinkedHashMap();

        final ClassifierFacade type = getType();
        if (type != null)
        {
            final String format = getValidatorFormat();
            if (format != null)
            {
                final boolean isRangeFormat = isRangeFormat(format);

                if (isRangeFormat)
                {
                    vars.put("min", Arrays.asList(new Object[]{"min", getRangeStart(format)}));
                    vars.put("max", Arrays.asList(new Object[]{"max", getRangeEnd(format)}));
                }
                else
                {
                    final Collection formats = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_FORMAT);
                    for (final Iterator formatIterator = formats.iterator(); formatIterator.hasNext();)
                    {
                        final String additionalFormat = String.valueOf(formatIterator.next());
                        if (isMinLengthFormat(additionalFormat)) vars.put("minlength",
                            Arrays.asList(new Object[]{"minlength", this.getMinLengthValue(additionalFormat)}));
                        else if (isMaxLengthFormat(additionalFormat)) vars.put("maxlength",
                            Arrays.asList(new Object[]{"maxlength", this.getMaxLengthValue(additionalFormat)}));
                        else if (isPatternFormat(additionalFormat)) vars
                            .put("mask", Arrays.asList(new Object[]{"mask", this.getPatternValue(additionalFormat)}));
                    }
                }
            }
            if (isValidatorDate())
            {
                if (format != null && isStrictDateFormat(format))
                {
                    vars.put("datePatternStrict",
                        Arrays.asList(new Object[]{"datePatternStrict", this.getDateFormat()}));
                }
                else
                {
                    vars.put("datePattern", Arrays.asList(new Object[]{"datePattern", this.getDateFormat()}));
                }
            }
            if (this.isValidatorTime())
            {
                vars.put("timePattern", Arrays.asList(new Object[]{"timePattern", this.getTimeFormat()}));
            }

            final String validWhen = getValidWhen();
            if (validWhen != null)
            {
                vars.put("test", Arrays.asList(new Object[]{"test", validWhen}));
            }
        }

        // custom (paramterized) validators are allowed here
        // in this case we will reuse the validator arg values
        Collection taggedValues = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_VALIDATORS);
        for (final Iterator iterator = taggedValues.iterator(); iterator.hasNext();)
        {
            String validator = String.valueOf(iterator.next());

            // guaranteed to be of the same length
            List validatorVars = Bpm4StrutsUtils.parseValidatorVars(validator);
            List validatorArgs = Bpm4StrutsUtils.parseValidatorArgs(validator);

            for (int i = 0; i < validatorVars.size(); i++)
            {
                String validatorVar = (String)validatorVars.get(i);
                String validatorArg = (String)validatorArgs.get(i);

                vars.put(validatorVar, Arrays.asList(new Object[]{validatorVar, validatorArg}));
            }
        }

        return vars.values();
    }
View Full Code Here

TOP

Related Classes of java.util.LinkedHashMap$ValueIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.