Java Code Examples for com.google.gwt.user.client.ui.Widget

The following examples show how to use com.google.gwt.user.client.ui.Widget. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: core   Source File: RemoteSocketForm.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public Widget asWidget() {

        buildForm();
        form.setEnabled(false);

        FormHelpPanel helpPanel = new FormHelpPanel(
                new FormHelpPanel.AddressCallback() {
                    @Override
                    public ModelNode getAddress() {
                        ModelNode address = new ModelNode();
                        address.add("socket-binding-group", "*");
                        address.add("remote-destination-outbound-socket-binding", "*");
                        return address;
                    }
                }, form);

        FormToolStrip<RemoteSocketBinding> formTools = new FormToolStrip<>(form, callback);
        FormLayout formLayout = new FormLayout().setForm(form).setHelp(helpPanel);
        formLayout.setTools(formTools);
        return formLayout.build();
    }
 
Example 2
Source Project: unitime   Source File: TaskExecutionsTable.java    License: Apache License 2.0 6 votes vote down vote up
protected Widget getCell(final TaskExecutionInterface e, final TaskExecutionsTableColumn column, final int idx) {
	switch (column) {
	case DATE: return new Label(sDateFormatMeeting.format(e.getExecutionDate()));
	case TIME: return new Label(e.getExecutionTime(CONSTANTS));
	case QUEUED: return new Label(e.getQueued() == null ? "" : sDateFormatTS.format(e.getQueued()));
	case STARTED: return new Label(e.getStarted() == null ? "" : sDateFormatTS.format(e.getStarted()));
	case FINISHED: return new Label(e.getFinished() == null ? "" : sDateFormatTS.format(e.getFinished()));
	case STATUS: return new Label(CONSTANTS.taskStatus()[e.getStatus().ordinal()]);
	case MESSAGE:
		Label message = new Label(e.getStatusMessage() == null ? "" : e.getStatusMessage()); message.addStyleName("status-message");
		if (e.getStatusMessage() != null)
			message.setTitle(e.getStatusMessage());
		return message;
	case OUTPUT:
		if (e.getOutput() != null) return new Anchor(e.getOutput(), GWT.getHostPageBaseURL() + "taskfile?e=" + e.getId());
		return new Label("");
	default:
		return null;
	}
}
 
Example 3
Source Project: cuba   Source File: CubaGroupTableWidget.java    License: Apache License 2.0 6 votes vote down vote up
public CubaGroupTableBody.CubaGroupTableGroupRow getRenderedGroupRowByKey(String key) {
    if (scrollBody != null) {
        Iterator<Widget> it = scrollBody.iterator();
        CubaGroupTableBody.CubaGroupTableGroupRow row;
        while (it.hasNext()) {
            Widget widget = it.next();
            if (widget instanceof CubaGroupTableBody.CubaGroupTableGroupRow) {
                row = (CubaGroupTableBody.CubaGroupTableGroupRow) widget;
                if (row.getGroupKey().equals(key)) {
                    return row;
                }
            }
        }
    }
    return null;
}
 
Example 4
Source Project: core   Source File: VerifyUploadStep.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected Widget asWidget(final Context context) {
    FlowPanel panel = new FlowPanel();
    panel.add(new StaticHelpPanel(StaticHelp.replace()).asWidget());

    form = new Form<>(UploadBean.class);
    TextBoxItem nameField = new TextBoxItem("name", Console.CONSTANTS.common_label_name());
    TextBoxItem runtimeNameField = new TextBoxItem("runtimeName", Console.CONSTANTS.common_label_runtimeName());
    enable = new CheckBoxItem("enableAfterDeployment", Console.CONSTANTS.common_label_enable());
    if (wizard instanceof CanEnableDeployment) {
        form.setFields(nameField, runtimeNameField, enable);
    } else {
        form.setFields(nameField, runtimeNameField);
    }
    panel.add(form.asWidget());

    return panel;
}
 
Example 5
public void launchNewConfigDialoge() {

        // TODO: server group store (circuit)
        serverGroupDAO.loadServerGroups(new SimpleCallback<List<ServerGroupRecord>>() {
            @Override
            public void onSuccess(List<ServerGroupRecord> serverGroups) {
                window = new DefaultWindow(Console.MESSAGES.createTitle("New Server Configuration"));
                window.setWidth(640);
                window.setHeight(480);

                NewServerConfigWizard wizard = new NewServerConfigWizard(DomainRuntimePresenter.this);
                Widget w = wizard.asWidget();


                wizard.updateGroups(serverGroups);
                wizard.updateHosts(hostStore.getHostNames());
                window.trapWidget(w);

                window.setGlassEnabled(true);
                window.center();
            }
        });

    }
 
Example 6
private SelectionHandler<Widget> getTabPanelSelectionHandler() {
	return new SelectionHandler<Widget>() {

		@Override
		public void onSelection(SelectionEvent<Widget> event) {
			if (UIMessages.INSTANCE.empty().equals(getActiveTab())) {
				dataFormatField.setVisible(false);
			} else {
				dataFormatField.setVisible(true);
			}
			if (UIMessages.INSTANCE.wfs().equals(getActiveTab())) {
				vectorFormatCombo.setValue(VectorFormat.GML_FORMAT);
			} else {
				vectorFormatCombo.setValue(null);
			}
			
			if (UIMessages.INSTANCE.gitHubResponseTitle().equals(getActiveTab())) {					
				layerName.setEnabled(false);
			} else {
				layerName.setEnabled(true);
			}
		}
	};
}
 
Example 7
private Widget createCommitPanel() {
	final VerticalPanel panel = new VerticalPanel();
	panel.setWidth("350px");		
	panel.setSpacing(10);				
	
	fileNameField = new TextField();
	fileNameField.setTitle(UIMessages.INSTANCE.gitHubFileNameField());
	fileNameField.setEmptyText(UIMessages.INSTANCE.gitHubFileNameField());
	fileNameField.setWidth(FIELD_WIDTH);
	panel.add(fileNameField);
			
	messageField = new TextField();
	messageField.setTitle(UIMessages.INSTANCE.gitHubMessageCommitField());
	messageField.setEmptyText(UIMessages.INSTANCE.gitHubMessageCommitField());
	messageField.setWidth(FIELD_WIDTH);
	panel.add(messageField);

	return panel;
}
 
Example 8
private Widget createPanel() {
	
	VerticalLayoutContainer container = new VerticalLayoutContainer();
	container.setScrollMode(ScrollMode.AUTO);
	container.setSize("450px", "160px");
			
	Label bboxLabel = new Label("Bbox (" + UIMessages.INSTANCE.lowerLeftXField() + ", " + UIMessages.INSTANCE.lowerLeftYField() + 
			", " + UIMessages.INSTANCE.upperRightXField() + ", " + UIMessages.INSTANCE.upperRightYField() + ")");
	bboxLabel.getElement().getStyle().setFontWeight(FontWeight.BOLD);		
	container.add(bboxLabel);
	bboxField = new TextField();
	bboxField.setEmptyText(UIMessages.INSTANCE.bboxFieldCustomExtent());		
	bboxField.setWidth("450px");
	container.add(bboxField);	
	return container;
}
 
Example 9
Source Project: appinventor-extensions   Source File: DragSourceSupport.java    License: Apache License 2.0 6 votes vote down vote up
private void onDragStart(Widget sender, int x, int y) {
  // Notify drag source of the drag starting
  dragSource.onDragStart();

  // Cache the set of permissible drop targets
  dropTargets = dragSource.getDropTargets();

  // Show drag proxy widget
  dragWidgetPopup = new DragWidgetPopup(dragSource.createDragWidget(startX, startY));
  dragWidgetPopup.setPopupPosition(
      /*absX*/ x + sender.getAbsoluteLeft(),
      /*absY*/ y + sender.getAbsoluteTop());
  dragWidgetPopup.show();

  // Initialize hover state
  hoverDropTarget = null;
}
 
Example 10
Source Project: consulo   Source File: GwtUIUtil.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@SuppressWarnings("unchecked")
public static <T extends Widget> T getParentOf(Widget widget, Class<T> type) {
  Widget target = widget;

  do {
    if (target.getClass() == type) {
      return (T)target;
    }

    target = target.getParent();
  }
  while (target != null);

  return null;
}
 
Example 11
Source Project: core   Source File: UploadStep.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected Widget asWidget(final Context context) {
    final FlowPanel panel = new FlowPanel();

    HTML description = new HTML(Console.CONSTANTS.common_label_chooseFile());
    description.getElement().setAttribute("style", "padding-bottom:15px;");
    panel.add(description);

    form = new FormPanel();

    // create a panel to hold all of the form widgets.
    VerticalPanel formPanel = new VerticalPanel();
    form.setWidget(formPanel);

    // create a FileUpload widgets.
    fileUpload = new FileUpload();
    fileUpload.setName("uploadFormElement");
    IdHelper.setId(fileUpload, id(), "file");
    formPanel.add(fileUpload);

    panel.add(form);
    return panel;
}
 
Example 12
@SuppressWarnings("static")
private void deferredHandler(final Flow flow) {
  handler = new GwtRenderingMutationHandler(flow) {
    @Override
    protected Widget createGwtWidget(Renderable element) {
      return null;
    }
  };

  initDoc();
}
 
Example 13
Source Project: gwt-material   Source File: ActiveMixin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setActive(boolean active) {
    this.active = active;
    if (target != null) {
        applyActiveStyle(target, active);
    } else {
        applyActiveStyle((Widget) uiObject, active);
    }
}
 
Example 14
Source Project: core   Source File: TopologyView.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Widget createWidget() {
    lifecycleLinkListener = new LifecycleLinkListener();

    ToolStrip topLevelTools = new ToolStrip();
    topLevelTools.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_refresh(),
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    presenter.loadTopology();
                }
            }));

    SimpleLayout layout = new SimpleLayout()
            .setTopLevelTools(topLevelTools)
            .setTitle("Topology")
            .setPlain(true)
            .setHeadline("Hosts, groups and server instances")
            .setDescription(Console.MESSAGES.topology_description());

    container = new FlowPanel();
    display = new HostsDisplay();
    pager = new HostsPager();
    pager.setDisplay(display);
    pager.setPageSize(TopologyPresenter.VISIBLE_HOSTS_COLUMNS);

    layout.addContent("topology", container);

    DefaultTabLayoutPanel tabLayoutpanel = new DefaultTabLayoutPanel(40, Style.Unit.PX);
    tabLayoutpanel.addStyleName("default-tabpanel");
    tabLayoutpanel.add(layout.build(), "Topology", true);
    tabLayoutpanel.add(extensions.asWidget(), "Extensions", true);
    tabLayoutpanel.selectTab(0);

    return tabLayoutpanel;
}
 
Example 15
Source Project: gwt-material   Source File: DOMHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static Widget getChildWidgetById(HasWidgets parent, String id) {
    if (parent != null) {
        for (Widget child : parent) {
            if (child.getElement().getId().equals(id)) {
                return child;
            }
        }
    }
    return null;
}
 
Example 16
@SuppressWarnings("static")
private void deferredHandler(final Flow flow) {
  handler = new GwtRenderingMutationHandler(flow) {
    @Override
    protected Widget createGwtWidget(Renderable element) {
      return null;
    }
  };

  initDoc();
}
 
Example 17
Source Project: cuba   Source File: VDDVerticalLayout.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Updates the drop details while dragging. This is needed to ensure client
 * side criterias can validate the drop location.
 * 
 * @param widget
 *            The container which we are hovering over
 * @param event
 *            The drag event
 */
protected void updateDragDetails(Widget widget, VDragEvent event) {
    if (widget == null) {
        return;
    }

    /*
     * The horizontal position within the cell{
     */
    event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION,
            getVerticalDropLocation(widget, event));

    /*
     * The index over which the drag is. Can be used by a client side
     * criteria to verify that a drag is over a certain index.
     */
    int index = -1;
    if (widget instanceof Slot) {
        WidgetCollection captionsAndSlots = getChildren();
        index = VDragDropUtil.findSlotIndex(captionsAndSlots,
                (Slot) widget);
    }

    event.getDropDetails().put(Constants.DROP_DETAIL_TO, index);

    // Add mouse event details
    MouseEventDetails details = MouseEventDetailsBuilder
            .buildMouseEventDetails(event.getCurrentGwtEvent(),
                    getElement());
    event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT,
            details.serialize());
}
 
Example 18
Source Project: core   Source File: AssignmentColumn.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Widget asWidget() {
    if (widget == null) {
        widget = super.asWidget();
    }
    return widget;
}
 
Example 19
@Override
public HandlerRegistration addSwipeRightHandler(final SwipeRightEvent.SwipeRightHandler<Widget> handler) {
    return addHandler(new SwipeRightEvent.SwipeRightHandler<Widget>() {
        @Override
        public void onSwipeRight(SwipeRightEvent<Widget> event) {
            if (isEnabled()) {
                handler.onSwipeRight(event);
            }
        }
    }, SwipeRightEvent.getType());
}
 
Example 20
Source Project: cuba   Source File: Tools.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean isSuitableWidget(Widget slotWidget) {
    if (slotWidget instanceof VButton) {
        VButton button = (VButton) slotWidget;

        if (button.isEnabled()) {
            return true;
        }
    } else if (slotWidget instanceof CubaFileUploadWidget) {
        return true;
    } else if (slotWidget instanceof VUpload) {
        return true;
    }

    return false;
}
 
Example 21
@Override
@SuppressWarnings("unchecked")
public Widget createWidget() {
    DefaultTabLayoutPanel tabs = new DefaultTabLayoutPanel(40, Style.Unit.PX);
    tabs.addStyleName("default-tabpanel");
    tabs.add(threadPoolPanel.asWidget(), "Batch");
    tabs.add(jobsPanel.asWidget(), "Jobs");
    tabs.selectTab(0);

    return tabs;
}
 
Example 22
Source Project: gwt-material-demo   Source File: MenuBarView.java    License: Apache License 2.0 5 votes vote down vote up
@UiHandler("dpMode")
void onSelectionMode(SelectionEvent<Widget> selection) {
    for(Widget w : dpMode.getItems()){
        if(w instanceof MaterialCheckBox){
            ((MaterialCheckBox) w).setValue(false);
        }
    }
    if(selection.getSelectedItem() instanceof MaterialCheckBox){
        ((MaterialCheckBox) selection.getSelectedItem()).setValue(true);
        MaterialToast.fireToast("Checked : " + ((MaterialCheckBox) selection.getSelectedItem()).getText());
    }
}
 
Example 23
Source Project: core   Source File: MultiViewImpl.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Widget asWidget() {

    if(null==deck) {
        this.deck = new DeckLayoutPanel();
        createWidget();
    }

    return deck;
}
 
Example 24
@Override
public Widget createWidget() {

    LayoutPanel layout = new LayoutPanel();

    FakeTabPanel titleBar = new FakeTabPanel("Messaging Connections");
    layout.add(titleBar);

    PagedView panel = new PagedView(true);

    acceptorOverview = new AcceptorOverview(presenter);
    connectorOverview = new ConnectorOverview(presenter);
    connectionFactories = new ConnectionFactoryList(presenter);
    connectorServiceList = new ConnectorServiceList(presenter);
    bridgesList = new BridgesList(presenter);
    pooledConnectionFactoryView = new PooledConnectionFactoryView(presenter);

    panel.addPage("Acceptor", acceptorOverview.asWidget());
    panel.addPage("Connector", connectorOverview.asWidget());
    panel.addPage("Connector Services", connectorServiceList.asWidget());
    panel.addPage("Connection Factories", connectionFactories.asWidget());
    panel.addPage("Pooled Connection Factory", pooledConnectionFactoryView.asWidget());
    panel.addPage("Bridges", bridgesList.asWidget());

    // default page
    panel.showPage(0);

    Widget panelWidget = panel.asWidget();
    layout.add(panelWidget);

    layout.setWidgetTopHeight(titleBar, 0, Style.Unit.PX, 40, Style.Unit.PX);
    layout.setWidgetTopHeight(panelWidget, 40, Style.Unit.PX, 100, Style.Unit.PCT);

    return layout;
}
 
Example 25
Source Project: unitime   Source File: TimeGrid.java    License: Apache License 2.0 5 votes vote down vote up
public Widget getPrintWidget(int width) {
	int firstHour = firstSlot() / 12;
	int lastHour = 1 + lastSlot() / 12;
	TimeGrid tg = new TimeGrid(iColor, iNrDays, width, true, (firstHour < 7 ? firstHour : 7), (lastHour > 18 ? lastHour : 18));
	int i = 0;
	for (ClassAssignmentInterface.ClassAssignment c: iClasses)
		for (Meeting m : tg.addClass(c, i++)) {
			m.hidePin();
			m.setDummy();
			m.addStyleName("meeting-selected-noshadow");
		}
	for (BusyPanel busy: iBusy)
		tg.addBusy(busy.getTitle(), busy.getDay(), busy.getStart(), busy.getLength());
	return tg;
}
 
Example 26
Source Project: core   Source File: ChooseStep.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected Widget asWidget(final Context context) {
    FlowPanel body = new FlowPanel();

    deployNew = new RadioButton("deployment_kind", Console.CONSTANTS.uploadNewDeployment());
    deployNew.addStyleName("radio-block");
    IdHelper.setId(deployNew, id(), "deployNew");
    addDescription(deployNew, Console.CONSTANTS.uploadNewDeploymentDescription());

    deployExisting = new RadioButton("deployment_kind", Console.CONSTANTS.chooseFromContentRepository());
    deployExisting.addStyleName("radio-block");
    IdHelper.setId(deployExisting, id(), "deployExisting");
    addDescription(deployExisting,Console.CONSTANTS.chooseFromContentRepositoryDescription());

    deployUnmanaged = new RadioButton("deployment_kind", Console.CONSTANTS.createUnmanaged());
    deployUnmanaged.addStyleName("radio-block");
    IdHelper.setId(deployUnmanaged, id(), "deployUnmanaged");
    addDescription(deployUnmanaged, Console.CONSTANTS.createUnmanagedDescription());

    if (showDeployNew) {
        body.add(deployNew);
    }
    if (showDeployExisting) {
        body.add(deployExisting);
    }
    if (showDeployUnmanaged) {
        body.add(deployUnmanaged);
    }
    return body;
}
 
Example 27
private Widget createPanel() {
	final VerticalLayoutContainer panel = new VerticalLayoutContainer();
	
	longitudTextField = new TextField();
	longitudTextField.setTitle(UIMessages.INSTANCE.longitude());
	longitudTextField.setAllowBlank(false);

	longitudTextField.setWidth(FIELD_WIDTH);

	final FieldLabel longitudLabel = new FieldLabel(longitudTextField,
			UIMessages.INSTANCE.longitude());
	panel.add(longitudLabel, new VerticalLayoutData(1, -1));
	
	latitudTextField = new TextField();
	latitudTextField.setTitle(UIMessages.INSTANCE.latitude());
	latitudTextField.setWidth(FIELD_WIDTH);
	latitudTextField.setAllowBlank(false);

	final FieldLabel latitudLabel = new FieldLabel(latitudTextField,
			UIMessages.INSTANCE.latitude());
	panel.add(latitudLabel, new VerticalLayoutData(1, -1));

	initializeFields();

	epsgCombo = new ProjectionComboBox(FIELD_WIDTH);
	epsgCombo.setValue("WGS84");
	final FieldLabel epsgLabel = new FieldLabel(epsgCombo,
			UIMessages.INSTANCE.lidProjectionLabel());
	panel.add(epsgLabel, new VerticalLayoutData(1, -1));
	return panel;
}
 
Example 28
Source Project: core   Source File: Wizard.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Widget asWidget() {
    assertSteps();
    state = initialState();

    VerticalPanel root = new VerticalPanel();
    root.setStyleName("window-content");

    header = new HTML();
    errorMessages = new HTML();
    errorMessages.setVisible(false);
    errorMessages.setStyleName("error-panel");
    body = new StateDeckPanel();
    footer = new Footer();

    int index = 0;
    for (Map.Entry<S, WizardStep<C, S>> entry : steps.entrySet()) {
        stateIndex.put(entry.getKey(), index);
        body.add(entry.getValue().asWidget(context));
        index++;
    }

    root.add(header);
    root.add(errorMessages);
    root.add(body);
    pushState(state);

    return new TrappedFocusPanel(new WindowContentBuilder(root, footer.asWidget()).build());
}
 
Example 29
Source Project: incubator-retired-wave   Source File: EditorHarness.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean onKeySignal(final Widget sender, SignalEvent event) {
  // Deferred command so we have a look at the content after it's updated
  ScheduleCommand.addCommand(new Task() {
    public void execute() {
       if (sender == editor1) {
         outputEditorState(editor1, prettyContent1, prettyHtml1);
       } else {
         outputEditorState(editor2, prettyContent2, prettyHtml2);
       }
    }
  });
  return false;
}
 
Example 30
private Widget createNowLink(final TextBox textbox) {
  return new CommandLink("Now", new Command() {
    //@Override
    public void execute() {
      textbox.setText(FORMAT.format(new Date()));
    }
  });
}