Example usage for com.vaadin.server Sizeable setSizeFull

List of usage examples for com.vaadin.server Sizeable setSizeFull

Introduction

In this page you can find the example usage for com.vaadin.server Sizeable setSizeFull.

Prototype

public void setSizeFull();

Source Link

Document

Sets the size to 100% x 100%.

Usage

From source file:at.jku.ce.adaptivetesting.vaadin.ui.QuestionManager.java

License:LGPL

@Override
public void questionChanged(IQuestion<? extends AnswerStorage> question) {
    // This cast won't fail as every question in the engine is a Component
    // as well//from  ww  w. ja  v a 2  s.  c  o  m
    if (question != null) {
        questionNo++;
        Label newTitel = HtmlLabel.getCenteredLabel("h1", "Aufgabe " + questionNo);
        replaceComponent(title, newTitel);
        title = newTitel;
        Component c = (Component) question;
        questionHolder.addComponent(c);
        Sizeable s = (Sizeable) question;
        s.setSizeFull();
    }
    next.setEnabled(true);
}

From source file:at.jku.ce.adaptivetesting.vaadin.ui.VaadinResultView.java

License:LGPL

public VaadinResultView(ResultFiredArgs args, String title) {
    setSpacing(true);//from w w  w .  j a  va 2 s .  c  o m
    addComponent(new HtmlLabel(title));
    //addComponent(HtmlLabel.getCenteredLabel("h2", "Test abgeschlossen"));
    addComponent(HtmlLabel.getCenteredLabel(
            "Der Test wurde beendet, da " + (args.outOfQuestions ? "keine weiteren Fragen verfgbar sind."
                    : "dein Kompetenzniveau bestimmt wurde.")));
    addComponent(HtmlLabel.getCenteredLabel(
            "Im Folgenden siehst du die Fragen und die gegebenen Antworten in zeitlich absteigender Reihenfolge."));
    addComponent(HtmlLabel.getCenteredLabel(
            "Die Zahl in der ersten Spalte bezieht sich auf die Schwierigkeit der jeweiligen Frage. Negative Zahlen stehen fr leichtere Fragen, positive Zahlen kennzeichnen schwierigere Fragen."));

    // Create HTML table of the history
    Table table = new Table();
    final String solution = "Korrekte Antwort", userAnswer = "Ihre Antwort";
    table.addContainerProperty("Schwierigkeitsgrad", Float.class, null);
    table.addContainerProperty("Resultat", String.class, null);
    table.addContainerProperty(userAnswer, Button.class, null);
    table.addContainerProperty(solution, Button.class, null);
    //List<HistoryEntry> entries = Lists.reverse(args.history);
    List<HistoryEntry> entries = new ArrayList<HistoryEntry>(args.history);
    Collections.reverse(entries);

    for (HistoryEntry entry : entries) {
        Button qAnswer = null, qSolution = null;
        if (entry.question instanceof Component && entry.question != null) {
            try {
                Class<? extends AnswerStorage> dataStorageClass = entry.question.getSolution().getClass();
                Constructor<? extends IQuestion> constructor = entry.question.getClass()
                        .getConstructor(dataStorageClass, dataStorageClass, float.class, String.class);
                // The following casts can not fail, because the question is
                // a component as well
                Component iQuestionSolution = (Component) constructor.newInstance(entry.question.getSolution(),
                        entry.question.getSolution(), entry.question.getDifficulty(),
                        entry.question.getQuestionText());
                Component iQuestionUser = (Component) constructor.newInstance(entry.question.getSolution(),
                        entry.question.getUserAnswer(), entry.question.getDifficulty(),
                        entry.question.getQuestionText());
                // Create the 2 needed click listeners
                ClickListener clickListenerSol = event -> {
                    Window window = new Window(solution);
                    event.getButton().setEnabled(false);
                    window.addCloseListener(e -> event.getButton().setEnabled(true));
                    window.setContent(iQuestionSolution);
                    window.center();
                    window.setWidth("90%");
                    window.setHeight("50%");
                    if (iQuestionSolution instanceof Sizeable) {
                        Sizeable sizeable = iQuestionSolution;
                        sizeable.setSizeFull();
                    }
                    getUI().addWindow(window);
                };

                ClickListener clickListenerUA = event -> {
                    Window window = new Window(userAnswer);
                    event.getButton().setEnabled(false);
                    window.addCloseListener(e -> event.getButton().setEnabled(true));
                    window.setContent(iQuestionUser);
                    window.center();
                    window.setWidth("90%");
                    window.setHeight("50%");
                    if (iQuestionUser instanceof Sizeable) {
                        Sizeable sizeable = iQuestionUser;
                        sizeable.setSizeFull();
                    }
                    getUI().addWindow(window);
                };

                // Create the two buttons
                qAnswer = new Button(userAnswer, clickListenerUA);
                qSolution = new Button(solution, clickListenerSol);

            } catch (Exception e) {
                // Ignore this line in the table
                LogHelper.logInfo("1 entry's solution/ user answer are missing on the final screen."
                        + entry.question.getClass().getName()
                        + " does not implement the constructors required by" + IQuestion.class.getName());
            }
        }

        table.addItem(new Object[] { entry.question.getDifficulty(),
                isCorrect(entry.points, entry.question.getMaxPoints()), qAnswer, qSolution }, null);
    }
    int size = table.size();
    if (size > 10) {
        size = 10;
    }
    table.setPageLength(size);
    addComponent(table);
    setComponentAlignment(table, Alignment.MIDDLE_CENTER);

    addComponent(HtmlLabel.getCenteredLabel("h3", "Dein Kompetenzniveau ist: <b>" + args.skillLevel + "</b>"));
    addComponent(HtmlLabel.getCenteredLabel("Delta:  " + args.delta));
    storeResults(args);
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.QuestionManager.java

License:LGPL

@Override
public void questionChanged(IQuestion<? extends AnswerStorage> question) {
    // This cast won't fail as every question in the engine is a Component
    // as well//from w ww  .j  a  v a 2s  . co  m
    if (question != null) {
        Component c = (Component) question;
        questionHolder.addComponent(c);
        Sizeable s = (Sizeable) question;
        s.setSizeFull();
    }
    next.setEnabled(true);
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.VaadinResultView.java

License:LGPL

public VaadinResultView(ResultFiredArgs args, String title) {
    setSpacing(true);//  w w  w  .j  a v a2s. c o m
    addComponent(new HtmlLabel(title));
    addComponent(HtmlLabel.getCenteredLabel("h2", "Finished test"));
    addComponent(HtmlLabel.getCenteredLabel("The test ended, because we "
            + (args.outOfQuestions ? "did not have any more questions" : "determined your skill level")));
    addComponent(HtmlLabel.getCenteredLabel(
            "This are the difficulties and your answers. On top are your last answers. The first column indicates the difficulty."));
    addComponent(HtmlLabel.getCenteredLabel(
            "Closer to -INF means easy question, to +INF dificult questions. This also applies to your skill level!"));

    // Create HTML table of the history
    Table table = new Table();
    final String solution = "Solution", userAnswewr = "Yourt answer";
    table.addContainerProperty("Question difficulty", Float.class, null);
    table.addContainerProperty("Result", String.class, null);
    table.addContainerProperty(userAnswewr, Button.class, null);
    table.addContainerProperty(solution, Button.class, null);
    List<HistoryEntry> entries = Lists.reverse(args.history);

    for (HistoryEntry entry : entries) {
        Button qAnswer = null, qSolution = null;
        if (entry.question instanceof Component && entry.question != null) {
            try {
                Class<? extends AnswerStorage> dataStorageClass = entry.question.getSolution().getClass();
                Constructor<? extends IQuestion> constructor = entry.question.getClass()
                        .getConstructor(dataStorageClass, dataStorageClass, float.class, String.class);
                // The following casts can not fail, because the question is
                // a component as well
                Component iQuestionSolution = (Component) constructor.newInstance(entry.question.getSolution(),
                        entry.question.getSolution(), entry.question.getDifficulty(),
                        entry.question.getQuestionText());
                Component iQuestionUser = (Component) constructor.newInstance(entry.question.getSolution(),
                        entry.question.getUserAnswer(), entry.question.getDifficulty(),
                        entry.question.getQuestionText());
                // Create the 2 needed click listeners
                ClickListener clickListenerSol = event -> {
                    Window window = new Window(solution);
                    event.getButton().setEnabled(false);
                    window.addCloseListener(e -> event.getButton().setEnabled(true));
                    window.setContent(iQuestionSolution);
                    window.center();
                    window.setWidth("90%");
                    window.setHeight("50%");
                    if (iQuestionSolution instanceof Sizeable) {
                        Sizeable sizeable = iQuestionSolution;
                        sizeable.setSizeFull();
                    }
                    getUI().addWindow(window);
                };

                ClickListener clickListenerUA = event -> {
                    Window window = new Window(userAnswewr);
                    event.getButton().setEnabled(false);
                    window.addCloseListener(e -> event.getButton().setEnabled(true));
                    window.setContent(iQuestionUser);
                    window.center();
                    window.setWidth("90%");
                    window.setHeight("50%");
                    if (iQuestionUser instanceof Sizeable) {
                        Sizeable sizeable = iQuestionUser;
                        sizeable.setSizeFull();
                    }
                    getUI().addWindow(window);
                };

                // Create the two buttons
                qAnswer = new Button(userAnswewr, clickListenerUA);
                qSolution = new Button(solution, clickListenerSol);

            } catch (Exception e) {
                // Ignore this line in the table
                LogHelper.logInfo("1 entry's solution/ user answer are missing on the final screen."
                        + entry.question.getClass().getName()
                        + " does not implement the constructors required by" + IQuestion.class.getName());
            }
        }

        table.addItem(new Object[] { entry.question.getDifficulty(),
                isCorrect(entry.points, entry.question.getMaxPoints()), qAnswer, qSolution }, null);
    }
    int size = table.size();
    if (size > 10) {
        size = 10;
    }
    table.setPageLength(size);
    addComponent(table);
    setComponentAlignment(table, Alignment.MIDDLE_CENTER);

    addComponent(HtmlLabel.getCenteredLabel("h3", "Your skill level is: <b>" + args.skillLevel + "</b>"));
    addComponent(HtmlLabel.getCenteredLabel("Delta (Valus close to 0 are best):  " + args.delta));
}