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

The following are top voted examples for showing how to use com.google.gwt.core.client.GWT. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: empiria.player   File: DataSourceManager.java   View source code 6 votes vote down vote up
public void loadMainDocument(String url) {
    if (mode == DataSourceManagerMode.LOADING_ASSESSMENT || mode == DataSourceManagerMode.LOADING_ITEMS || "".equals(url)) {
        return;
    }

    mode = DataSourceManagerMode.LOADING_ASSESSMENT;

    String resolvedURL;

    resolvedURL = PathUtil.resolvePath(url, GWT.getHostPageBaseURL());

    new eu.ydp.empiria.player.client.util.file.xml.XmlDocument(resolvedURL, new DocumentLoadCallback<Document>() {

        @Override
        public void finishedLoading(Document document, String baseURL) {
            assesmentXML = new XmlData(document, baseURL);
            assessmentDataManager.initializeAssessmentData(assesmentXML);
        }

        @Override
        public void loadingError(String error) {
            assessmentDataManager.setAssessmentLoadingError(error);
            onLoadFinished();
        }
    });
}
 
Example 2
Project: empiria.player   File: ResponseNodeParserGWTTestCase.java   View source code 6 votes vote down vote up
public void testParseResponseFromNodeTest() {
    ResponseNodeJAXBParserFactory responseNodeJAXBParserFactory = GWT.create(ResponseNodeJAXBParserFactory.class);

    responseNodeParser = new ResponseNodeParser(responseNodeJAXBParserFactory, new ResponseBeanConverter());

    Response response = responseNodeParser.parseResponseFromNode(getResponseDeclaration());

    assertEquals(response.cardinality, Cardinality.MULTIPLE);
    assertEquals(response.identifier, "CONNECTION_RESPONSE_1");
    assertEquals(response.evaluate, Evaluate.CORRECT);
    assertEquals(response.cardinality, Cardinality.MULTIPLE);
    assertEquals(response.getCheckMode(), CheckMode.EXPRESSION);
    assertEquals(3, response.correctAnswers.getAllAnswers().size());
    assertEquals(response.correctAnswers.getAllAnswers().get(0), "CONNECTION_RESPONSE_1_0 CONNECTION_RESPONSE_1_1");
    assertEquals(response.correctAnswers.getAllAnswers().get(1), "CONNECTION_RESPONSE_1_0 CONNECTION_RESPONSE_1_2");
    assertEquals(response.correctAnswers.getAllAnswers().get(2), "CONNECTION_RESPONSE_1_3 CONNECTION_RESPONSE_1_4");
    assertEquals(response.getID(), "CONNECTION_RESPONSE_1"); // checkMode
    assertEquals(response.getAppropriateCountMode(), CountMode.SINGLE);
    assertEquals(response.groups.get(0), "x1");
    assertEquals(response.groups.get(1), "x2");
}
 
Example 3
Project: domino-todolist   File: LayoutUIClientModule.java   View source code 6 votes vote down vote up
public void onModuleLoad() {
	ScriptInjector.fromUrl(GWT.getModuleBaseURL()+"bower_components/webcomponents-lite.min.js").setWindow(ScriptInjector.TOP_WINDOW).setCallback(
               new Callback<Void, Exception>() {
                   @Override
                   public void onSuccess(Void result) {
					LOGGER.info("injection success");
					importPolymer();
				}

				@Override
				public void onFailure(Exception reason) {

				}
			}).inject();


	LOGGER.info("Initializing Layout client UI module ...");
	new ModuleConfigurator().configureModule(new LayoutUIModuleConfiguration());
}
 
Example 4
Project: errai-spring-boot-sample   File: App.java   View source code 6 votes vote down vote up
@AfterInitialization
public void afterInitialization() {
    authenticationServiceCaller.call(new RemoteCallback<User>() {
        @Override
        public void callback(User user) {
            Label userLabel = new Label(
                    "User logged in: username=" + user.getIdentifier() + ", roles=" + user.getRoles());
            RootPanel.get().add(userLabel);
            SimplePanel panel = new SimplePanel();
            Anchor logoutLink = new Anchor("Spring Security Logout URL", GWT.getHostPageBaseURL() + "logout");
            panel.add(logoutLink);
            RootPanel.get().add(panel);
            initBtns();
        }
    }).getUser();
}
 
Example 5
Project: sig-seguimiento-vehiculos   File: GeoprocessComboBox.java   View source code 6 votes vote down vote up
public GeoprocessComboBox(Collection<Geoprocess> spatialOperations) {
	super(new ListStore<Geoprocess>(
			((GeoprocessProperties)GWT.create(GeoprocessProperties.class)).key()),
			((GeoprocessProperties)GWT.create(GeoprocessProperties.class)).name());
	initialize();
	getStore().addAll(spatialOperations);
}
 
Example 6
Project: Charba   File: Injector.java   View source code 6 votes vote down vote up
/**
 * Injects ChartJS if not injected yet.
 */
static void ensureInjected() {
	if (!injected) {
		// gets resource
		Resources res = GWT.create(Resources.class);
		// gets source of ChartJS
		String source = res.chartJsSource().getText();
		// creates a script element
		ScriptElement scriptElement = Document.get().createScriptElement();
		// sets ID
		scriptElement.setId(CHART_JS_SCRIPT_ELEMENT_ID);
		// sets the script content with ChartJS source
		scriptElement.setInnerText(source);
		// appends to the body
		Document.get().getBody().appendChild(scriptElement);
		injected = true;
	}
}
 
Example 7
Project: EasyML   File: DatasetTreeLoader.java   View source code 6 votes vote down vote up
/**
 * TODO: query the programs by users
 *
 * @param userEmail used to filter myDatasets
 */
public static DatasetTree load(final String userEmail) {
	final DatasetTree tree = new DatasetTree();
	DatasetServiceAsync svc = GWT.create(DatasetService.class);
	svc.load(new AsyncCallback<List<Dataset>>() {

		@Override
		public void onFailure(Throwable caught) {
			logger.info("Failed to load data component:" + caught.getMessage());
		}

		@Override
		public void onSuccess(List<Dataset> result) {
			for (Dataset m : result) {
				if (!m.getDeprecated()) {
					DatasetLeaf node = new DatasetLeaf(m);
					addDatasetLeaf(tree, node, userEmail);
					addContextMenu(tree,node);
				}
			}
		}
	});
	return tree;
}
 
Example 8
Project: EasyML   File: BaseWidgetMenuItemFactory.java   View source code 6 votes vote down vote up
/**
 * Create DownloadDataItem
 * @param com
 * @return DownloadDataItem
 */
public static MenuItem createDownloadData(HasRightMouseUpMenu com) {
	Command command = new MenuItemCommand(com) {

		@Override
		public void execute() {

			DatasetWidget widget = (DatasetWidget) this.component;
			widget.getContextMenu().hide();
			OutNodeShape shape = widget.getOutNodeShapes().get(0);
			String filename = shape.getAbsolutePath() + "/" + shape.getFileId();
			String url = GWT.getModuleBaseURL().split("EMLStudio")[0]
					+ "EMLStudioMonitor/filedownload?filename=" + filename;
			Window.open(url, "_blank", "status=0,toolbar=0,menubar=0,location=0");

		}

	};

	MenuItem item = new MenuItem("Download", command);
	return item;
}
 
Example 9
Project: domino   File: MessageFormatter.java   View source code 6 votes vote down vote up
private static void safeObjectAppend(StringBuilder sbuf, Object o) {
        try {
            sbuf.append(o.toString());
        } catch (Throwable t) {
            GWT.log("SLF4J: Failed toString() invocation on an object of type ["
                    + o.getClass().getName() + "]", t);
/*
            System.err
                    .println("SLF4J: Failed toString() invocation on an object of type ["
                            + o.getClass().getName() + "]");
            t.printStackTrace();
*/
            sbuf.append("[FAILED toString()]");
        }

    }
 
Example 10
Project: domino   File: CoreModule.java   View source code 6 votes vote down vote up
public static void init() {
    GWT.setUncaughtExceptionHandler(throwable -> LOGGER.error("Uncaught Exception", throwable));
    ClientRouter clientRouter = new ClientRouter(new ClientEventFactory());
    ServerRouter serverRouter = new ServerRouter(new GwtRequestAsyncSender(new ServerEventFactory()));
    RequestEventProcessor requestEventProcessor = new RequestEventProcessor();
    SimpleEventsBus eventBus = new SimpleEventsBus(requestEventProcessor);
    ClientApp.ClientAppBuilder
            .clientRouter(clientRouter)
            .serverRouter(serverRouter)
            .eventsBus(eventBus)
            .requestRepository(new InMemoryCommandsRepository())
            .presentersRepository(new InMemoryPresentersRepository())
            .viewsRepository(new InMemoryViewRepository())
            .contributionsRepository(new InMemoryContributionRepository())
            .requestSendersRepository(new InMemoryRequestRestSendersRepository())
            .history(new StateHistory())
            .asyncRunner(new GwtAsyncRunner())
            .mainExtensionPoint(new CoreMainExtensionPoint())
            .dominoOptions(new RestyGwtOptions())
            .build();
}
 
Example 11
Project: sig-seguimiento-vehiculos   File: OpenProjectDialog.java   View source code 6 votes vote down vote up
private SelectHandler createUrlToShare(final VerticalPanel geoDataContainer) {
	return new SelectHandler() {
		@Override
		public void onSelect(SelectEvent event) {
			urlToShareAnchor.setHref(getHref());
			urlToShareAnchor.setText(
					UIMessages.INSTANCE.seeOtherWindow("GeoWE Project"),
					Direction.LTR);

			urlShared.setText(getHref());
			urlPanel.setVisible(true);
			urlShared.setVisible(true);
		}

		private String getHref() {
			String baseUrl = GWT.getHostPageBaseURL();

			baseUrl += "?projectUrl="
					+ URL.encodeQueryString(urlTextField.getValue());

			return baseUrl;
		}
	};
}
 
Example 12
Project: domino   File: RequestSenderSourceWriter.java   View source code 6 votes vote down vote up
@Override
public String write() throws IOException {
    TypeSpec.Builder senderBuilder = makeSenderBuilder();
    if (hasServiceRoot())
        senderBuilder.addField(addServiceRoot());
    senderBuilder.addField(addPathField());
    TypeSpec serviceInterface = new ServiceInterfaceBuilder().build();
    senderBuilder.addType(serviceInterface);


    ClassName serviceInterfaceType = ClassName.bestGuess(serviceInterface.name);
    FieldSpec serviceInterfaceField = FieldSpec.builder(serviceInterfaceType, "service")
            .addModifiers(Modifier.PRIVATE)
            .initializer("$T.create($T.class)", GWT.class, serviceInterfaceType)
            .build();

    senderBuilder.addField(serviceInterfaceField);

    senderBuilder.addMethod(new SendMethodBuilder().build());

    StringBuilder asString = new StringBuilder();
    JavaFile.builder(processorElement.elementPackage(), senderBuilder.build()).skipJavaLangImports(true).build().writeTo(asString);
    return asString.toString();
}
 
Example 13
Project: unitimes   File: Client.java   View source code 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 14
Project: sig-seguimiento-vehiculos   File: CopyElementDialog.java   View source code 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 15
Project: unitimes   File: UserAuthentication.java   View source code 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 16
Project: Mindustry   File: HtmlLauncher.java   View source code 5 votes vote down vote up
@Override
   public PreloaderCallback getPreloaderCallback () {
	final Panel preloaderPanel = new VerticalPanel();
	preloaderPanel.setStyleName("gdx-preloader");
	final Image logo = new Image(GWT.getModuleBaseURL() + "logo.png");
	logo.setStyleName("logo");		
	preloaderPanel.add(logo);
	final Panel meterPanel = new SimplePanel();
	meterPanel.setStyleName("gdx-meter");
	meterPanel.addStyleName("red");
	final InlineHTML meter = new InlineHTML();
	final Style meterStyle = meter.getElement().getStyle();
	meterStyle.setWidth(0, Unit.PCT);
	meterPanel.add(meter);
	preloaderPanel.add(meterPanel);
	getRootPanel().add(preloaderPanel);
	return new PreloaderCallback() {

		@Override
		public void error (String file) {
			System.out.println("error: " + file);
		}
		
		@Override
		public void update (PreloaderState state) {
			meterStyle.setWidth(100f * state.getProgress(), Unit.PCT);
		}			
		
	};
}
 
Example 17
Project: empiria.player   File: MathModule.java   View source code 5 votes vote down vote up
@Override
public void initModule(Element element) {
    uiBinder = GWT.create(MathModuleViewUiBinder.class);
    uiBinder.createAndBindUi(this);

    moduleElement = element;
    styles = styleSocket.getStyles(moduleElement);

    readAttributes(element);
    initStyles(styles);
    initializePanels();
    initializeMathPlayer();
    generateGaps(getBodyGenerator());
    setGapMathStyles();
}
 
Example 18
Project: sig-seguimiento-vehiculos   File: GeoprocessHelpDialog.java   View source code 5 votes vote down vote up
private HTML getHtmlReport() {
	VectorLayerTemplate template = GWT.create(VectorLayerTemplate.class);
	VectorFeature[] features = null;
	if (features == null) {
		features = new ArrayList<VectorFeature>()
				.toArray(new VectorFeature[0]);
	}
	return new HTML(template.renderTemplate(HelpMessages.INSTANCE, UIMessages.INSTANCE));
}
 
Example 19
Project: sig-seguimiento-vehiculos   File: GeoDataImportDialog.java   View source code 5 votes vote down vote up
private SelectHandler createUrlToShare(final VerticalPanel geoDataContainer) {
	return new SelectHandler() {
		@Override
		public void onSelect(SelectEvent event) {
			urlToShareAnchor.setHref(getHref());
			urlToShareAnchor.setText(
					UIMessages.INSTANCE.seeOtherWindow(getLayerName()),
					Direction.LTR);

			urlShared.setText(getHref());
			urlPanel.setVisible(true);
			urlShared.setVisible(true);
		}

		private String getHref() {
			String baseUrl = GWT.getHostPageBaseURL();

			baseUrl += "?layerUrl="
					+ URL.encodeQueryString(urlTextField.getValue())
					+ "&layerName=" + getLayerName() + "&layerProj="
					+ getProjectionName() + "&layerFormat="
					+ getDataFormat();

			return baseUrl;
		}
	};
}
 
Example 20
Project: sig-seguimiento-vehiculos   File: JoinDataTool.java   View source code 5 votes vote down vote up
private void lodaDataFromURL(final String url) {
	final String urlBase = GWT.getHostPageBaseURL() + "gwtOpenLayersProxy";
	try {
		autoMessageBox.show();
		RestClient.create(URLFileRestService.class, urlBase,
				new RemoteCallback<String>() {
					@Override
					public void callback(String response) {
						parseCsvData(response);
						autoMessageBox.hide();
					}
				}, new RestErrorCallback() {
					@Override
					public boolean error(Request message,
							Throwable throwable) {
						autoMessageBox.hide();

						showAlert("Error"
								+ UIMessages.INSTANCE.unexpectedError());
						return false;
					}
				}, Response.SC_OK).getContent(url);
	} catch (Exception e) {
		autoMessageBox.hide();
		showAlert("Error loading data..." + e.getMessage());
	}
}
 
Example 21
Project: empiria.player   File: SoundExecutorSwfSimple.java   View source code 5 votes vote down vote up
private void playFromSource(String src) {
    panelMain.clear();
    FlowPanel panelEmbed = new FlowPanel();
    String htmlId = Document.get().createUniqueId();
    panelEmbed.getElement().setId(htmlId);
    panelMain.add(panelEmbed);
    String installSrc = GWT.getModuleBaseURL() + "swfobject/expressInstall.swf";
    String swfSrc = GWT.getModuleBaseURL() + "flashAudioExecutorSimple/flashAudioExecutorSimple.swf";
    embedSwf(htmlId, swfSrc, installSrc, src);
}
 
Example 22
Project: empiria.player   File: GinjectorFragmentOutputter.java   View source code 5 votes vote down vote up
@Inject
GinjectorFragmentOutputter(GeneratorContext ctx, GinjectorFragmentContext.Factory ginjectorFragmentContextFactory, ErrorManager errorManager,
                           TreeLogger logger, SourceWriteUtil.Factory sourceWriteUtilFactory, @Assisted GinjectorBindings bindings,
                           @Assisted FragmentPackageName fragmentPackageName, @Assisted("ginjectorPackageName") String ginjectorPackageName,
                           @Assisted("ginjectorClassName") String ginjectorClassName) {

    this.ctx = ctx;
    this.errorManager = errorManager;
    this.logger = logger;
    this.sourceWriteUtil = sourceWriteUtilFactory.create(bindings);

    this.fragmentPackageName = fragmentPackageName;
    this.ginjectorClassName = ginjectorClassName;
    this.nameGenerator = bindings.getNameGenerator();

    fragmentClassName = nameGenerator.getFragmentClassName(ginjectorClassName, fragmentPackageName);
    if (fragmentClassName.contains(".")) {
        errorManager.logError("Internal error: the fragment class name \"%s\" contains a full stop.", fragmentClassName);
    }

    PrintWriter printWriter = ctx.tryCreate(logger, fragmentPackageName.toString(), fragmentClassName);
    if (printWriter == null) {
        // Something is very wrong! We already created this fragment, but the
        // GinjectorBindingsOutputter should only create each fragment once.
        // Something bad will probably happen later on if we continue, so just
        // abort.
        logger.log(TreeLogger.Type.ERROR, "The fragment " + fragmentPackageName + "." + fragmentClassName + " already exists.");
        throw new IllegalStateException("The fragment " + fragmentClassName + " already exists.");
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(fragmentPackageName.toString(), fragmentClassName);

    composerFactory.addImport(GWT.class.getCanonicalName());
    composerFactory.addImport(ginjectorPackageName + "." + ginjectorClassName);
    writer = composerFactory.createSourceWriter(ctx, printWriter);

    injectorWriteContext = ginjectorFragmentContextFactory.create(bindings, fragmentPackageName, writer);
}
 
Example 23
Project: empiria.player   File: SelectionModuleJAXBParserGWTTestCase.java   View source code 5 votes vote down vote up
public void testCreate() {
    SelectionModuleJAXBParser jaxbParserFactory = GWT.create(SelectionModuleJAXBParser.class);
    JAXBParser<SelectionInteractionBean> jaxbParser = jaxbParserFactory.create();

    SelectionInteractionBean interactionBean = jaxbParser.parse(testXml);

    assertNotNull(interactionBean);
    assertEquals("dummy1", interactionBean.getId());
    assertEquals(1, interactionBean.getMatchMax());
    assertEquals("SELECTION_RESPONSE_1", interactionBean.getResponseIdentifier());
    assertEquals(false, interactionBean.isMulti());
    assertEquals(true, interactionBean.isShuffle());

    // validate items
    List<SelectionItemBean> items = interactionBean.getItems();
    assertEquals(2, items.size());

    validateItem(items.get(0), "SELECTION_RESPONSE_1_0", 1, true, "<math>a1</math>");
    validateItem(items.get(1), "SELECTION_RESPONSE_1_3", 2, false, "b1");

    // validate choices
    List<SelectionSimpleChoiceBean> simpleChoices = interactionBean.getSimpleChoices();
    assertEquals(2, simpleChoices.size());

    validateChoice(simpleChoices.get(0), "SELECTION_RESPONSE_1_1", 1, "<math>a2</math>");
    validateChoice(simpleChoices.get(1), "SELECTION_RESPONSE_1_4", 2, "b2");
}
 
Example 24
Project: sig-seguimiento-vehiculos   File: VectorFormatComboBox.java   View source code 5 votes vote down vote up
public VectorFormatComboBox(String width,
		Collection<VectorFormat> vectorFormats) {
	super(new ListStore<VectorFormat>(
			((VectorFormatProperties)GWT.create(VectorFormatProperties.class)).key()),
			((VectorFormatProperties)GWT.create(VectorFormatProperties.class)).name());
	initialize(width);
	getStore().addAll(vectorFormats);
}
 
Example 25
Project: empiria.player   File: ExternalInteractionModuleJAXBParserFactoryGWTTestCase.java   View source code 5 votes vote down vote up
public void testShouldParseExternalInteractionBean() {
    //given
    final String expectedURL = "external/view.html";
    String xml = "<externalInteraction src=\"" + expectedURL + "\"/>";

    ExternalInteractionModuleJAXBParserFactory jaxbParserFactory = GWT.create(ExternalInteractionModuleJAXBParserFactory.class);
    JAXBParser<ExternalInteractionModuleBean> externalInteractionModuleBeanJAXBParser = jaxbParserFactory.create();

    // when
    ExternalInteractionModuleBean actual = externalInteractionModuleBeanJAXBParser.parse(xml);

    // then
    assertEquals(actual.getSrc(), expectedURL);
}
 
Example 26
Project: convertigo-che-assembly   File: MainViewPresenter.java   View source code 5 votes vote down vote up
@Inject
  public MainViewPresenter(MainView mainView, AppContext appContext) {
  	this.mainView = mainView;
  	this.appContext = appContext;

  	exportGetKeyConvertigoMachineUrl();
  	exportInjectDocReadyAndC8OCoreScripts();
  	exportGetConvertigoMachineUrl();

defineConvertigoUrl(getConvertigoMachineUrl());

  	final String jsFile = "init.js";
  	ScriptInjector.fromUrl(GWT.getModuleBaseURL() + jsFile)
       .setWindow(ScriptInjector.TOP_WINDOW)
       .setCallback(new Callback<Void, Exception>() {
           @Override
           public void onSuccess(final Void result) {
               Log.info(MainViewPresenter.class, jsFile + " loaded.");
           }
	
           @Override
           public void onFailure(final Exception e) {
               Log.error(MainViewPresenter.class, "Unable to load " + jsFile, e);
           }
       })
       .inject();
  }
 
Example 27
Project: sig-seguimiento-vehiculos   File: VectorLayerInitializer.java   View source code 5 votes vote down vote up
public void initialize() {
	final List<Layer> vectorLayers = new ArrayList<Layer>();

	final LayerTree vectorialLayerTree = GWT.create(LayerTree.class);
	vectorialLayerTree.createTree(vectorLayers, VECTOR_ROOT_NAME);
	vectorialLayerTree.setToolbar(vectorLayerToolBar);
	vectorialLayerTree.setMap(geoMap);
	vectorialLayerTree.setCell(layerManagerWidget.getTreeClickEvent());
	layerManagerWidget.add(LayerManagerWidget.VECTOR_TAB,
			vectorialLayerTree);		
}
 
Example 28
Project: calendar-component   File: SimpleDayCell.java   View source code 5 votes vote down vote up
public void startCalendarItemDrag(MouseDownEvent event, final MonthItemLabel label) {

        moveRegistration = addMouseMoveHandler(this);
        startX = event.getClientX();
        startY = event.getClientY();
        startYrelative = event.getRelativeY(label.getParent().getElement())
                % getHeigth();
        startXrelative = event.getRelativeX(label.getParent().getElement())
                % getWidth();

        CalendarItem e = getItemByWidget(label);
        dndSourceDateFrom = (Date) e.getStart().clone();
        dndSourceDateTo = (Date) e.getEnd().clone();

        dndSourceStartDateTime = (Date) e.getStartTime().clone();
        dndSourceEndDateTime = (Date) e.getEndTime().clone();

        Event.setCapture(getElement());
        keyDownHandler = addKeyDownHandler(keyDownHandler -> {
            if (keyDownHandler.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
                cancelItemDrag(label);
            }
        });

        focus();

        GWT.log("Start drag");
    }
 
Example 29
Project: empiria.player   File: ModulesStateLoaderGWTTestCase.java   View source code 5 votes vote down vote up
@Override
protected void gwtSetUp() throws Exception {

    TestGinjector injector = GWT.create(TestGinjector.class);
    loader = injector.getModulesStateLoader();

    firstModule = new ModuleMock(FIRST_IDENTIFIER);
    secondModule = new ModuleMock(SECOND_IDENTIFIER);

    modules = Lists.newArrayList((IModule) firstModule, (IModule) secondModule);
}
 
Example 30
Project: odb-artax   File: HtmlLauncher.java   View source code 5 votes vote down vote up
@Override
public Preloader.PreloaderCallback getPreloaderCallback() {
    final VerticalPanel preloaderPanel = new VerticalPanel();
    preloaderPanel.setStyleName("gdx-preloader");
    preloaderPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    final Image logo = new Image(GWT.getModuleBaseURL() + "logo.gif");
    logo.setStyleName("logo");
    preloaderPanel.add(logo);
    final Panel meterPanel = new SimplePanel();
    meterPanel.setStyleName("gdx-meter");
    meterPanel.addStyleName("red");
    final InlineHTML meter = new InlineHTML();
    final Style meterStyle = meter.getElement().getStyle();
    meterStyle.setWidth(0, Style.Unit.PCT);
    meterPanel.add(meter);
    preloaderPanel.add(meterPanel);
    getRootPanel().add(preloaderPanel);
    return new Preloader.PreloaderCallback() {
        @Override
        public void error(String file) {
            System.out.println("error: " + file);
        }

        @Override
        public void update(Preloader.PreloaderState state) {
            meterStyle.setWidth(100f * state.getProgress(), Style.Unit.PCT);
        }

    };
}
 
Example 31
Project: rxgwt-tips   File: Tips.java   View source code 5 votes vote down vote up
private void schedulers() {
    // GWT Schedulers, various callbacks, not easy to combine or specify timing operations like a timeout!
    gwtScheduler().scheduleDeferred((ScheduledCommand) () -> L.log("one time command done!"));
    gwtScheduler().scheduleIncremental((RepeatingCommand) () -> {L.log("repeating command done!"); return false;});
    // to use RX first just wrap the task in a RX type, for example a log call into a Completable
    Completable rxTask = Completable.fromAction(() -> L.log("one time command done!")); // by default synchronous
    // with RX you can specify in which scheduler do you want to execute the task
    rxTask.subscribeOn(GwtSchedulers.deferredScheduler()); // async using a deferred scheduler
    rxTask.subscribeOn(GwtSchedulers.incrementalScheduler()); // async using a incremental scheduler
    rxTask.subscribeOn(Schedulers.io()); // GWT agnostic, but yep, this is mapped to deferred
    rxTask.subscribeOn(Schedulers.computation()); // and this one to is mapped to incremental
    // remember that this is a chained description, so you should save the instance, like this
    rxTask.subscribeOn(Schedulers.io()).subscribe(() -> L.log("task executed async!"));

    // for repeating tasks like a timer
    new Timer() { public void run() { L.log("whOOt? inheritance instead of composition?!");} }.schedule(100);
    // you should generate stream of ticks, called 'interval' (timer exists, but just emmit 1 tick)
    interval(100, MILLISECONDS).flatMapCompletable(n -> rxTask);

    // and a final example, if the web is online (and stop if not) do a task each 5min
    online().switchMap(online -> online ? interval(5, MINUTES) : Observable.never())
            // fetching a big list of data, so big that need to be reduced incrementally to no block the
            // main loop, as our API is RX friendly, just observe each result item in the computation scheduler
            .flatMapSingle(refresh -> requestData().observeOn(computation())
                    // and reduce each item here, until the whole response is processed
                    .<Set<String>>reduceWith(HashSet::new, (acc,n) -> { acc.add(n); return acc; }))
            // at this point the response has been processed incrementally!
            .doOnNext(result -> GWT.log("save the processed result: " + result))
            // if something goes wrong, wait 1 minute and try again, the try will reconnect the whole observable
            // so if the web is offline, it will not try to process again until it get online!
            .retryWhen(at -> at.flatMapSingle(ex -> { GWT.log("updater error", ex); return timer(1, MINUTES); }))
            .subscribe(); // eventually we'll see that subscribe responsibility can be delegated! (safer!)
}
 
Example 32
Project: EasyML   File: DatasetDeleteMenu.java   View source code 5 votes vote down vote up
public static MenuItem create(final DatasetLeaf node) {

		Command command = new MenuItemCommand(node) {

			@Override
			public void execute() {
				String id = node.getModule().getId();
				boolean y = Window.confirm("Ready to delete " + node.getText() + "?");
				if (y) {
					DatasetServiceAsync svc = GWT.create(DatasetService.class);
					svc.delete(id, new AsyncCallback<Void>() {

						@Override
						public void onFailure(Throwable caught) {
							Window.alert(caught.getMessage());
						}

						@Override
						public void onSuccess(Void result) {
							node.delete();
						}
					});
				}

				this.component.getContextMenu().hide();
			}
		};

		MenuItem item = new MenuItem("Delete", command);
		return item;
	}
 
Example 33
Project: EasyML   File: ProgramDeleteMenu.java   View source code 5 votes vote down vote up
public static MenuItem create(final ProgramLeaf node) {

		Command command = new MenuItemCommand(node) {

			@Override
			public void execute() {
				String id = node.getModule().getId();
				boolean y = Window.confirm("Are you ready to delete " + node.getText() + "?");
				if (y) {
					ProgramServiceAsync svc = GWT.create(ProgramService.class);
					svc.delete(id, new AsyncCallback<Void>() {

						@Override
						public void onFailure(Throwable caught) {
							Window.alert(caught.getMessage());
						}

						@Override
						public void onSuccess(Void result) {
							node.delete();
						}

					});
				}
				this.component.getContextMenu().hide();
			}
		};

		MenuItem item = new MenuItem("delete", command);
		return item;
	}
 
Example 34
Project: EasyML   File: JobAddExampleMenu.java   View source code 5 votes vote down vote up
public static MenuItem create(final JobLeaf node) {
	Command command = new MenuItemCommand(node) {

		@Override
		public void execute() {
			String id = node.getModule().getJobId();
			boolean y = Window.confirm("Are you sure you want to join the example task?");
			if (y) {
				JobServiceAsync srv = GWT.create(JobService.class);
				srv.setExampleJobs(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}
				});
			}
			this.component.getContextMenu().hide();
		}
	};
	MenuItem item = new MenuItem("Join example task", command);
	return item;
}
 
Example 35
Project: EasyML   File: ProgramDeprecateMenu.java   View source code 5 votes vote down vote up
public static MenuItem create(final ProgramLeaf node) {
	Command command = new MenuItemCommand(node) {
		@Override
		public void execute() {
			String id = node.getModule().getId();
			boolean y = Window.confirm("Are you ready to deprecate " + node.getModule().getName() + "?");
			if (y) {
				ProgramServiceAsync svc = GWT.create(ProgramService.class);
				svc.deprecate(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}

				});
			}
			this.component.getContextMenu().hide();
		}

	};

	MenuItem item = new MenuItem("deprecate", command);
	return item;
}
 
Example 36
Project: EasyML   File: JobDeleteMenu.java   View source code 5 votes vote down vote up
public static MenuItem create(final JobLeaf node) {
	Command command = new MenuItemCommand(node) {

		@Override
		public void execute() {
			String id = node.getModule().getJobId();
			boolean y = Window.confirm("Are you sure you want to delete?");
			if (y) {
				JobServiceAsync srv = GWT.create(JobService.class);
				srv.deleteJob(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}
				});
			}
			this.component.getContextMenu().hide();
		}
	};
	MenuItem item = new MenuItem("Delete", command);
	return item;
}
 
Example 37
Project: EasyML   File: DatasetDeprecateMenu.java   View source code 5 votes vote down vote up
public static MenuItem create(final DatasetLeaf node) {
	Command command = new MenuItemCommand(node) {
		@Override
		public void execute() {
			String id = node.getModule().getId();
			boolean y = Window.confirm("Ready to deprecate " + node.getModule().getName() + "?");
			if (y) {
				DatasetServiceAsync svc = GWT.create(DatasetService.class);
				svc.deprecate(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}

				});
			}
			this.component.getContextMenu().hide();
		}
	};

	MenuItem item = new MenuItem("Deprecate", command);
	return item;
}
 
Example 38
Project: EasyML   File: ProgramDownloadMenu.java   View source code 5 votes vote down vote up
public static MenuItem create(final ProgramLeaf node) {
	Command command = new MenuItemCommand(node) {

		@Override
		public void execute() {
			String id = node.getModule().getId();
			ProgramServiceAsync svc = GWT.create(ProgramService.class);
			svc.download(id, new AsyncCallback<String>() {

				@Override
				public void onFailure(Throwable caught) {
					Window.alert(caught.getMessage());
				}

				@Override
				public void onSuccess(String result) {
					String url = GWT.getModuleBaseURL().split("EML")[0]
							+ "EMLStudioMonitor/filedownload?filename=" + result;
					Window.open(url, "_blank",
							"status=0,toolbar=0,menubar=0,location=0");
				}

			});
			this.component.getContextMenu().hide();
		}
	};

	MenuItem item = new MenuItem("Download", command);
	return item;
}
 
Example 39
Project: domino   File: RestfulRemoteLogHandler.java   View source code 5 votes vote down vote up
@Override
public void publish(LogRecord record) {
    if (isLoggable(record)) {
        if (!ServiceRootMatcher.hasServiceRoot(PATH))
            ((RestServiceProxy) service).setResource(new Resource(GWT.getHostPageBaseURL()));
        else
            ((RestServiceProxy) service).setResource(new Resource(ServiceRootMatcher.matchedServiceRoot(PATH)));
        service.send(asSerializableLogRecord(record), new RemoteLoggingCallBack());
    }
}
 
Example 40
Project: domino   File: RestfulRemoteLogHandler.java   View source code 5 votes vote down vote up
private SerializableLogRecord asSerializableLogRecord(LogRecord record) {
    SerializableLogRecord serializableLogRecord = new SerializableLogRecord();
    serializableLogRecord.level = record.getLevel().toString();
    serializableLogRecord.millis = record.getMillis();
    serializableLogRecord.message = record.getMessage();
    serializableLogRecord.loggerName = record.getLoggerName();
    serializableLogRecord.permutationStrongName = GWT.getPermutationStrongName();
    serializableLogRecord.thrown = serializableThrowable(unwrap(record.getThrown()));
    return serializableLogRecord;
}