Example usage for com.vaadin.server FontAwesome DOWNLOAD

List of usage examples for com.vaadin.server FontAwesome DOWNLOAD

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome DOWNLOAD.

Prototype

FontAwesome DOWNLOAD

To view the source code for com.vaadin.server FontAwesome DOWNLOAD.

Click Source Link

Usage

From source file:annis.gui.controlpanel.QueryPanel.java

License:Apache License

public QueryPanel(final AnnisUI ui) {
    super(4, 5);/*from   ww w  . j  av a2 s.  c  o  m*/
    this.ui = ui;

    this.lastPublicStatus = "Welcome to ANNIS! " + "A tutorial is available on the right side.";

    this.state = ui.getQueryState();

    setSpacing(true);
    setMargin(false);

    setRowExpandRatio(0, 1.0f);
    setColumnExpandRatio(0, 0.0f);
    setColumnExpandRatio(1, 0.1f);
    setColumnExpandRatio(2, 0.0f);
    setColumnExpandRatio(3, 0.0f);

    txtQuery = new AqlCodeEditor();
    txtQuery.setPropertyDataSource(state.getAql());
    txtQuery.setInputPrompt("Please enter AQL query");
    txtQuery.addStyleName("query");
    if (ui.getInstanceFont() == null) {
        txtQuery.addStyleName("default-query-font");
        txtQuery.setTextareaStyle("default-query-font");
    } else {
        txtQuery.addStyleName(Helper.CORPUS_FONT);
        txtQuery.setTextareaStyle(Helper.CORPUS_FONT);
    }

    txtQuery.addStyleName("keyboardInput");
    txtQuery.setWidth("100%");
    txtQuery.setHeight(15f, Unit.EM);
    txtQuery.setTextChangeTimeout(500);

    final VirtualKeyboardCodeEditor virtualKeyboard;
    if (ui.getInstanceConfig().getKeyboardLayout() == null) {
        virtualKeyboard = null;
    } else {
        virtualKeyboard = new VirtualKeyboardCodeEditor();
        virtualKeyboard.setKeyboardLayout(ui.getInstanceConfig().getKeyboardLayout());
        virtualKeyboard.extend(txtQuery);
    }

    txtStatus = new TextArea();
    txtStatus.setValue(this.lastPublicStatus);
    txtStatus.setWidth("100%");
    txtStatus.setHeight(4.0f, Unit.EM);
    txtStatus.addStyleName("border-layout");
    txtStatus.setReadOnly(true);

    piCount = new ProgressBar();
    piCount.setIndeterminate(true);
    piCount.setEnabled(false);
    piCount.setVisible(false);

    btShowResult = new Button("Search");
    btShowResult.setIcon(FontAwesome.SEARCH);
    btShowResult.setWidth("100%");
    btShowResult.addClickListener(new ShowResultClickListener());
    btShowResult.setDescription("<strong>Show Result</strong><br />Ctrl + Enter");
    btShowResult.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL);
    btShowResult.setDisableOnClick(true);

    VerticalLayout historyListLayout = new VerticalLayout();
    historyListLayout.setSizeUndefined();

    lstHistory = new ListSelect();
    lstHistory.setWidth("200px");
    lstHistory.setNullSelectionAllowed(false);
    lstHistory.setValue(null);
    lstHistory.addValueChangeListener((ValueChangeListener) this);
    lstHistory.setImmediate(true);
    lstHistory.setContainerDataSource(historyContainer);
    lstHistory.setItemCaptionPropertyId("query");
    lstHistory.addStyleName(Helper.CORPUS_FONT);

    Button btShowMoreHistory = new Button("Show more details", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (historyWindow == null) {
                historyWindow = new Window("History");
                historyWindow.setModal(false);
                historyWindow.setWidth("400px");
                historyWindow.setHeight("250px");
            }
            historyWindow.setContent(new HistoryPanel(state.getHistory(), ui.getQueryController()));

            if (UI.getCurrent().getWindows().contains(historyWindow)) {
                historyWindow.bringToFront();
            } else {
                UI.getCurrent().addWindow(historyWindow);
            }
        }
    });
    btShowMoreHistory.setWidth("100%");

    historyListLayout.addComponent(lstHistory);
    historyListLayout.addComponent(btShowMoreHistory);

    historyListLayout.setExpandRatio(lstHistory, 1.0f);
    historyListLayout.setExpandRatio(btShowMoreHistory, 0.0f);

    btHistory = new PopupButton("History");
    btHistory.setContent(historyListLayout);
    btHistory.setDescription("<strong>Show History</strong><br />"
            + "Either use the short overview (arrow down) or click on the button " + "for the extended view.");

    Button btShowKeyboard = null;
    if (virtualKeyboard != null) {
        btShowKeyboard = new Button();
        btShowKeyboard.setWidth("100%");
        btShowKeyboard.setDescription("Click to show a virtual keyboard");
        btShowKeyboard.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        btShowKeyboard.addStyleName(ValoTheme.BUTTON_SMALL);
        btShowKeyboard.setIcon(new ClassResource(VirtualKeyboardCodeEditor.class, "keyboard.png"));
        btShowKeyboard.addClickListener(new ShowKeyboardClickListener(virtualKeyboard));
    }

    Button btShowQueryBuilder = new Button("Query<br />Builder");
    btShowQueryBuilder.setHtmlContentAllowed(true);
    btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_SMALL);
    btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    btShowQueryBuilder.setIcon(new ThemeResource("images/tango-icons/32x32/document-properties.png"));
    btShowQueryBuilder.addClickListener(new ShowQueryBuilderClickListener(ui));

    VerticalLayout moreActionsLayout = new VerticalLayout();
    moreActionsLayout.setWidth("250px");
    btMoreActions = new PopupButton("More");
    btMoreActions.setContent(moreActionsLayout);

    //    btShowResultNewTab = new Button("Search (open in new tab)");
    //    btShowResultNewTab.setWidth("100%");
    //    btShowResultNewTab.addClickListener(new ShowResultInNewTabClickListener());
    //    btShowResultNewTab.setDescription("<strong>Show Result and open result in new tab</strong><br />Ctrl + Shift + Enter");
    //    btShowResultNewTab.setDisableOnClick(true);
    //    btShowResultNewTab.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL, ModifierKey.SHIFT);
    //    moreActionsLayout.addComponent(btShowResultNewTab);

    Button btShowExport = new Button("Export", new ShowExportClickListener(ui));
    btShowExport.setIcon(FontAwesome.DOWNLOAD);
    btShowExport.setWidth("100%");
    moreActionsLayout.addComponent(btShowExport);

    Button btShowFrequency = new Button("Frequency Analysis", new ShowFrequencyClickListener(ui));
    btShowFrequency.setIcon(FontAwesome.BAR_CHART_O);
    btShowFrequency.setWidth("100%");
    moreActionsLayout.addComponent(btShowFrequency);

    /*
     * We use the grid layout for a better rendering efficiency, but this comes
     * with the cost of some complexity when defining the positions of the
     * elements in the layout.
     * 
     * This grid hopefully helps a little bit in understanding the "magic"
     * numbers better.
     * 
     * Q: Query text field
     * QB: Button to toggle query builder // TODO
     * KEY: Button to show virtual keyboard
     * SEA: "Search" button
     * MOR: "More actions" button 
     * HIST: "History" button
     * STAT: Text field with the real status
     * PROG: indefinite progress bar (spinning circle)
     * 
     *   \  0  |  1  |  2  |  3  
     * --+-----+---+---+---+-----
     * 0 |  Q  |  Q  |  Q  | QB 
     * --+-----+-----+-----+-----
     * 1 |  Q  |  Q  |  Q  | KEY 
     * --+-----+-----+-----+-----
     * 2 | SEA | MOR | HIST|     
     * --+-----+-----+-----+-----
     * 3 | STAT| STAT| STAT| PROG
     */
    addComponent(txtQuery, 0, 0, 2, 1);
    addComponent(txtStatus, 0, 3, 2, 3);
    addComponent(btShowResult, 0, 2);
    addComponent(btMoreActions, 1, 2);
    addComponent(btHistory, 2, 2);
    addComponent(piCount, 3, 3);
    addComponent(btShowQueryBuilder, 3, 0);
    if (btShowKeyboard != null) {
        addComponent(btShowKeyboard, 3, 1);
    }

    // alignment
    setRowExpandRatio(0, 0.0f);
    setRowExpandRatio(1, 1.0f);
    setColumnExpandRatio(0, 1.0f);
    setColumnExpandRatio(1, 0.0f);
    setColumnExpandRatio(2, 0.0f);
    setColumnExpandRatio(3, 0.0f);

    //setComponentAlignment(btShowQueryBuilder, Alignment.BOTTOM_CENTER);
}

From source file:annis.gui.ExportPanel.java

License:Apache License

public ExportPanel(QueryPanel queryPanel, QueryController controller, QueryUIState state) {
    super(2, 3);/*from  ww  w  . j ava 2  s. c  o m*/
    this.queryPanel = queryPanel;
    this.controller = controller;
    this.state = state;

    this.eventBus = new EventBus();
    this.eventBus.register(ExportPanel.this);

    this.formLayout = new FormLayout();
    formLayout.setWidth("-1px");

    setWidth("99%");
    setHeight("-1px");

    initHelpMessages();

    setColumnExpandRatio(0, 0.0f);
    setColumnExpandRatio(1, 1.0f);

    cbExporter = new ComboBox("Exporter");
    cbExporter.setNewItemsAllowed(false);
    cbExporter.setNullSelectionAllowed(false);
    cbExporter.setImmediate(true);

    for (Exporter e : SearchView.EXPORTER) {
        cbExporter.addItem(e.getClass().getSimpleName());
    }

    cbExporter.setValue(SearchView.EXPORTER[0].getClass().getSimpleName());
    cbExporter.addValueChangeListener(new ExporterSelectionHelpListener());

    formLayout.addComponent(cbExporter);
    addComponent(formLayout, 0, 0);

    lblHelp = new Label(help4Exporter.get((String) cbExporter.getValue()));
    lblHelp.setContentMode(ContentMode.HTML);
    addComponent(lblHelp, 1, 0);

    cbLeftContext = new ComboBox("Left Context");
    cbRightContext = new ComboBox("Right Context");

    cbLeftContext.setNullSelectionAllowed(false);
    cbRightContext.setNullSelectionAllowed(false);

    cbLeftContext.setNewItemsAllowed(true);
    cbRightContext.setNewItemsAllowed(true);

    cbLeftContext
            .addValidator(new IntegerRangeValidator("must be a number", Integer.MIN_VALUE, Integer.MAX_VALUE));
    cbRightContext
            .addValidator(new IntegerRangeValidator("must be a number", Integer.MIN_VALUE, Integer.MAX_VALUE));

    for (Integer i : SearchOptionsPanel.PREDEFINED_CONTEXTS) {
        cbLeftContext.addItem(i);
        cbRightContext.addItem(i);
    }

    cbLeftContext.setValue(5);
    cbRightContext.setValue(5);

    formLayout.addComponent(cbLeftContext);
    formLayout.addComponent(cbRightContext);

    txtAnnotationKeys = new TextField("Annotation Keys");
    txtAnnotationKeys.setDescription("Some exporters will use this comma "
            + "seperated list of annotation keys to limit the exported data to these " + "annotations.");
    formLayout.addComponent(new HelpButton(txtAnnotationKeys));

    txtParameters = new TextField("Parameters");
    txtParameters.setDescription(
            "You can input special parameters " + "for certain exporters. See the description of each exporter "
                    + "(? button above) for specific parameter settings.");
    formLayout.addComponent(new HelpButton(txtParameters));

    btExport = new Button("Perform Export");
    btExport.setIcon(FontAwesome.PLAY);
    btExport.setDisableOnClick(true);
    btExport.addClickListener(new ExportButtonListener());

    btCancel = new Button("Cancel Export");
    btCancel.setIcon(FontAwesome.TIMES_CIRCLE);
    btCancel.setEnabled(false);
    btCancel.addClickListener(new CancelButtonListener());
    btCancel.setVisible(SearchView.EXPORTER[0].isCancelable());

    btDownload = new Button("Download");
    btDownload.setDescription("Click here to start the actual download.");
    btDownload.setIcon(FontAwesome.DOWNLOAD);
    btDownload.setDisableOnClick(true);
    btDownload.setEnabled(false);

    HorizontalLayout layoutExportButtons = new HorizontalLayout(btExport, btCancel, btDownload);
    addComponent(layoutExportButtons, 0, 1, 1, 1);

    VerticalLayout vLayout = new VerticalLayout();
    addComponent(vLayout, 0, 2, 1, 2);

    progressBar = new ProgressBar();
    progressBar.setVisible(false);
    progressBar.setIndeterminate(true);
    vLayout.addComponent(progressBar);

    progressLabel = new Label();
    vLayout.addComponent(progressLabel);

    if (state != null) {
        cbLeftContext.setPropertyDataSource(state.getLeftContext());
        cbRightContext.setPropertyDataSource(state.getRightContext());
        cbExporter.setPropertyDataSource(state.getExporterName());

        state.getExporterName().setValue(SearchView.EXPORTER[0].getClass().getSimpleName());

        txtAnnotationKeys.setConverter(new CommaSeperatedStringConverterList());
        txtAnnotationKeys.setPropertyDataSource(state.getExportAnnotationKeys());

        txtParameters.setPropertyDataSource(state.getExportParameters());

    }

}

From source file:annis.gui.frequency.FrequencyResultPanel.java

License:Apache License

public FrequencyResultPanel(FrequencyTable table, FrequencyQuery query, FrequencyQueryPanel queryPanel) {
    this.query = query;
    this.queryPanel = queryPanel;

    setSizeFull();//from w w w  . ja v  a  2s  .  c o  m

    chart = new FrequencyChart(this);
    chart.setHeight("350px");
    chart.setVisible(false);
    addComponent(chart);

    btDownloadCSV = new Button("Download as CSV");
    btDownloadCSV.setDescription("Download as CSV");
    btDownloadCSV.setSizeUndefined();
    addComponent(btDownloadCSV);
    setComponentAlignment(btDownloadCSV, Alignment.TOP_RIGHT);

    btDownloadCSV.setVisible(false);
    btDownloadCSV.setIcon(FontAwesome.DOWNLOAD);
    btDownloadCSV.addStyleName(ValoTheme.BUTTON_SMALL);

    showResult(table);
}

From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java

License:Open Source License

public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) {
    this.setSpacing(true);
    this.baseFolder = rootFolder;
    this.rootPath = rootPath;
    externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class);
    externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class);
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    VerticalLayout mainBodyLayout = new VerticalLayout();
    mainBodyLayout.setSpacing(true);//w  w w  . ja  v a2 s. c  o  m
    mainBodyLayout.addStyleName("box-no-border-left");

    // file breadcrum ---------------------
    HorizontalLayout breadcrumbContainer = new HorizontalLayout();
    breadcrumbContainer.setMargin(false);
    fileBreadCrumb = new FileBreadcrumb(rootPath);
    breadcrumbContainer.addComponent(fileBreadCrumb);
    mainBodyLayout.addComponent(breadcrumbContainer);

    // Construct controllGroupBtn
    controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true));

    final Button selectAllBtn = new Button();
    selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    selectAllBtn.setIcon(FontAwesome.SQUARE_O);
    selectAllBtn.setData(false);
    selectAllBtn.setImmediate(true);
    selectAllBtn.setDescription("Select all");

    selectAllBtn.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!(Boolean) selectAllBtn.getData()) {
                selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O);
                selectAllBtn.setData(true);
                resourcesContainer.setAllValues(true);
            } else {
                selectAllBtn.setData(false);
                selectAllBtn.setIcon(FontAwesome.SQUARE_O);
                resourcesContainer.setAllValues(false);
            }
        }
    });
    controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT);

    Button goUpBtn = new Button("Up");
    goUpBtn.setIcon(FontAwesome.ARROW_UP);

    goUpBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Folder parentFolder;
            if (baseFolder instanceof ExternalFolder) {
                if (baseFolder.getPath().equals("/")) {
                    parentFolder = baseFolder;
                } else {
                    parentFolder = externalResourceService.getParentResourceFolder(
                            ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath());
                }
            } else if (!baseFolder.getPath().equals(rootPath)) {
                parentFolder = resourceService.getParentFolder(baseFolder.getPath());
            } else {
                parentFolder = baseFolder;
            }

            resourcesContainer.constructBody(parentFolder);
            baseFolder = parentFolder;
            fileBreadCrumb.gotoFolder(baseFolder);
        }
    });
    goUpBtn.setDescription("Back to parent folder");
    goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    goUpBtn.setDescription("Go up");

    controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT);

    ButtonGroup navButton = new ButtonGroup();
    navButton.addStyleName(UIConstants.THEME_BROWN_LINK);
    Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow();
                    UI.getCurrent().addWindow(addnewFolderWindow);
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    createBtn.setDescription("Create new folder");
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(createBtn);

    Button uploadBtn = new Button("Upload", new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow();
            UI.getCurrent().addWindow(multiUploadWindow);
        }
    });
    uploadBtn.setIcon(FontAwesome.UPLOAD);
    uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    uploadBtn.setDescription("Upload");

    uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(uploadBtn);

    Button downloadBtn = new Button("Download");

    LazyStreamSource streamSource = new LazyStreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        protected StreamSource buildStreamSource() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources);
        }

        @Override
        public String getFilename() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getDownloadFileName(selectedResources);
        }
    };
    OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
    downloaderExt.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    downloadBtn.setDescription("Download");
    downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(downloadBtn);

    Button moveToBtn = new Button("Move", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Collection<Resource> selectedResources = getSelectedResources();
            if (CollectionUtils.isNotEmpty(selectedResources)) {
                MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources);
                UI.getCurrent().addWindow(moveResourceWindow);
            } else {
                NotificationUtil.showWarningNotification("Please select at least one item to move");
            }
        }
    });
    moveToBtn.setIcon(FontAwesome.ARROWS);
    moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    moveToBtn.setDescription("Move to");
    navButton.addButton(moveToBtn);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    Collection<Resource> selectedResources = getSelectedResources();
                    if (CollectionUtils.isEmpty(selectedResources)) {
                        NotificationUtil.showWarningNotification("Please select at least one item to delete");
                    } else {
                        deleteResourceAction();
                    }
                }
            });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.THEME_RED_LINK);
    deleteBtn.setDescription("Delete resource");
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));

    navButton.addButton(deleteBtn);
    controllGroupBtn.addComponent(navButton);

    mainBodyLayout.addComponent(controllGroupBtn);

    resourcesContainer = new ResourcesContainer(baseFolder);

    mainBodyLayout.addComponent(resourcesContainer);
    this.addComponent(mainBodyLayout);
}

From source file:com.esofthead.mycollab.vaadin.ui.AttachmentDisplayComponent.java

License:Open Source License

public static Component constructAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }/*from  w w w.  j  a  va2 s .  c o m*/

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT);
    attachmentLayout.setStyleName("attachment-block");

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setSizeFull();
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Image thumbnail = new Image(null);
    if (org.apache.commons.lang3.StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setSource(DEFAULT_SOURCE);
    } else {
        thumbnail.setSource(VaadinResourceManager.getResourceManager()
                .getImagePreviewResource(attachment.getThumbnail(), DEFAULT_SOURCE));
    }
    thumbnail.setDescription(docName);
    thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.addClickListener(new MouseEvents.ClickListener() {
            private static final long serialVersionUID = -2853211588120500523L;

            @Override
            public void click(MouseEvents.ClickEvent event) {
                Resource previewResource = VaadinResourceManager.getResourceManager()
                        .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE);
                UI.getCurrent().addWindow(new AttachmentPreviewWindow(previewResource));
            }
        });
    }

    CssLayout attachmentNameWrap = new CssLayout();
    attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentNameWrap.setStyleName("attachment-name-wrap");

    Label attachmentName = new Label(StringUtils.trim(docName, 60, true));
    attachmentName.setStyleName("attachment-name");
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    Button trashBtn = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                ResourceService attachmentService = ApplicationContextUtil
                                        .getSpringBean(ResourceService.class);
                                attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(),
                                        AppContext.getAccountId());
                                ((ComponentContainer) attachmentLayout.getParent())
                                        .removeComponent(attachmentLayout);
                            }
                        }
                    });

        }
    });
    trashBtn.setIcon(FontAwesome.TRASH_O);
    trashBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    Button downloadBtn = new Button();
    FileDownloader fileDownloader = new FileDownloader(
            VaadinResourceManager.getResourceManager().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    return attachmentLayout;
}

From source file:com.esofthead.mycollab.vaadin.web.ui.AttachmentDisplayComponent.java

License:Open Source License

public void addAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }/*from   w  ww .j a v  a  2  s.  c  o  m*/

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT);
    attachmentLayout.setStyleName("attachment-block");

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setSizeFull();
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Link thumbnail = new Link();
    if (StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setIcon(FileAssetsUtil.getFileIconResource(attachment.getName()));
    } else {
        thumbnail.setIcon(VaadinResourceFactory.getInstance().getResource(attachment.getThumbnail()));
    }

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.setResource(VaadinResourceFactory.getInstance().getResource(attachment.getPath()));
        new Fancybox(thumbnail).setPadding(0).setVersion("2.1.5").setEnabled(true).setDebug(true);
    }

    Div contentTooltip = new Div().appendChild(new Span().appendText(docName).setStyle("font-weight:bold"));
    Ul ul = new Ul()
            .appendChild(new Li().appendText("Size: " + FileUtils.getVolumeDisplay(attachment.getSize())))
            .setStyle("line-height:1.5em");
    ul.appendChild(new Li().appendText(
            "Last modified: " + AppContext.formatPrettyTime(attachment.getLastModified().getTime())));
    contentTooltip.appendChild(ul);
    thumbnail.setDescription(contentTooltip.write());
    thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    CssLayout attachmentNameWrap = new CssLayout();
    attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentNameWrap.setStyleName("attachment-name-wrap");

    Label attachmentName = new Label(StringUtils.trim(docName, 60, true));
    attachmentName.setStyleName("attachment-name");
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    Button trashBtn = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                ResourceService attachmentService = AppContextUtil
                                        .getSpringBean(ResourceService.class);
                                attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(),
                                        AppContext.getAccountId());
                                ((ComponentContainer) attachmentLayout.getParent())
                                        .removeComponent(attachmentLayout);
                            }
                        }
                    });

        }
    });
    trashBtn.setIcon(FontAwesome.TRASH_O);
    trashBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    Button downloadBtn = new Button();
    FileDownloader fileDownloader = new FileDownloader(
            VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    this.addComponent(attachmentLayout);
}

From source file:com.moscaville.ui.CsvVaadinUI.java

private void buildTemplateGridHeader() {
    HorizontalLayout templateGridHeaderLayout = new HorizontalLayout();
    templateGridHeaderLayout.setSpacing(true);
    templateGridHeaderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    Button btnNew = new Button("New", FontAwesome.FILE);
    btnNew.setDescription("New template file");
    btnNew.addClickListener((Button.ClickEvent event) -> {
        templateManager.newTemplate();/*from  w w w .  j  a va2s . c om*/
    });
    templateGridHeaderLayout.addComponent(btnNew);

    Button btnOpen = new Button("Open", FontAwesome.FILE_O);
    btnOpen.setDescription("Open template file");
    btnOpen.addClickListener((Button.ClickEvent event) -> {
        fileChooser.setFileExtension(FileChooser.FILE_EXTENSION_TEMPLATE);
        addWindow(fileChooser);
    });
    templateGridHeaderLayout.addComponent(btnOpen);

    Button btnSave = new Button("Save", FontAwesome.SAVE);
    tfTemplateFileName = new TextField();
    tfTemplateFileName.setDescription("template file name");
    tfTemplateFileName.setInputPrompt("template file name");
    tfTemplateFileName.setImmediate(true);
    tfTemplateFileName.addValueChangeListener((Property.ValueChangeEvent event) -> {
        btnSave.setEnabled(tfTemplateFileName.getValue() != null && tfTemplateFileName.getValue().length() > 0);
    });
    templateGridHeaderLayout.addComponent(tfTemplateFileName);

    FieldGroup binder = new FieldGroup(templateManager.getTemplateBeanItem());
    binder.setBuffered(false);
    binder.bind(tfTemplateFileName, "templateFileName");

    btnSave.setDescription("Save template file");
    btnSave.setImmediate(true);
    btnSave.setEnabled(false);
    btnSave.addClickListener((Button.ClickEvent event) -> {
        templateManager.saveTemplate();
    });
    templateGridHeaderLayout.addComponent(btnSave);

    Button btnData = new Button("Data", FontAwesome.DATABASE);
    btnData.setDescription("Load data");
    btnData.addClickListener((Button.ClickEvent event) -> {
        fileChooser.setFileExtension(FileChooser.FILE_EXTENSION_CSV);
        addWindow(fileChooser);
    });
    templateGridHeaderLayout.addComponent(btnData);

    Button btnImport = new Button("Import", FontAwesome.DOWNLOAD);

    templateGridHeaderLayout.addComponent(btnImport);
    mainLayout.addComponent(templateGridHeaderLayout);
}

From source file:com.mycollab.module.file.view.components.FileDownloadWindow.java

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {//from   ww  w .j  av  a  2  s.c o m
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        inforLayout.addComponent(descLbl, "Description", 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(),
            AppContext.getAccountId());
    if (user == null) {
        inforLayout.addComponent(new UserLink(AppContext.getUsername(), AppContext.getUserAvatarId(),
                AppContext.getUserDisplayName()), "Created by", 0, 1);
    } else {
        inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                "Created by", 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    inforLayout.addComponent(size, "Size", 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime());
    inforLayout.addComponent(dateCreate, "Created date", 0, 3);

    layout.addComponent(inforLayout.getLayout());

    final MHorizontalLayout buttonControls = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, true, false));

    final Button downloadBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD));
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);
    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.BUTTON_ACTION);

    final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(cancelBtn, downloadBtn).alignAll(Alignment.TOP_RIGHT);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
    this.setContent(layout);
}

From source file:com.mycollab.module.file.view.FileDownloadWindow.java

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {//ww w  . j  a  v  a2s  . c  o m
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        inforLayout.addComponent(descLbl, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(),
            MyCollabUI.getAccountId());
    if (user == null) {
        inforLayout.addComponent(
                new UserLink(UserUIContext.getUsername(), UserUIContext.getUserAvatarId(),
                        UserUIContext.getUserDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    } else {
        inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    inforLayout.addComponent(size, UserUIContext.getMessage(FileI18nEnum.OPT_SIZE), 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime());
    inforLayout.addComponent(dateCreate, UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), 0, 3);

    layout.addComponent(inforLayout.getLayout());

    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withIcon(FontAwesome.DOWNLOAD).withStyleName(WebThemes.BUTTON_ACTION);
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);
    final MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, downloadBtn);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
    this.setContent(layout);
}

From source file:com.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java

License:Open Source License

private void buildLanguageUpdatePanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    Label logoDesc = new Label(UserUIContext.getMessage(ShellI18nEnum.OPT_LANGUAGE_DOWNLOAD));
    leftPanel.with(logoDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.DOWNLOAD);
    BrowserWindowOpener opener = new BrowserWindowOpener(
            SiteConfiguration.getApiUrl("localization/translations"));
    opener.extend(downloadBtn);//from  w w w . ja  v  a  2  s  .  c  o  m
    rightPanel.with(downloadBtn,
            new ELabel(UserUIContext.getMessage(ShellI18nEnum.OPT_UPDATE_LANGUAGE_INSTRUCTION))
                    .withStyleName(UIConstants.META_INFO));
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Languages", layout);
    this.with(formContainer);
}