List of usage examples for com.vaadin.ui DragAndDropWrapper DragAndDropWrapper
public DragAndDropWrapper(Component root)
From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.DeployablePanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();//from ww w . j a v a2 s . co 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 a v a 2 s.c om 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();//w ww . j a v a 2 s . co 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:com.peergreen.webconsole.scope.deployment.internal.DeploymentScope.java
License:Open Source License
@PostConstruct public void init() { deploymentViewManager = createDeploymentViewManager(); OptionGroup option = new OptionGroup(); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setWidth("100%"); toolBar.setSpacing(true);//from w w w.j a v a2 s . c om toolBar.setMargin(true); VerticalLayout uploadLayout = new VerticalLayout(); Upload uploader = new Upload("Upload a file here", null); uploader.setButtonCaption("Upload"); final FileUploader fileUploader = new FileUploader(deploymentViewManager, notifierService, artifactBuilder, option); uploader.setReceiver(fileUploader); uploader.addSucceededListener(fileUploader); uploader.addStartedListener(fileUploader); uploadLayout.addComponent(uploader); HorizontalLayout target = new HorizontalLayout(); option.addContainerProperty("id", String.class, null); option.setItemCaptionPropertyId("id"); option.addItem(DeployableContainerType.DEPLOYABLE.attribute()).getItemProperty("id") .setValue("Add to deployables"); option.addItem(DeployableContainerType.DEPLOYED.attribute()).getItemProperty("id").setValue("Deploy"); option.addItem(DeployableContainerType.DEPLOYMENT_PLAN.attribute()).getItemProperty("id") .setValue("Create a deployment plan"); option.addStyleName("horizontal"); option.select(DeployableContainerType.DEPLOYABLE.attribute()); target.addComponent(option); uploadLayout.addComponent(target); toolBar.addComponent(uploadLayout); Label infoLabel = new Label("Drop files here to create a deployment plan"); infoLabel.setSizeUndefined(); final VerticalLayout deploymentPlanMaker = new VerticalLayout(infoLabel); deploymentPlanMaker.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER); Button draft = new Button("A draft is under construction"); draft.addStyleName("link"); draft.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { deploymentViewManager.showDeploymentPlanView(); } }); draft.setVisible(false); deploymentViewManager.setDeploymentPlanDraftViewer(draft); deploymentPlanMaker.addComponent(draft); deploymentPlanMaker.setComponentAlignment(draft, Alignment.TOP_CENTER); deploymentPlanMaker.setSizeFull(); deploymentPlanMaker.addStyleName("drop-area"); deploymentPlanMakerWrapper = new DragAndDropWrapper(deploymentPlanMaker); deploymentPlanMakerWrapper.setSizeFull(); toolBar.addComponent(deploymentPlanMakerWrapper); addComponent(toolBar); addComponent(framesContainer); setExpandRatio(framesContainer, 1.5f); helpWindow = notifierService.createHelpOverlay("Deployment module", "<p>To deploy, or undeploy, artifacts, you can drag and drop elements from deployables panel " + "to deployed panel and vice versa.</p>" + "<p>You can also drag files from desktop and drop them where you want to add them."); }
From source file:com.wintindustries.pfserver.interfaces.container.components.PFUpload.PFDDragAndDropUpload.java
/** * Sets up DragAndDropWrapper to accept multi file drops. *//*from w w w . j a va 2 s. com*/ private void prepareDropZone() { System.out.println("REGISTERED DROP ZONE"); if (dropZone == null) { // Component label = new Label(getAreaText(), Label.CONTENT_XHTML); // label.setSizeUndefined(); dropZone = new DragAndDropWrapper(contentArea); dropZone.setDragStartMode(DragAndDropWrapper.DragStartMode.HTML5); dropZone.setStyleName("v-multifileupload-dropzone"); dropZone.setStyleName("drop-area"); dropZone.setSizeFull(); addComponent(dropZone); dropZone.setDropHandler(this); // addStyleName("no-horizontal-drag-hints"); // addStyleName("no-vertical-drag-hints"); } }
From source file:gov.va.ds4p.ds4pmobileportal.ui.eHealthDirect.java
License:Open Source License
private Panel getDropPanel() { Panel p = new Panel(); VerticalLayout v = (VerticalLayout) p.getContent(); v.setSpacing(true);/*from w ww . j ava2 s . com*/ //v.setHeight("100%"); p.setStyleName(Runo.PANEL_LIGHT); Panel wrapperPanel = new Panel(); VerticalLayout vDPanel = (VerticalLayout) wrapperPanel.getContent(); deleteBTN.setIcon(new ThemeResource("../runo/icons/64/folder-add.png")); deleteBTN.setWidth("64px"); deleteBTN.setHeight("64px"); vDPanel.addComponent(deleteBTN); final DragAndDropWrapper wrapper = new DragAndDropWrapper(wrapperPanel); wrapper.setWidth("100px"); wrapper.setHeight("100px"); wrapperPanel.setStyleName(Runo.PANEL_LIGHT); wrapper.setDropHandler(new DropHandler() { @Override public void drop(DragAndDropEvent event) { // expecting this to be an html5 drag DragAndDropWrapper.WrapperTransferable tr = (DragAndDropWrapper.WrapperTransferable) event .getTransferable(); Html5File[] files = tr.getFiles(); if (files != null) { for (final Html5File html5File : files) { final String fileName = html5File.getFileName(); if (html5File.getFileSize() > FILE_SIZE_LIMIT) { getWindow().showNotification("File rejected. Max 2MB files are accepted by Sampler", Window.Notification.TYPE_WARNING_MESSAGE); } else { final ByteArrayOutputStream bas = new ByteArrayOutputStream(); StreamVariable streamVariable = new StreamVariable() { public OutputStream getOutputStream() { return bas; } public boolean listenProgress() { return false; } public void onProgress(StreamVariable.StreamingProgressEvent event) { } public void streamingStarted(StreamVariable.StreamingStartEvent event) { } public void streamingFinished(StreamVariable.StreamingEndEvent event) { progress.setVisible(false); Boolean res = updateProviderProcessingInbox(bas.toByteArray()); if (res.booleanValue()) { getWindow().showNotification( "Processing Complete: " + fileName + " " + html5File.getType() + " " + html5File.getFileSize(), Window.Notification.TYPE_HUMANIZED_MESSAGE); } else { getWindow().showNotification( "Processing Error: You Do Not Have Necessary Permissions to Receive and Process Files.", Window.Notification.TYPE_TRAY_NOTIFICATION); } } public void streamingFailed(StreamVariable.StreamingErrorEvent event) { progress.setVisible(false); } public boolean isInterrupted() { return false; } }; html5File.setStreamVariable(streamVariable); progress.setVisible(true); } } } else { String text = tr.getText(); if (text != null) { getWindow().showNotification(text, Window.Notification.TYPE_HUMANIZED_MESSAGE); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); v.addComponent(wrapper); return p; }
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 w w .j a v a2 s.c o 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:info.magnolia.ui.form.field.upload.AbstractUploadField.java
License:Open Source License
/** * The dropZone is a wrapper around a Component. *//* w ww . j ava 2 s .co m*/ protected DragAndDropWrapper createDropZone(Component c) { dropZone = new DragAndDropWrapper(c) { }; dropZone.setDropHandler(this); return this.dropZone; }
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 ww . ja va 2 s . co 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.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);/* w w w . j a v a 2 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); }