com.google.gwt.core.client.GWT Java Examples

The following examples show how to use com.google.gwt.core.client.GWT. 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: Client.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void initPageAsync(final String page) {
	GWT.runAsync(new RunAsyncCallback() {
		public void onSuccess() {
			init(page);
			LoadingWidget.getInstance().hide();
		}
		public void onFailure(Throwable reason) {
			Label error = new Label(MESSAGES.failedToLoadPage(reason.getMessage()));
			error.setStyleName("unitime-ErrorMessage");
			RootPanel loading = RootPanel.get("UniTimeGWT:Loading");
			if (loading != null) loading.setVisible(false);
			RootPanel.get("UniTimeGWT:Body").add(error);
			LoadingWidget.getInstance().hide();
			UniTimeNotifications.error(MESSAGES.failedToLoadPage(reason.getMessage()), reason);
		}
	});
}
 
Example #2
Source File: VertexStyleComboBox.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
public VertexStyleComboBox(String width) {
	super(new ListStore<VertexStyleDef>(
			((VertexStyleDefProperties)GWT.create(VertexStyleDefProperties.class)).key()),
			((VertexStyleDefProperties)GWT.create(VertexStyleDefProperties.class)).name(),
			new AbstractSafeHtmlRenderer<VertexStyleDef>() {
				final VertexStyleComboTemplates comboBoxTemplates = GWT
						.create(VertexStyleComboTemplates.class);

				public SafeHtml render(VertexStyleDef item) {
					return comboBoxTemplates.vertexStyle(item.getImage()
							.getSafeUri(), item.getName());
				}
			});
	
	setWidth(width);
	setTypeAhead(true);
	setEmptyText(UIMessages.INSTANCE.sbLayerComboEmptyText());
	setTriggerAction(TriggerAction.ALL);
	setForceSelection(true);
	setEditable(false);
	enableEvents();
	
	getStore().addAll(VertexStyles.getAll());
}
 
Example #3
Source File: Util.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static String webstartURL(String appName, Map<String, String> params) {
	StringBuffer url = new StringBuffer(GWT.getHostPageBaseURL());
	url.append("webstart/");
	url.append(appName);
	url.append(".jsp?random=");
	url.append(new Date().getTime());
	url.append("&language=");
	url.append(I18N.getLocale());
	url.append("&docLanguage=");
	url.append(I18N.getDefaultLocaleForDoc());
	url.append("&sid=");
	url.append(Session.get().getSid());
	if (params != null)
		for (String p : params.keySet()) {
			url.append("&");
			url.append(p);
			url.append("=");
			url.append(URL.encode(params.get(p)));
		}
	return url.toString();
}
 
Example #4
Source File: CopyElementDialog.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private ComboBox<VectorLayerInfo> initLayerCombo1() {
					
	VectorLayerProperties properties = GWT
			.create(VectorLayerProperties.class);

	layerStore1 = new ListStore<VectorLayerInfo>(properties.key());

	layerCombo1 = new ComboBox<VectorLayerInfo>(layerStore1,
			properties.name());
	layerCombo1.setEmptyText((UIMessages.INSTANCE.sbLayerComboEmptyText()));
	layerCombo1.setTypeAhead(true);
	layerCombo1.setTriggerAction(TriggerAction.ALL);
	layerCombo1.setForceSelection(true);
	layerCombo1.setEditable(false);
	layerCombo1.enableEvents();
	layerCombo1.setWidth(width);

	layerCombo1.addSelectionHandler(new SelectionHandler<VectorLayerInfo>() {
		@Override
		public void onSelection(SelectionEvent<VectorLayerInfo> event) {
			layerCombo1.setValue(event.getSelectedItem(), true);
		}
	});

	return layerCombo1;
}
 
Example #5
Source File: UserAuthentication.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void authenticate() {
	if (!CONSTANTS.allowUserLogin()) {
		if (isAllowLookup())
			doLookup();
		else
			ToolBox.open(GWT.getHostPageBaseURL() + "login.do?target=" + URL.encodeQueryString(Window.Location.getHref()));
		return;
	}
	AriaStatus.getInstance().setText(ARIA.authenticationDialogOpened());
	iError.setVisible(false);
	iDialog.center();
	Scheduler.get().scheduleDeferred(new ScheduledCommand() {
		@Override
		public void execute() {
			iUserName.selectAll();
			iUserName.setFocus(true);
		}
	});
}
 
Example #6
Source File: RequestorImpl.java    From requestor with Apache License 2.0 6 votes vote down vote up
public RequestorImpl(FormDataSerializer formDataSerializer, RequestDispatcherFactory requestDispatcherFactory,
                     DeferredFactory deferredFactory) {
    this.formDataSerializer = formDataSerializer;
    this.requestDispatcherFactory = requestDispatcherFactory;
    this.deferredFactory = deferredFactory;

    // init processor
    serializationEngine = new SerializationEngine(serdesManager, providerManager);
    final FilterEngine filterEngine = new FilterEngine(filterManager);
    final InterceptorEngine interceptorEngine = new InterceptorEngine(interceptorManager);
    requestProcessor = new RequestProcessor(serializationEngine, filterEngine, interceptorEngine,
            formDataSerializer);

    // init dispatcher
    final ResponseProcessor responseProcessor = new ResponseProcessor(serializationEngine, filterEngine,
            interceptorEngine);
    requestDispatcher = requestDispatcherFactory.getRequestDispatcher(responseProcessor, deferredFactory);

    // register generated serdes to the requestor
    GeneratedJsonSerdesBinder.bind(serdesManager, providerManager);

    // perform initial set-up by user
    GWT.<RequestorInitializer>create(RequestorInitializer.class).configure(this);
}
 
Example #7
Source File: ClientJsonCodec.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Decodes a value encoded on the server using
 * {@link JsonCodec#encodeWithoutTypeInfo(Object)}. This is a no-op in
 * compiled JavaScript since the JSON representation can be used as-is, but
 * some special handling is needed for tests running in the JVM.
 *
 * @param json
 *            the JSON value to convert
 * @return the decoded Java value
 */
@SuppressWarnings("boxing")
public static Object decodeWithoutTypeInfo(JsonValue json) {
    if (GWT.isScript()) {
        return json;
    } else {
        // JRE implementation for cases that have so far been needed
        switch (json.getType()) {
        case BOOLEAN:
            return json.asBoolean();
        case STRING:
            return json.asString();
        case NUMBER:
            return json.asNumber();
        case NULL:
            return null;
        default:
            throw new IllegalArgumentException(
                    "Can't (yet) convert " + json.getType());
        }
    }
}
 
Example #8
Source File: MaterialListValueBox.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public void setEmptyPlaceHolder(String value) {
    if (value == null) {
        // about to un-set emptyPlaceHolder
        if (emptyPlaceHolder != null) {
            // emptyPlaceHolder is about to change from null to non-null
            if (isEmptyPlaceHolderListed()) {
                // indeed first item is actually emptyPlaceHolder
                removeEmptyPlaceHolder();
            } else {
                GWT.log("WARNING: emptyPlaceHolder is set but not listed.", new IllegalStateException());
            }
        }   // else no change
    } else {
        if (!value.equals(emptyPlaceHolder)) {
            // adding emptyPlaceHolder
            insertEmptyPlaceHolder(value);
        }   // else no change
    }

    emptyPlaceHolder = value;
}
 
Example #9
Source File: GpsEmulator.java    From android-gps-emulator with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the Map widget and default zoom/position
 */
private void initializeMap() {
   // Create a map centered on Cawker City, KS USA
   final MapOptions opts = MapOptions.newInstance();
   if (opts == null) {
      GWT.log("MapOptions was null");
   }
   final LatLng center = LatLng.newInstance(30.0, 0.00);
   opts.setCenter(center);
   opts.setZoom(2);

   _map = new MapWidget(opts);

   // Register map click handler
   _map.addClickHandler(this);
   RootLayoutPanel.get().add(_map);
}
 
Example #10
Source File: FakeClientBundleProvider.java    From gwtmockito with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new instance of the given type that implements methods as
 * described in the class description.
 *
 * @param type interface to be implemented by the returned type.
 */
@Override
public ClientBundle getFake(Class<?> type) {
  return (ClientBundle) Proxy.newProxyInstance(
      FakeClientBundleProvider.class.getClassLoader(),
      new Class<?>[] {type},
      new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
          Class<?> returnType = method.getReturnType();
          if (CssResource.class.isAssignableFrom(returnType)) {
            return GWT.create(returnType);
          } else {
            return createFakeResource(returnType, method.getName());
          }
        }
      });
}
 
Example #11
Source File: GadgetWidget.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a display widget for the gadget.
 *
 * @param element ContentElement from the wave.
 * @param blip gadget blip.
 * @return display widget for the gadget.
 */
public static GadgetWidget createGadgetWidget(ContentElement element, WaveletName waveletName,
    ConversationBlip blip, ObservableSupplementedWave supplement,
    ProfileManager profileManager, Locale locale, String loginName) {

  final GadgetWidget widget = GWT.create(GadgetWidget.class);

  widget.element = element;
  widget.editingIndicator =
    new BlipEditingIndicator(element.getRenderedContentView().getDocumentElement());
  widget.ui = new GadgetWidgetUi(widget.getGadgetName(), widget.editingIndicator);
  widget.state = StateMap.create();
  initializeGadgets();
  widget.blip = blip;
  widget.initializeGadgetContainer();
  widget.ui.setGadgetUiListener(widget);
  widget.waveletName = waveletName;
  widget.supplement = supplement;
  widget.profileManager = profileManager;
  widget.locale = locale;
  widget.loginName = loginName;
  supplement.addListener(widget);
  return widget;
}
 
Example #12
Source File: ItemIdClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verifies that drag source is valid for the configured id (strict mode)")
public void matchInStrictMode() {
    final ItemIdClientCriterion cut = new ItemIdClientCriterion();

    // prepare drag-event:
    final String testId = "thisId";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    final String configuredId = "component0";
    final String id = "thisId";
    when(uidl.getStringAttribute(configuredId)).thenReturn(id);
    final String configuredMode = "m";
    final String strictMode = "s";
    when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
    final String count = "c";
    when(uidl.getIntAttribute(count)).thenReturn(1);

    // act
    final boolean result = cut.accept(dragEvent, uidl);

    // verify that in strict mode: [thisId equals thisId]
    assertThat(result).as("Expected: [" + id + " equals " + testId + "].").isTrue();
}
 
Example #13
Source File: DataInput.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public double readDouble() throws IOException {
    // See  https://issues.jboss.org/browse/AS7-4126
    //return IEEE754.toDouble(bytes[pos++], bytes[pos++], bytes[pos++], bytes[pos++], bytes[pos++], bytes[pos++], bytes[pos++], bytes[pos++]);
    byte doubleBytes[] = new byte[8];
    readFully(doubleBytes);

    // a workaround: I couldn't figure out why
    // one method fails in web mode and the other in hosted mode.
    if(GWT.isScript()) {
        return IEEE754.toDouble(doubleBytes);
    }
    else {
        return IEEE754.toDouble(
                doubleBytes[0],
                doubleBytes[1],
                doubleBytes[2],
                doubleBytes[3],
                doubleBytes[4],
                doubleBytes[5],
                doubleBytes[6],
                doubleBytes[7]);
    }

}
 
Example #14
Source File: Console.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void onSuccess(BootstrapContext context) {
    LoadingPanel.get().off();

    // DMR notifications
    Notifications.addReloadHandler(Console.this);

   /* StringBuilder title = new StringBuilder();
    title.append(context.getProductName()).append(" Management");
    if (context.getServerName() != null) {
        title.append(" | ").append(context.getServerName());
    }
    Window.setTitle(title.toString());*/

    ProductConfig productConfig = GWT.create(ProductConfig.class);
    new LoadMainApp(productConfig, context, MODULES.getPlaceManager(), MODULES.getTokenFormatter()).execute();
}
 
Example #15
Source File: ModelBrowserView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void updateResource(ModelNode address, SecurityContext securityContext, ModelNode description, ModelNode resource) {

        // description
        nodeHeader.updateDescription(address,description);
        descView.updateDescription(address, description);

        // data
        final List<Property> tokens = address.asPropertyList();
        String name = tokens.isEmpty() ? DEFAULT_ROOT : tokens.get(tokens.size()-1).getValue().asString();

        if(resource.isDefined())
            formView.display(address, description, securityContext, new Property(name, resource));
        else
            formView.clearDisplay();

        if(!GWT.isScript())
        {
            securityView.display(securityContext);
        }
    }
 
Example #16
Source File: ReservationTable.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void insert(final RootPanel panel) {
	initCallbacks();
	iOfferingId = Long.valueOf(panel.getElement().getInnerText());
	if (ReservationCookie.getInstance().getReservationCoursesDetails()) {
		refresh();
	} else {
		clear(false);
		iHeader.clearMessage();
		iHeader.setCollapsible(false);
	}
	panel.getElement().setInnerText(null);
	panel.add(this);
	panel.setVisible(true);
	addReservationClickHandler(new ReservationClickHandler() {
		@Override
		public void onClick(ReservationClickedEvent evt) {
			ToolBox.open(GWT.getHostPageBaseURL() + "gwt.jsp?page=reservation&id=" + evt.getReservation().getId() + "&reservations=" + getReservationIds());
		}
	});
}
 
Example #17
Source File: TimePreferenceCell.java    From unitime with Apache License 2.0 6 votes vote down vote up
@Override
public void refresh() {
	clear();
	RoomCookie cookie = RoomCookie.getInstance();
	if (iPattern != null && !iPattern.isEmpty() && !cookie.isGridAsText()) {
		final Image availability = new Image(GWT.getHostPageBaseURL() + "pattern?pref=" + iPattern + "&v=" + (cookie.areRoomsHorizontal() ? "0" : "1") + (cookie.hasMode() ? "&s=" + cookie.getMode() : ""));
		availability.setStyleName("grid");
		add(availability);
	} else {
		for (PreferenceInfo p: iPreferences) {
			P prf = new P("prf");
			prf.setText(p.getOwnerName());
			PreferenceInterface preference = iProperties.getPreference(p.getPreference());
			if (preference != null) {
				prf.getElement().getStyle().setColor(preference.getColor());
				prf.setTitle(preference.getName() + " " + p.getOwnerName());
			}
			add(prf);
		}
	}
}
 
Example #18
Source File: ContextMenuConnector.java    From context-menu with Apache License 2.0 6 votes vote down vote up
@Override
protected void init() {
    super.init();
    contextMenu = GWT.create(VContextMenu.class);
    contextMenu.connector = this;
    contextMenuRoot = contextMenu.addItem("", null);
    contextMenuRoot.setSubMenu(new VContextMenu(true, contextMenu));

    registerRpc(ContextMenuClientRpc.class, new ContextMenuClientRpc() {
        @Override
        public void showContextMenu(int x, int y) {
            contextMenu.showRootMenu(x, y);
        }
    });

}
 
Example #19
Source File: PopupFactory.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the singleton popup provider.
 */
public static PopupProvider getProvider() {
  if (provider == null) {
    provider = GWT.create(PopupProvider.class);
  }
  return provider;
}
 
Example #20
Source File: MaterialComboBox.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the currently selected index.
 * <p>
 * After calling this method, only the specified item in the list will
 * remain selected. For a ListBox with multiple selection enabled.
 *
 * @param selectedIndex - the index of the item to be selected
 */
public void setSelectedIndex(int selectedIndex) {
    this.selectedIndex = selectedIndex;
    if (values.size() > 0) {
        T value = values.get(selectedIndex);
        if (value != null || isAllowBlank()) {
            $(listbox.getElement()).val(keyFactory.generateKey(value)).trigger("change.select2", selectedIndex);
        } else {
            GWT.log("Value index is not found.", new IndexOutOfBoundsException());
        }
    }
}
 
Example #21
Source File: AceEditorConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected Widget createWidget() {
       AceEditorWidget widget = GWT.create(AceEditorWidget.class);
	widget.addTextChangeListener(this);
	widget.addSelectionChangeListener(this);
	widget.setFocusChangeListener(this);
	return widget;
}
 
Example #22
Source File: BootstrapServerSetup.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
String getBaseUrl() {
    String hostUrl = GWT.getHostPageBaseURL();
    int schemeIndex = hostUrl.indexOf("://");
    int slash = hostUrl.indexOf('/', schemeIndex + 3);
    if (slash != -1) {
        return hostUrl.substring(0, slash);
    }
    return hostUrl;
}
 
Example #23
Source File: PopupChromeFactory.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the singleton popup chrome provider.
 */
public static PopupChromeProvider getProvider() {
  if (provider == null) {
    provider = GWT.create(PopupChromeProvider.class);
  }
  return provider;
}
 
Example #24
Source File: GwtStatisticsEventDispatcher.java    From swellrt with Apache License 2.0 5 votes vote down vote up
public StatisticsEvent newEvent(String system, String group, double millis, String type) {
  Event event = new Event(GWT.getModuleName(), system, group, millis);
  if (type != null) {
    setExtraParameter(event, "type", type);
  }
  return event;
}
 
Example #25
Source File: LineChart.java    From lumongo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onClick(String x, Integer y) {
	GWT.log("dataSource: " + dataSource + " Category: " + x + " :: " + y);
	if (null != selectionHandler)
		selectionHandler.handleDataSelection(dataSource, x, y);
	return false;
}
 
Example #26
Source File: EventResourceTimetable.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected void export(String format, boolean includeRoomWeekFilter) {
	RPC.execute(EncodeQueryRpcRequest.encode(query(format, includeRoomWeekFilter)), new AsyncCallback<EncodeQueryRpcResponse>() {
		@Override
		public void onFailure(Throwable caught) {
		}
		@Override
		public void onSuccess(EncodeQueryRpcResponse result) {
			ToolBox.open(GWT.getHostPageBaseURL() + "export?q=" + result.getQuery());
		}
	});
}
 
Example #27
Source File: Game.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
private void ensureVisible(int x, int y) {
    int maxScrollX = ssa.getMaxHorizontalScrollPosition();
    int maxScrollY = ssa.getMaxScrollPosition();

    int currentMinX = ssa.getHorizontalScrollPosition();
    int currentMaxX = ssa.getOffsetWidth() + currentMinX;
    int currentMinY = ssa.getScrollPosition();
    int currentMaxY = ssa.getOffsetHeight() + currentMinY;

    GWT.log("X range " + currentMinX + " to " + currentMaxX, null);
    GWT.log("Desired X:" + x, null);
    GWT.log("Y range " + currentMinY + " to " + currentMaxY, null);
    GWT.log("Desired Y:" + y, null);

    int newScrollX = ssa.getHorizontalScrollPosition();
    int newScrollY = ssa.getScrollPosition();

    if ((x < currentMinX) || (x > currentMaxX)) {
        newScrollX = (x > maxScrollX) ? maxScrollX : x;
    }

    if ((y < currentMinY) || (y > currentMaxY)) {
        newScrollY = (y > maxScrollY) ? maxScrollY : y;
    }

    ssa.setHorizontalScrollPosition(newScrollX);
    ssa.setScrollPosition(newScrollY);
}
 
Example #28
Source File: FastArrayNumber.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public FastArrayNumber() {
	if(GWT.isScript()) {
		stackNative = JsArrayNumber.createArray().cast();
	} else {
		stackJava = new JsList<Double>();
	}
}
 
Example #29
Source File: Log.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void warn(String message, String detail) {
	try {
		GWT.log("warn: " + message, null);
		EventPanel.get().warn(message, detail);
	} catch (Throwable t) {
	}
}
 
Example #30
Source File: FastArrayNumber.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public double[] reinterpretCast() {
	if(GWT.isScript()) {
		return reinterpretCast(stackNative);
	} else {
		double[] ret = new double[stackJava.size()];
		for (int i = 0; i < stackJava.size(); i++) {
			ret[i] = stackJava.get(i);
		}
		return ret;
	}
}