Please see in attachment the demo.

2010/12/18 Greg Brown <[email protected]>

> Any chance you could provide a simple app that demonstrates the issue?
>
> On Dec 17, 2010, at 1:10 PM, Eugene Kondrashev wrote:
>
> > Hi
> >
> > I faced with issue while refreshing my accordion view.
> >
> > Let say I have one accordion and one button refreshing accordions data
> and setting index.
> >
> >
> >         nextCompanyButton.getButtonPressListeners().add(new
> ButtonPressListener() {
> >
> >             @Override
> >             public void buttonPressed(Button button) {
> >                 companiesAccordion.getPanels().remove(0,
> companiesAccordion.getPanels().getLength());
> >
> >                 CompanyViewController companyView =
> UIComponents.companyView();
> >                 companyView.load(new BeanAdapter(new Company()));
> >                 Accordion.setLabel(companyView, "T1");
> >                 companiesAccordion.getPanels().add(companyView);
> >                 companyView = UIComponents.companyView();
> >                 companyView.load(new BeanAdapter(new Company()));
> >                 Accordion.setLabel(companyView, "T2");
> >                 companiesAccordion.getPanels().add(companyView);
> >                 companiesAccordion.setSelectedIndex(1);
> >             }
> >         });
> >
> > As you can see, i'm removing all the panels and initing them from the
> scrach.
> > So when i'm setting selection index to 0 it is ok no artifacts appears,
> but if it is 1 accrodion is flipping. I mean the accordion area is getting
> blank for a second or half and then is back to normal with right panel
> selected. Seems like that half a second perion selection transition is done.
> But there is no animation on screen.
> >
> > So finally, I need to refresh my accordion and set correct panel index.
> Can you tell me how can i do that without that flipping affect?
> > Perhaps I can turn off that selection animation while refresh or
> something?
> >
> > Thanks, Eugene
>
>
import com.mbt.client.gui.pivot.CompanyViewController;
import com.mbt.client.gui.pivot.factory.UIComponents;
import com.mbt.core.bean.CompanyVO;
import org.apache.pivot.beans.BeanAdapter;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.*;
import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.Label;
import org.apache.pivot.wtk.Window;

import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: eugene
 * Date: 18.12.2010
 * Time: 15:38:07
 */
public class AccordionTest implements Application {
    private Window window = null;
    private Accordion accordion = null;
    private PushButton button;


    private Label getLabel(String text) {
        Label label = new Label();
        label.setText(text);
        label.getStyles().put("font", new Font("Arial", Font.BOLD, 24));
        label.getStyles().put("color", Color.RED);
        label.getStyles().put("horizontalAlignment",
            HorizontalAlignment.CENTER);
        label.getStyles().put("verticalAlignment",
            VerticalAlignment.CENTER);
        return label;
    }
    @Override
    public void startup(Display display, Map<String, String> properties) throws Exception {
//        Label accordion = new Label();
//        accordion.setText("Hello World!");
//        accordion.getStyles().put("font", new Font("Arial", Font.BOLD, 24));
//        accordion.getStyles().put("color", Color.RED);
        BoxPane boxPane = new BoxPane();
        accordion = new Accordion();
        button = new PushButton("next");
        Label label = getLabel("L1");
        Accordion.setLabel(label, "T1");
        accordion.getPanels().add(label);
        label = getLabel("T2");
        Accordion.setLabel(label, "T2");
        accordion.getPanels().add(label);
        
        button.getButtonPressListeners().add(new ButtonPressListener() {

            @Override
            public void buttonPressed(Button button) {
                accordion.getPanels().remove(0, accordion.getPanels().getLength());

                Label label = getLabel("L1");
                Accordion.setLabel(label, "T1");
                accordion.getPanels().add(label);
                label = getLabel("T2");
                Accordion.setLabel(label, "T2");
                accordion.getPanels().add(label);
                accordion.setSelectedIndex(1);
            }
        });

        boxPane.setOrientation(Orientation.VERTICAL);
        boxPane.getStyles().put("fill",
                Boolean.TRUE);

        boxPane.add(accordion);
        boxPane.add(button);
        window = new Window();
        window.setContent(boxPane);
        window.setTitle("Hello World!");
        window.setMaximized(true);
        window.open(display);
    }

    @Override
    public boolean shutdown(boolean optional) throws Exception {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void suspend() throws Exception {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void resume() throws Exception {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    public static void main(String[] args) {
        DesktopApplicationContext.main(AccordionTest.class, args);
    }
}

Reply via email to