List of usage examples for com.vaadin.shared.ui.dd HorizontalDropLocation RIGHT
HorizontalDropLocation RIGHT
To view the source code for com.vaadin.shared.ui.dd HorizontalDropLocation RIGHT.
Click Source Link
From source file:com.esofthead.mycollab.module.project.view.task.TaskKanbanBoardViewImpl.java
License:Open Source License
public TaskKanbanBoardViewImpl() { this.setSizeFull(); this.withSpacing(true).withMargin(new MarginInfo(false, true, true, true)); searchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); searchPanel.addHeaderRight(groupWrapLayout); toggleShowColumsBtn = new Button(""); toggleShowColumsBtn.addClickListener(new Button.ClickListener() { @Override//w w w . j a va2 s.co m public void buttonClick(Button.ClickEvent clickEvent) { displayHiddenColumns = !displayHiddenColumns; reload(); toggleShowButton(); } }); toggleShowColumsBtn.addStyleName(UIConstants.BUTTON_LINK); groupWrapLayout.addComponent(toggleShowColumsBtn); toggleShowButton(); Button addNewColumnBtn = new Button(AppContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { UI.getCurrent().addWindow(new AddNewColumnWindow(TaskKanbanBoardViewImpl.this, ProjectTypeConstants.TASK, "status")); } }); addNewColumnBtn.setIcon(FontAwesome.PLUS); addNewColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)); addNewColumnBtn.setStyleName(UIConstants.BUTTON_ACTION); groupWrapLayout.addComponent(addNewColumnBtn); Button deleteColumnBtn = new Button("Delete columns", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent() .addWindow(new DeleteColumnWindow(TaskKanbanBoardViewImpl.this, ProjectTypeConstants.TASK)); } }); deleteColumnBtn.setIcon(FontAwesome.TRASH_O); deleteColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)); deleteColumnBtn.setStyleName(UIConstants.BUTTON_DANGER); Button advanceDisplayBtn = new Button("List", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new TaskEvent.GotoDashboard(TaskKanbanBoardViewImpl.this, null)); } }); advanceDisplayBtn.setWidth("100px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription("Advance View"); Button kanbanBtn = new Button("Kanban"); kanbanBtn.setWidth("100px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(kanbanBtn); viewButtons.withDefaultButton(kanbanBtn); groupWrapLayout.addComponent(viewButtons); kanbanLayout = new DDHorizontalLayout(); kanbanLayout.setHeight("100%"); kanbanLayout.addStyleName("kanban-layout"); kanbanLayout.setSpacing(true); kanbanLayout.setMargin(new MarginInfo(true, false, true, false)); kanbanLayout.setComponentHorizontalDropRatio(0.3f); kanbanLayout.setDragMode(LayoutDragMode.CLONE_OTHER); // Enable dropping components kanbanLayout.setDropHandler(new DropHandler() { @Override public void drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); DDHorizontalLayout.HorizontalLayoutTargetDetails details = (DDHorizontalLayout.HorizontalLayoutTargetDetails) event .getTargetDetails(); Component dragComponent = transferable.getComponent(); if (dragComponent instanceof KanbanBlock) { KanbanBlock kanbanItem = (KanbanBlock) dragComponent; int newIndex = details.getOverIndex(); if (details.getDropLocation() == HorizontalDropLocation.RIGHT) { kanbanLayout.addComponent(kanbanItem); } else if (newIndex == -1) { kanbanLayout.addComponent(kanbanItem, 0); } else { kanbanLayout.addComponent(kanbanItem, newIndex); } //Update options index for this project List<Map<String, Integer>> indexMap = new ArrayList<>(); for (int i = 0; i < kanbanLayout.getComponentCount(); i++) { KanbanBlock blockItem = (KanbanBlock) kanbanLayout.getComponent(i); Map<String, Integer> map = new HashedMap(2); map.put("id", blockItem.optionVal.getId()); map.put("index", i); indexMap.add(map); } if (indexMap.size() > 0) { optionValService.massUpdateOptionIndexes(indexMap, AppContext.getAccountId()); } } } @Override public AcceptCriterion getAcceptCriterion() { return new Not(VerticalLocationIs.MIDDLE); } }); this.setWidth("100%"); this.with(searchPanel, kanbanLayout).expand(kanbanLayout); }
From source file:com.esofthead.mycollab.module.project.view.task.TaskKanbanviewImpl.java
License:Open Source License
public TaskKanbanviewImpl() { this.setSizeFull(); this.withSpacing(true).withMargin(new MarginInfo(false, true, true, true)); searchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); searchPanel.addHeaderRight(groupWrapLayout); Button addNewColumnBtn = new Button("New column", new Button.ClickListener() { @Override/*from ww w . j a v a 2 s. c om*/ public void buttonClick(Button.ClickEvent clickEvent) { UI.getCurrent() .addWindow(new AddNewColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK)); } }); addNewColumnBtn.setIcon(FontAwesome.PLUS); addNewColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)); addNewColumnBtn.setStyleName(UIConstants.BUTTON_ACTION); groupWrapLayout.addComponent(addNewColumnBtn); Button deleteColumBtn = new Button("Delete columns", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent() .addWindow(new DeleteColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK)); } }); deleteColumBtn.setIcon(FontAwesome.TRASH_O); deleteColumBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)); deleteColumBtn.setStyleName(UIConstants.BUTTON_DANGER); Button advanceDisplayBtn = new Button("List", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new TaskEvent.GotoDashboard(TaskKanbanviewImpl.this, null)); } }); advanceDisplayBtn.setWidth("100px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription("Advance View"); Button kanbanBtn = new Button("Kanban"); kanbanBtn.setWidth("100px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(kanbanBtn); viewButtons.setDefaultButton(kanbanBtn); groupWrapLayout.addComponent(viewButtons); kanbanLayout = new DDHorizontalLayout(); kanbanLayout.setHeight("100%"); kanbanLayout.addStyleName("kanban-layout"); kanbanLayout.setSpacing(true); kanbanLayout.setMargin(new MarginInfo(true, false, true, false)); kanbanLayout.setComponentHorizontalDropRatio(0.3f); kanbanLayout.setDragMode(LayoutDragMode.CLONE_OTHER); // Enable dropping components kanbanLayout.setDropHandler(new DropHandler() { @Override public void drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); DDHorizontalLayout.HorizontalLayoutTargetDetails details = (DDHorizontalLayout.HorizontalLayoutTargetDetails) event .getTargetDetails(); Component dragComponent = transferable.getComponent(); if (dragComponent instanceof KanbanBlock) { KanbanBlock kanbanItem = (KanbanBlock) dragComponent; int newIndex = details.getOverIndex(); if (details.getDropLocation() == HorizontalDropLocation.RIGHT) { kanbanLayout.addComponent(kanbanItem); } else if (newIndex == -1) { kanbanLayout.addComponent(kanbanItem, 0); } else { kanbanLayout.addComponent(kanbanItem, newIndex); } //Update options index for this project List<Map<String, Integer>> indexMap = new ArrayList<>(); for (int i = 0; i < kanbanLayout.getComponentCount(); i++) { KanbanBlock blockItem = (KanbanBlock) kanbanLayout.getComponent(i); Map<String, Integer> map = new HashedMap(2); map.put("id", blockItem.optionVal.getId()); map.put("index", i); indexMap.add(map); } if (indexMap.size() > 0) { optionValService.massUpdateOptionIndexes(indexMap, AppContext.getAccountId()); } } } @Override public AcceptCriterion getAcceptCriterion() { return new Not(VerticalLocationIs.MIDDLE); } }); this.setWidth("100%"); this.with(searchPanel, kanbanLayout).expand(kanbanLayout); }
From source file:com.foc.vaadin.gui.layouts.FVHorizontal_WYSIWYG_DropHandler.java
License:Apache License
@Override protected void handleComponentReordering(DragAndDropEvent event) { // Component re-ordering LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event.getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget(); Component comp = transferable.getComponent(); int idx = (details).getOverIndex(); // Detach// w w w . j a v a2s .c o m if (layout != null && comp != null) layout.removeComponent(comp); idx--; // Increase index if component is dropped after or above a previous // component HorizontalDropLocation loc = details.getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } if (comp != null) { AttributesImpl newAttributes = removeNotNeededAttributes(((FocXMLGuiComponent) comp).getAttributes(), (FVLayout) comp.getParent()); if (newAttributes.getIndex(FXML.ATT_IDX) != -1) { newAttributes.setValue(newAttributes.getIndex("idx"), idx + ""); } else { newAttributes.addAttribute("", FXML.ATT_IDX, FXML.ATT_IDX, "CDATA", idx + ""); } ((FocXMLGuiComponent) comp).setAttributes(newAttributes); // Add component if (layout != null) { if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } } if (comp instanceof FVLayout) { Globals.logString("Here3"); ((FVLayout) comp).setDragDrop(true); } // Add component alignment if given if (dropAlignment != null && layout != null && comp != null) { layout.setComponentAlignment(comp, dropAlignment); } } }
From source file:com.foc.vaadin.gui.layouts.FVHorizontal_WYSIWYG_DropHandler.java
License:Apache License
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event.getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); Component comp = transferable.getComponent(); // Check that we are not dragging an outer layout into an inner // layout//from w ww . j a va 2 s . c o m Component parent = layout.getParent(); while (parent != null) { if (parent == comp) { return; } parent = parent.getParent(); } // If source is an instance of a component container then remove // it // from there, // the component cannot have two parents. ComponentContainer sourceLayout = null; if (source instanceof ComponentContainer) { sourceLayout = (ComponentContainer) source; sourceLayout.removeComponent(comp); } // Increase index if component is dropped after or above a // previous // component HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } AttributesImpl newAttributes = removeNotNeededAttributes(((FocXMLGuiComponent) comp).getAttributes(), (FVLayout) sourceLayout); if (newAttributes.getIndex(FXML.ATT_IDX) > -1) { newAttributes.setValue(newAttributes.getIndex(FXML.ATT_IDX), idx + ""); } ((FocXMLGuiComponent) comp).setAttributes(newAttributes); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultCssLayoutDropHandler.java
License:Apache License
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); CssLayoutTargetDetails details = (CssLayoutTargetDetails) event.getTargetDetails(); DDCssLayout layout = (DDCssLayout) details.getTarget(); HorizontalDropLocation hl = details.getHorizontalDropLocation(); VerticalDropLocation vl = details.getVerticalDropLocation(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); Component comp = transferable.getComponent(); Component over = details.getOverComponent(); if (over == layout) { if (vl == VerticalDropLocation.TOP || hl == HorizontalDropLocation.LEFT) { idx = 0;/* w w w.j a v a2 s .c o m*/ } else if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) { idx = -1; } } else { if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) { idx++; } } // Check that we are not dragging an outer layout into an inner // layout Component parent = layout.getParent(); while (parent != null) { if (parent == comp) { return; } parent = parent.getParent(); } // If source is an instance of a component container then remove // it // from there, // the component cannot have two parents. if (source instanceof ComponentContainer) { ComponentContainer sourceLayout = (ComponentContainer) source; sourceLayout.removeComponent(comp); } // Add component if (idx >= 0 && idx < layout.getComponentCount()) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultCssLayoutDropHandler.java
License:Apache License
@Override protected void handleHTML5Drop(DragAndDropEvent event) { CssLayoutTargetDetails details = (CssLayoutTargetDetails) event.getTargetDetails(); Component over = details.getOverComponent(); DDCssLayout layout = (DDCssLayout) details.getTarget(); int idx = (details).getOverIndex(); HorizontalDropLocation hl = details.getHorizontalDropLocation(); VerticalDropLocation vl = details.getVerticalDropLocation(); if (over == layout) { if (vl == VerticalDropLocation.TOP || hl == HorizontalDropLocation.LEFT) { idx = 0;//from w ww . j a v a2 s. c o m } else if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) { idx = -1; } } else { if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) { idx++; } } if (idx >= 0 && idx < layout.getComponentCount()) { layout.addComponent(resolveComponentFromHTML5Drop(event), idx); } else { layout.addComponent(resolveComponentFromHTML5Drop(event)); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultHorizontalLayoutDropHandler.java
License:Apache License
/** * Called when a component changed location within the layout * //from ww w. ja v a2s. c om * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { // Component re-ordering LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event.getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget(); Component comp = transferable.getComponent(); int idx = details.getOverIndex(); int oldIndex = layout.getComponentIndex(comp); if (idx == oldIndex) { // Index did not change return; } // Detach layout.removeComponent(comp); // Account for detachment if new index is bigger then old index if (idx > oldIndex) { idx--; } // Increase index if component is dropped after or above a previous // component HorizontalDropLocation loc = details.getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp, 0); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultHorizontalLayoutDropHandler.java
License:Apache License
/** * Handle a drop from another layout// w w w . ja v a2 s .co m * * @param event * The drag and drop event */ @Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event.getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); Component comp = transferable.getComponent(); // Check that we are not dragging an outer layout into an inner // layout Component parent = layout.getParent(); while (parent != null) { if (parent == comp) { return; } parent = parent.getParent(); } // Detach from old source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(comp); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // Increase index if component is dropped after or above a // previous // component HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultHorizontalLayoutDropHandler.java
License:Apache License
@Override protected void handleHTML5Drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event.getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); // Increase index if component is dropped after or above a // previous component HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++;/*from w w w. j a v a 2s . c o m*/ } Component comp = resolveComponentFromHTML5Drop(event); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultHorizontalSplitPanelDropHandler.java
License:Apache License
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); ComponentContainer source = (ComponentContainer) transferable.getSourceComponent(); HorizontalSplitPanelTargetDetails details = (HorizontalSplitPanelTargetDetails) event.getTargetDetails(); Component component = transferable.getComponent(); DDHorizontalSplitPanel panel = (DDHorizontalSplitPanel) details.getTarget(); // Detach from old source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(component); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); }/*from w w w . j a v a 2s . c o m*/ if (details.getDropLocation() == HorizontalDropLocation.LEFT) { // Dropped in the left area panel.setFirstComponent(component); } else if (details.getDropLocation() == HorizontalDropLocation.RIGHT) { // Dropped in the right area panel.setSecondComponent(component); } }