List of usage examples for com.vaadin.ui DragAndDropWrapper setSizeFull
@Override public void setSizeFull()
From source file:com.mcparland.john.DragAndDropPanel.java
License:Apache License
/** * Create a drag-and-droppable layout./*from w ww. j a v a 2s .c o m*/ * * @param layout * the layout. * @return a drag-and-droppable layout. */ private Component createLayout(final AbstractLayout layout) { layout.addComponent(createButton("One")); layout.addComponent(createButton("Two")); layout.addComponent(createButton("Three")); layout.addComponent(createButton("Four")); final DragAndDropWrapper dndWrapper = new DragAndDropWrapper(layout); dndWrapper.setSizeFull(); dndWrapper.setDropHandler(new DropHandler() { /* * (non-Javadoc) * * @see com.vaadin.event.dd.DropHandler#getAcceptCriterion() */ public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } /* * (non-Javadoc) * * @see com.vaadin.event.dd.DropHandler#drop(com.vaadin.event.dd. * DragAndDropEvent) */ public void drop(DragAndDropEvent event) { WrapperTransferable t = (WrapperTransferable) event.getTransferable(); layout.addComponent(t.getSourceComponent()); } }); return dndWrapper; }
From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.DeployablePanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();/*from w w w.ja va 2 s.c o m*/ VerticalLayout mainContent = new VerticalLayout(); mainContent.setSpacing(true); mainContent.setMargin(true); mainContent.setStyleName("deployable-style"); mainContent.setSizeFull(); HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); Button openManager = new Button("Edit repositories"); openManager.addStyleName("link"); openManager.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (tabSheet.getTab(manager) == null) { tabSheet.addTab(manager, "Manager", new ClassResource(getClass(), "/images/22x22/configuration.png"), containers.size()) .setClosable(true); } tabSheet.setSelectedTab(manager); } }); header.addComponent(openManager); header.setComponentAlignment(openManager, Alignment.MIDDLE_RIGHT); mainContent.addComponent(header); tabSheet.setSizeFull(); mainContent.addComponent(tabSheet); mainContent.setExpandRatio(tabSheet, 1.5f); DragAndDropWrapper mainContentWrapper = new DragAndDropWrapper(mainContent); mainContentWrapper.setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService)); mainContentWrapper.setSizeFull(); setContent(mainContentWrapper); }
From source file:com.peergreen.webconsole.scope.deployment.internal.deployed.DeployedPanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();/*from w w w. j av a 2s. co m*/ Table table = new Table(); VerticalLayout mainContent = new VerticalLayout(); mainContent.setSpacing(true); mainContent.setMargin(true); mainContent.setStyleName("deployable-style"); mainContent.setSizeFull(); setContent(mainContent); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setMargin(true); toolBar.setSpacing(true); toolBar.setWidth("100%"); // Select all deployed artifacts CheckBox selectAll = new CheckBox("All"); selectAll.addValueChangeListener(new SelectAll(table)); toolBar.addComponent(selectAll); toolBar.setExpandRatio(selectAll, 1); // Filter TextField filter = new TextField(); filter.setInputPrompt("Filter deployed artifacts"); filter.setWidth("100%"); filter.addTextChangeListener(new FilterFiles(TREE_ITEM_ID, container)); toolBar.addComponent(filter); toolBar.setComponentAlignment(filter, Alignment.TOP_LEFT); toolBar.setExpandRatio(filter, 3); HorizontalLayout actionArea = new HorizontalLayout(); final NativeSelect actionSelection = new NativeSelect(); actionSelection.addItem(DeploymentActions.UNDEPLOY); actionSelection.addItem(DeploymentActions.DELETE); actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN); actionSelection.setWidth("100px"); actionSelection.setNullSelectionAllowed(false); Button doButton = new Button("Do"); doButton.addStyleName("default"); doButton.addClickListener( new DoClickListener(artifactBuilder, table, actionSelection, deploymentViewManager)); actionArea.addComponent(actionSelection); actionArea.addComponent(doButton); toolBar.addComponent(actionArea); toolBar.setComponentAlignment(actionArea, Alignment.TOP_RIGHT); mainContent.addComponent(toolBar); VerticalLayout deployedContainer = new VerticalLayout(); DragAndDropWrapper deployedContainerWrapper = new DragAndDropWrapper(deployedContainer); deployedContainerWrapper .setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService)); deployedContainerWrapper.setSizeFull(); mainContent.addComponent(deployedContainerWrapper); mainContent.setExpandRatio(deployedContainerWrapper, 1.5f); container.addContainerProperty(TREE_ITEM_ID, String.class, null); table.setSizeFull(); table.setImmediate(true); table.setMultiSelect(true); table.setSelectable(true); table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); table.setContainerDataSource(container); table.setDragMode(Table.TableDragMode.MULTIROW); table.setItemCaptionPropertyId(TREE_ITEM_ID); table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED, deploymentManager)); table.addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, table, "Delete", ShortcutAction.KeyCode.DELETE, null)); table.setItemDescriptionGenerator(new ItemDescription()); table.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { DeployableEntry deployableEntry = (DeployableEntry) event.getItemId(); try { ArtifactStatusReport report = deploymentManager .getReport(deployableEntry.getUri().toString()); event.getComponent().getUI() .addWindow(new DeployableWindow(deployableEntry, report).getWindow()); } catch (ArtifactStatusReportException e) { LOGGER.warn("Cannot get artifact status report for ''{0}''", deployableEntry.getUri(), e); event.getComponent().getUI().addWindow(new DeployableWindow(deployableEntry).getWindow()); } } } }); deployedContainer.addComponent(table); deployedContainer.setExpandRatio(table, 1.5f); refresh(); }
From source file:com.peergreen.webconsole.scope.deployment.internal.deploymentplan.DeploymentPlanPanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();//from w w w . ja v a 2s . c o m TreeTable table = new TreeTable(); VerticalLayout mainContent = new VerticalLayout(); mainContent.setSpacing(true); mainContent.setMargin(true); mainContent.setStyleName("deployable-style"); mainContent.setSizeFull(); setContent(mainContent); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setMargin(true); toolBar.setSpacing(true); toolBar.setWidth("100%"); // Deployment Plan name Label deploymentPlanNameLabel = new Label("Plan"); toolBar.addComponent(deploymentPlanNameLabel); toolBar.setExpandRatio(deploymentPlanNameLabel, 1); deploymentPlanName = new TextField(); deploymentPlanName.setInputPrompt(getDefaultName()); deploymentPlanName.setWidth("100%"); toolBar.addComponent(deploymentPlanName); toolBar.setComponentAlignment(deploymentPlanName, Alignment.TOP_LEFT); toolBar.setExpandRatio(deploymentPlanName, 3); error = new Label("", ContentMode.HTML); error.addStyleName("error"); error.setSizeUndefined(); error.addStyleName("light"); error.addStyleName("v-animate-reveal"); error.setVisible(false); toolBar.addComponent(error); toolBar.setComponentAlignment(error, Alignment.TOP_RIGHT); toolBar.setExpandRatio(error, 1); mainContent.addComponent(toolBar); mainContent.setComponentAlignment(toolBar, Alignment.TOP_LEFT); mainContent.setExpandRatio(toolBar, 1); VerticalLayout deploymentPlanContainer = new VerticalLayout(); DragAndDropWrapper deploymentPlanContainerWrapper = new DragAndDropWrapper(deploymentPlanContainer); DropHandler deploymentPlanDropHandler = new DeploymentDropHandler(deploymentViewManager, this, notifierService); deploymentPlanContainerWrapper.setDropHandler(deploymentPlanDropHandler); deploymentPlanContainerWrapper.setSizeFull(); mainContent.addComponent(deploymentPlanContainerWrapper); mainContent.setExpandRatio(deploymentPlanContainerWrapper, 10); container.addContainerProperty(TREE_ITEM_ID, String.class, null); table.setSizeFull(); table.setImmediate(true); table.setMultiSelect(true); table.setSelectable(true); table.setContainerDataSource(container); table.setDragMode(Table.TableDragMode.MULTIROW); table.setItemCaptionPropertyId(TREE_ITEM_ID); table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED)); table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); table.setDropHandler(new OrderedContainerDropHandler(table, deploymentPlanDropHandler)); table.addShortcutListener(new ShortcutListener("Delete", ShortcutAction.KeyCode.DELETE, null) { @Override public void handleAction(Object sender, Object target) { Table table = (Table) target; Collection<DeployableEntry> deployableEntries = (Collection<DeployableEntry>) table.getValue(); for (DeployableEntry deployableEntry : deployableEntries) { removeDeployable(deployableEntry); } } }); deploymentPlanContainer.addComponent(table); HorizontalLayout footer = new HorizontalLayout(); footer.setSizeFull(); footer.setSpacing(true); footer.setMargin(true); footer.addStyleName("footer"); footer.setWidth("100%"); deployIt = new CheckBox("Deploy this deployment plan"); footer.addComponent(deployIt); footer.setComponentAlignment(deployIt, Alignment.TOP_LEFT); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(true); Button cancel = new Button("Cancel"); cancel.addClickListener(new CancelButtonListener()); Button create = new Button("Create"); create.addClickListener(new CreateButtonListener()); create.addStyleName("wide"); create.addStyleName("default"); buttons.addComponent(cancel); buttons.addComponent(create); footer.addComponent(buttons); footer.setComponentAlignment(buttons, Alignment.TOP_RIGHT); mainContent.addComponent(footer); mainContent.setComponentAlignment(footer, Alignment.BOTTOM_RIGHT); mainContent.setExpandRatio(footer, 1); }
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);//from w ww . j av a 2 s. c om 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);/*from w w w . ja v a2 s .c o m*/ 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.apache.ace.webui.vaadin.VaadinClient.java
License:Apache License
private void initGrid() { User user = (User) getUser();//from w w w . j av 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(); }