Search in sources :

Example 16 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project perun by CESNET.

the class FindExternalPublications method getEmptyTable.

/**
 * Returns table with publications
 * @return table
 */
public CellTable<Publication> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Publication>(list);
    // Cell table
    table = new PerunTable<Publication>(list);
    table.removeRowCountChangeHandler();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Publication> columnSortHandler = new ListHandler<Publication>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage.prepareToSearch("Please select external pub. system and year range to search for publications for import."));
    loaderImage.setEmptyResultMessage("No publications found in external system.");
    // show checkbox column
    if (this.checkable) {
        table.addCheckBoxColumn();
    }
    /*
		// CATEGORY COLUMN
		ArrayList<String> categories = new ArrayList<String>();
		categories.add("Bodované v RIVu");
		categories.add("Nebodované v RIVu");
		categories.add("Příspěvek do ročenky");
		categories.add("Výjimečné výsledky");
		categories.add("Jiné");

		Column<Publication, String> categoryColumn = new Column<Publication, String>(new SelectionCell(categories)){
		@Override
		public String getValue(Publication object) {
		// category ID as string, 0 if not set
		int id = object.getCategoryId();
		if (id == 0) {
		// set default == 21/Bodované v RIVu to object
		object.setCategoryId(21);
		}
		if (id == 21) {
		return "Bodované v RIVu";
		} else if (id == 22) {
		return "Nebodované v RIVu";
		} else if (id == 23) {
		return "Výjimečné výsledky";
		} else if (id == 24) {
		return "Příspěvek do ročenky";
		} else if (id == 25) {
		return "Jiné";
		} else {
		return String.valueOf(id); // return ID if no match
		}
		}
		};
		categoryColumn.setFieldUpdater(new FieldUpdater<Publication, String>() {
		public void update(int index, Publication object, String value) {

		int id = 0;
		if (value.equalsIgnoreCase("Bodované v RIVu")) {
		id = 21;
		} else if (value.equalsIgnoreCase("Nebodované v RIVu")) {
		id = 22;
		} else if (value.equalsIgnoreCase("Příspěvek do ročenky")) {
		id = 24;
		} else if (value.equalsIgnoreCase("Výjimečné výsledky")) {
		id = 23;
		} else if (value.equalsIgnoreCase("Jiné")) {
		id = 25;
		}
		object.setCategoryId(id);
		selectionModel.setSelected(object, true);

		}
		});
		table.addColumn(categoryColumn, "Category");

		// NOT USEFULL => DISABLED
		// EXTERNAL ID
		TextColumn<Publication> externalIdColumn = new TextColumn<Publication>() {
		public String getValue(Publication object) {
		return String.valueOf(object.getExternalId());
		};
		};
		externalIdColumn.setSortable(true);
		columnSortHandler.setComparator(externalIdColumn, new PublicationComparator(PublicationComparator.Column.EXTERNAL_ID));
		table.addColumn(externalIdColumn, "External Id");
		*/
    // TITLE COLUMN
    TextColumn<Publication> titleColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return object.getTitle();
        }
    };
    titleColumn.setSortable(true);
    columnSortHandler.setComparator(titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
    table.addColumn(titleColumn, "Title");
    // AUTHORS COLUMN
    TextColumn<Publication> authorColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return object.getAuthorsFormatted();
        }
    };
    authorColumn.setSortable(true);
    columnSortHandler.setComparator(authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
    table.addColumn(authorColumn, "Authors");
    // YEAR COLUMN
    TextColumn<Publication> yearColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return String.valueOf(object.getYear());
        }
    };
    yearColumn.setSortable(true);
    columnSortHandler.setComparator(yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
    table.addColumn(yearColumn, "Year");
    // ISBN COLUMN
    TextColumn<Publication> isbnColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return object.getIsbn();
        }
    };
    isbnColumn.setSortable(true);
    columnSortHandler.setComparator(isbnColumn, new PublicationComparator(PublicationComparator.Column.ISBN));
    table.addColumn(isbnColumn, "ISBN");
    // CITE COLUMN
    Column<Publication, String> citaceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return "Cite";
        }
    }, new FieldUpdater<Publication, String>() {

        public void update(int index, Publication object, String value) {
            SimplePanel sp = new SimplePanel();
            sp.add(new HTML(object.getMain()));
            Confirm cf = new Confirm("Cite publication", sp, true);
            cf.show();
        }
    });
    table.addColumn(citaceColumn, "Cite");
    return table;
}
Also used : PublicationComparator(cz.metacentrum.perun.webgui.json.comparators.PublicationComparator) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Publication(cz.metacentrum.perun.webgui.model.Publication) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 17 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project perun by CESNET.

the class TabPanelForTabItems method add.

/**
 * Adds a new tab to the panel
 *
 * @param tabItem
 * @param caption
 */
public void add(TabItem tabItem, String caption) {
    SimplePanel sp = new SimplePanel();
    innerTabsSimplePanels.add(sp);
    innerTabs.add(tabItem);
    super.add(sp, caption);
    sp.addStyleName("smallTabPanel");
}
Also used : SimplePanel(com.google.gwt.user.client.ui.SimplePanel)

Example 18 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project perun by CESNET.

the class TabPanelForTabItems method runOnSelectEvent.

/**
 * When selected tab, draw and resize it
 *
 * @param i
 */
protected void runOnSelectEvent(int i) {
    // run resize commands for parent tab
    if (parentTab != null) {
        UiElements.runResizeCommands(parentTab);
    } else {
        UiElements.runResizeCommands();
    }
    // selected tab
    setLastTabId(i, false);
    // check size
    if ((innerTabs.size() < (i + 1)) || (innerTabsSimplePanels.size() < (i + 1))) {
        return;
    }
    // if widget not drawn - draw
    SimplePanel sp = innerTabsSimplePanels.get(i);
    TabItem tab = innerTabs.get(i);
    // check null
    if (sp == null || tab == null) {
        return;
    }
    // if widget null, call draw
    if (sp.getWidget() == null) {
        sp.setWidget(tab.draw());
    }
    UiElements.runResizeCommands(tab);
}
Also used : TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) SimplePanel(com.google.gwt.user.client.ui.SimplePanel)

Example 19 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project gwt-test-utils by gwt-test-utils.

the class SimplePanelTest method remove.

@Test
public void remove() {
    // Given
    SimplePanel panel = new SimplePanel();
    Button b = new Button();
    panel.add(b);
    // When & Then
    assertThat(panel.remove(b)).isTrue();
}
Also used : Button(com.google.gwt.user.client.ui.Button) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) Test(org.junit.Test)

Example 20 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project gwt-test-utils by gwt-test-utils.

the class SimplePanelTest method title.

@Test
public void title() {
    // Given
    SimplePanel sp = new SimplePanel();
    // Preconditions
    assertThat(sp.getTitle()).isEqualTo("");
    // When
    sp.setTitle("title");
    // Then
    assertThat(sp.getTitle()).isEqualTo("title");
}
Also used : SimplePanel(com.google.gwt.user.client.ui.SimplePanel) Test(org.junit.Test)

Aggregations

SimplePanel (com.google.gwt.user.client.ui.SimplePanel)60 Label (com.google.gwt.user.client.ui.Label)19 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)14 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)9 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 HTML (com.google.gwt.user.client.ui.HTML)7 Test (org.junit.Test)5 Element (com.google.gwt.dom.client.Element)4 Style (com.google.gwt.dom.client.Style)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 Button (com.google.gwt.user.client.ui.Button)4 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)4 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)3 Image (com.google.gwt.user.client.ui.Image)3 Widget (com.google.gwt.user.client.ui.Widget)3 HorizontalScrollWrapper (org.pentaho.mantle.client.ui.custom.HorizontalScrollWrapper)3 ListBoxTitle (org.pentaho.mantle.client.ui.custom.ListBoxTitle)3 Context (com.google.gwt.cell.client.Cell.Context)2