Package org.apache.jetspeed.om.common.preference

Examples of org.apache.jetspeed.om.common.preference.PreferenceComposite


        if(action.equals("add_preference"))
        {
            String name = actionRequest.getParameter("name");
            String value = actionRequest.getParameter("value");
           
            PreferenceComposite pref = (PreferenceComposite) portlet.getPreferenceSet().get(name);
            if(pref == null)
            {
                portlet.addPreference(name, new String[] { value });
            }
            else
            {
                pref.addValue(value);
            }
           
            registry.savePortletDefinition(portlet);
        }
        else if(action.equals("edit_preference"))
        {
            String[] prefNames = actionRequest.getParameterValues("pref_edit_id");
            for (int i = 0; i < prefNames.length; i++)
            {
                String prefName = prefNames[i];
                PreferenceComposite prefComp = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
                String[] values = prefComp.getValueArray();
                for (int j = 0; j < values.length; j++)
                {
                    String value = values[j];
                    String newValue = actionRequest.getParameter(prefName + ":" + j);
                    if(!value.equals(newValue))
                    {
                        prefComp.setValueAt(j, newValue);
                    }
                }
            }
           
            registry.savePortletDefinition(portlet);
        }
        else if(action.equals("remove_preference"))
        {
            String[] prefNames = actionRequest.getParameterValues("pref_remove_id");
           
            Iterator prefIter = portlet.getPreferenceSet().iterator();
            while (prefIter.hasNext())
            {
                PreferenceComposite pref = (PreferenceComposite) prefIter.next();
                String name = pref.getName();
               
                for(int i=0; i<prefNames.length; i++)
                {
                    String prefName = prefNames[i];
                    if(name.equals(prefName))
View Full Code Here


       
        buffer.append("\t<portlet-preferences>\n");
        Iterator prefIter = pDef.getPreferenceSet().iterator();
        while (prefIter.hasNext())
        {
            PreferenceComposite pref = (PreferenceComposite) prefIter.next();
            buffer.append("\t\t<preference>\n");
            buffer.append("\t\t\t<name>);");
            buffer.append(pref.getName());
            buffer.append("</name>\n");
            String[] values = pref.getValueArray();
            for (int i = 0; i < values.length; i++)
            {
                String value = values[i];
                buffer.append("\t\t\t<value>");
                buffer.append(value);
View Full Code Here

        while (valueItr.hasNext())
        {
            list.add(valueItr.next());
        }

        PreferenceComposite newPref = (PreferenceComposite) ((PreferenceSetComposite) getPreferenceSet()).add(
                preference.getName(), list);

        Iterator descItr = newPref.getDescriptions();
        while (descItr.hasNext())
        {
            Description desc = (Description) descItr.next();
            newPref.addDescription(desc.getLocale(), desc.getDescription());
        }

    }
View Full Code Here

        prefs = (PreferenceSetComposite) entity.getPreferenceSet();

        assertNotNull(prefs.get("pref1"));

        PreferenceComposite pref = (PreferenceComposite) prefs.get("pref1");

        assertEquals("1", pref.getValueAt(0));

        pref.setValueAt(0, "2");

        assertEquals("2", pref.getValueAt(0));

        entity.reset();

        pref = (PreferenceComposite) prefs.get("pref1");

        assertEquals("1", pref.getValueAt(0));

        prefs.remove(pref);

        assertNull(prefs.get("pref1"));

        entity.reset();

        assertNotNull(prefs.get("pref1"));

        prefs.add("pref2", Arrays.asList(new String[]
        { "2", "3" }));

        entity.store();

        PreferenceComposite pref2 = (PreferenceComposite) prefs.get("pref2");

        assertNotNull(pref2);

        Iterator prefsValues = pref2.getValues();
        int count = 0;
        while (prefsValues.hasNext())
        {
            prefsValues.next();
            count++;
        }

        assertEquals(2, count);

        pref2.addValue("4");
        prefsValues = pref2.getValues();
        count = 0;
        while (prefsValues.hasNext())
        {
            assertEquals(String.valueOf(count + 2), prefsValues.next());
            count++;
        }
        assertEquals(3, count);

        entity.reset();

        prefsValues = pref2.getValues();
        count = 0;
        while (prefsValues.hasNext())
        {
            assertEquals(String.valueOf(count + 2), prefsValues.next());
            count++;
View Full Code Here

        PreferenceSet prefs = portlet.getPreferenceSet();
        it = prefs.iterator();
        count = 0;
        while (it.hasNext())
        {
            PreferenceComposite pref = (PreferenceComposite) it.next();
            assertNotNull("Preference.Name is null", pref.getName());
            if (pref.getName().equals("time-server"))
            {
                assertTrue("Preference.Name invalid: " + pref.getName(), pref.getName().equals("time-server"));
                assertTrue("Preference.Modifiable invalid: ", pref.isReadOnly() == false);
                validatePreferences(pref, new String[] { "http://timeserver.myco.com", "http://timeserver.foo.com" });
            }
            else
            {
                assertTrue("Preference.Name invalid: " + pref.getName(), pref.getName().equals("port"));
                assertTrue("Preference.Modifiable invalid: ", pref.isReadOnly() == true);
                validatePreferences(pref, new String[] { "404" });
            }
            count++;
        }
        assertTrue("PortletPreference Count != 2, count = " + count, count == 2);
View Full Code Here

        addDublinCore(portlet.getMetadata());

        // PreferenceComposite pc = new PrefsPreference();
        app.addPortletDefinition(portlet);
        PreferenceSetCtrl prefSetCtrl = (PreferenceSetCtrl) portlet.getPreferenceSet();
        PreferenceComposite pc = (PreferenceComposite) prefSetCtrl.add("preference 1", Arrays.asList(new String[]{
                "value 1", "value 2"}));
        pc.addDescription(JetspeedLocale.getDefaultLocale(), "Preference Description");

        assertNotNull(pc.getValueAt(0));

        portlet.addLanguage(registry.createLanguage(Locale.getDefault(), "Portlet 1", "Portlet 1", "This is Portlet 1",
                null));

        ContentTypeComposite html = new ContentTypeImpl();
View Full Code Here

        while (valueItr.hasNext())
        {
            list.add(valueItr.next());
        }

        PreferenceComposite newPref = (PreferenceComposite) ((PreferenceSetComposite) getPreferenceSet()).add(
                preference.getName(), list);

        Iterator descItr = newPref.getDescriptions();
        while (descItr.hasNext())
        {
            Description desc = (Description) descItr.next();
            newPref.addDescription(desc.getLocale(), desc.getDescription());
        }

    }
View Full Code Here

        PreferenceSet prefs = portlet.getPreferenceSet();
        it = prefs.iterator();
        count = 0;
        while (it.hasNext())
        {
            PreferenceComposite pref = (PreferenceComposite) it.next();
            assertNotNull("Preference.Name is null", pref.getName());
            if (pref.getName().equals("time-server"))
            {
                assertTrue("Preference.Name invalid: " + pref.getName(), pref.getName().equals("time-server"));
                assertTrue("Preference.Modifiable invalid: ", pref.isReadOnly() == false);
                validatePreferences(pref, new String[] { "http://timeserver.myco.com", "http://timeserver.foo.com" });
            }
            else
            {
                assertTrue("Preference.Name invalid: " + pref.getName(), pref.getName().equals("port"));
                assertTrue("Preference.Modifiable invalid: ", pref.isReadOnly() == true);
                validatePreferences(pref, new String[] { "404" });
            }
            count++;
        }
        assertTrue("PortletPreference Count != 2, count = " + count, count == 2);
View Full Code Here

       
        prefs = (PreferenceSetComposite) entity.getPreferenceSet();
       
        assertNotNull(prefs.get("pref1"));
       
        PreferenceComposite pref = (PreferenceComposite) prefs.get("pref1");
       
        assertEquals("1", pref.getValueAt(0));
       
        pref.setValueAt(0, "2");
       
        assertEquals("2", pref.getValueAt(0));
       
        entity.reset();
       
        pref = (PreferenceComposite) prefs.get("pref1");
       
        assertEquals("1", pref.getValueAt(0));
       
        prefs.remove(pref);      
       
        assertNull(prefs.get("pref1"));
       
        entity.reset();
       
        assertNotNull(prefs.get("pref1"));
       
        prefs.add("pref2", Arrays.asList(new String[]{"2", "3"}));
       
        entity.store();
       
        PreferenceComposite pref2 = (PreferenceComposite) prefs.get("pref2");
       
        assertNotNull(pref2);
       
        Iterator prefsValues = pref2.getValues();
        int count = 0;
        while(prefsValues.hasNext())
        {
            prefsValues.next();
            count++;
        }
       
        assertEquals(2, count);
       
        pref2.addValue("4");
        prefsValues = pref2.getValues();
        count = 0;
        while(prefsValues.hasNext())
        {
            assertEquals(String.valueOf(count+2), prefsValues.next());
            count++;
        }
        assertEquals(3, count);
       
        entity.reset();
       
        prefsValues = pref2.getValues();
        count = 0;
        while(prefsValues.hasNext())
        {
            assertEquals(String.valueOf(count+2), prefsValues.next());
            count++;
View Full Code Here

        if(action.equals("add_preference"))
        {
            String name = actionRequest.getParameter("name");
            String value = actionRequest.getParameter("value");
           
            PreferenceComposite pref = (PreferenceComposite) portlet.getPreferenceSet().get(name);
            if(pref == null)
            {
                portlet.addPreference(name, new String[] { value });
            }
            else
            {
                pref.addValue(value);
            }
           
            registry.savePortletDefinition(portlet);
        }
        else if(action.equals("edit_preference"))
        {
            String[] prefNames = actionRequest.getParameterValues("pref_edit_id");
            for (int i = 0; i < prefNames.length; i++)
            {
                String prefName = prefNames[i];
                PreferenceComposite prefComp = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
                String[] values = prefComp.getValueArray();
                for (int j = 0; j < values.length; j++)
                {
                    String value = values[j];
                    String newValue = actionRequest.getParameter(prefName + ":" + j);
                    if(!value.equals(newValue))
                    {
                        prefComp.setValueAt(j, newValue);
                    }
                }
            }
           
            registry.savePortletDefinition(portlet);
        }
        else if(action.equals("remove_preference"))
        {
            String[] prefNames = actionRequest.getParameterValues("pref_remove_id");
           
            Iterator prefIter = portlet.getPreferenceSet().iterator();
            while (prefIter.hasNext())
            {
                PreferenceComposite pref = (PreferenceComposite) prefIter.next();
                String name = pref.getName();
               
                for(int i=0; i<prefNames.length; i++)
                {
                    String prefName = prefNames[i];
                    if(name.equals(prefName))
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.common.preference.PreferenceComposite

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.