com.google.gwt.user.client.Window Java Examples

The following examples show how to use com.google.gwt.user.client.Window. 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: DesignToolbar.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() {
  Ode ode = Ode.getInstance();
  if (ode.screensLocked()) {
    return;                 // Don't permit this if we are locked out (saving files)
  }
  YoungAndroidSourceNode sourceNode = ode.getCurrentYoungAndroidSourceNode();
  if (sourceNode != null && !sourceNode.isScreen1()) {
    // DeleteFileCommand handles the whole operation, including displaying the confirmation
    // message dialog, closing the form editor and the blocks editor,
    // deleting the files in the server's storage, and deleting the
    // corresponding client-side nodes (which will ultimately trigger the
    // screen deletion in the DesignToolbar).
    final String deleteConfirmationMessage = MESSAGES.reallyDeleteForm(
        sourceNode.getFormName());
    ChainableCommand cmd = new DeleteFileCommand() {
      @Override
      protected boolean deleteConfirmation() {
        return Window.confirm(deleteConfirmationMessage);
      }
    };
    cmd.startExecuteChain(Tracking.PROJECT_ACTION_REMOVEFORM_YA, sourceNode);
  }
}
 
Example #2
Source File: EventPreviewAutoHiderRegistrar.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
@Override
public void registerAutoHider(final AutoHider autoHider) {
  autoHider.setRegistered(true);
  autoHiders.add(autoHider);

  if (eventPreviewRegistration == null) {
    eventPreviewRegistration = Event.addNativePreviewHandler(this);
  }

  if (onResizeRegistration == null) {
    onResizeRegistration = Window.addResizeHandler(this);
  }

  if (onHistoryRegistration == null) {
    onHistoryRegistration = History.addValueChangeHandler(this);
  }
}
 
Example #3
Source File: StreamingProgress.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void monitor(final String logFile) {
    this.logFile = logFile;

    // deferred show
    pending = true;
    Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
        @Override
        public boolean execute() {
            // still streaming?
            if (pending) {
                setPopupPosition((Window.getClientWidth() / 2) - (WIDTH / 2),
                        (Window.getClientHeight() / 2) - (HEIGHT / 2) - 50);
                StreamingProgress.this.show();
                cancel.setFocus(true);
            }
            return false;
        }
    }, timeout);
}
 
Example #4
Source File: MicrosoftHostingService.java    From codenvy with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Promise<HostUser> authenticate(CurrentUser user) {
  final Workspace workspace = this.appContext.getWorkspace();
  if (workspace == null) {
    return Promises.reject(JsPromiseError.create("Error accessing current workspace"));
  }
  final String authUrl =
      baseUrl
          + "/oauth/authenticate?oauth_provider=microsoft&userId="
          + user.getProfile().getUserId()
          + "&scope=vso.code_manage%20vso.code_status&redirect_after_login="
          + Window.Location.getProtocol()
          + "//"
          + Window.Location.getHost()
          + "/ws/"
          + workspace.getConfig().getName();
  return ServiceUtil.performWindowAuth(this, authUrl, securityTokenProvider);
}
 
Example #5
Source File: Main.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * loadTranslations
 */
public void loadTranslations() {
	// Getting language
	languageService.getFrontEndTranslations(Main.get().getLang(), new AsyncCallback<Map<String, String>>() {
		@Override
		public void onSuccess(Map<String, String> result) {
			hI18n = result;
			onModuleLoad2(); // continues normal loading
		}

		@Override
		public void onFailure(Throwable caught) {
			Window.alert("Error getting translations: " + caught.getMessage());
		}
	});
}
 
Example #6
Source File: Header.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Layout getHomeLabel() {
	Layout layout = new VLayout();
	layout.setStyleName("n52_sensorweb_client_logoBlock");
	Img homeLabel = new Img("../img/client-logo.png", 289, 55);
	homeLabel.setStyleName("n52_sensorweb_client_logo");
	homeLabel.setCursor(Cursor.POINTER);
       homeLabel.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			String url = "http://52north.org/communities/sensorweb/";
               Window.open(url, "_blank", "");
		}
       });
       layout.addMember(homeLabel);
	return layout;
}
 
Example #7
Source File: MailViewer.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * getMailWidget
 */
private Button getMailWidget(final String mail, FlowPanel flowPanel) {
	final Button button = new Button();
	final String mailTo = mail.contains("<") ? mail.substring(mail.indexOf("<") + 1, mail.indexOf(">")).trim() : mail.trim();
	String mailHTML = mail.trim().replace("<", "&lt;").replace(">", "&gt;");
	button.setHTML(mailHTML);
	button.setTitle(mailHTML);
	button.setStyleName("okm-Button-Mail");
	button.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			Window.open("mailto:" + mailTo, "_blank", "");
		}
	});
	return button;
}
 
Example #8
Source File: AriaStatus.java    From unitime with Apache License 2.0 6 votes vote down vote up
public static AriaStatus getInstance() {
	if (sStatus == null) {
		RootPanel statusPanel = RootPanel.get("UniTimeGWT:AriaStatus");
		if (statusPanel != null && "1".equals(Window.Location.getParameter("aria"))) {
			sStatus = new AriaStatus(statusPanel.getElement(), false);
			sStatus.setStyleName("unitime-VisibleAriaStatus");
		} else {
			sStatus  = new AriaStatus(false);
			RootPanel.get().add(sStatus);
		}
		
		RootPanel.get().addDomHandler(new KeyUpHandler() {
			@Override
			public void onKeyUp(KeyUpEvent event) {
   				if (event.getNativeEvent().getKeyCode() == 191 && (event.isControlKeyDown() || event.isAltKeyDown())) {
   					sStatus.setHTML(sStatus.getHTML());
   				}
   			}
   		}, KeyUpEvent.getType());
	}
	return sStatus;
}
 
Example #9
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Dialog unmarshall(String xml)
{

    try {
        Document document = XMLParser.parse(xml);
        Element root = document.getDocumentElement();

        // model
        Builder builder = new Builder();
        dfsElement(builder, DOMUtils.getFirstChildElement(root));

        // dialog
        Dialog dialog = new Dialog(new QName(root.getNamespaceURI(), root.getAttribute("id")), builder.build());

        return dialog;
    } catch (RuntimeException e) {
        Window.alert("Faile to parse XML: "+e.getMessage());
        throw e;
    }
}
 
Example #10
Source File: ParticipantController.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Shows an add-participant popup.
 */
private void handleAddButtonClicked(Element context) {
  String addressString = Window.prompt("Add a participant(s) (separate with comma ','): ", "");
  if (addressString == null) {
    return;
  }

  ParticipantId[] participants;

  try {
    participants = buildParticipantList(localDomain, addressString);
  } catch (InvalidParticipantAddress e) {
    Window.alert(e.getMessage());
    return;
  }

  ParticipantsView participantsUi = views.fromAddButton(context);
  Conversation conversation = models.getParticipants(participantsUi);
  for (ParticipantId participant : participants) {
    conversation.addParticipant(participant);
  }
}
 
Example #11
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void goTo(final Place newPlace) {

	if (this.getWhere().equals(newPlace)) {
		return;
	}

	PlaceChangeRequestEvent willChange = new PlaceChangeRequestEvent(newPlace);
	EventBus.get().fireEvent(willChange);
	String warning = willChange.getWarning();
	if (warning == null || Window.confirm(warning)) {
		this.doGo(newPlace);
	} else {
		this.goTo(this.getWhere());
	}
}
 
Example #12
Source File: TeachingRequestDetailPage.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void showRequestDetail(Long id) {
	iAssignmentTable.clearTable(1);
	LoadingWidget.getInstance().show(MESSAGES.waitLoadTeachingRequestDetail());
	ToolBox.setMaxHeight(iScroll.getElement().getStyle(), Math.round(0.9 * Window.getClientHeight()) + "px");
	RPC.execute(new TeachingRequestDetailRequest(id), new AsyncCallback<TeachingRequestInfo>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingRequestDetail(caught.getMessage()), caught);
			ToolBox.checkAccess(caught);
		}

		@Override
		public void onSuccess(TeachingRequestInfo result) {
			LoadingWidget.getInstance().hide();
			populate(result, null, null);
			GwtHint.hideHint();
			center();
			RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
		}
	});
}
 
Example #13
Source File: YoungAndroidFormUpgrader.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Upgrades the given sourceProperties if necessary.
 *
 * @param sourceProperties the properties from the source file
 * @return true if the sourceProperties was upgraded, false otherwise
 */
public static boolean upgradeSourceProperties(Map<String, JSONValue> sourceProperties) {
  StringBuilder upgradeDetails = new StringBuilder();
  try {
    int srcYaVersion = getSrcYaVersion(sourceProperties);
    if (needToUpgrade(srcYaVersion)) {
      Map<String, JSONValue> formProperties =
          sourceProperties.get("Properties").asObject().getProperties();
      upgradeComponent(srcYaVersion, formProperties, upgradeDetails);
      // The sourceProperties were upgraded. Update the version number.
      setSrcYaVersion(sourceProperties);
      if (upgradeDetails.length() > 0) {
        Window.alert(MESSAGES.projectWasUpgraded(upgradeDetails.toString()));
      }
      return true;
    }
  } catch (LoadException e) {
    // This shouldn't happen. If it does it's our fault, not the user's fault.
    Window.alert(MESSAGES.unexpectedProblem(e.getMessage()));
    OdeLog.xlog(e);
  }
  return false;
}
 
Example #14
Source File: DocumentationDisplay.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public DocumentationDisplay() {
	this.initWidget(Binder.BINDER.createAndBindUi(this));

	Window.addResizeHandler(new ResizeHandler() {

		@Override
		public void onResize(ResizeEvent event) {
			DocumentationDisplay.this.redraw(false);
		}
	});

	Scheduler.get().scheduleDeferred(new ScheduledCommand() {

		@Override
		public void execute() {
			DocumentationDisplay.this.redraw(true);
		}
	});
}
 
Example #15
Source File: RespondEntryPoint.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
@Override
public void onModuleLoad() {
    if (Window.Navigator.getUserAgent().contains(MSIE) && Window.Navigator.getUserAgent().contains(EIGHT)) {
        ScriptInjector.fromString(RespondClientBundle.INSTANCE.respond().getText()).setWindow(ScriptInjector.TOP_WINDOW)
                .inject();
        ScriptInjector.fromString(RespondClientBundle.INSTANCE.html5Shiv().getText()).setWindow(ScriptInjector.TOP_WINDOW)
                .inject();
    }
}
 
Example #16
Source File: TextValidators.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public static boolean checkNewComponentName(String componentName) {

    // Check that it meets the formatting requirements.
    if (!TextValidators.isValidComponentIdentifier(componentName)) {
      Window.alert(MESSAGES.malformedComponentNameError());
      return false;
    }

    long projectId = Ode.getInstance().getCurrentYoungAndroidProjectId();
    if ( projectId == 0) { // Check we have a current Project
      return false;
    }

    YaProjectEditor editor = (YaProjectEditor) Ode.getInstance().getEditorManager().getOpenProjectEditor(projectId);

    // Check that it's unique.
    final List<String> names = editor.getComponentInstances();
    if (names.contains(componentName)) {
      Window.alert(MESSAGES.sameAsComponentInstanceNameError());
      return false;
    }

    // Check that it is a variable name used in the Yail code
    if (TextValidators.isReservedName(componentName)) {
      Window.alert(MESSAGES.reservedNameError());
      return false;
    }

    //Check that it is not a Component type name
    SimpleComponentDatabase COMPONENT_DATABASE = SimpleComponentDatabase.getInstance(projectId);
    if (COMPONENT_DATABASE.isComponent(componentName)) {
      Window.alert(MESSAGES.duplicateComponentNameError());
      return false;
    }

    return true;
  }
 
Example #17
Source File: TopToolbar.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() {
  final DialogBox db = new DialogBox(false, true);
  db.setText("About The Companion");
  db.setStyleName("ode-DialogBox");
  db.setHeight("200px");
  db.setWidth("400px");
  db.setGlassEnabled(true);
  db.setAnimationEnabled(true);
  db.center();

  String downloadinfo = "";
  if (!YaVersion.COMPANION_UPDATE_URL1.equals("")) {
    String url = "http://" + Window.Location.getHost() + YaVersion.COMPANION_UPDATE_URL1;
    downloadinfo = "<br/>\n<a href=" + url + ">Download URL: " + url + "</a><br/>\n";
    downloadinfo += BlocklyPanel.getQRCode(url);
  }

  VerticalPanel DialogBoxContents = new VerticalPanel();
  HTML message = new HTML(
      "Companion Version " + BlocklyPanel.getCompVersion() + downloadinfo
  );

  SimplePanel holder = new SimplePanel();
  Button ok = new Button("Close");
  ok.addClickListener(new ClickListener() {
    public void onClick(Widget sender) {
      db.hide();
    }
  });
  holder.add(ok);
  DialogBoxContents.add(message);
  DialogBoxContents.add(holder);
  db.setWidget(DialogBoxContents);
  db.show();
}
 
Example #18
Source File: TopToolbar.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() {
  DesignToolbar.DesignProject currentProject = Ode.getInstance().getDesignToolbar().getCurrentProject();
  if (currentProject == null) {
    Window.alert(MESSAGES.companionUpdateMustHaveProject());
    return;
  }
  DesignToolbar.Screen screen = currentProject.screens.get(currentProject.currentScreen);
  screen.blocksEditor.updateCompanion();
}
 
Example #19
Source File: RoomDepartmentsEdit.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(MESSAGES.pageEditRoomsDepartments());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example #20
Source File: Header.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private Label getHelpLink() {
	Label help = getHeaderLinkLabel(i18n.help());
       help.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
           public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
               String helpUrl = GWT.getHostPageBaseURL() + i18n.helpPath();
               Window.open(helpUrl, "", "");
           }
       });
	return help;
}
 
Example #21
Source File: RoomDetail.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(MESSAGES.pageRoomDetail());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example #22
Source File: EventResourceTimetable.java    From unitime with Apache License 2.0 5 votes vote down vote up
public HistoryToken(PageType type) {
	iType = type.name();
	
	// 1. take page type defaults --> DEFAULTS
	if (type.getParams() != null)
		for (int i = 0; 1 + i < type.getParams().length; i += 2)
			iDefaults.put(type.getParams()[i], type.getParams()[i + 1]);

	// 2. take page parameters --> DEFAULTS (on top of the page type defaults)
	for (Map.Entry<String, List<String>> params: Window.Location.getParameterMap().entrySet())
		iDefaults.put(params.getKey(), params.getValue().get(0));
	
	// 3. take cookie --> PARAMS (override defaults)
	String cookie = EventCookie.getInstance().getHash(iType);
	if (cookie != null) {
		for (String pair: cookie.split("\\&")) {
			int idx = pair.indexOf('=');
			if (idx >= 0) {
				String key = pair.substring(0, idx);
				if (Location.getParameter(key) == null)
					iParams.put(key, URL.decodeQueryString(pair.substring(idx + 1)));
			}
		}
	}			
	
	// 4. take page token (hash) --> PARAMS (override cookie)
	parse(History.getToken());
}
 
Example #23
Source File: ThesaurusSelectPopup.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Shows the popup 
 */
public void show(int selectedFrom) {
	this.selectedFrom = selectedFrom;
	initButtons();
	int left = (Window.getClientWidth() - 400) / 2;
	int top = (Window.getClientHeight() - 325) / 2;
	setPopupPosition(left, top);
	setText(Main.i18n("thesaurus.directory.select.label"));

	// Resets to initial tree value
	thesaurusPanel.reset();

	center();
}
 
Example #24
Source File: ClientUtils.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
public static String[] getDecodedParameters(String parameter) {
    String value = Window.Location.getParameter(parameter);
    if (value == null || value.isEmpty()) {
        return new String[] {};
    }
    if (value.startsWith("{")) {
        return splitJsonObjects(value);
    }
    else {
        return value.split(",");
    }
}
 
Example #25
Source File: BackendService.java    From mvn-golang with Apache License 2.0 5 votes vote down vote up
private static String makeUrlForResource(final String path) {
    final UrlBuilder urlBuilder = new UrlBuilder();
    urlBuilder.setHost(Window.Location.getHost());
    urlBuilder.setPath(path);

    final String port = Window.Location.getPort();
    if (!port.isEmpty()) {
        urlBuilder.setPort(Integer.parseInt(port));
    }

    return urlBuilder.buildString();
}
 
Example #26
Source File: RoomFeatureEdit.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iFeature.getId() == null ? MESSAGES.pageAddRoomFeature() : MESSAGES.pageEditRoomFeature());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example #27
Source File: ETLProgramWidget.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@Override
protected ProgramConf createProgramConf() {
	Commander cmd = null;
	try {
		cmd = CommandParser.parse(program.getCommandline());
	} catch (CommandParseException e) {
		Window.alert( e.getMessage() );
	}
	ETLProgramConf conf = new ETLProgramConf(cmd, !program.isDistributed());

	return conf;
}
 
Example #28
Source File: DefaultTabLayoutPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void onAttach() {
    super.onAttach();
    if (Window.Navigator.getUserAgent().contains("MSIE")) {
        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
            @Override
            public void execute() {
                forceLayout();
            }
        });
    }
}
 
Example #29
Source File: WindowTitleHandler.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public void onOpened(WaveContext wave) {
  String waveTitle = TitleHelper.getTitle(wave);
  String windowTitle = formatTitle(waveTitle);
  if (waveTitle == null || waveTitle.isEmpty()) {
    windowTitle = DEFAULT_TITLE;
  }
  Window.setTitle(windowTitle);
  waveFrame.setTitleText(waveTitle);
}
 
Example #30
Source File: TeachingRequestsWidget.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected void populate() {
	RPC.execute(new TeachingRequestsPageRequest(iOfferingId), new AsyncCallback<GwtRpcResponseList<TeachingRequestInfo>>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setCollapsible(null);
			iHeader.setErrorMessage(MESSAGES.failedToLoadTeachingRequests(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingRequests(caught.getMessage()), caught);
		}

		@Override
		public void onSuccess(GwtRpcResponseList<TeachingRequestInfo> result) {
			iHeader.clearMessage();
			LoadingWidget.getInstance().hide();
			iTable.populate(result, null);
			iTable.setVisible(true);
			String requestId = Window.Location.getParameter("requestId");
			if (requestId != null && !requestId.isEmpty()) {
				Long id = Long.valueOf(requestId);
				for (int row = 0; row < iTable.getRowCount(); row++) {
					SingleTeachingAssingment a = iTable.getData(row);
					if (a != null && a.getRequest() != null && id.equals(a.getRequest().getRequestId())) {
						ToolBox.scrollToElement(iTable.getRowFormatter().getElement(row));
						break;
					}
				}
			}
		}
	});
}