Search in sources :

Example 6 with Application

use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.

the class GetApplicationsForVo method setList.

public void setList(ArrayList<Application> list) {
    clearTable();
    this.list.addAll(list);
    for (Application a : list) {
        if (a.getUser() != null) {
            oracle.add(a.getUser().getFullName());
        } else {
            oracle.add(Utils.convertCertCN(a.getCreatedBy()));
        }
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : Application(cz.metacentrum.perun.webgui.model.Application)

Example 7 with Application

use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.

the class SelfApplicationsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Applications");
    VerticalPanel bodyContents = new VerticalPanel();
    bodyContents.setWidth("100%");
    // callback
    final GetApplicationsForUser req = new GetApplicationsForUser(user.getId());
    req.setCheckable(false);
    // tab menu for filtering
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    tabMenu.addFilterWidget(new ExtendedSuggestBox(req.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            req.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterByVoOrGroup());
    bodyContents.add(tabMenu);
    CellTable<Application> appsTable = req.getTable(new FieldUpdater<Application, String>() {

        @Override
        public void update(int index, Application object, String value) {
            session.getTabManager().addTab(new SelfApplicationDetailTabItem(object));
        }
    });
    appsTable.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(appsTable);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    bodyContents.add(sp);
    this.contentWidget.setWidget(bodyContents);
    return getWidget();
}
Also used : GetApplicationsForUser(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUser) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application)

Example 8 with Application

use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.

the class VoApplicationsTabItem method draw.

public Widget draw() {
    // request
    final GetApplicationsForVo applicationsRequest = new GetApplicationsForVo(vo.getId());
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
    applicationsRequest.setCheckable(false);
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "applications");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    /*

		// verify button
		final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
		verify.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
							request.verifyApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, events));
							request.verifyApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		// accept button
		final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
		approve.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
							request.approveApplication(list.get(i));
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, events));
							request.approveApplication(list.get(i));
						}
					}
				}
			}
		});

		//reject button
		final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
		reject.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					// confirm content
					FlexTable content = new FlexTable();
					content.setCellSpacing(10);
					content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
					content.getFlexCellFormatter().setColSpan(0, 0, 2);
					final TextArea reason = new TextArea();
					reason.setSize("300px", "150px");
					content.setHTML(1, 0, "<strong>Reason: </strong>");
					content.setWidget(1, 1, reason);

					Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
						public void onClick(ClickEvent event) {

							for (int i=0; i<list.size(); i++) {
								if (i != list.size()-1) {
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								} else {
									// refresh table on last call
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, events));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								}
							}

						}
					}, true);
					c.show();
				}
			}
		});

		// delete button
		final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
		delete.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
							request.deleteApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, events));
							request.deleteApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		menu.addWidget(verify);
		menu.addWidget(approve);
		menu.addWidget(reject);
		menu.addWidget(delete);

		*/
    // FILTER
    menu.addWidget(new HTML("<strong>State: </strong>"));
    // state
    final ListBox stateListBox = new ListBox();
    stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
    stateListBox.addItem("Pending", "NEW,VERIFIED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
    stateListBox.setSelectedIndex(selectedIndex);
    menu.addWidget(stateListBox);
    stateListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            selectedIndex = stateListBox.getSelectedIndex();
            applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
            applicationsRequest.clearTable();
            applicationsRequest.retrieveData();
        }
    });
    // FILTER 2
    menu.addWidget(new HTML("<strong>Submitted&nbsp;by: </strong>"));
    menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            applicationsRequest.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterApplications());
    // TABLE
    applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
    CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {

        public void update(int index, Application object, String value) {
            session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
        }
    });
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    /*
		verify.setEnabled(false);
		approve.setEnabled(false);
		reject.setEnabled(false);
		delete.setEnabled(false);

		if (session.isVoAdmin(voId)) {
			JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
			JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
			JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
		}
		if (session.isPerunAdmin()) {
			JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
		}
		*/
    session.getUiElements().resizePerunTable(sp, 100);
    firstTabPanel.add(sp);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ApplicationDetailTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem) GetApplicationsForVo(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForVo) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application) HandleApplication(cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)

Example 9 with Application

use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.

the class GroupApplicationsTabItem method draw.

public Widget draw() {
    // request
    final GetApplicationsForGroup applicationsRequest = new GetApplicationsForGroup(group.getId());
    final JsonCallbackEvents refreshEvent = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "applications");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    /*
		// verify button
		final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
		verify.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
							request.verifyApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, refreshEvent));
							request.verifyApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		// accept button
		final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
		approve.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
							request.approveApplication(list.get(i));
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, refreshEvent));
							request.approveApplication(list.get(i));
						}
					}
				}
			}
		});

		//reject button
		final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
		reject.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					// confirm content
					FlexTable content = new FlexTable();
					content.setCellSpacing(10);
					content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
					content.getFlexCellFormatter().setColSpan(0, 0, 2);
					final TextArea reason = new TextArea();
					reason.setSize("300px", "150px");
					content.setHTML(1, 0, "<strong>Reason: </strong>");
					content.setWidget(1, 1, reason);

					Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
						public void onClick(ClickEvent event) {

							for (int i=0; i<list.size(); i++) {
								if (i != list.size()-1) {
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								} else {
									// refresh table on last call
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, refreshEvent));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								}
							}

						}
					}, true);
					c.show();
				}
			}
		});

		// delete button
		final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
		delete.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
							request.deleteApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, refreshEvent));
							request.deleteApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		menu.addWidget(verify);
		menu.addWidget(approve);
		menu.addWidget(reject);
		menu.addWidget(delete);
		*/
    // FILTER
    menu.addWidget(new HTML("<strong>State: </strong>"));
    // state
    final ListBox stateListBox = new ListBox();
    stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
    stateListBox.addItem("Pending", "NEW,VERIFIED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
    stateListBox.setSelectedIndex(selectedIndex);
    menu.addWidget(stateListBox);
    stateListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            selectedIndex = stateListBox.getSelectedIndex();
            applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
            applicationsRequest.clearTable();
            applicationsRequest.retrieveData();
        }
    });
    // FILTER 2
    menu.addWidget(new HTML("<strong>Submitted&nbsp;by: </strong>"));
    menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            applicationsRequest.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterApplications());
    // TABLE
    applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
    CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {

        public void update(int index, Application object, String value) {
            session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
        }
    });
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 100);
    firstTabPanel.add(sp);
    /*
		verify.setEnabled(false);
		approve.setEnabled(false);
		reject.setEnabled(false);
		delete.setEnabled(false);

		if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))  {

			JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
			JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
			JsonUtils.addTableManagedButton(applicationsRequest, table, delete);

			if (session.isPerunAdmin()) {

				JsonUtils.addTableManagedButton(applicationsRequest, table, verify);

			}

		} else {



		}

		*/
    applicationsRequest.setCheckable(false);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) GetApplicationsForGroup(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForGroup) ApplicationDetailTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application) HandleApplication(cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)

Example 10 with Application

use of cz.metacentrum.perun.webgui.model.Application in project perun by CESNET.

the class GetApplicationsForMember method getTable.

/**
	 * Returns just the celltable
	 * @return
	 */
public CellTable<Application> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<Application>(list);
    // Cell table
    table = new PerunTable<Application>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Application> columnSortHandler = new ListHandler<Application>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Application>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    if (groupId == 0) {
        loaderImage.setEmptyResultMessage("No member's applications found for this VO or it's groups.");
    } else {
        loaderImage.setEmptyResultMessage("No member's applications found for this group.");
    }
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("App ID", tableFieldUpdater, 85);
    // DATE COLUMN
    Column<Application, String> dateColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            // return only day
            return object.getCreatedAt().split(" ")[0];
        }
    }, tableFieldUpdater);
    dateColumn.setSortable(true);
    columnSortHandler.setComparator(dateColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return arg0.getCreatedAt().compareToIgnoreCase(arg1.getCreatedAt());
        }
    });
    table.addColumn(dateColumn, "Created date");
    table.setColumnWidth(dateColumn, "120px");
    // Type column
    Column<Application, String> typeColumn = new Column<Application, String>(new PerunAppTypeCell()) {

        @Override
        public String getValue(Application object) {
            return object.getType();
        }
    };
    typeColumn.setFieldUpdater(tableFieldUpdater);
    typeColumn.setSortable(true);
    columnSortHandler.setComparator(typeColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return (arg0.getType()).compareToIgnoreCase(arg1.getType());
        }
    });
    table.addColumn(typeColumn, "Type");
    table.setColumnWidth(typeColumn, "60px");
    // State column
    Column<Application, String> stateColumn = new Column<Application, String>(new CustomClickableTextCell()) {

        @Override
        public String getValue(Application object) {
            return object.getTranslatedState(object.getState());
        }

        @Override
        public String getCellStyleNames(Cell.Context context, Application object) {
            if ("NEW".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowgreen";
            } else if ("VERIFIED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowyellow";
            } else if ("APPROVED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowdarkgreen";
            } else if ("REJECTED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowred";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    stateColumn.setFieldUpdater(tableFieldUpdater);
    stateColumn.setSortable(true);
    columnSortHandler.setComparator(stateColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return (arg0.getTranslatedState(arg0.getState())).compareToIgnoreCase(arg1.getTranslatedState(arg1.getState()));
        }
    });
    table.addColumn(stateColumn, "State");
    table.setColumnWidth(stateColumn, "120px");
    Column<Application, String> extSourceColumn = JsonUtils.addColumn(new ClickableTextCell() {

        @Override
        public void render(com.google.gwt.cell.client.Cell.Context context, SafeHtml value, SafeHtmlBuilder sb) {
            if (value != null) {
                sb.appendHtmlConstant("<div class=\"customClickableTextCell\">");
                sb.append(value);
                sb.appendHtmlConstant("</div>");
            }
        }
    }, new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            if (object.getUser() != null) {
                return object.getUser().getFullNameWithTitles();
            }
            return Utils.convertCertCN(object.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(object.getExtSourceName()));
        }
    }, tableFieldUpdater);
    extSourceColumn.setSortable(true);
    columnSortHandler.setComparator(extSourceColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            String compare1 = "";
            String compare2 = "";
            if (arg0.getUser() != null) {
                compare1 = arg0.getUser().getFullName();
            } else {
                compare1 = Utils.convertCertCN(arg0.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg0.getExtSourceName()));
            }
            if (arg1.getUser() != null) {
                compare2 = arg1.getUser().getFullName();
            } else {
                compare2 = Utils.convertCertCN(arg1.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg1.getExtSourceName()));
            }
            return compare1.compareToIgnoreCase(compare2);
        }
    });
    table.addColumn(extSourceColumn, "Submitted by");
    Column<Application, String> loaColumn = JsonUtils.addColumn(new ClickableTextCell() {

        @Override
        public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
            if (value != null) {
                sb.appendHtmlConstant("<div class=\"customClickableTextCell\">");
                sb.append(value);
                sb.appendHtmlConstant("</div>");
            }
        }
    }, new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            return String.valueOf(object.getExtSourceLoa());
        }
    }, tableFieldUpdater);
    loaColumn.setSortable(true);
    columnSortHandler.setComparator(loaColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return arg0.getExtSourceLoa() - arg1.getExtSourceLoa();
        }
    });
    table.addColumn(loaColumn, "LoA");
    table.setColumnWidth(loaColumn, "40px");
    // GROUP COLUMN
    Column<Application, String> groupColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            if (object.getGroup() != null) {
                return object.getGroup().getName();
            } else {
                return "---";
            }
        }
    }, tableFieldUpdater);
    groupColumn.setSortable(true);
    columnSortHandler.setComparator(groupColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            String name1 = "";
            String name2 = "";
            if (arg0.getGroup() != null) {
                name1 = arg0.getGroup().getName();
            } else {
                name1 = "---";
            }
            if (arg1.getGroup() != null) {
                name2 = arg1.getGroup().getName();
            } else {
                name2 = "---";
            }
            return (name1).compareToIgnoreCase(name2);
        }
    });
    table.addColumn(groupColumn, "Group");
    Column<Application, String> modifiedColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            return Utils.convertCertCN(object.getModifiedBy());
        }
    }, tableFieldUpdater);
    table.addColumn(modifiedColumn, "Modified by");
    modifiedColumn.setSortable(true);
    columnSortHandler.setComparator(modifiedColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return Utils.convertCertCN(arg0.getModifiedBy()).compareTo(Utils.convertCertCN(arg1.getModifiedBy()));
        }
    });
    table.setRowStyles(new RowStyles<Application>() {

        public String getStyleNames(Application application, int i) {
            if (application.getType().equalsIgnoreCase("INITIAL")) {
                return "rowlightgreen";
            } else {
                return "rowlightyellow";
            }
        }
    });
    return table;
}
Also used : PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Column(com.google.gwt.user.cellview.client.Column) Application(cz.metacentrum.perun.webgui.model.Application) PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) Cell(com.google.gwt.cell.client.Cell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell)

Aggregations

Application (cz.metacentrum.perun.webgui.model.Application)20 Column (com.google.gwt.user.cellview.client.Column)5 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)5 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)5 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)5 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 Cell (com.google.gwt.cell.client.Cell)3 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)3 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 HandleApplication (cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)3 ApplicationDetailTabItem (cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem)3 PerunAppTypeCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell)3 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1