Example usage for org.apache.wicket.markup.html.list ListView ListView

List of usage examples for org.apache.wicket.markup.html.list ListView ListView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListView ListView.

Prototype

public ListView(final String id, final List<T> list) 

Source Link

Usage

From source file:com.przemo.projectmanagementweb.pages.ProjectsPage.java

public ProjectsPage() {

    ListView<Projects> view = new ListView("plist", projectService.getAllProjects()) {

        @Override//from w  ww.  ja v  a2 s  . c  om
        protected void populateItem(ListItem li) {
            Link l = new Link("link") {

                @Override
                public void onClick() {
                    setResponsePage(new ProjectPage(new CompoundPropertyModel<>(li.getModel())));
                }

            };
            l.add(new Label("name", new PropertyModel(li.getModel(), "name")));
            li.add(l);
        }

    };
    add(view);
    add(new Link("new_project_link") {

        @Override
        public void onClick() {
            setResponsePage(new ProjectPage(new CompoundPropertyModel<>(new Projects())));
        }

    });
}

From source file:com.rex.crm.TemplatePage.java

License:Apache License

/**
 * Constructor//from w ww .j a  v a  2s . c o  m
 */
public TemplatePage() {

    final int roleId = ((SignIn2Session) getSession()).getRoleId();
    add(new Label("title", new PropertyModel<String>(this, "pageTitle")));
    UserInfo user = DAOImpl.getUserInfoById(Integer.parseInt(((SignIn2Session) getSession()).getUserId()));

    //TODO get function work with real id
    List<String> menulist = DAOImpl.getMenuByRole(roleId);

    //populate menu items. TODO componentize it. pass arg: menuList
    ArrayList<MenuItem> menu = Lists.newArrayList();
    for (String key : menulist) {
        menu.add(pageMenuMap.get(key));
    }

    //@SuppressWarnings("unchecked")
    ListView lv = new ListView("menu", menu) {
        @Override
        protected void populateItem(ListItem item) {
            MenuItem menuitem = (MenuItem) item.getModelObject();
            BookmarkablePageLink link = new BookmarkablePageLink("link", menuitem.getDestination());
            link.add(new Label("caption", menuitem.getCaption()).setEscapeModelStrings(false));
            item.add(link);
            item.add(new AttributeAppender("id", Model.of(menuitem.getId())));
            // item.add(new SimpleAttributeModifier("class", "my-css-class"));

        }
    };
    add(lv);

    add(new Link("signout_link") {

        @Override
        public void onClick() {
            SignIn2Session session = (SignIn2Session) getSession();
            LogInOut loginout = new LogInOut();
            loginout.setLoginName(session.getUser());
            loginout.setLogints(System.currentTimeMillis());
            loginout.setSessionId(session.getId());
            CRMUtility.printStat(CRMUtility.STAT_LOG_IN_OUT, loginout, LogInOut.class);
            session.invalidate();
            this.setResponsePage(SignIn.class);
        }

    });

    BookmarkablePageLink user_settings_link = new BookmarkablePageLink("user_settings_link",
            UserDeatialInfo.class);
    add(user_settings_link);
    user_settings_link.add(new Label("loginName", user.getName()));

    WebMarkupContainer admin_menu = new WebMarkupContainer("admin_menu");
    add(admin_menu);
    BookmarkablePageLink adminTreePage = new BookmarkablePageLink("adminTreePage", AdminTreePage.class);
    admin_menu.add(adminTreePage);

    //        BookmarkablePageLink positionTreePage = new BookmarkablePageLink("positionTreePage",PositionTreePage.class );
    //        admin_menu.add(positionTreePage);

    BookmarkablePageLink productTreePage = new BookmarkablePageLink("productTreePage", ProductTreePage.class);
    admin_menu.add(productTreePage);

    BookmarkablePageLink positionPage = new BookmarkablePageLink("positionPage", PositionPage.class);
    admin_menu.add(positionPage);

    //        BookmarkablePageLink reportPage = new BookmarkablePageLink("reportPage",ReportPage.class );
    //        admin_menu.add(reportPage);

    //        BookmarkablePageLink downloadPage = new BookmarkablePageLink("downloadPage",DownloadPage.class );
    //        admin_menu.add(downloadPage);

    BookmarkablePageLink userPage = new BookmarkablePageLink("userPage", UserPage.class);
    admin_menu.add(userPage);

    BookmarkablePageLink userPositionPage = new BookmarkablePageLink("userPositionPage",
            UserPositionPage.class);
    admin_menu.add(userPositionPage);

    //        BookmarkablePageLink productPage = new BookmarkablePageLink("productPage",ProductPage.class );
    //        admin_menu.add(productPage);

    BookmarkablePageLink dataImportPage = new BookmarkablePageLink("dataImportPage", DataImportPage.class);
    admin_menu.add(dataImportPage);
    BookmarkablePageLink alertPage = new BookmarkablePageLink("alertPage", AlertPage.class);
    admin_menu.add(alertPage);

    BookmarkablePageLink areaPage = new BookmarkablePageLink("areaPage", AreaPage.class);
    admin_menu.add(areaPage);
    //        
    //        BookmarkablePageLink applicationPage = new BookmarkablePageLink("applicationPage",AreaPage.class );
    //        admin_menu.add(applicationPage);
    //        
    //        BookmarkablePageLink flowPage = new BookmarkablePageLink("flowPage",AreaPage.class );
    //        admin_menu.add(flowPage);
    //        
    //        BookmarkablePageLink jurisdictionPage = new BookmarkablePageLink("jurisdictionPage",AreaPage.class );
    //        admin_menu.add(jurisdictionPage);
    //        
    //        BookmarkablePageLink contentPage = new BookmarkablePageLink("contentPage",AreaPage.class );
    //        admin_menu.add(contentPage);
    //        
    //        BookmarkablePageLink integrationPage = new BookmarkablePageLink("integrationPage",AreaPage.class );
    //        admin_menu.add(integrationPage);

    BookmarkablePageLink importLogPage = new BookmarkablePageLink("importLog", ImportLogPage.class);
    admin_menu.add(importLogPage);

    //        BookmarkablePageLink merge_data = new BookmarkablePageLink("merge_data",MergePage.class );
    //        admin_menu.add(merge_data);

    admin_menu.setVisible(false);
    if (roleId == 1)
        admin_menu.setVisible(true);

    //end of populate menu items

    AbstractAjaxBehavior ajaxBehaviour = new AbstractAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onRequest() {
            RequestCycle requestCycle = RequestCycle.get();
            readRequestData(requestCycle);
        }

        private void readRequestData(final RequestCycle requestCycle) {
            WebRequest wr = (WebRequest) requestCycle.getRequest();

            HttpServletRequest hsr = (HttpServletRequest) wr.getContainerRequest();
            String response = "{}";
            try {
                BufferedReader br = hsr.getReader();

                String jsonString = br.readLine();
                if ((jsonString == null) || jsonString.isEmpty()) {
                    logger.debug(" no json found");
                } else {
                    logger.debug(" json  is :" + jsonString);
                }
                FunctionClass method = new Gson().fromJson(jsonString, FunctionClass.class);

                FunctionInvoker invoker = new FunctionInvoker(DataProvider.class);
                System.out.println(" method:" + method);
                response = (String) invoker.invoke(method.getF(), method.getP());
                System.out.println("response:" + response);

                br.close();
            } catch (Exception e) {
                e.printStackTrace();
            }

            requestCycle
                    .replaceAllRequestHandlers(new TextRequestHandler("application/json", "UTF-8", response));

        }

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            super.renderHead(component, response);

            final String posId = ((SignIn2Session) getSession()).getPositionId();
            String callbackUrl = getCallbackUrl().toString();

            Map<String, Object> map = new HashMap<>();
            map.put("userInfo", DataProvider.getCRMUserInfoById(new String[] { posId }));
            map.put("ajaxURL", callbackUrl);
            //map.put("allUsers", DataProvider.getAllCRMUsers(new String[0]));
            //map.put("allAccounts", DataProvider.getAllAccounts(new String[0]));
            map.put("context_name", getRootContext());

            PackageTextTemplate ptt = new PackageTextTemplate(getClass(), "template.js");
            //System.out.println(ptt.asString(map));
            response.render(JavaScriptHeaderItem.forScript(ptt.asString(map), null));
            try {
                ptt.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    };
    add(ajaxBehaviour);

}

From source file:com.romeikat.datamessie.core.base.ui.page.AbstractAuthenticatedPage.java

License:Open Source License

private void initialize() {
    // Active project
    final IModel<ProjectDto> activeProjectModel = new LoadableDetachableModel<ProjectDto>() {

        private static final long serialVersionUID = 1L;

        @Override//from w w w  . jav a 2 s .c  o m
        protected ProjectDto load() {
            // Determine requested project id
            final StringValue projectParameter = getRequest().getRequestParameters()
                    .getParameterValue("project");
            // Load respective project
            ProjectDto activeProject;
            if (projectParameter.isNull()) {
                activeProject = getDefaultProject();
            } else {
                final Long userId = DataMessieSession.get().getUserId();
                activeProject = projectDao.getAsDto(sessionFactory.getCurrentSession(),
                        projectParameter.toLong(), userId);
                if (activeProject == null) {
                    activeProject = getDefaultProject();
                }
            }
            // Ensure project parameter
            if (activeProject != null) {
                getPageParameters().set("project", activeProject.getId());
                DataMessieSession.get().getDocumentsFilterSettings().setProjectId(activeProject.getId());
            }
            // Done
            return activeProject;
        }
    };

    aciveProjectDropDownChoice = new ProjectSelector("activeProjectSelector", activeProjectModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSelectionChanged(final ProjectDto newSelection) {
            if (newSelection == null) {
                return;
            }

            final PageParameters projectPageParameters = new PageParameters();
            final Long selectedProjectId = newSelection.getId();
            projectPageParameters.set("project", selectedProjectId);
            final Class<? extends Page> responsePage = AbstractAuthenticatedPage.this.getNavigationLinkClass();
            final PageParameters pageParameters = getDefaultPageParameters(projectPageParameters);
            AbstractAuthenticatedPage.this.setResponsePage(responsePage, pageParameters);
        }

        @Override
        protected boolean wantOnSelectionChangedNotifications() {
            return true;
        }
    };
    add(aciveProjectDropDownChoice);

    // Navigation links
    final List<NavigationLink<? extends Page>> navigationLinks = getDataMessieApplication()
            .getNavigationLinks();
    final ListView<NavigationLink<? extends Page>> navigationLinksListView = new ListView<NavigationLink<? extends Page>>(
            "navigationLinks", navigationLinks) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<NavigationLink<? extends Page>> item) {
            // Link
            final NavigationLink<? extends Page> navigationLink = item.getModelObject();
            final PageParameters projectPageParameters = createProjectPageParameters();
            final BookmarkablePageLink<? extends Page> bookmarkablePageLink = createBookmarkablePageLink(
                    "navigationLink", navigationLink, projectPageParameters);
            final Label bookmarkablePageLinkLabel = new Label("navigationLinkLabel", navigationLink.getLabel());
            // Active link
            if (AbstractAuthenticatedPage.this.getNavigationLinkClass() == navigationLink.getPageClass()) {
                markLinkSelected(bookmarkablePageLink);
            }
            // Done
            bookmarkablePageLink.add(bookmarkablePageLinkLabel);
            item.add(bookmarkablePageLink);
        }
    };
    add(navigationLinksListView);

    // Sign out link
    signOutLink = new Link<SignInPage>("signOutLink") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            AuthenticatedWebSession.get().invalidate();
            setResponsePage(getApplication().getHomePage());
        }
    };
    add(signOutLink);

    // Side panels
    final List<SidePanel> sidePanels = getDataMessieApplication().getSidePanels();
    final ListView<SidePanel> sidePanelsListView = new ListView<SidePanel>("sidePanels", sidePanels) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<SidePanel> item) {
            // Link
            final SidePanel sidePanel = item.getModelObject();
            final Panel panel = sidePanel.getPanel();
            item.add(panel);
        }
    };
    add(sidePanelsListView);

    // Task executions container
    final WebMarkupContainer taskExecutionsContainer = new WebMarkupContainer("taskExecutionsContainer");
    taskExecutionsContainer.setOutputMarkupId(true);
    taskExecutionsContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(selfUpdatingInterval)));
    add(taskExecutionsContainer);
    // Task executions
    taskExecutionsPanel = new AjaxLazyLoadPanel("taskExecutionsPanel") {
        private static final long serialVersionUID = 1L;

        @Override
        public Component getLazyLoadComponent(final String id) {
            final TaskExecutionsPanel taskExecutionsPanel = new TaskExecutionsPanel(id);
            return taskExecutionsPanel;
        }

    };
    taskExecutionsContainer.add(taskExecutionsPanel);
}

From source file:com.romeikat.datamessie.core.base.ui.panel.DynamicListViewPanel.java

License:Open Source License

public DynamicListViewPanel(final String id, final IModel<List<T>> itemsModel) {
    super(id);/*from  w  w  w. j  a  v a2  s  .  c o  m*/
    // Rules
    this.itemModel = itemsModel;
    // Container for the ListView (needed to update the ListView with Ajax)
    itemsListContainer = new WebMarkupContainer("itemsListContainer");
    itemsListContainer.setOutputMarkupId(true);
    add(itemsListContainer);
    // One line per rule
    final List<T> items = itemsModel.getObject();
    itemsList = new ListView<T>("itemsList", items) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<T> listItem) {
            // Item
            final IModel<T> itemModel = listItem.getModel();
            final Panel itemPanel = DynamicListViewPanel.this.getItemPanel("itemPanel", itemModel);
            listItem.add(itemPanel);
            // Links for editing the list
            listItem.add(createRemoveLink(listItem));
            listItem.add(createMoveDownLink(listItem));
            listItem.add(createMoveUpLink(listItem));
        }
    };
    itemsList.setReuseItems(true);
    itemsListContainer.add(itemsList);
    // Link for adding a new rule
    add(createAddLink());
}

From source file:com.romeikat.datamessie.core.base.ui.panel.FileUploadPanel.java

License:Open Source License

private void initialize() {
    setTitle("File Upload");

    uploadForm = new Form<Void>("uploadForm");
    uploadForm.setMultiPart(true);/*from   w  w w .  j a v  a  2s.  c  o  m*/
    add(uploadForm);

    // Input panel (only create once, so the same panel will be reused for future versions of
    // the FileUplodPanel)
    if (inputPanel == null) {
        inputPanel = getInputPanel("inputPanel");
    }
    uploadForm.add(inputPanel);

    final String[] fileUploadLabels = getFileUploadLabels();
    final boolean[] fileUploadRequireds = getFileUploadRequireds();
    final int numberOfFileUploads = fileUploadLabels.length;

    final String fileUploadLabelsText = numberOfFileUploads == 1 ? "Select file:" : "Select files:";
    final Label fileUploadsLabel = new Label("fileUploadsLabel", fileUploadLabelsText);
    uploadForm.add(fileUploadsLabel);

    final List<Integer> fileUploadNumbers = new ArrayList<Integer>(numberOfFileUploads);
    for (int i = 0; i < numberOfFileUploads; i++) {
        fileUploadNumbers.add(i);
    }
    fileUploadFields = new FileUploadField[numberOfFileUploads];
    final ListView<Integer> fileUploadList = new ListView<Integer>("fileUploadList", fileUploadNumbers) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Integer> item) {
            final int numberOfFileUpload = item.getModelObject();
            // Label
            final String fileUploadLabelText = fileUploadLabels[numberOfFileUpload] + ":";
            final Label fileUploadLabel = new Label("fileUploadLabel", fileUploadLabelText);
            fileUploadLabel.setVisible(fileUploadLabelText != null);
            item.add(fileUploadLabel);
            // File upload
            final FileUploadField fileUploadField = new FileUploadField("fileUploadField");
            fileUploadFields[numberOfFileUpload] = fileUploadField;
            item.add(fileUploadField);
        }
    };
    uploadForm.add(fileUploadList);

    feedbackTextArea = new TextArea<String>("feedbackTextArea", feedbackModel);
    feedbackTextArea.setOutputMarkupId(true);
    uploadForm.add(feedbackTextArea);

    final AjaxFallbackButton submitButton = new AjaxFallbackButton("submitButton",
            Model.of(getSubmitButtonLabel()), uploadForm) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            // Process uploaded files
            final List<String> uploadedFileContents = new ArrayList<String>(numberOfFileUploads);
            for (int i = 0; i < numberOfFileUploads; i++) {
                // Get uploaded file content
                final FileUploadField fileUploadField = fileUploadFields[i];
                final FileUpload uploadedFile = fileUploadField.getFileUpload();
                final boolean fileUploadRequired = fileUploadRequireds[i];
                if (uploadedFile == null && fileUploadRequired) {
                    return;
                }
                final String uploadedFileContent;
                if (uploadedFile == null) {
                    uploadedFileContent = null;
                } else {
                    InputStream uploadStream;
                    try {
                        uploadStream = uploadedFile.getInputStream();
                    } catch (final IOException e) {
                        LOG.error("Could not read content from uploaded file", e);
                        return;
                    }
                    final Scanner uploadFileScanner = new Scanner(uploadStream, "UTF-8");
                    uploadedFileContent = uploadFileScanner.useDelimiter("\\A").next();
                    uploadFileScanner.close();
                }
                // Remember uploaded file content
                uploadedFileContents.add(uploadedFileContent);
            }
            // Process uploaded files
            try {
                processFileContents(inputPanel, uploadedFileContents);
            }
            // In case of error, show feedback
            catch (final FileProcessingException e) {
                feedbackModel.setObject(e.getMessage());
                target.add(feedbackTextArea);
                return;
            }
            // Otherwise, close
            modalContentWindow.close(target);
            // Update tasks immediately
            target.add(((AbstractAuthenticatedPage) getPage()).getTaskExecutionsPanel());
        }
    };
    uploadForm.add(submitButton);
}

From source file:com.romeikat.datamessie.core.base.ui.panel.TaskExecutionsPanel.java

License:Open Source License

public TaskExecutionsPanel(final String id) {
    super(id);//from   w  w  w.  j a  va 2 s .co  m

    // Model
    taskExecutionsModel = new LoadableDetachableModel<List<TaskExecutionDto>>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<TaskExecutionDto> load() {
            final List<TaskExecutionDto> taskExecutions = taskExecutionService
                    .getVisibleTaskExecutionsOrderedByLatestActivityDesc();
            // Reverse so the latest one is the first one
            return taskExecutions;
        }
    };

    // Task executions
    taskExecutionsList = new ListView<TaskExecutionDto>("taskExecutionsList", taskExecutionsModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<TaskExecutionDto> item) {
            final IModel<TaskExecutionDto> taskExecutionModel = item.getModel();
            final TaskExecutionDto taskExecution = taskExecutionModel.getObject();
            // Link to works
            final AjaxLink<Void> modalContentWindowLink = new AjaxLink<Void>("modalContentWindowLink") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    final ModalContentWindow modalContentWindow = TaskExecutionsPanel.this
                            .allocateModalWindow();
                    if (modalContentWindow != null) {
                        final TaskExecutionWorksPanel detailsPanel = new TaskExecutionWorksPanel(
                                modalContentWindow, taskExecutionModel);
                        detailsPanel.show(target);
                    }
                }
            };
            String taskLabelContent = taskExecution.getName();
            if (taskExecution.getStatus() != null) {
                taskLabelContent += " (" + taskExecution.getStatus().getName().toLowerCase() + ")";
            }
            final Label taskLabel = new Label("taskLabel", taskLabelContent);
            modalContentWindowLink.add(taskLabel);
            item.add(modalContentWindowLink);
        }
    };
    taskExecutionsList.setOutputMarkupId(true);
    add(taskExecutionsList);
}

From source file:com.romeikat.datamessie.core.base.ui.panel.TaskExecutionWorksPanel.java

License:Open Source License

public TaskExecutionWorksPanel(final ModalContentWindow modalContentWindow,
        final IModel<TaskExecutionDto> taskExecutionModel) {
    super(modalContentWindow, null);
    this.taskExecutionModel = taskExecutionModel;
    setTitle("Task Details");

    // Model//from w  w w . ja va2 s . c o m
    taskExecutionWorksModel = new LoadableDetachableModel<List<TaskExecutionWorkDto>>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<TaskExecutionWorkDto> load() {
            final TaskExecutionDto taskExecution = taskExecutionModel.getObject();
            if (taskExecution == null) {
                return Collections.emptyList();
            }

            final List<TaskExecutionWorkDto> taskExecutionWorks = taskExecution.getWorks();
            final int taskExecutionWorksSize = taskExecutionWorks.size();
            if (taskExecutionWorksSize <= MAX_TASK_EXECUTION_WORKS) {
                return taskExecutionWorks;
            }
            return taskExecutionWorks.subList(taskExecutionWorksSize - MAX_TASK_EXECUTION_WORKS,
                    taskExecutionWorksSize);
        }
    };

    // Task execution works
    taskExecutionsWorkList = new ListView<TaskExecutionWorkDto>("worksList", taskExecutionWorksModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<TaskExecutionWorkDto> item) {
            final IModel<TaskExecutionWorkDto> taskExecutionWorkModel = item.getModel();
            final TaskExecutionWorkDto taskExecutionWork = taskExecutionWorkModel.getObject();
            final StringBuilder workLabelContent = new StringBuilder();
            final boolean empty = taskExecutionWork.getMessage() == null;
            if (!empty) {
                // Start
                if (taskExecutionWork.getStart() != null) {
                    workLabelContent.append(
                            DateConverter.INSTANCE_UI.convertToString(new Date(taskExecutionWork.getStart())));
                    workLabelContent.append(": ");
                }
                // Message
                if (taskExecutionWork.getMessage() != null) {
                    workLabelContent.append(taskExecutionWork.getMessage());
                }
                // Duration
                if (taskExecutionWork.getDuration() != null) {
                    final long seconds = Math.round(taskExecutionWork.getDuration() / 1000d);
                    workLabelContent.append(" (");
                    workLabelContent.append(seconds);
                    workLabelContent.append(" s)");
                }
            }
            final Label workLabel = new Label("workLabel", workLabelContent.toString());
            item.add(workLabel);
        }
    };
    taskExecutionsWorkList.setOutputMarkupId(true);
    add(taskExecutionsWorkList);

    updateLink = new AjaxLink<Void>("updateLink") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure() {
            super.onConfigure();
            final TaskExecutionDto taskExecution = TaskExecutionWorksPanel.this.taskExecutionModel.getObject();
            final boolean visible = taskExecution.getStatus() != TaskExecutionStatus.COMPLETED
                    && taskExecution.getStatus() != TaskExecutionStatus.CANCELLED
                    && taskExecution.getStatus() != TaskExecutionStatus.FAILED;
            setVisible(visible);
        }

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.add(TaskExecutionWorksPanel.this);
            target.add(((AbstractAuthenticatedPage) getPage()).getTaskExecutionsPanel());
        }
    };
    add(updateLink);

    final String confirmation = "Would you really like to cancel the execution of this task?";
    cancelLink = new AjaxConfirmationLink<Void>("cancelLink", confirmation) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure() {
            super.onConfigure();
            final TaskExecutionDto taskExecution = TaskExecutionWorksPanel.this.taskExecutionModel.getObject();
            final boolean visible = taskExecution.getStatus() != TaskExecutionStatus.COMPLETED
                    && taskExecution.getStatus() != TaskExecutionStatus.CANCEL_REQUESTED
                    && taskExecution.getStatus() != TaskExecutionStatus.CANCELLED
                    && taskExecution.getStatus() != TaskExecutionStatus.FAILED;
            setVisible(visible);
        }

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final TaskExecutionDto taskExecution = TaskExecutionWorksPanel.this.taskExecutionModel.getObject();
            taskManager.cancelTask(taskExecution.getId());
            target.add(TaskExecutionWorksPanel.this);
            target.add(((AbstractAuthenticatedPage) getPage()).getTaskExecutionsPanel());
            modalContentWindow.close(target);
        }
    };
    add(cancelLink);
}

From source file:com.romeikat.datamessie.core.base.ui.table.AbstractPageableTablePanel.java

License:Open Source License

private void initialize() {
    setOutputMarkupId(true);/*from   ww  w. ja  v a2 s  .  c o m*/

    final List<ITableColumn<T>> tableColumns = getTalbeColumns();

    // Paging navigator
    pagingNavigator = new AjaxPagingNavigator("pagingNavigator", rowsList) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure() {
            super.onConfigure();
            final long pageCount = getPageable().getPageCount();
            setVisible(pageCount > 1);
        }
    };
    pagingNavigator.setOutputMarkupId(true);
    add(pagingNavigator);

    // Headline
    final ListView<ITableColumn<T>> columnHeadersListView = new ListView<ITableColumn<T>>("columnHeaders",
            tableColumns) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ITableColumn<T>> item) {
            final ITableColumn<T> tableColumn = item.getModelObject();
            final ITableComponent columnHeader = tableColumn.getColumnHeader();
            addToTable(item, columnHeader);
        }
    };
    add(columnHeadersListView);

    // Rows
    rowsDataProvider = new RowsDataProvider();
    rowsList = new DataView<T>("rowsList", rowsDataProvider) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<T> item) {
            final IModel<T> rowModel = item.getModel();
            final ListView<ITableColumn<T>> rowColumnsListView = new ListView<ITableColumn<T>>("columnValues",
                    tableColumns) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(final ListItem<ITableColumn<T>> item) {
                    final ITableColumn<T> tableColumn = item.getModelObject();
                    final ITableComponent columnValue = tableColumn.getColumnValue(rowModel);
                    addToTable(item, columnValue);
                }
            };
            item.add(rowColumnsListView);
        }
    };
    rowsList.setItemsPerPage(rowsPerPage);
    add(rowsList);

    // Number of rows
    final long numberOfRows = rowsDataProvider.size();
    final String suffix = numberOfRows == 1 ? getRowsSingularName() : getRowsPluralName();
    final Label numberOfRowsLabel = new Label("numberOfRows", numberOfRows + " " + suffix);
    add(numberOfRowsLabel);
}

From source file:com.senacor.wbs.web.core.layout.menu.Menu.java

License:Apache License

public Menu(String id) {
    super(id);//  w w w  . ja  va  2  s  .  co  m
    setRenderBodyOnly(true);
    add(new ListView("topLevelMenuItemList", topLevelMenuItemList) {
        protected void populateItem(ListItem item) {
            TopLevelMenuItem menuItem = (TopLevelMenuItem) item.getModelObject();
            item.add(menuItem);
        }
    });
}

From source file:com.senacor.wbs.web.core.layout.menu.SecondLevelMenu.java

License:Apache License

public SecondLevelMenu(String id) {
    super(id);/*  w ww. j a va  2  s .  c  o m*/
    add(new ListView("links", links) {
        protected void populateItem(ListItem item) {
            Link link = (Link) item.getModelObject();
            item.add(link);
        }
    });
}