Example usage for com.vaadin.ui DragAndDropWrapper setDropHandler

List of usage examples for com.vaadin.ui DragAndDropWrapper setDropHandler

Introduction

In this page you can find the example usage for com.vaadin.ui DragAndDropWrapper setDropHandler.

Prototype

public void setDropHandler(DropHandler dropHandler) 

Source Link

Usage

From source file:info.magnolia.ui.admincentral.shellapp.favorites.FavoritesViewImpl.java

License:Open Source License

@Override
public void init(AbstractJcrNodeAdapter favorites, JcrNewNodeAdapter favoriteSuggestion,
        JcrNewNodeAdapter groupSuggestion, Map<String, String> availableGroups, boolean itemIconsVisible) {

    editableFavoriteItemList = new ArrayList<EditableFavoriteItem>();
    final Map<String, AbstractJcrNodeAdapter> nodeAdapters = favorites.getChildren();

    if (nodeAdapters.isEmpty()) {
        emptyPlaceHolder.setVisible(true);
        splitPanel.setVisible(false);/* w w w.  j  a v  a  2s . co  m*/
        layout.setExpandRatio(splitPanel, 0);
        layout.setExpandRatio(emptyPlaceHolder, 1);
    } else {
        emptyPlaceHolder.setVisible(false);
        splitPanel.setVisible(true);
        layout.setExpandRatio(splitPanel, 1);
        layout.setExpandRatio(emptyPlaceHolder, 0);

        noGroup = new FavoritesGroup(i18n);
        splitPanel.getLeftContainer().removeAllComponents();
        splitPanel.getRightContainer().removeAllComponents();
        for (String key : nodeAdapters.keySet()) {
            final AbstractJcrNodeAdapter favoriteAdapter = nodeAdapters.get(key);
            if (AdmincentralNodeTypes.Favorite.NAME.equals(favoriteAdapter.getPrimaryNodeTypeName())) {
                final FavoritesEntry favEntry = new FavoritesEntry(favoriteAdapter, listener, shell, i18n);
                final EntryDragAndDropWrapper wrapper = new EntryDragAndDropWrapper(favEntry, listener);
                favEntry.addEditingListener(new EditingEvent.EditingListener() {
                    @Override
                    public void onEdit(EditingEvent event) {
                        if (event.isEditing()) {
                            wrapper.setDragStartMode(DragAndDropWrapper.DragStartMode.NONE);
                        } else {
                            wrapper.setDragStartMode(DragAndDropWrapper.DragStartMode.WRAPPER);
                        }
                    }
                });
                editableFavoriteItemList.add(favEntry);
                noGroup.addComponent(wrapper);
            } else {
                final FavoritesGroup group = new FavoritesGroup(favoriteAdapter, listener, shell, this, i18n,
                        editableFavoriteItemList);
                editableFavoriteItemList.add(group);
                group.addEditingListener(new EditingEvent.EditingListener() {
                    @Override
                    public void onEdit(EditingEvent event) {
                        if (event.isEditing()) {
                            group.getDragAndDropWrapper()
                                    .setDragStartMode(DragAndDropWrapper.DragStartMode.NONE);
                        } else {
                            group.getDragAndDropWrapper()
                                    .setDragStartMode(DragAndDropWrapper.DragStartMode.WRAPPER);
                        }
                    }
                });
                splitPanel.getRightContainer().addComponent(group);
            }
        }
        DragAndDropWrapper nogroupWrap = new DragAndDropWrapper(noGroup);
        noGroup.setSizeFull();
        nogroupWrap.setSizeFull();

        nogroupWrap.setDropHandler(new DropHandler() {

            @Override
            public void drop(DragAndDropEvent event) {
                Component wrappedComponent = ((EntryDragAndDropWrapper) event.getTransferable()
                        .getSourceComponent()).getWrappedComponent();
                String sourcePath = ((FavoritesEntry) wrappedComponent).getRelPath();
                listener.moveFavorite(sourcePath, null);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {

                return new ServerSideCriterion() {

                    @Override
                    public boolean accept(DragAndDropEvent dragEvent) {
                        // accept only entries, not groups
                        AbstractFavoritesDragAndDropWrapper wrapper = (AbstractFavoritesDragAndDropWrapper) dragEvent
                                .getTransferable().getSourceComponent();
                        if (!(wrapper.getWrappedComponent() instanceof FavoritesEntry)) {
                            return false;
                        }
                        // drop location: can drop anywhere in the target zone.
                        return true;
                    }
                };
            }

        });
        splitPanel.getLeftContainer().addComponent(nogroupWrap);
    }

    if (favoriteForm == null) {
        favoriteForm = new FavoritesForm(listener, shell, i18n);
        layout.addComponent(favoriteForm);
    }
    setFavoriteLocation(favoriteSuggestion, groupSuggestion, availableGroups);
    favoriteForm.setEditActionEnabled(listener.hasItems());

    for (EditableFavoriteItem item : getEditableFavoriteItemList()) {
        item.setIconsVisibility(itemIconsVisible);
    }

}

From source file:net.pkhsolutions.pecsapp.ui.components.PictureLayout.java

License:Open Source License

public PictureLayout(@NotNull PictureModel model) {
    this.model = model;
    setSpacing(true);/*w w w  . j  a  va 2  s.  c om*/

    infoLabel = new Label("Drag och slpp en bild hr");
    infoLabel.setSizeUndefined();

    dropPane = new VerticalLayout();
    dropPane.setSizeFull();
    dropPane.addComponent(infoLabel);
    dropPane.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER);

    image = new Image();
    image.setSizeUndefined();
    dropPane.addComponent(image);
    dropPane.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    progressBar = new ProgressBar();
    progressBar.setIndeterminate(true);
    progressBar.setVisible(false);
    dropPane.addComponent(progressBar);
    dropPane.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);

    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(dropPane);
    dragAndDropWrapper.setDropHandler(this);
    dragAndDropWrapper.setSizeFull();
    addComponent(dragAndDropWrapper);
    setExpandRatio(dragAndDropWrapper, 1f);

    title = new TextField();
    title.setInputPrompt("Skriv namnet hr");
    title.setWidth("100%");
    title.setImmediate(true);
    addComponent(title);
    setComponentAlignment(title, Alignment.BOTTOM_LEFT);

    imageChanged(null);
}

From source file:org.activiti.explorer.ui.custom.UploadComponent.java

License:Apache License

protected void addDropPanel() {
    Panel dropPanel = new Panel();
    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(dropPanel);
    dragAndDropWrapper.setDropHandler(this);
    dragAndDropWrapper.setWidth("80%");
    addComponent(dragAndDropWrapper);/*from  w w  w  . j  a  va2  s . com*/
    setComponentAlignment(dragAndDropWrapper, Alignment.MIDDLE_CENTER);

    Label dropLabel = new Label(i18nManager.getMessage(Messages.UPLOAD_DROP));
    dropLabel.setSizeUndefined();
    dropPanel.addComponent(dropLabel);
    ((VerticalLayout) dropPanel.getContent()).setComponentAlignment(dropLabel, Alignment.MIDDLE_CENTER);
}

From source file:org.apache.ace.webui.vaadin.AddArtifactWindow.java

License:Apache License

/**
 * Creates a new {@link AddArtifactWindow} instance.
 * //from ww w  .j  a  v  a2s  . com
 * @param sessionDir
 *            the session directory to temporary place artifacts in;
 * @param obrUrl
 *            the URL of the OBR to use.
 */
public AddArtifactWindow(File sessionDir, URL obrUrl, String repositoryXML) {
    super("Add artifact");

    m_sessionDir = sessionDir;
    m_obrUrl = obrUrl;
    m_repositoryXML = repositoryXML;

    setModal(true);
    setWidth("50em");
    setCloseShortcut(KeyCode.ESCAPE);

    m_artifactsTable = new Table("Artifacts in repository");
    m_artifactsTable.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null);
    m_artifactsTable.addContainerProperty(PROPERTY_VERSION, String.class, null);
    m_artifactsTable.addContainerProperty(PROPERTY_PURGE, Button.class, null);
    m_artifactsTable.setSizeFull();
    m_artifactsTable.setSelectable(true);
    m_artifactsTable.setMultiSelect(true);
    m_artifactsTable.setImmediate(true);
    m_artifactsTable.setHeight("15em");

    final Table uploadedArtifacts = new Table("Uploaded artifacts");
    uploadedArtifacts.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null);
    uploadedArtifacts.addContainerProperty(PROPERTY_VERSION, String.class, null);
    uploadedArtifacts.setSizeFull();
    uploadedArtifacts.setSelectable(false);
    uploadedArtifacts.setMultiSelect(false);
    uploadedArtifacts.setImmediate(true);
    uploadedArtifacts.setHeight("15em");

    final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir) {
        @Override
        public void updateProgress(long readBytes, long contentLength) {
            // TODO Auto-generated method stub
        }

        @Override
        protected void artifactsUploaded(List<UploadHandle> uploads) {
            for (UploadHandle handle : uploads) {
                try {
                    URL artifact = handle.getFile().toURI().toURL();

                    Item item = uploadedArtifacts.addItem(artifact);
                    item.getItemProperty(PROPERTY_SYMBOLIC_NAME).setValue(handle.getFilename());
                    item.getItemProperty(PROPERTY_VERSION).setValue("");

                    m_uploadedArtifacts.add(handle.getFile());
                } catch (MalformedURLException e) {
                    showErrorNotification("Upload artifact processing failed",
                            "<br />Reason: " + e.getMessage());
                    logError("Processing of " + handle.getFilename() + " failed.", e);
                }
            }
        }
    };

    final Upload uploadArtifact = new Upload();
    uploadArtifact.setCaption("Upload Artifact");
    uploadHandler.install(uploadArtifact);

    final DragAndDropWrapper finalUploadedArtifacts = new DragAndDropWrapper(uploadedArtifacts);
    finalUploadedArtifacts.setDropHandler(new ArtifactDropHandler(uploadHandler));

    addListener(new Window.CloseListener() {
        public void windowClose(CloseEvent e) {
            for (File artifact : m_uploadedArtifacts) {
                artifact.delete();
            }
        }
    });

    HorizontalLayout searchBar = new HorizontalLayout();
    searchBar.setMargin(false);
    searchBar.setSpacing(true);

    final TextField searchField = new TextField();
    searchField.setImmediate(true);
    searchField.setValue("");

    final IndexedContainer dataSource = (IndexedContainer) m_artifactsTable.getContainerDataSource();

    m_searchButton = new Button("Search", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            String searchValue = (String) searchField.getValue();

            dataSource.removeAllContainerFilters();

            if (searchValue != null && searchValue.trim().length() > 0) {
                dataSource.addContainerFilter(PROPERTY_SYMBOLIC_NAME, searchValue, true /* ignoreCase */,
                        false /* onlyMatchPrefix */);
            }
        }
    });
    m_searchButton.setImmediate(true);

    searchBar.addComponent(searchField);
    searchBar.addComponent(m_searchButton);

    m_addButton = new Button("Add", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            // Import all "local" (existing) bundles...
            importLocalBundles(m_artifactsTable);
            // Import all "remote" (non existing) bundles...
            importRemoteBundles(m_uploadedArtifacts);

            close();
        }
    });
    m_addButton.setImmediate(true);
    m_addButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    m_addButton.setClickShortcut(KeyCode.ENTER);

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(true);
    layout.setSpacing(true);

    layout.addComponent(searchBar);
    layout.addComponent(m_artifactsTable);
    layout.addComponent(uploadArtifact);
    layout.addComponent(finalUploadedArtifacts);
    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(m_addButton);
    layout.setComponentAlignment(m_addButton, Alignment.MIDDLE_RIGHT);

    searchField.focus();
}

From source file:org.apache.ace.webui.vaadin.VaadinClient.java

License:Apache License

private void initGrid() {
    User user = (User) getUser();/*  w  w w  .  ja  v a  2  s .c o m*/
    Authorization auth = m_userAdmin.getAuthorization(user);
    int count = 0;
    for (String role : new String[] { "viewArtifact", "viewFeature", "viewDistribution", "viewTarget" }) {
        if (auth.hasRole(role)) {
            count++;
        }
    }

    final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir) {
        @Override
        public void updateProgress(long readBytes, long contentLength) {
            Float percentage = new Float(readBytes / (float) contentLength);
            m_progress.setValue(percentage);
        }

        @Override
        protected void artifactsUploaded(List<UploadHandle> uploadedArtifacts) {
            StringBuilder failedMsg = new StringBuilder();
            StringBuilder successMsg = new StringBuilder();
            Set<String> selection = new HashSet<>();

            for (UploadHandle handle : uploadedArtifacts) {
                if (!handle.isSuccessful()) {
                    // Upload failed, so let's report this one...
                    appendFailure(failedMsg, handle);

                    m_log.log(LogService.LOG_ERROR, "Upload of " + handle.getFile() + " failed.",
                            handle.getFailureReason());
                } else {
                    try {
                        // Upload was successful, try to upload it to our OBR...
                        ArtifactObject artifact = uploadToOBR(handle);
                        if (artifact != null) {
                            selection.add(artifact.getDefinition());

                            appendSuccess(successMsg, handle);
                        }
                    } catch (ArtifactAlreadyExistsException exception) {
                        appendFailureExists(failedMsg, handle);

                        m_log.log(LogService.LOG_WARNING,
                                "Upload of " + handle.getFilename() + " failed, as it already exists!");
                    } catch (Exception exception) {
                        appendFailure(failedMsg, handle, exception);

                        m_log.log(LogService.LOG_ERROR, "Upload of " + handle.getFilename() + " failed.",
                                exception);
                    }
                }

                // We're done with this (temporary) file, so we can remove it...
                handle.cleanup();
            }

            m_artifactsPanel.setValue(selection);

            // Notify the user what the overall status was...
            Notification notification = createNotification(failedMsg, successMsg);
            getMainWindow().showNotification(notification);

            m_progress.setStyleName("invisible");
            m_statusLine.setStatus(notification.getCaption() + "...");
        }

        @Override
        protected void uploadStarted(UploadHandle upload) {
            m_progress.setStyleName("visible");
            m_progress.setValue(new Float(0.0f));

            m_statusLine.setStatus("Upload of '%s' started...", upload.getFilename());
        }

        private void appendFailure(StringBuilder sb, UploadHandle handle) {
            appendFailure(sb, handle, handle.getFailureReason());
        }

        private void appendFailure(StringBuilder sb, UploadHandle handle, Exception cause) {
            sb.append("<li>'").append(handle.getFile().getName()).append("': failed");
            if (cause != null) {
                sb.append(", possible reason:<br/>").append(cause.getMessage());
            }
            sb.append("</li>");
        }

        private void appendFailureExists(StringBuilder sb, UploadHandle handle) {
            sb.append("<li>'").append(handle.getFile().getName())
                    .append("': already exists in repository</li>");
        }

        private void appendSuccess(StringBuilder sb, UploadHandle handle) {
            sb.append("<li>'").append(handle.getFile().getName()).append("': added to repository</li>");
        }

        private Notification createNotification(StringBuilder failedMsg, StringBuilder successMsg) {
            String caption = "Upload completed";
            int delay = 500; // msec.
            StringBuilder notification = new StringBuilder();
            if (failedMsg.length() > 0) {
                caption = "Upload completed with failures";
                delay = -1;
                notification.append("<ul>").append(failedMsg).append("</ul>");
            }
            if (successMsg.length() > 0) {
                notification.append("<ul>").append(successMsg).append("</ul>");
            }
            if (delay < 0) {
                notification.append("<p>(click to dismiss this notification).</p>");
            }

            Notification summary = new Notification(caption, notification.toString(),
                    Notification.TYPE_TRAY_NOTIFICATION);
            summary.setDelayMsec(delay);
            return summary;
        }

        private ArtifactObject uploadToOBR(UploadHandle handle) throws IOException {
            return UploadHelper.importRemoteBundle(m_artifactRepository, handle.getFile());
        }
    };

    m_grid = new GridLayout(count, 4);
    m_grid.setSpacing(true);
    m_grid.setSizeFull();

    m_mainToolbar = createToolbar();
    m_grid.addComponent(m_mainToolbar, 0, 0, count - 1, 0);

    m_artifactsPanel = createArtifactsPanel();
    m_artifactToolbar = createArtifactToolbar();

    final DragAndDropWrapper artifactsPanelWrapper = new DragAndDropWrapper(m_artifactsPanel);
    artifactsPanelWrapper.setDragStartMode(DragStartMode.HTML5);
    artifactsPanelWrapper.setDropHandler(new ArtifactDropHandler(uploadHandler));
    artifactsPanelWrapper.setCaption(m_artifactsPanel.getCaption());
    artifactsPanelWrapper.setSizeFull();

    count = 0;
    if (auth.hasRole("viewArtifact")) {
        m_grid.addComponent(artifactsPanelWrapper, count, 2);
        m_grid.addComponent(m_artifactToolbar, count, 1);
        count++;
    }

    m_featuresPanel = createFeaturesPanel();
    m_featureToolbar = createFeatureToolbar();

    if (auth.hasRole("viewFeature")) {
        m_grid.addComponent(m_featuresPanel, count, 2);
        m_grid.addComponent(m_featureToolbar, count, 1);
        count++;
    }

    m_distributionsPanel = createDistributionsPanel();
    m_distributionToolbar = createDistributionToolbar();

    if (auth.hasRole("viewDistribution")) {
        m_grid.addComponent(m_distributionsPanel, count, 2);
        m_grid.addComponent(m_distributionToolbar, count, 1);
        count++;
    }

    m_targetsPanel = createTargetsPanel();
    m_targetToolbar = createTargetToolbar();

    if (auth.hasRole("viewTarget")) {
        m_grid.addComponent(m_targetsPanel, count, 2);
        m_grid.addComponent(m_targetToolbar, count, 1);
    }

    m_statusLine = new StatusLine();

    m_grid.addComponent(m_statusLine, 0, 3, 2, 3);

    m_progress = new ProgressIndicator(0f);
    m_progress.setStyleName("invisible");
    m_progress.setIndeterminate(false);
    m_progress.setPollingInterval(1000);

    m_grid.addComponent(m_progress, 3, 3);

    m_grid.setRowExpandRatio(2, 1.0f);

    m_grid.setColumnExpandRatio(0, 0.31f);
    m_grid.setColumnExpandRatio(1, 0.23f);
    m_grid.setColumnExpandRatio(2, 0.23f);
    m_grid.setColumnExpandRatio(3, 0.23f);

    // Wire up all panels so they have the correct associations...
    m_artifactsPanel.setAssociatedTables(null, m_featuresPanel);
    m_featuresPanel.setAssociatedTables(m_artifactsPanel, m_distributionsPanel);
    m_distributionsPanel.setAssociatedTables(m_featuresPanel, m_targetsPanel);
    m_targetsPanel.setAssociatedTables(m_distributionsPanel, null);

    addListener(m_statusLine, StatefulTargetObject.TOPIC_ALL,
            RepositoryObject.PUBLIC_TOPIC_ROOT.concat(RepositoryObject.TOPIC_ALL_SUFFIX));
    addListener(m_mainToolbar, StatefulTargetObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_artifactsPanel, ArtifactObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_featuresPanel, FeatureObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_distributionsPanel, DistributionObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_targetsPanel, StatefulTargetObject.TOPIC_ALL, TargetObject.TOPIC_ALL,
            RepositoryAdmin.TOPIC_STATUSCHANGED, RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);

    m_mainWindow.addComponent(m_grid);
    // Ensure the focus is properly defined (for the shortcut keys to work)...
    m_mainWindow.focus();
}

From source file:org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons.java

License:Open Source License

private DragAndDropWrapper createDragAndDropWrapper(final Button tagButton, final String name, final Long id) {
    final DragAndDropWrapper bsmBtnWrapper = new DragAndDropWrapper(tagButton);
    bsmBtnWrapper.addStyleName(ValoTheme.DRAG_AND_DROP_WRAPPER_NO_VERTICAL_DRAG_HINTS);
    bsmBtnWrapper.addStyleName(ValoTheme.DRAG_AND_DROP_WRAPPER_NO_HORIZONTAL_DRAG_HINTS);
    bsmBtnWrapper.addStyleName(SPUIStyleDefinitions.FILTER_BUTTON_WRAPPER);
    if (getButtonWrapperData() != null) {
        if (id == null) {
            bsmBtnWrapper.setData(getButtonWrapperData());
        } else {//  www.java 2s .co  m
            bsmBtnWrapper.setData(getButtonWrapperData().concat("" + id));
        }
    }
    bsmBtnWrapper.setId(getButttonWrapperIdPrefix().concat(name));
    bsmBtnWrapper.setDragStartMode(DragStartMode.WRAPPER);
    bsmBtnWrapper.setDropHandler(getFilterButtonDropHandler());
    return bsmBtnWrapper;
}

From source file:org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout.java

License:Open Source License

private DragAndDropWrapper createDeleteWrapperLayout() {
    final Button dropToDelete = new Button(i18n.getMessage("label.components.drop.area"));
    dropToDelete.setCaptionAsHtml(true);
    dropToDelete.setIcon(FontAwesome.TRASH_O);
    dropToDelete.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    dropToDelete.addStyleName("drop-to-delete-button");
    dropToDelete.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
    dropToDelete.addStyleName(SPUIStyleDefinitions.DEL_ACTION_BUTTON);
    dropToDelete.addStyleName("delete-icon");

    final DragAndDropWrapper wrapper = new DragAndDropWrapper(dropToDelete);
    wrapper.setStyleName(ValoTheme.BUTTON_PRIMARY);
    wrapper.setId(getDeleteAreaId());// w ww.  ja  v  a  2s  .c om
    wrapper.setDropHandler(this);
    wrapper.addStyleName("delete-button-border");
    return wrapper;
}

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

License:Open Source License

private void buildLayout() {
    final HorizontalLayout titleFilterIconsLayout = createHeaderFilterIconLayout();

    titleFilterIconsLayout.addComponents(headerCaption, searchField, searchResetIcon, showFilterButtonLayout);
    titleFilterIconsLayout.setComponentAlignment(headerCaption, Alignment.TOP_LEFT);
    titleFilterIconsLayout.setComponentAlignment(searchField, Alignment.TOP_RIGHT);
    titleFilterIconsLayout.setComponentAlignment(searchResetIcon, Alignment.TOP_RIGHT);
    titleFilterIconsLayout.setComponentAlignment(showFilterButtonLayout, Alignment.TOP_RIGHT);
    if (hasCreatePermission() && isAddNewItemAllowed()) {
        titleFilterIconsLayout.addComponent(addIcon);
        titleFilterIconsLayout.setComponentAlignment(addIcon, Alignment.TOP_RIGHT);
    }/*from   w w  w  .j av a  2s.com*/
    if (hasCreatePermission() && isBulkUploadAllowed()) {
        titleFilterIconsLayout.addComponent(bulkUploadIcon);
        titleFilterIconsLayout.setComponentAlignment(bulkUploadIcon, Alignment.TOP_RIGHT);
    }
    titleFilterIconsLayout.addComponent(maxMinIcon);
    titleFilterIconsLayout.setComponentAlignment(maxMinIcon, Alignment.TOP_RIGHT);
    titleFilterIconsLayout.setExpandRatio(headerCaption, 0.4F);
    titleFilterIconsLayout.setExpandRatio(searchField, 0.6F);

    addComponent(titleFilterIconsLayout);

    final HorizontalLayout dropHintDropFilterLayout = new HorizontalLayout();
    dropHintDropFilterLayout.addStyleName("filter-drop-hint-layout");
    dropHintDropFilterLayout.setWidth(100, Unit.PERCENTAGE);
    if (isDropFilterRequired()) {
        filterDroppedInfo = new HorizontalLayout();
        filterDroppedInfo.setImmediate(true);
        filterDroppedInfo.setStyleName("target-dist-filter-info");
        filterDroppedInfo.setHeightUndefined();
        filterDroppedInfo.setSizeUndefined();
        displayFilterDropedInfoOnLoad();
        final DragAndDropWrapper dropFilterLayout = new DragAndDropWrapper(filterDroppedInfo);
        dropFilterLayout.setId(getDropFilterId());
        dropFilterLayout.setDropHandler(getDropFilterHandler());

        dropHintDropFilterLayout.addComponent(dropFilterLayout);
        dropHintDropFilterLayout.setComponentAlignment(dropFilterLayout, Alignment.TOP_CENTER);
        dropHintDropFilterLayout.setExpandRatio(dropFilterLayout, 1.0F);
    }
    addComponent(dropHintDropFilterLayout);
    setComponentAlignment(dropHintDropFilterLayout, Alignment.TOP_CENTER);
    addStyleName("bordered-layout");
    addStyleName("no-border-bottom");
}

From source file:org.hip.vif.web.util.UploadComponent.java

License:Open Source License

private Component createDropBox(final IBibliographyTask inTask) {
    final CssLayout lDropPane = new CssLayout();
    lDropPane.setWidth("200px"); //$NON-NLS-1$
    lDropPane.setHeight("40px"); //$NON-NLS-1$
    lDropPane.addStyleName("v-textfield"); //$NON-NLS-1$
    final Label lHint = new Label(Activator.getMessages().getMessage("ui.upload.drop.box")); //$NON-NLS-1$
    lHint.setStyleName("vif-drop-hint"); //$NON-NLS-1$
    lDropPane.addComponent(lHint);//from   w ww.j av  a 2s  . c  o m

    final DragAndDropWrapper outDrop = new DragAndDropWrapper(lDropPane);
    outDrop.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() { // NOPMD
            return AcceptAll.get();
        }

        @Override
        public void drop(final DragAndDropEvent inEvent) { // NOPMD
            final Transferable lTransferable = inEvent.getTransferable();
            if (lTransferable instanceof WrapperTransferable) {
                final Html5File[] lFiles = ((WrapperTransferable) lTransferable).getFiles();
                for (final Html5File lFile : lFiles) {
                    lFile.setStreamVariable(createStreamVariable(lFile.getFileName(), inTask));
                }
            }
        }
    });

    outDrop.setSizeUndefined();
    outDrop.setImmediate(true);
    return outDrop;
}

From source file:org.jumpmind.metl.ui.views.design.EditFlowPanel.java

License:Open Source License

public EditFlowPanel(ApplicationContext context, String flowId, DesignNavigator designNavigator,
        TabbedPanel tabs) {/* w ww  .  j a va 2  s. c  o  m*/

    this.configurationService = context.getConfigurationService();
    this.flow = configurationService.findFlow(flowId);
    this.readOnly = context.isReadOnly(configurationService.findProjectVersion(flow.getProjectVersionId()),
            Privilege.DESIGN);
    this.context = context;
    this.tabs = tabs;
    this.designNavigator = designNavigator;

    this.propertySheet = new PropertySheet(context, tabs, readOnly);
    this.propertySheet.setListener((components) -> {
        List<FlowStep> steps = new ArrayList<FlowStep>();
        for (Component c : components) {
            steps.add(EditFlowPanel.this.flow.findFlowStepWithComponentId(c.getId()));
        }
        refreshStepOnDiagram(steps);
    });
    this.propertySheet.setCaption("Property Sheet");

    this.componentPalette = new EditFlowPalette(this, context, flow.getProjectVersionId());

    addComponent(componentPalette);

    VerticalLayout rightLayout = new VerticalLayout();
    rightLayout.setSizeFull();

    rightLayout.addComponent(buildButtonBar());

    VerticalSplitPanel splitPanel = new VerticalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setSplitPosition(50, Unit.PERCENTAGE);

    diagramLayout = new VerticalLayout();
    diagramLayout.setWidth(10000, Unit.PIXELS);
    diagramLayout.setHeight(10000, Unit.PIXELS);

    DragAndDropWrapper wrapper = new DragAndDropWrapper(diagramLayout);
    wrapper.setSizeUndefined();
    wrapper.setDropHandler(new DropHandler());

    flowPanel = new Panel();
    flowPanel.setSizeFull();
    flowPanel.addStyleName(ValoTheme.PANEL_WELL);
    flowPanel.setContent(wrapper);

    splitPanel.addComponent(flowPanel);
    splitPanel.addComponent(propertySheet);

    rightLayout.addComponent(splitPanel);
    rightLayout.setExpandRatio(splitPanel, 1);

    addComponent(rightLayout);
    setExpandRatio(rightLayout, 1);

    if (flow.getFlowSteps().size() > 0) {
        selected = new ArrayList<AbstractObject>();
        selected.add(flow.getFlowSteps().get(0));
        propertySheet.setSource(selected);
    }

    redrawFlow();
}