Example usage for com.vaadin.ui Panel setHeight

List of usage examples for com.vaadin.ui Panel setHeight

Introduction

In this page you can find the example usage for com.vaadin.ui Panel setHeight.

Prototype

@Override
    public void setHeight(float height, Unit unit) 

Source Link

Usage

From source file:org.activiti.editor.ui.EditorProcessDefinitionInfoComponent.java

License:Apache License

protected void initImage() {
    processImageContainer = new VerticalLayout();

    Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processImageContainer.addComponent(processTitle);

    StreamSource streamSource = null;
    final byte[] editorSourceExtra = repositoryService.getModelEditorSourceExtra(modelData.getId());
    if (editorSourceExtra != null) {
        streamSource = new StreamSource() {
            private static final long serialVersionUID = 1L;

            public InputStream getStream() {
                InputStream inStream = null;
                try {
                    inStream = new ByteArrayInputStream(editorSourceExtra);
                } catch (Exception e) {
                    LOGGER.warn("Error reading PNG in StreamSource", e);
                }/*from   www  .j a  va2  s  .  c  o  m*/
                return inStream;
            }
        };
    }

    if (streamSource != null) {
        Embedded embedded = new Embedded(null, new ImageStreamSource(streamSource, ExplorerApp.get()));
        embedded.setType(Embedded.TYPE_IMAGE);
        embedded.setSizeUndefined();

        Panel imagePanel = new Panel(); // using panel for scrollbars
        imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
        imagePanel.setWidth(100, UNITS_PERCENTAGE);
        imagePanel.setHeight(700, UNITS_PIXELS);
        HorizontalLayout panelLayout = new HorizontalLayout();
        panelLayout.setSizeUndefined();
        imagePanel.setContent(panelLayout);
        imagePanel.addComponent(embedded);

        processImageContainer.addComponent(imagePanel);
    } else {
        Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM));
        processImageContainer.addComponent(noImageAvailable);
    }
    addComponent(processImageContainer);
}

From source file:org.activiti.explorer.ui.content.email.EmailDetailPanel.java

License:Apache License

protected void addHtmlContent(String html) {
    Panel panel = new Panel();
    panel.setWidth(800, UNITS_PIXELS);//from  ww w.j  a va2s.co  m
    panel.setHeight(300, UNITS_PIXELS);

    content = new Label(html, Label.CONTENT_XHTML);
    content.setHeight(100, UNITS_PERCENTAGE);

    panel.addComponent(content);
    addComponent(panel);
}

From source file:org.activiti.explorer.ui.management.process.ProcessInstanceDetailPanel.java

License:Apache License

protected void addProcessImage() {
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
            .getDeployedProcessDefinition(processDefinition.getId());

    // Only show when graphical notation is defined
    if (processDefinitionEntity != null && processDefinitionEntity.isGraphicalNotationDefined()) {
        StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder()
                .buildStreamResource(processInstance, repositoryService, runtimeService);

        if (diagram != null) {
            Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
            header.addStyleName(ExplorerLayout.STYLE_H3);
            header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
            header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
            panelLayout.addComponent(header);

            Embedded embedded = new Embedded(null, diagram);
            embedded.setType(Embedded.TYPE_IMAGE);
            embedded.setSizeUndefined();

            Panel imagePanel = new Panel(); // using panel for scrollbars
            imagePanel.setScrollable(true);
            imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
            imagePanel.setWidth(100, UNITS_PERCENTAGE);
            imagePanel.setHeight(400, UNITS_PIXELS);

            HorizontalLayout panelLayoutT = new HorizontalLayout();
            panelLayoutT.setSizeUndefined();
            imagePanel.setContent(panelLayoutT);
            imagePanel.addComponent(embedded);

            panelLayout.addComponent(imagePanel);
        }/*from w w  w .  j av a 2 s.c  om*/
    }
}

From source file:org.activiti.explorer.ui.management.processinstance.ProcessInstanceDetailPanel.java

License:Apache License

protected void addProcessImage() {
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
            .getDeployedProcessDefinition(processDefinition.getId());

    // Only show when graphical notation is defined
    if (processDefinitionEntity != null) {

        boolean didDrawImage = false;

        if (ExplorerApp.get().isUseJavascriptDiagram()) {
            try {

                final InputStream definitionStream = repositoryService.getResourceAsStream(
                        processDefinition.getDeploymentId(), processDefinition.getResourceName());
                XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
                XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
                BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

                if (!bpmnModel.getFlowLocationMap().isEmpty()) {

                    int maxX = 0;
                    int maxY = 0;
                    for (String key : bpmnModel.getLocationMap().keySet()) {
                        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
                        double elementX = graphicInfo.getX() + graphicInfo.getWidth();
                        if (maxX < elementX) {
                            maxX = (int) elementX;
                        }/*from  www .j a v  a  2s  .  c  o  m*/
                        double elementY = graphicInfo.getY() + graphicInfo.getHeight();
                        if (maxY < elementY) {
                            maxY = (int) elementY;
                        }
                    }

                    Panel imagePanel = new Panel(); // using panel for scrollbars
                    imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
                    imagePanel.setWidth(100, UNITS_PERCENTAGE);
                    imagePanel.setHeight(100, UNITS_PERCENTAGE);
                    URL explorerURL = ExplorerApp.get().getURL();
                    URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(),
                            explorerURL.getPath().replace("/ui", "")
                                    + "diagram-viewer/index.html?processDefinitionId="
                                    + processDefinition.getId() + "&processInstanceId="
                                    + processInstance.getId());
                    Embedded browserPanel = new Embedded("", new ExternalResource(url));
                    browserPanel.setType(Embedded.TYPE_BROWSER);
                    browserPanel.setWidth(maxX + 350 + "px");
                    browserPanel.setHeight(maxY + 220 + "px");

                    HorizontalLayout panelLayoutT = new HorizontalLayout();
                    panelLayoutT.setSizeUndefined();
                    imagePanel.setContent(panelLayoutT);
                    imagePanel.addComponent(browserPanel);

                    panelLayout.addComponent(imagePanel);

                    didDrawImage = true;
                }

            } catch (Exception e) {
                LOGGER.error("Error loading process diagram component", e);
            }
        }

        if (!didDrawImage && processDefinitionEntity.isGraphicalNotationDefined()) {
            ProcessEngineConfiguration processEngineConfiguration = ProcessEngines.getDefaultProcessEngine()
                    .getProcessEngineConfiguration();
            ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
            StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(
                    processInstance, repositoryService, runtimeService, diagramGenerator,
                    processEngineConfiguration);

            if (diagram != null) {
                Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
                header.addStyleName(ExplorerLayout.STYLE_H3);
                header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
                header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
                panelLayout.addComponent(header);

                Embedded embedded = new Embedded(null, diagram);
                embedded.setType(Embedded.TYPE_IMAGE);
                embedded.setSizeUndefined();

                Panel imagePanel = new Panel(); // using panel for scrollbars
                imagePanel.setScrollable(true);
                imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
                imagePanel.setWidth(100, UNITS_PERCENTAGE);
                imagePanel.setHeight(100, UNITS_PERCENTAGE);

                HorizontalLayout panelLayoutT = new HorizontalLayout();
                panelLayoutT.setSizeUndefined();
                imagePanel.setContent(panelLayoutT);
                imagePanel.addComponent(embedded);

                panelLayout.addComponent(imagePanel);
            }
        }
    }
}

From source file:org.activiti.explorer.ui.process.ProcessDefinitionInfoComponent.java

License:Apache License

protected void initImage() {
    processImageContainer = new VerticalLayout();

    Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processImageContainer.addComponent(processTitle);

    boolean didDrawImage = false;

    if (ExplorerApp.get().isUseJavascriptDiagram()) {
        try {//  w  w  w  . j  a  v a 2  s .  c o  m

            final InputStream definitionStream = repositoryService.getResourceAsStream(
                    processDefinition.getDeploymentId(), processDefinition.getResourceName());
            XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
            XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
            BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

            if (!bpmnModel.getFlowLocationMap().isEmpty()) {

                int maxX = 0;
                int maxY = 0;
                for (String key : bpmnModel.getLocationMap().keySet()) {
                    GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
                    double elementX = graphicInfo.getX() + graphicInfo.getWidth();
                    if (maxX < elementX) {
                        maxX = (int) elementX;
                    }
                    double elementY = graphicInfo.getY() + graphicInfo.getHeight();
                    if (maxY < elementY) {
                        maxY = (int) elementY;
                    }
                }

                Panel imagePanel = new Panel(); // using panel for scrollbars
                imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
                imagePanel.setWidth(100, UNITS_PERCENTAGE);
                imagePanel.setHeight(100, UNITS_PERCENTAGE);

                URL explorerURL = ExplorerApp.get().getURL();
                URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(),
                        explorerURL.getPath().replace("/ui", "")
                                + "diagram-viewer/index.html?processDefinitionId=" + processDefinition.getId());
                Embedded browserPanel = new Embedded("", new ExternalResource(url));
                browserPanel.setType(Embedded.TYPE_BROWSER);
                browserPanel.setWidth(maxX + 350 + "px");
                browserPanel.setHeight(maxY + 220 + "px");

                HorizontalLayout panelLayout = new HorizontalLayout();
                panelLayout.setSizeUndefined();
                imagePanel.setContent(panelLayout);
                imagePanel.addComponent(browserPanel);

                processImageContainer.addComponent(imagePanel);

                didDrawImage = true;
            }

        } catch (Exception e) {
            LOGGER.error("Error loading process diagram component", e);
        }
    }

    if (didDrawImage == false) {

        StreamResource diagram = null;

        // Try generating process-image stream
        if (processDefinition.getDiagramResourceName() != null) {
            diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(processDefinition,
                    repositoryService);
        }

        if (diagram != null) {

            Embedded embedded = new Embedded(null, diagram);
            embedded.setType(Embedded.TYPE_IMAGE);
            embedded.setSizeUndefined();

            Panel imagePanel = new Panel(); // using panel for scrollbars
            imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
            imagePanel.setWidth(100, UNITS_PERCENTAGE);
            imagePanel.setHeight(100, UNITS_PERCENTAGE);
            HorizontalLayout panelLayout = new HorizontalLayout();
            panelLayout.setSizeUndefined();
            imagePanel.setContent(panelLayout);
            imagePanel.addComponent(embedded);
            processImageContainer.addComponent(imagePanel);

            didDrawImage = true;
        }
    }

    if (didDrawImage == false) {
        Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM));
        processImageContainer.addComponent(noImageAvailable);
    }
    addComponent(processImageContainer);
}

From source file:org.eclipse.hawkbit.ui.common.table.AbstractTableLayout.java

License:Open Source License

private void buildLayout() {
    setSizeFull();//from  w w  w.  j a v a  2  s.  c  o  m
    setSpacing(true);
    setMargin(false);
    setStyleName("group");
    final VerticalLayout tableHeaderLayout = new VerticalLayout();
    tableHeaderLayout.setSizeFull();
    tableHeaderLayout.setSpacing(false);
    tableHeaderLayout.setMargin(false);

    tableHeaderLayout.setStyleName("table-layout");
    tableHeaderLayout.addComponent(tableHeader);

    tableHeaderLayout.setComponentAlignment(tableHeader, Alignment.TOP_CENTER);
    if (isShortCutKeysRequired()) {
        final Panel tablePanel = new Panel();
        tablePanel.setStyleName("table-panel");
        tablePanel.setHeight(100.0F, Unit.PERCENTAGE);
        tablePanel.setContent(table);
        tablePanel.addActionHandler(getShortCutKeysHandler(i18n));
        tablePanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
        tableHeaderLayout.addComponent(tablePanel);
        tableHeaderLayout.setComponentAlignment(tablePanel, Alignment.TOP_CENTER);
        tableHeaderLayout.setExpandRatio(tablePanel, 1.0F);
    } else {
        tableHeaderLayout.addComponent(table);
        tableHeaderLayout.setComponentAlignment(table, Alignment.TOP_CENTER);
        tableHeaderLayout.setExpandRatio(table, 1.0F);
    }

    addComponent(tableHeaderLayout);
    addComponent(detailsLayout);
    setComponentAlignment(tableHeaderLayout, Alignment.TOP_CENTER);
    setComponentAlignment(detailsLayout, Alignment.TOP_CENTER);
    setExpandRatio(tableHeaderLayout, 1.0F);
}

From source file:org.esn.esobase.view.tab.QuestTranslateTab.java

public QuestTranslateTab(DBService service_) {
    this.setSizeFull();
    this.setSpacing(false);
    this.setMargin(false);
    this.service = service_;
    QuestChangeListener questChangeListener = new QuestChangeListener();
    FilterChangeListener filterChangeListener = new FilterChangeListener();
    questListlayout = new HorizontalLayout();
    questListlayout.setWidth(100f, Unit.PERCENTAGE);
    questListlayout.setSpacing(false);// w  ww  .  j a  v a2 s. c o m
    questListlayout.setMargin(false);
    locationTable = new ComboBox("?");
    locationTable.setPageLength(30);
    locationTable.setScrollToSelectedItem(true);
    locationTable.setWidth(100f, Unit.PERCENTAGE);
    locationTable.addValueChangeListener(filterChangeListener);
    locationTable.setDataProvider(new ListDataProvider<>(locations));
    questTable = new ComboBox("?");
    questTable.setWidth(100f, Unit.PERCENTAGE);
    questTable.setPageLength(15);
    questTable.setScrollToSelectedItem(true);

    questTable.setWidth(100f, Unit.PERCENTAGE);
    questTable.addValueChangeListener(questChangeListener);
    questTable.setDataProvider(new ListDataProvider<>(questList));
    questListlayout.addComponent(questTable);
    FormLayout locationAndQuestLayout = new FormLayout(locationTable, questTable);
    locationAndQuestLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    locationAndQuestLayout.setSizeFull();
    questListlayout.addComponent(locationAndQuestLayout);
    translateStatus = new ComboBoxMultiselect("? ",
            Arrays.asList(TRANSLATE_STATUS.values()));
    translateStatus.setClearButtonCaption("?");
    translateStatus.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            LoadFilters();
            LoadContent();
        }
    });
    noTranslations = new CheckBox("?  ?");
    noTranslations.setValue(Boolean.FALSE);
    noTranslations.addValueChangeListener(filterChangeListener);
    emptyTranslations = new CheckBox("?  ");
    emptyTranslations.setValue(Boolean.FALSE);
    emptyTranslations.addValueChangeListener(filterChangeListener);
    HorizontalLayout checkBoxlayout = new HorizontalLayout(noTranslations, emptyTranslations);
    checkBoxlayout.setSpacing(false);
    checkBoxlayout.setMargin(false);
    translatorBox = new ComboBox("");
    translatorBox.setPageLength(15);
    translatorBox.setScrollToSelectedItem(true);
    translatorBox.setDataProvider(new ListDataProvider<SysAccount>(service.getSysAccounts()));
    translatorBox.addValueChangeListener(filterChangeListener);
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadFilters();
            LoadContent();
        }
    });
    countLabel = new Label();
    searchField = new TextField("?? ?");
    searchField.setSizeFull();
    searchField.addValueChangeListener(filterChangeListener);

    FormLayout filtersLayout = new FormLayout(translateStatus, translatorBox, checkBoxlayout, searchField);
    filtersLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    filtersLayout.setSizeFull();
    questListlayout.addComponent(filtersLayout);
    questListlayout.addComponent(refreshButton);
    questListlayout.addComponent(countLabel);
    questListlayout.setExpandRatio(locationAndQuestLayout, 0.4f);
    questListlayout.setExpandRatio(filtersLayout, 0.4f);
    questListlayout.setExpandRatio(refreshButton, 0.1f);
    questListlayout.setExpandRatio(countLabel, 0.1f);
    questListlayout.setHeight(105f, Unit.PIXELS);
    this.addComponent(questListlayout);
    infoLayout = new VerticalLayout();
    infoLayout.setSizeFull();
    infoLayout.setSpacing(false);
    infoLayout.setMargin(false);
    tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    nameLayout = new VerticalLayout();
    nameLayout.setSizeFull();
    nameHLayout = new HorizontalLayout();
    nameHLayout.setSizeFull();
    nameHLayout.setSpacing(false);
    nameHLayout.setMargin(false);
    nameLayout = new VerticalLayout();
    nameLayout.setSizeFull();
    nameLayout.setSpacing(false);
    nameLayout.setMargin(false);
    questNameEnArea = new TextArea("?");
    questNameEnArea.setSizeFull();
    questNameEnArea.setRows(1);
    questNameEnArea.setReadOnly(true);
    questNameRuArea = new TextArea("? Ru");
    questNameRuArea.setSizeFull();
    questNameRuArea.setRows(1);
    questNameRuArea.setReadOnly(true);
    questNameRawEnArea = new TextArea("?  ");
    questNameRawEnArea.setSizeFull();
    questNameRawEnArea.setRows(1);
    questNameRawEnArea.setReadOnly(true);
    questNameRawRuArea = new TextArea("?   Ru");
    questNameRawRuArea.setSizeFull();
    questNameRawRuArea.setRows(1);
    questNameRawRuArea.setReadOnly(true);
    nameLayout.addComponents(questNameEnArea, questNameRuArea, questNameRawEnArea, questNameRawRuArea);
    nameHLayout.addComponent(nameLayout);
    nameTranslateLayout = new VerticalLayout();
    nameTranslateLayout.setSizeFull();
    nameTranslateLayout.setSpacing(false);
    nameTranslateLayout.setMargin(false);
    nameHLayout.addComponent(nameTranslateLayout);
    infoLayout.addComponent(nameHLayout);
    descriptionLayout = new VerticalLayout();
    descriptionLayout.setSizeFull();
    descriptionHLayout = new HorizontalLayout();
    descriptionHLayout.setSizeFull();
    descriptionHLayout.setSpacing(false);
    descriptionHLayout.setMargin(false);
    descriptionLayout = new VerticalLayout();
    descriptionLayout.setSizeFull();
    descriptionLayout.setSpacing(false);
    descriptionLayout.setMargin(false);
    questDescriptionEnArea = new TextArea("?");
    questDescriptionEnArea.setSizeFull();
    questDescriptionEnArea.setRows(4);
    questDescriptionEnArea.setReadOnly(true);
    questDescriptionRuArea = new TextArea("? Ru");
    questDescriptionRuArea.setSizeFull();
    questDescriptionRuArea.setRows(4);
    questDescriptionRuArea.setReadOnly(true);
    questDescriptionRawEnArea = new TextArea("?  ");
    questDescriptionRawEnArea.setSizeFull();
    questDescriptionRawEnArea.setRows(4);
    questDescriptionRawEnArea.setReadOnly(true);
    questDescriptionRawRuArea = new TextArea("?   Ru");
    questDescriptionRawRuArea.setSizeFull();
    questDescriptionRawRuArea.setRows(4);
    questDescriptionRawRuArea.setReadOnly(true);
    descriptionLayout.addComponents(questDescriptionEnArea, questDescriptionRuArea, questDescriptionRawEnArea,
            questDescriptionRawRuArea);
    descriptionHLayout.addComponent(descriptionLayout);
    descriptionTranslateLayout = new VerticalLayout();
    descriptionTranslateLayout.setSizeFull();
    descriptionTranslateLayout.setSpacing(false);
    descriptionTranslateLayout.setMargin(false);
    descriptionHLayout.addComponent(descriptionTranslateLayout);
    infoLayout.addComponent(descriptionHLayout);
    tabSheet.addTab(infoLayout, "?");
    stepsLayout = new VerticalLayout();
    stepsLayout.setSizeFull();
    stepsLayout.setSpacing(false);
    stepsLayout.setMargin(false);
    stepsData = new TreeData();
    stepsGrid = new TreeGrid(new TreeDataProvider(stepsData));
    stepsGrid.setSelectionMode(Grid.SelectionMode.NONE);
    stepsGrid.setRowHeight(250);
    stepsGrid.setHeaderVisible(false);
    stepsGrid.setSizeFull();
    stepsGrid.setItemCollapseAllowedProvider(new ItemCollapseAllowedProvider() {
        @Override
        public boolean test(Object item) {
            return false;
        }
    });
    stepsGrid.addColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            if (source instanceof QuestStep) {
                return "?";
            }
            if (source instanceof QuestDirection) {
                return " - " + ((QuestDirection) source).getDirectionType().name();
            }
            return null;
        }
    }).setId("rowType").setCaption("").setWidth(132).setStyleGenerator(rowStyleGenerator);
    stepsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestStep) {

                QuestStep step = (QuestStep) source;
                if (step.getTextEn() != null && !step.getTextEn().isEmpty()) {
                    TextArea textEnArea = new TextArea("?  ");
                    textEnArea.setValue(step.getTextEn());
                    textEnArea.setReadOnly(true);
                    textEnArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnArea);
                }
                if (step.getTextRu() != null && !step.getTextRu().isEmpty()) {
                    TextArea textRuArea = new TextArea("  ");
                    textRuArea.setValue(step.getTextRu());
                    textRuArea.setReadOnly(true);
                    textRuArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textRuArea);
                }
            } else if (source instanceof QuestDirection) {
                QuestDirection d = (QuestDirection) source;
                if (d.getTextEn() != null && !d.getTextEn().isEmpty()) {
                    TextArea textEnArea = new TextArea("?  ");
                    textEnArea.setValue(d.getTextEn());
                    textEnArea.setRows(2);
                    textEnArea.setReadOnly(true);
                    textEnArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnArea);
                }
                if (d.getTextRu() != null && !d.getTextRu().isEmpty()) {
                    TextArea textRuArea = new TextArea("  ");
                    textRuArea.setValue(d.getTextRu());
                    textRuArea.setRows(2);
                    textRuArea.setReadOnly(true);
                    textRuArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textRuArea);
                }

            }
            return result;
        }
    }).setId("ingameText").setStyleGenerator(rowStyleGenerator);
    stepsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestStep) {

                QuestStep step = (QuestStep) source;
                if (step.getSheetsJournalEntry() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(step.getSheetsJournalEntry().getTextEn());
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (step.getSheetsJournalEntry().getTextRu() != null && !step.getSheetsJournalEntry()
                            .getTextRu().equals(step.getSheetsJournalEntry().getTextEn())) {
                        TextArea textRuRawArea = new TextArea("    "
                                + step.getSheetsJournalEntry().getTranslator());
                        textRuRawArea.setValue(step.getSheetsJournalEntry().getTextRu());
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);//, "  " 
                    }
                }

            } else if (source instanceof QuestDirection) {
                QuestDirection d = (QuestDirection) source;
                if (d.getSheetsQuestDirection() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(d.getSheetsQuestDirection().getTextEn());
                    textEnRawArea.setRows(2);
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (d.getSheetsQuestDirection().getTextRu() != null && !d.getSheetsQuestDirection()
                            .getTextRu().equals(d.getSheetsQuestDirection().getTextEn())) {
                        TextArea textRuRawArea = new TextArea("    "
                                + d.getSheetsQuestDirection().getTranslator());
                        textRuRawArea.setValue(d.getSheetsQuestDirection().getTextRu());
                        textRuRawArea.setRows(2);
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);
                    }
                }
            }
            return result;
        }
    }).setId("rawText").setStyleGenerator(rowStyleGenerator);
    stepsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            Panel panel = new Panel();
            panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
            panel.setWidth(100f, Unit.PERCENTAGE);
            panel.setHeight(245f, Unit.PIXELS);
            final VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestStep) {

                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestStep step = (QuestStep) source;
                list.addAll(step.getSheetsJournalEntry().getTranslatedTexts());

                if (list != null) {
                    for (TranslatedText t : list) {
                        result.addComponent(new TranslationCell(t));
                        accounts.add(t.getAuthor());
                    }
                }
                if (!accounts.contains(SpringSecurityHelper.getSysAccount())
                        && step.getSheetsJournalEntry() != null
                        && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                    final TranslatedText translatedText = new TranslatedText();
                    translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                    translatedText.setSpreadSheetsJournalEntry(step.getSheetsJournalEntry());
                    Button addTranslation = new Button(" ",
                            FontAwesome.PLUS_SQUARE);
                    addTranslation.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {

                            if (translatedText.getSpreadSheetsJournalEntry() != null) {
                                translatedText.getSpreadSheetsJournalEntry().getTranslatedTexts()
                                        .add(translatedText);
                            }
                            result.addComponent(new TranslationCell(translatedText));
                            event.getButton().setVisible(false);
                        }
                    });
                    result.addComponent(addTranslation);
                }
            } else if (source instanceof QuestDirection) {
                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestDirection d = (QuestDirection) source;
                list.addAll(d.getSheetsQuestDirection().getTranslatedTexts());

                if (list != null) {
                    for (TranslatedText t : list) {
                        result.addComponent(new TranslationCell(t));
                        accounts.add(t.getAuthor());
                    }
                }
                if (!accounts.contains(SpringSecurityHelper.getSysAccount())
                        && d.getSheetsQuestDirection() != null
                        && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                    final TranslatedText translatedText = new TranslatedText();
                    translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                    translatedText.setSpreadSheetsQuestDirection(d.getSheetsQuestDirection());
                    Button addTranslation = new Button(" ");
                    addTranslation.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {

                            if (translatedText.getSpreadSheetsQuestDirection() != null) {
                                translatedText.getSpreadSheetsQuestDirection().getTranslatedTexts()
                                        .add(translatedText);
                            }
                            result.addComponent(new TranslationCell(translatedText));
                            event.getButton().setVisible(false);
                        }
                    });
                    result.addComponent(addTranslation);
                }
            }
            panel.setContent(result);
            return panel;
        }
    }).setId("translation").setStyleGenerator(rowStyleGenerator);
    stepsGrid.setColumns("rowType", "ingameText", "rawText", "translation");
    stepsLayout.addComponent(stepsGrid);
    tabSheet.addTab(stepsLayout, "");
    itemsGrid = new Grid(new ListDataProvider(itemList));
    itemsGrid.setSelectionMode(Grid.SelectionMode.NONE);
    itemsGrid.setRowHeight(250);
    itemsGrid.setHeaderVisible(false);
    itemsGrid.setSizeFull();
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                QuestItem item = (QuestItem) source;
                if (item.getName() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(item.getName().getTextEn());
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (item.getName().getTextRu() != null
                            && !item.getName().getTextRu().equals(item.getName().getTextEn())) {
                        TextArea textRuRawArea = new TextArea(
                                " ?    "
                                        + item.getName().getTranslator());
                        textRuRawArea.setValue(item.getName().getTextRu());
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);//, "  " 
                    }
                }

            }
            return result;
        }
    }).setId("rawName");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                QuestItem item = (QuestItem) source;
                if (item.getDescription() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(item.getDescription().getTextEn());
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (item.getDescription().getTextRu() != null
                            && !item.getDescription().getTextRu().equals(item.getDescription().getTextEn())) {
                        TextArea textRuRawArea = new TextArea(
                                " ??    "
                                        + item.getDescription().getTranslator());
                        textRuRawArea.setValue(item.getDescription().getTextRu());
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);//, "  " 
                    }
                }

            }
            return result;
        }
    }).setId("rawDescription");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            Panel panel = new Panel();
            panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
            panel.setWidth(100f, Unit.PERCENTAGE);
            panel.setHeight(245f, Unit.PIXELS);
            final VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestItem item = (QuestItem) source;
                if (item.getName() != null) {
                    String text = item.getName().getTextEn();
                    list.addAll(item.getName().getTranslatedTexts());

                    if (list != null) {
                        for (TranslatedText t : list) {
                            result.addComponent(new TranslationCell(t));
                            accounts.add(t.getAuthor());
                        }
                    }
                    if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null
                            && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                        final TranslatedText translatedText = new TranslatedText();
                        translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                        translatedText.setSpreadSheetsItemName(item.getName());
                        Button addTranslation = new Button(" ",
                                FontAwesome.PLUS_SQUARE);
                        addTranslation.addClickListener(new Button.ClickListener() {

                            @Override
                            public void buttonClick(Button.ClickEvent event) {

                                if (translatedText.getSpreadSheetsItemName() != null) {
                                    translatedText.getSpreadSheetsItemName().getTranslatedTexts()
                                            .add(translatedText);
                                }
                                result.addComponent(new TranslationCell(translatedText));
                                event.getButton().setVisible(false);
                            }
                        });
                        result.addComponent(addTranslation);
                    }
                }
            }
            panel.setContent(result);
            return panel;
        }
    }).setId("nameTranslation");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            Panel panel = new Panel();
            panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
            panel.setWidth(100f, Unit.PERCENTAGE);
            panel.setHeight(245f, Unit.PIXELS);
            final VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestItem item = (QuestItem) source;
                if (item.getDescription() != null) {
                    String text = item.getDescription().getTextEn();
                    list.addAll(item.getDescription().getTranslatedTexts());

                    if (list != null) {
                        for (TranslatedText t : list) {
                            result.addComponent(new TranslationCell(t));
                            accounts.add(t.getAuthor());
                        }
                    }
                    if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null
                            && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                        final TranslatedText translatedText = new TranslatedText();
                        translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                        translatedText.setSpreadSheetsItemDescription(item.getDescription());
                        Button addTranslation = new Button(" ",
                                FontAwesome.PLUS_SQUARE);
                        addTranslation.addClickListener(new Button.ClickListener() {

                            @Override
                            public void buttonClick(Button.ClickEvent event) {

                                if (translatedText.getSpreadSheetsItemDescription() != null) {
                                    translatedText.getSpreadSheetsItemDescription().getTranslatedTexts()
                                            .add(translatedText);
                                }
                                result.addComponent(new TranslationCell(translatedText));
                                event.getButton().setVisible(false);
                            }
                        });
                        result.addComponent(addTranslation);
                    }
                }
            }
            panel.setContent(result);
            return panel;
        }
    }).setId("descriptionTranslation");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setMargin(new MarginInfo(true, false, false, false));
            result.setSpacing(false);
            if (source instanceof QuestItem) {
                GSpreadSheetsItemName name = ((QuestItem) source).getName();
                if (name.getIcon() != null) {
                    Image image = new Image(null, new ExternalResource(
                            "https://elderscrolls.net" + name.getIcon().replaceAll(".dds", ".png")));
                    result.addComponent(image);
                    return result;
                }
            }
            return result;
        }
    }).setId("icon").setWidth(95);
    itemsGrid.setColumns("icon", "rawName", "nameTranslation", "rawDescription", "descriptionTranslation");
    tabSheet.addTab(itemsGrid, "");
    this.addComponent(tabSheet);
    this.setExpandRatio(tabSheet, 1f);
    GridScrollExtension stepsScrollExtension = new GridScrollExtension(stepsGrid);
    GridScrollExtension itemsScrollExtension = new GridScrollExtension(itemsGrid);
    new NoAutcompleteComboBoxExtension(locationTable);
    new NoAutcompleteComboBoxExtension(questTable);
    new NoAutcompleteComboBoxExtension(translatorBox);
    LoadFilters();
}

From source file:org.groom.review.ui.flows.reviewer.ReviewFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(2, 4);
    gridLayout.setSizeFull();//ww  w.j a  v a 2s  .com
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    //gridLayout.setRowExpandRatio(0, 0.5f);
    gridLayout.setRowExpandRatio(1, 1f);
    gridLayout.setColumnExpandRatio(1, 1f);
    setViewContent(gridLayout);

    reviewEditor = new ValidatingEditor(ReviewFields.getFieldDescriptors(Review.class));
    reviewEditor.setCaption("Review");
    reviewEditor.addListener((ValidatingEditorStateListener) this);
    reviewEditor.setWidth(450, Unit.PIXELS);
    reviewEditor.setReadOnly(true);

    gridLayout.addComponent(reviewEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 3);

    beanQueryFactory = new BeanQueryFactory<FileDiffBeanQuery>(FileDiffBeanQuery.class);
    queryConfiguration = new HashMap<String, Object>();
    beanQueryFactory.setQueryConfiguration(queryConfiguration);

    container = new LazyQueryContainer(beanQueryFactory, "path", 20, false);

    container.addContainerProperty("status", Character.class, null, true, false);
    container.addContainerProperty("reviewed", String.class, null, true, false);
    container.addContainerProperty("path", String.class, null, true, false);

    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    fileDiffTable = new Table() {
        @Override
        protected String formatPropertyValue(Object rowId, Object colId, Property property) {
            Object v = property.getValue();
            if (v instanceof Date) {
                Date dateValue = (Date) v;
                return format.format(v);
            }
            return super.formatPropertyValue(rowId, colId, property);
        }
    };
    fileDiffTable.setNullSelectionAllowed(false);
    fileDiffTable.setSizeFull();
    fileDiffTable.setContainerDataSource(container);
    fileDiffTable.setVisibleColumns(new Object[] { "reviewed", "path" });

    //table.setColumnWidth("path", 500);
    fileDiffTable.setColumnWidth("status", 40);
    fileDiffTable.setColumnWidth("reviewed", 40);

    fileDiffTable.setColumnHeaders(new String[] { "", getSite().localize("field-path") });

    fileDiffTable.setColumnCollapsingAllowed(false);
    fileDiffTable.setSelectable(true);
    fileDiffTable.setMultiSelect(false);
    fileDiffTable.setImmediate(true);

    fileDiffTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            final String selectedPath = (String) event.getItemId();

            if (selectedPath != null) {
                reviewFileDiff(selectedPath);
            }
        }
    });

    fileDiffTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
        @Override
        public String getStyle(Table source, Object itemId, Object propertyId) {
            if (propertyId != null && propertyId.equals("status")) {
                final FileDiff fileDiff = ((NestingBeanItem<FileDiff>) source.getItem(itemId)).getBean();
                switch (fileDiff.getStatus()) {
                case 'A':
                    return "added";
                case 'D':
                    return "deleted";
                case 'M':
                    return "modified";
                default:
                    return "";
                }
            } else if (propertyId != null && propertyId.equals("path")) {
                final FileDiff fileDiff = ((NestingBeanItem<FileDiff>) source.getItem(itemId)).getBean();
                switch (fileDiff.getStatus()) {
                case 'A':
                    return "path-added";
                case 'D':
                    return "path-deleted";
                case 'M':
                    return "path-modified";
                default:
                    return "";
                }
            } else if (propertyId != null && propertyId.equals("reviewed")) {
                final FileDiff fileDiff = ((NestingBeanItem<FileDiff>) source.getItem(itemId)).getBean();
                if (fileDiff.isReviewed()) {
                    return "ok";
                } else {
                    return "";
                }
            } else {
                return "";
            }
        }
    });

    fileDiffTable.setConverter("status", new Converter<String, Character>() {
        @Override
        public Character convertToModel(String value, Class<? extends Character> targetType, Locale locale)
                throws ConversionException {
            throw new UnsupportedOperationException();
        }

        @Override
        public String convertToPresentation(Character value, Class<? extends String> targetType, Locale locale)
                throws ConversionException {
            return "";
        }

        @Override
        public Class<Character> getModelType() {
            return Character.class;
        }

        @Override
        public Class<String> getPresentationType() {
            return String.class;
        }
    });

    fileDiffTable.setConverter("reviewed", new Converter<String, Boolean>() {
        @Override
        public Boolean convertToModel(String value, Class<? extends Boolean> targetType, Locale locale)
                throws ConversionException {
            throw new UnsupportedOperationException();
        }

        @Override
        public String convertToPresentation(Boolean value, Class<? extends String> targetType, Locale locale)
                throws ConversionException {
            return "";
        }

        @Override
        public Class<Boolean> getModelType() {
            return Boolean.class;
        }

        @Override
        public Class<String> getPresentationType() {
            return String.class;
        }
    });

    Panel fileDiffPanel = new Panel("Diffs");
    fileDiffPanel.setStyleName(ValoTheme.PANEL_BORDERLESS);
    fileDiffPanel.setSizeFull();
    fileDiffPanel.setContent(fileDiffTable);

    gridLayout.addComponent(fileDiffPanel, 1, 0, 1, 1);

    reviewStatusContainer = new LazyEntityContainer<ReviewStatus>(entityManager, true, false, false,
            ReviewStatus.class, 0, new String[] { "reviewer.emailAddress" }, new boolean[] { true },
            "reviewStatusId");
    final List<FieldDescriptor> fieldDescriptors = ReviewFields.getFieldDescriptors(ReviewStatus.class);
    ContainerUtil.addContainerProperties(reviewStatusContainer, fieldDescriptors);
    final Table reviewerStatusesTable = new FormattingTable();
    org.bubblecloud.ilves.component.grid.Grid grid = new org.bubblecloud.ilves.component.grid.Grid(
            reviewerStatusesTable, reviewStatusContainer);
    grid.setFields(fieldDescriptors);
    reviewerStatusesTable.setColumnCollapsed("reviewStatusId", true);
    reviewerStatusesTable.setColumnCollapsed("created", true);
    reviewerStatusesTable.setColumnCollapsed("modified", true);
    reviewerStatusesTable.setSelectable(false);

    reviewerStatusesTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
        @Override
        public String getStyle(Table source, Object itemId, Object propertyId) {
            if (propertyId != null && propertyId.equals("completed")) {
                final ReviewStatus reviewStatus = ((NestingBeanItem<ReviewStatus>) source.getItem(itemId))
                        .getBean();
                if (reviewStatus.isCompleted()) {
                    return "ok";
                } else {
                    return "";
                }
            } else {
                return "";
            }
        }
    });

    reviewerStatusesTable.setConverter("completed", new Converter<String, Boolean>() {
        @Override
        public Boolean convertToModel(String value, Class<? extends Boolean> targetType, Locale locale)
                throws ConversionException {
            throw new UnsupportedOperationException();
        }

        @Override
        public String convertToPresentation(Boolean value, Class<? extends String> targetType, Locale locale)
                throws ConversionException {
            return "";
        }

        @Override
        public Class<Boolean> getModelType() {
            return Boolean.class;
        }

        @Override
        public Class<String> getPresentationType() {
            return String.class;
        }
    });

    Panel reviewerPanel = new Panel("Reviewers");
    reviewerPanel.setStyleName(ValoTheme.PANEL_BORDERLESS);
    reviewerPanel.setHeight(300, Unit.PIXELS);
    reviewerPanel.setContent(grid);

    gridLayout.addComponent(reviewerPanel, 0, 2);

    commentContainer = new LazyEntityContainer<Comment>(entityManager, true, false, false, Comment.class, 0,
            new String[] { "path", "line" }, new boolean[] { true, true }, "reviewCommentId");
    final List<FieldDescriptor> commentFieldDescriptors = ReviewFields.getFieldDescriptors(Comment.class);
    ContainerUtil.addContainerProperties(commentContainer, commentFieldDescriptors);
    final Table commentTable = new FormattingTable();
    org.bubblecloud.ilves.component.grid.Grid commentGrid = new org.bubblecloud.ilves.component.grid.Grid(
            commentTable, commentContainer);
    commentTable.setNullSelectionAllowed(false);
    commentGrid.setSizeFull();
    commentGrid.setFields(commentFieldDescriptors);
    commentTable.setImmediate(true);
    commentTable.setColumnCollapsed("reviewCommentId", true);
    commentTable.setColumnCollapsed("created", true);
    commentTable.setColumnCollapsed("modified", true);
    commentTable.setColumnCollapsed("committer", true);
    commentTable.setColumnCollapsed("path", true);
    commentTable.setColumnCollapsed("line", true);
    commentTable.setColumnCollapsed("hash", true);

    commentTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
        @Override
        public String getStyle(Table source, Object itemId, Object propertyId) {
            if (propertyId != null && propertyId.equals("severity")) {
                final Comment comment = ((NestingBeanItem<Comment>) source.getItem(itemId)).getBean();
                switch (comment.getSeverity()) {
                case 1:
                    return "kudo";
                case -1:
                    return "warning";
                case -2:
                    return "red-flag";
                default:
                    return "";
                }
            } else {
                return "";
            }
        }
    });

    commentTable.setConverter("severity", new Converter<String, Integer>() {
        @Override
        public Integer convertToModel(String value, Class<? extends Integer> targetType, Locale locale)
                throws ConversionException {
            throw new UnsupportedOperationException();
        }

        @Override
        public String convertToPresentation(Integer value, Class<? extends String> targetType, Locale locale)
                throws ConversionException {
            return "";
        }

        @Override
        public Class<Integer> getModelType() {
            return Integer.class;
        }

        @Override
        public Class<String> getPresentationType() {
            return String.class;
        }
    });

    Panel commentPanel = new Panel("Review Comments");
    commentPanel.setStyleName(ValoTheme.PANEL_BORDERLESS);
    commentPanel.setHeight(300, Unit.PIXELS);
    commentPanel.setContent(commentGrid);

    gridLayout.addComponent(commentPanel, 1, 2, 1, 2);

    commentTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            final String commentId = (String) event.getItemId();

            if (commentId != null) {
                final Comment comment = ((NestingBeanItem<Comment>) commentTable.getItem(commentId)).getBean();
                final String path = comment.getPath();
                final FileDiff fileDiff = ((NestingBeanItem<FileDiff>) fileDiffTable.getItem(path)).getBean();
                fileDiff.setReviewed(true);
                ReviewDao.saveReviewStatus(entityManager, reviewStatus);
                final char status = fileDiff.getStatus();
                if (status == 'A' || status == 'M') {
                    final ReviewFileDiffFlowlet view = getFlow().forward(ReviewFileDiffFlowlet.class);
                    view.setFileDiff(review, fileDiff, comment.getDiffLine());
                }

            }
        }
    });

    completeButton = new Button(getSite().localize("button-complete"));
    completeButton.setImmediate(true);
    buttonLayout.addComponent(completeButton);
    completeButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final ReviewCommentDialog commentDialog = new ReviewCommentDialog(
                    new ReviewCommentDialog.DialogListener() {
                        @Override
                        public void onOk(final String message) {
                            reviewStatus.setReviewComment(message);
                            reviewStatus.setCompleted(true);
                            ReviewDao.saveReviewStatus(entityManager, reviewStatus);
                            enter();
                        }

                        @Override
                        public void onCancel() {
                        }
                    });
            commentDialog.setCaption("Please enter final comment.");
            UI.getCurrent().addWindow(commentDialog);
            commentDialog.getTextArea().focus();
        }
    });

    reopenButton = new Button(getSite().localize("button-reopen"));
    reopenButton.setImmediate(true);
    buttonLayout.addComponent(reopenButton);
    reopenButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            reviewStatus.setCompleted(false);
            ReviewDao.saveReviewStatus(entityManager, reviewStatus);
            enter();
        }
    });
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationPanel.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///from   w ww .j av a2 s  . co  m
@SuppressWarnings("serial")
protected void init() {
    layout = new GridLayout(5, 6);
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setWidth("100%");

    this.addStyleName(ValoTheme.PANEL_BORDERLESS);

    paramQueriesLayout = new VerticalLayout();

    toolBarLayout = new HorizontalLayout();
    toolBarLayout.setWidth("100%");

    Button linkButton = new Button();

    linkButton.setIcon(VaadinIcons.REPLY_ALL);
    linkButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    linkButton.setDescription("Return to search results");
    linkButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    linkButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer());

            for (IkasanUIView view : topLevelNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }

            saveRequiredMonitor.manageSaveRequired("mappingView");

            navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer());

            for (IkasanUIView view : mappingNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }
        }
    });

    toolBarLayout.addComponent(linkButton);
    toolBarLayout.setExpandRatio(linkButton, 0.865f);

    this.editButton.setIcon(VaadinIcons.EDIT);
    this.editButton.setDescription("Edit the mapping configuration");
    this.editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.editButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.editButton.setVisible(false);
    this.editButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            setEditable(true);
            mappingConfigurationFunctionalGroup.editButtonPressed();
        }
    });

    toolBarLayout.addComponent(this.editButton);
    toolBarLayout.setExpandRatio(this.editButton, 0.045f);

    this.saveButton.setIcon(VaadinIcons.HARDDRIVE);
    this.saveButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.saveButton.setDescription("Save the mapping configuration");
    this.saveButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.saveButton.setVisible(false);
    this.saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                logger.info("Save button clicked!!");
                save();
                setEditable(false);
                Notification.show("Changes Saved!", "", Notification.Type.HUMANIZED_MESSAGE);
                mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed();
            } catch (InvalidValueException e) {
                // We can ignore this one as we have already dealt with the
                // validation messages using the validation framework.
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Cauget exception trying to save a Mapping Configuration!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    toolBarLayout.addComponent(this.saveButton);
    toolBarLayout.setExpandRatio(this.saveButton, 0.045f);

    this.cancelButton.setIcon(VaadinIcons.CLOSE_CIRCLE);
    this.cancelButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.cancelButton.setDescription("Cancel the current edit");
    this.cancelButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.cancelButton.setVisible(false);
    this.cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            setEditable(false);
            mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed();

            Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer());

            for (IkasanUIView view : topLevelNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }

            saveRequiredMonitor.manageSaveRequired("mappingView");

            navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer());

            for (IkasanUIView view : mappingNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }
        }
    });

    toolBarLayout.addComponent(this.cancelButton);
    toolBarLayout.setExpandRatio(this.cancelButton, 0.045f);

    FileDownloader fd = new FileDownloader(this.getMappingConfigurationExportStream());
    fd.extend(exportMappingConfigurationButton);

    this.exportMappingConfigurationButton.setIcon(VaadinIcons.DOWNLOAD_ALT);
    this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.exportMappingConfigurationButton.setDescription("Export the current mapping configuration");
    this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    toolBarLayout.addComponent(this.exportMappingConfigurationButton);
    toolBarLayout.setExpandRatio(this.exportMappingConfigurationButton, 0.045f);

    final GridLayout contentLayout = new GridLayout(1, 2);
    contentLayout.setWidth("100%");

    contentLayout.addComponent(toolBarLayout);
    contentLayout.addComponent(createMappingConfigurationForm());

    VerticalSplitPanel vpanel = new VerticalSplitPanel(contentLayout, createTableLayout(false));
    vpanel.setStyleName(ValoTheme.SPLITPANEL_LARGE);

    paramQueriesLayout.setSpacing(true);

    Label configValueLabels = new Label("Source Configuration Value Queries:");
    layout.addComponent(configValueLabels, 2, 2, 3, 2);
    Panel queryParamsPanel = new Panel();
    queryParamsPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    queryParamsPanel.setHeight(100, Unit.PIXELS);
    queryParamsPanel.setWidth(100, Unit.PERCENTAGE);
    queryParamsPanel.setContent(paramQueriesLayout);
    this.layout.addComponent(queryParamsPanel, 2, 3, 3, 5);

    vpanel.setSplitPosition(325, Unit.PIXELS);
    this.setContent(vpanel);
    this.setSizeFull();
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.NewMappingConfigurationPanel.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///w w  w  .j  av  a  2s . co  m
@SuppressWarnings("serial")
protected void init() {
    layout = new GridLayout(5, 6);
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setWidth("100%");

    this.addStyleName(ValoTheme.PANEL_BORDERLESS);

    this.parameterQueryTextFields = new ArrayList<TextField>();

    this.typeComboBox.setReadOnly(false);
    this.clientComboBox.setReadOnly(false);
    this.sourceContextComboBox.setReadOnly(false);
    this.targetContextComboBox.setReadOnly(false);
    super.clientComboBox.unselect(super.clientComboBox.getValue());
    super.sourceContextComboBox.unselect(super.sourceContextComboBox.getValue());
    super.targetContextComboBox.unselect(super.targetContextComboBox.getValue());
    super.typeComboBox.unselect(super.typeComboBox.getValue());

    super.mappingConfigurationFunctionalGroup.editButtonPressed();

    super.mappingConfiguration = new MappingConfiguration();
    this.mappingConfigurationConfigurationValuesTable.populateTable(mappingConfiguration);

    HorizontalLayout toolBarLayout = new HorizontalLayout();
    toolBarLayout.setWidth("100%");

    Label spacerLabel = new Label("");
    toolBarLayout.addComponent(spacerLabel);
    toolBarLayout.setExpandRatio(spacerLabel, 0.865f);

    this.editButton.setIcon(VaadinIcons.EDIT);
    this.editButton.setDescription("Edit the mapping configuration");
    this.editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.editButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    toolBarLayout.addComponent(editButton);
    toolBarLayout.setExpandRatio(editButton, 0.045f);

    this.saveButton.setIcon(VaadinIcons.HARDDRIVE);
    this.saveButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.saveButton.setDescription("Save the mapping configuration");
    this.saveButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    toolBarLayout.addComponent(saveButton);
    toolBarLayout.setExpandRatio(saveButton, 0.045f);

    this.cancelButton.setIcon(VaadinIcons.CLOSE_CIRCLE);
    this.cancelButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.cancelButton.setDescription("Cancel the current edit");
    this.cancelButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    toolBarLayout.addComponent(this.cancelButton);
    toolBarLayout.setExpandRatio(this.cancelButton, 0.045f);

    final VerticalLayout contentLayout = new VerticalLayout();

    contentLayout.addComponent(toolBarLayout);
    contentLayout.addComponent(createMappingConfigurationForm());

    VerticalSplitPanel vpanel = new VerticalSplitPanel(contentLayout, createTableLayout(false));
    vpanel.setStyleName(ValoTheme.SPLITPANEL_LARGE);

    Button addParametersButton = new Button();
    addParametersButton.setIcon(VaadinIcons.FORM);
    addParametersButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    addParametersButton.setDescription(
            "Add new key location queries. The number of fields created corresponds to the number of query parameters.");
    addParametersButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    addParametersButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            addParamQueryFields();
        }
    });

    paramQueriesLayout.removeAllComponents();
    //        paramQueriesLayout.addComponent(addParametersButton);
    paramQueriesLayout.setSpacing(true);

    Label configValueLabels = new Label("Source Configuration Value Queries:");
    layout.addComponent(configValueLabels, 2, 2);
    layout.addComponent(addParametersButton, 3, 2);

    Panel queryParamsPanel = new Panel();
    queryParamsPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    queryParamsPanel.setHeight(140, Unit.PIXELS);
    queryParamsPanel.setWidth(100, Unit.PERCENTAGE);
    queryParamsPanel.setContent(paramQueriesLayout);
    this.layout.addComponent(queryParamsPanel, 2, 3, 3, 5);

    vpanel.setSplitPosition(325, Unit.PIXELS);
    this.setContent(vpanel);
    this.setSizeFull();

}