Java Code Examples for com.google.gwt.user.client.ui.VerticalPanel#addStyleName()

The following examples show how to use com.google.gwt.user.client.ui.VerticalPanel#addStyleName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayerManagerWidget.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private VerticalPanel getFoot() {
	slider.setWidth("290px");
	slider.disable();
	slider.setIncrement(1);

	slider.addValueChangeHandler(new ValueChangeHandler<Integer>() {

		@Override
		public void onValueChange(final ValueChangeEvent<Integer> event) {
			final Layer layer = getSelectedLayer(getSelectedTabName());
			layer.setOpacity((float) (event.getValue().intValue() / 100.0));
		}

	});

	final VerticalPanel panel = new VerticalPanel();
	panel.setWidth("300px");
	panel.addStyleName(ThemeStyles.get().style().borderTop());
	panel.add(new HTML(UIMessages.INSTANCE.lmOpacityHtmlLabel()));
	panel.add(slider);

	panel.add(statusBar);
	return panel;
}
 
Example 2
Source File: AppUtils.java    From swcv with MIT License 6 votes vote down vote up
public static DialogBox createLoadingBox()
{
    final DialogBox box = new DialogBox();
    VerticalPanel rows = new VerticalPanel();
    rows.setSpacing(1);

    HTML html = new HTML("<img src=\"" + GWT.getHostPageBaseURL() + "static/imgs/loader.gif\" alt=\"loading\" />");
    rows.add(html);
    rows.addStyleName("whiteWithBorder");
    rows.setCellHeight(html, "100");
    rows.setCellWidth(html, "300");

    rows.setCellHorizontalAlignment(html, HasHorizontalAlignment.ALIGN_CENTER);
    rows.setCellVerticalAlignment(html, HasVerticalAlignment.ALIGN_MIDDLE);

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(rows);
    box.setWidget(hp);
    box.hide();
    return box;
}
 
Example 3
Source File: SecurityDomainRealmEditor.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    setupTable();
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);

    panel.add(setupTableButtons());

    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example 4
Source File: GenericListComplexAttribute.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    setupTable();
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);

    panel.add(setupTableButtons());

    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example 5
Source File: SimplePermissionMappingEditor.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    setupTable();
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);

    setupPermissionsTable();
    panel.add(setupTableButtons());


    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example 6
Source File: ConstantPermissionMappingEditor.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    setupTable();
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);

    panel.add(setupTableButtons());

    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example 7
Source File: NewCoreQueueWizard.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
Widget asWidget() {
    VerticalPanel layout = new VerticalPanel();
    layout.addStyleName("window-content");
    Form<ActivemqCoreQueue> form = new Form<>(ActivemqCoreQueue.class);

    TextBoxItem name = new TextBoxItem("name", "Name");
    TextBoxItem queueAddress = new TextBoxItem("queueAddress", "Address");
    TextBoxItem filter = new TextBoxItem("filter", "Filter", false);

    CheckBoxItem durable = new CheckBoxItem("durable", "Durable?");
    durable.setValue(true); // new queues are durable by default (AS7-4955)
    durable.setRequired(false);
    form.setFields(name, queueAddress, filter, durable);
    

    FormHelpPanel helpPanel = new FormHelpPanel(() -> {
        ModelNode address = Baseadress.get();
        address.add("subsystem", "messaging-activemq");
        address.add("server", presenter.getCurrentServer());
        address.add("queue", "*");
        return address;
    }, form);

    layout.add(helpPanel.asWidget());
    layout.add(form.asWidget());

    DialogueOptions options = new DialogueOptions(
            event -> {
                FormValidation validation = form.validate();
                if (!validation.hasErrors()) {
                    presenter.onCreateCoreQueue(form.getUpdatedEntity()); }
            },
            event -> presenter.closeDialogue()
    );

    return new WindowContentBuilder(layout, options).build();
}
 
Example 8
Source File: GenericAliasEditor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    setupTable();
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);

    panel.add(setupTableButtons());

    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    selectionModel.addSelectionChangeHandler(selectionChangeEvent -> {
        ModelNode selected = selectionModel.getSelectedObject();
        if (selected != null) {
            removeButton.setEnabled(true);
            editButton.setEnabled(true);
        } else {
            removeButton.setEnabled(false);
            editButton.setEnabled(false);

        }
    });
    return panel;
}
 
Example 9
Source File: GeneralView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Widget asWidget() {

        columns = new Column[]{
                new TextColumn("Status", "OFF"),
                new NumberColumn("average-commit-time", "Average Commit Time"),
                new NumberColumn("number-of-inflight-transactions", "Inflight Transactions"),
                new NumberColumn("number-of-nested-transactions", "Nested Transactions")
        };
        grid = new Grid(columns.length, 2);
        grid.addStyleName("metric-grid");

        for (int row = 0; row < columns.length; ++row) {
            grid.getCellFormatter().addStyleName(row, 0, "nominal");
            grid.getCellFormatter().addStyleName(row, 1, "numerical");
        }
        grid.setText(0, 0, "Status");

        HorizontalPanel header = new HorizontalPanel();
        header.addStyleName("fill-layout-width");
        header.add(new HTML("<h3 class='metric-label'>General Statistics</h3>"));

        final HelpSystem.AddressCallback addressCallback = () -> {
            ModelNode address = new ModelNode();
            address.get(ModelDescriptionConstants.ADDRESS).set(RuntimeBaseAddress.get());
            address.get(ModelDescriptionConstants.ADDRESS).add("subsystem", "transactions");
            return address;
        };

        MetricHelpPanel helpPanel = new MetricHelpPanel(addressCallback, this.columns);

        VerticalPanel metricsPanel = new VerticalPanel();
        metricsPanel.addStyleName("metric-container");
        metricsPanel.add(header);
        metricsPanel.add(helpPanel.asWidget());
        metricsPanel.add(grid);

        return metricsPanel.asWidget();
    }
 
Example 10
Source File: NewJMSQueueWizard.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
Widget asWidget() {
    VerticalPanel layout = new VerticalPanel();
    layout.addStyleName("window-content");
    Form<ActivemqJMSQueue> form = new Form<>(ActivemqJMSQueue.class);

    TextBoxItem name = new TextBoxItem("name", "Name");
    ListItem jndiName = new JndiNamesItem("entries", "JNDI Names");

    CheckBoxItem durable = new CheckBoxItem("durable", "Durable?");
    durable.setValue(true); // new queues are durable by default (AS7-4955)
    TextBoxItem selector = new TextBoxItem("selector", "Selector") {
        @Override
        public boolean isRequired() {
            return false;
        }
    };
    form.setFields(name, jndiName, durable, selector);

    FormHelpPanel helpPanel = new FormHelpPanel(() -> {
        ModelNode address = Baseadress.get();
        address.add("subsystem", "messaging-activemq");
        address.add("server", presenter.getCurrentServer());
        address.add("jms-queue", "*");
        return address;
    }, form);

    layout.add(helpPanel.asWidget());
    layout.add(form.asWidget());

    DialogueOptions options = new DialogueOptions(
            event -> {
                FormValidation validation = form.validate();
                if (!validation.hasErrors()) { presenter.onCreateJMSQueue(form.getUpdatedEntity()); }
            },
            event -> presenter.closeDialogue()
    );

    return new WindowContentBuilder(layout, options).build();
}
 
Example 11
Source File: NewCFWizard.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
Widget asWidget() {
    VerticalPanel layout = new VerticalPanel();
    layout.addStyleName("window-content");

    DefaultCFForm defaultAttributes = new DefaultCFForm(presenter,
            new FormToolStrip.FormCallback<ActivemqConnectionFactory>() {
                @Override
                public void onSave(Map<String, Object> changeset) {}

                @Override
                public void onDelete(ActivemqConnectionFactory entity) {}
            }, false
    );

    defaultAttributes.getForm().setNumColumns(1);
    defaultAttributes.getForm().setEnabled(true);
    defaultAttributes.setIsCreate(true);

    layout.add(defaultAttributes.asWidget());

    DialogueOptions options = new DialogueOptions(
            event -> {
                Form<ActivemqConnectionFactory> form = defaultAttributes.getForm();
                FormValidation validation = form.validate();
                if (!validation.hasErrors()) { presenter.onCreateCF(form.getUpdatedEntity()); }
            },
            event -> presenter.closeDialogue()
    );

    return new WindowContentBuilder(layout, options).build();
}
 
Example 12
Source File: IdentityAttributeMappingView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    // table
    table = new DefaultCellTable<>(20);
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);
    table.setSelectionModel(selectionModel);

    // columns
    Column<ModelNode, String> fromColumn = createColumn("from");
    Column<ModelNode, String> toColumn = createColumn("to");
    Column<ModelNode, String> referenceColumn = createColumn("reference");
    Column<ModelNode, String> filterColumn = createColumn("filter");
    Column<ModelNode, String> filterBaseColumn = createColumn("filter-base-dn");
    Column<ModelNode, String> searchRecursiveColumn = createColumn("search-recursive");
    Column<ModelNode, String> roleRecursionColumn = createColumn("role-recursion");
    Column<ModelNode, String> roleRecursioNameColumn = createColumn("role-recursion-name");
    Column<ModelNode, String> extractDnColumn = createColumn("extract-rdn");
    table.addColumn(fromColumn, "From");
    table.addColumn(toColumn, "To");
    table.addColumn(referenceColumn, "Reference");
    table.addColumn(filterColumn, "Filter");
    table.addColumn(filterBaseColumn, "Filter Base DN");
    table.addColumn(searchRecursiveColumn, "Search Recursive");
    table.addColumn(roleRecursionColumn, "Role Recursion");
    table.addColumn(roleRecursioNameColumn, "Role Recursion Name");
    table.addColumn(extractDnColumn, "Extract RDN");

    panel.add(mainTableTools());
    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example 13
Source File: HostSelector.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Widget asWidget() {

        VerticalPanel layout = new VerticalPanel();
        layout.getElement().setId("host_selection");
        layout.getElement().setAttribute("title", Console.CONSTANTS.pleaseChoseHost());
        layout.setStyleName("fill-layout-width");
        layout.addStyleName("lhs-selector");
        layout.getElement().setAttribute("style", "padding:4px;");

        hosts = new ComboPicker();
        hosts.addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(final ValueChangeEvent<String> event) {
                if (!event.getValue().isEmpty()) {
                    Scheduler.get().scheduleDeferred(
                            new Scheduler.ScheduledCommand() {
                                @Override
                                public void execute() {
                                    Console.getCircuit().dispatch(new HostSelection(hosts.getSelectedValue()));
                                }
                            }
                    );
                }
            }
        });

        Label hostLabel = new Label("Host:");
        hostLabel.setStyleName("header-label");
        layout.add(hostLabel);
        Widget hWidget = hosts.asWidget();
        hWidget.getElement().addClassName("table-picker");
        layout.add(hWidget);

        // combo box use all available space
        hWidget.getElement().getParentElement().setAttribute("width", "100%");

        return layout;
    }
 
Example 14
Source File: SimpleForm.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private Widget build() {

        deck = new DeckPanel();
        deck.setStyleName("fill-layout-width");

        // ----------------------
        // view panel

        VerticalPanel viewPanel = new VerticalPanel();
        viewPanel.setStyleName("fill-layout-width");
        viewPanel.addStyleName("form-view-panel");
        deck.add(viewPanel.asWidget());

        // ----------------------
        // edit panel

        VerticalPanel editPanel = new VerticalPanel();
        editPanel.setStyleName("fill-layout-width");
        editPanel.addStyleName("form-edit-panel");

        RenderMetaData metaData = new RenderMetaData();
        metaData.setNumColumns(numColumns);

        GroupRenderer groupRenderer = new DefaultGroupRenderer();;


        Map<String, FormItem> groupItems = new LinkedHashMap<String, FormItem>();
        for(FormItem item : items)
        {
            groupItems.put(item.getName(), item);
        }

        // edit view
        Widget widget = groupRenderer.render(metaData, "default", groupItems);
        editPanel.add(widget);

        // plain view
        PlainFormView plainView = new PlainFormView(items);
        plainView.setNumColumns(numColumns);
        plainViews.add(plainView);
        viewPanel.add(groupRenderer.renderPlain(metaData, "default", plainView));

        deck.add(editPanel);

        // toggle default view
        toggleViews();
        refreshPlainView(); // make sureit's build, even empty...

        return deck;
    }
 
Example 15
Source File: HistoryPopupPanel.java    From EasyML with Apache License 2.0 4 votes vote down vote up
/**
 * UI Initialization
 */
protected void init() {
	this.setSize("850px", "400px");
	this.setGlassEnabled(true);
	this.setModal(true);

	desc.setText(desc.getText()+"  Job Id - "+bdaJobId);
	closeButton.setSize("10px", "10px");
	closeButton.setStyleName("closebtn");

	VerticalPanel topPanel = new VerticalPanel(); //Outermost vertical panel
	topPanel.add(closeButton);
	topPanel.setCellHeight(closeButton, "13px");
	topPanel.setStyleName("vpanel");
	desc.setStyleName("popupTitle");
	topPanel.add(desc);
	topPanel.setCellHeight(desc, "30px");

	HorizontalPanel optPanel = new HorizontalPanel(); //Operation panel(include search, batch delete.etc)
	optPanel.addStyleName("run-history-optPanel");
	DateTimeFormat pickerFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
	startTimeBox.setFormat(new DateBox.DefaultFormat(pickerFormat));
	startTimeBox.getDatePicker().addStyleName("run-history-datepicker-popup");
	endTimeBox.setFormat(new DateBox.DefaultFormat(pickerFormat));
	endTimeBox.getDatePicker().addStyleName("run-history-datepicker-popup");
	searchBtn.removeStyleName("gwt-Button");
	searchBtn.addStyleName("run-history-search-button");
	//The initial time is set to 2016-1-1
	endTime = new Date();
	DateTimeFormat tmpFormatter = DateTimeFormat.getFormat("yyyy-MM-dd");
	startTime = tmpFormatter.parse("2016-01-01");
	selectAllChkBox.setVisible(false);
	batchDelBtn.removeStyleName("gwt-Button");
	batchDelBtn.addStyleName("run-history-batch-del-button");

	optPanel.add(startTimeLabel); 
	optPanel.add(startTimeBox);
	optPanel.add(endTimeLabel);
	optPanel.add(endTimeBox);
	optPanel.add(searchBtn);
	if(isExample && !AppController.power.equals("111"))  //Example job only can be deleted by administrator privileges
	{}
	else
		optPanel.add(batchDelBtn);
	optPanel.add(selectAllChkBox);

	runHistoryGrid.addStyleName("run-history-table"); //Data view
	runHistoryGrid.addStyleName("table-striped");
	runHistoryGrid.addStyleName("table-hover");
	runHistoryGrid.resize(rowNum, colNum);
	for(int i=0;i<colNum;i++)
	{
		runHistoryGrid.setText(0, i, columns[i]);
	}
	initGridData();

	topPanel.add(optPanel);
	topPanel.add(runHistoryGrid);

	VerticalPanel bottomPanel = new VerticalPanel(); //Paging control
	bottomPanel.add(pageGrid);
	bottomPanel.addStyleName("run-history-bottomPanel");

	VerticalPanel panel = new VerticalPanel();
	panel.add(topPanel);
	panel.add(bottomPanel);

	this.add(panel);
	this.setStyleName("loading_container");
}
 
Example 16
Source File: AddressingDetails.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
Widget asWidget() {
    addrTable = new DefaultCellTable<>(8, ActivemqAddressingPattern::getPattern);
    addrProvider = new ListDataProvider<>();
    addrProvider.addDataDisplay(addrTable);

    Column<ActivemqAddressingPattern, String> patternColumn = new Column<ActivemqAddressingPattern, String>(new TextCell()) {
        @Override
        public String getValue(ActivemqAddressingPattern object) {
            return object.getPattern();
        }
    };

    addrTable.addColumn(patternColumn, "Pattern");

    form = new Form<>(ActivemqAddressingPattern.class,
            "{selected.profile}/subsystem=messaging-activemq/server=*/address-setting=*");
    form.setNumColumns(2);
    form.bind(addrTable);

    TextBoxItem dlQ = new TextBoxItem("deadLetterQueue", "Dead Letter Address");
    TextBoxItem expQ = new TextBoxItem("expiryQueue", "Expiry Address");
    NumberBoxItem redelivery = new NumberBoxItem("redeliveryDelay", "Redelivery Delay");
    NumberBoxItem maxDelivery = new NumberBoxItem("maxDelivery", "Max Delivery Attempts", -1, Integer.MAX_VALUE);

    form.setFields(dlQ, expQ, redelivery, maxDelivery);

    FormHelpPanel helpPanel = new FormHelpPanel(() -> {
        ModelNode address = Baseadress.get();
        address.add("subsystem", "messaging-activemq");
        address.add("server", presenter.getCurrentServer());
        address.add("address-setting", "*");
        return address;
    }, form);

    FormToolStrip<ActivemqAddressingPattern> formTools = new FormToolStrip<>(
            form,
            new FormToolStrip.FormCallback<ActivemqAddressingPattern>() {
                @Override
                public void onSave(Map<String, Object> changeset) {
                    presenter.onSaveAddressDetails(form.getEditedEntity(), changeset);
                }

                @Override
                public void onDelete(ActivemqAddressingPattern entity) {}
            }
    );
    ToolStrip tableTools = new ToolStrip();
    ToolButton addBtn = new ToolButton(Console.CONSTANTS.common_label_add(),
            event -> presenter.launchNewAddrDialogue());
    addBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_addressingDetails());
    tableTools.addToolButtonRight(addBtn);

    ToolButton removeBtn = new ToolButton(Console.CONSTANTS.common_label_delete(), event -> Feedback.confirm(
            Console.MESSAGES.deleteTitle("Addressing Config"),
            Console.MESSAGES.deleteConfirm("Addressing Config"),
            isConfirmed -> {
                if (isConfirmed) { presenter.onDeleteAddressDetails(form.getEditedEntity()); }
            }));

    tableTools.addToolButtonRight(removeBtn);

    VerticalPanel formPanel = new VerticalPanel();
    formPanel.addStyleName("fill-layout-width");

    formPanel.add(helpPanel.asWidget());
    formPanel.add(formTools.asWidget());
    formPanel.add(form.asWidget());

    serverName = new ContentHeaderLabel();

    MultipleToOneLayout layout = new MultipleToOneLayout()
            .setPlain(true)
            .setHeadlineWidget(serverName)
            .setDescription(
                    Console.CONSTANTS.addressingDescription())
            .setMaster(Console.MESSAGES.available("Address Settings"), addrTable)
            .setMasterTools(tableTools.asWidget())
            .setDetail(Console.CONSTANTS.common_label_details(), formPanel);

    return layout.build();

}
 
Example 17
Source File: BulletGraphView.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Widget asWidget() {

    VerticalPanel desc = new VerticalPanel();
    desc.addStyleName("metric-container");
    if(embeddedUse)
        desc.add(new HTML("<h3 class='metric-label-embedded'>" + title + "</h3>"));
    else
        desc.add(new HTML("<h3 class='metric-label'>" + title + "</h3>"));

    container = new HorizontalPanel();
    container.setStyleName("fill-layout-width");
    container.addStyleName("metric-panel");


    grid = new Grid(columns.length, 2);
    grid.addStyleName("metric-grid");

    // format
    for (int row = 0; row < columns.length; ++row) {
        grid.getCellFormatter().addStyleName(row, 0,  "nominal");
        grid.getCellFormatter().addStyleName(row, 1, "numerical");
    }

    int baselineIndex = getBaseLineIndex();
    if(baselineIndex>=0)
        grid.getRowFormatter().addStyleName(baselineIndex, "baseline");

    // init
    for(int i=0; i<columns.length;i++)
    {
        grid.setText(i, 0, columns[i].label);
        grid.setText(i, 1, "0");
    }


    container.add(grid);

    ProtovisWidget graphWidget = new ProtovisWidget();
    graphWidget.initPVPanel();
    vis = createVisualization(graphWidget);

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            renderDefault();    // the 'empty' display
        }
    });

    if (address != null) {
        MetricHelpPanel helpPanel = new MetricHelpPanel(address, this.columns);
        desc.add(helpPanel.asWidget());
    }

    container.add(graphWidget);
    graphWidget.getElement().getParentElement().setAttribute("align", "center");
    graphWidget.getElement().getParentElement().setAttribute("width", "80%");

    desc.add(container);

    return desc;
}
 
Example 18
Source File: ProfileSelector.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Widget asWidget() {


        VerticalPanel layout = new VerticalPanel();
        layout.getElement().setId("profile_selection");
        layout.getElement().setAttribute("title", "Please chose a configuration profile");
        layout.setStyleName("fill-layout-width");
        layout.addStyleName("lhs-selector");
        layout.getElement().setAttribute("style","padding:4px;");

        profiles = new ComboPicker();
        profiles.addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(final ValueChangeEvent<String> event) {

                if(event.getValue()!=null && !event.getValue().equals(""))
                {
                    Scheduler.get().scheduleDeferred(
                            new Scheduler.ScheduledCommand() {
                                @Override
                                public void execute() {
                                    Console.getEventBus().fireEvent(
                                            new ProfileSelectionEvent(event.getValue())
                                    );
                                }
                            });
                }
            }
        });

        Label profileLabel = new Label(Console.CONSTANTS.common_label_profile()+":");
        profileLabel.setStyleName("header-label");
        layout.add(profileLabel);
        Widget hWidget = profiles.asWidget();
        hWidget.getElement().addClassName("table-picker");
        layout.add(hWidget);

        // the combox box use all available space
        hWidget.getElement().getParentElement().setAttribute("width", "100%");


        return layout;
    }
 
Example 19
Source File: PropertyEditor.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    // table
    table = new DefaultCellTable<>(numRows, keyProvider);
    dataProvider = new ListDataProvider<>(keyProvider);
    dataProvider.addDataDisplay(table);
    final SingleSelectionModel<Property> selectionModel = new SingleSelectionModel<>(keyProvider);
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(event -> {
        Property selection = selectionModel.getSelectedObject();
        if (selection == null) {
            propertyManager.onDeselect();
        } else {
            propertyManager.onSelect(selection);
        }
    });

    // columns
    Column<Property, String> keyColumn = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            return property.getName();
        }
    };
    keyColumn.setSortable(true);
    Column<Property, String> valueColumn;
    if (inlineEditing) {
        valueColumn = new Column<Property, String>(new DefaultEditTextCell()) { {
                setFieldUpdater((index, property, value) -> getPropertyValue(property).set(value));
            }

            @Override
            public String getValue(Property property) {
                return property.getValue().get(VALUE).asString();
            }
        };
    } else {
        valueColumn = new TextColumn<Property>() {
            @Override
            public String getValue(Property property) {
                return getPropertyValue(property).asString();
            }
        };
    }
    ColumnSortEvent.ListHandler<Property> sortHandler = new ColumnSortEvent.ListHandler<>(dataProvider.getList());
    sortHandler.setComparator(keyColumn, new Comparator<Property>() {
        @Override
        public int compare(Property o1, Property o2) {
            return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
        }
    });
    table.addColumn(keyColumn, Console.CONSTANTS.common_label_key());
    table.addColumn(valueColumn, Console.CONSTANTS.common_label_value());
    table.setColumnWidth(keyColumn, 40, Style.Unit.PCT);
    table.setColumnWidth(valueColumn, 60, Style.Unit.PCT);
    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(keyColumn);

    // tools
    if (!hideTools) {
        ToolStrip tools = new ToolStrip();
        addButton = new ToolButton(addLabel, event -> {
            addDialog.clearValues();
            propertyManager.openAddDialog(addDialog);
        });
        removeButton = new ToolButton(removeLabel, event -> {
            final Property selection = selectionModel.getSelectedObject();
            if (selection != null) {
                Feedback.confirm(Console.MESSAGES.removeProperty(),
                        Console.MESSAGES.removePropertyConfirm(selection.getName()),
                        new Feedback.ConfirmationHandler() {
                            @Override
                            public void onConfirmation(boolean isConfirmed) {
                                if (isConfirmed) {
                                    propertyManager.onRemove(selection);
                                }
                            }
                        });
            }
        });
        AddressTemplate effectiveAddress = operationAddress != null ? operationAddress : propertyManager
                .getAddress();
        if (effectiveAddress != null) {
            addButton.setOperationAddress(effectiveAddress.getTemplate(), propertyManager.getAddOperationName());
            removeButton
                    .setOperationAddress(effectiveAddress.getTemplate(), propertyManager.getRemoveOperationName());
        }
        tools.addToolButtonRight(addButton);
        tools.addToolButtonRight(removeButton);
        panel.add(tools);
    }

    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example 20
Source File: ListEditor.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Widget asWidget() {
        VerticalPanel panel = new VerticalPanel();
        panel.addStyleName("fill-layout-width");

        listTable = new DefaultCellTable<T>(numRows);
        listTable.getElement().setAttribute("style", "margin-top:5px;");
        listProvider = new ListDataProvider<T>();
        listProvider.addDataDisplay(listTable);

        ToolStrip itemTools = new ToolStrip();

        addItem = new ToolButton(Console.CONSTANTS.common_label_add());

        addItem.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if(ListEditor.this.enabled)
                    listManager.launchNewItemDialoge();
            }
        });
        addItem.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_listEditor());
        itemTools.addToolButtonRight(addItem);

        panel.add(itemTools);

        //       ColumnSortEvent.ListHandler<T> sortHandler =
        //               new ColumnSortEvent.ListHandler<T>(listProvider.getList());

        // Create columns
        Column<T, String> valueColumn = new Column<T, String>(new TextCell()) {

            @Override
            public String getValue(T object) {
                return object.toString();
            }

        };
        //      valueColumn.setSortable(true);

        Column<T, T> removeCol = new Column<T, T>(
                new TextLinkCell<T>(I18n.CONSTANTS.common_label_delete(), new ActionCell.Delegate<T>() {
                    @Override
                    public void execute(final T o) {
                        Feedback.confirm(
                                Console.MESSAGES.deleteTitle(Console.CONSTANTS.common_label_item()),
                                Console.MESSAGES.deleteConfirm(Console.CONSTANTS.common_label_item())
                                , new Feedback.ConfirmationHandler() {
                            @Override
                            public void onConfirmation(boolean isConfirmed) {
                                if (isConfirmed)
                                     listManager.onDeleteItem(o);
                            }
                        });


                    }
                })
        ) {
            @Override
            public T getValue(T item) {
                return item;
            }
        };

        // Add the columns.
        listTable.addColumn(valueColumn, this.headerLabel);

        listTable.addColumn(removeCol, Console.CONSTANTS.common_label_option());


        listTable.setColumnWidth(valueColumn, 30, Style.Unit.PCT);

        listTable.setColumnWidth(removeCol, 20, Style.Unit.PCT);

//        listTable.addColumnSortHandler(sortHandler);
        listTable.getColumnSortList().push(valueColumn);

        if(helpText!=null)
        {
            StaticHelpPanel helpPanel = new StaticHelpPanel(helpText);
            panel.add(helpPanel.asWidget());
        }

        panel.add(listTable);

        DefaultPager pager = new DefaultPager();
        pager.setDisplay(listTable);

        panel.add(pager);

        return panel;
    }