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

The following examples show how to use com.google.gwt.user.client.Window. 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
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 2
Source Project: codenvy   Source File: MicrosoftHostingService.java    License: 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 3
/**
 * 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 4
@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 5
Source Project: unitime   Source File: AriaStatus.java    License: 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 6
Source Project: core   Source File: DialogXML.java    License: 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 7
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 8
/**
 * 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 9
Source Project: unitime   Source File: TeachingRequestDetailPage.java    License: 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 10
Source Project: appinventor-extensions   Source File: DesignToolbar.java    License: 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 11
/**
 * 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 12
Source Project: SensorWebClient   Source File: Header.java    License: 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 13
/**
 * 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 14
@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 15
Source Project: unitime   Source File: RoomDepartmentsEdit.java    License: 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 16
Source Project: unitime   Source File: RoomDetail.java    License: 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 17
Source Project: nalu   Source File: NaluPluginGWT.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void alert(String message) {
  if (customAlertPresenter == null) {
    Window.alert(message);
  } else {
    this.customAlertPresenter.alert(message);
  }
}
 
Example 18
Source Project: swellrt   Source File: MenuController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  BlipMenuItemView item = panel.asBlipMenuItem(context);
  switch (item.getOption()) {
    case EDIT:
      actions.startEditing(item.getParent().getParent());
      break;
    case EDIT_DONE:
      actions.stopEditing();
      break;
    case REPLY:
      actions.reply(item.getParent().getParent());
      break;
    case DELETE:
      // We delete the blip without confirmation if shift key is pressed
      if (event.getNativeEvent().getShiftKey() || Window.confirm(messages.confirmDeletion())) {
        actions.delete(item.getParent().getParent());
      }
      break;
    case LINK:
      actions.popupLink(item.getParent().getParent());
      break;
    default:
      throw new AssertionError();
  }
  event.preventDefault();
  return true;
}
 
Example 19
Source Project: gwt-material-demo   Source File: ApplicationView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onAttach() {
    super.onAttach();

    ThemeManager.register(footer);
    ThemeManager.register(footerCopyRight, ThemeManager.DARKER_SHADE);
    ThemeManager.initialize();

    chipJava.getElement().getStyle().setCursor(Style.Cursor.POINTER);
    chipJava.addClickHandler(clickEvent -> {
        String java = "https://github.com/GwtMaterialDesign/gwt-material-demo/tree/master/src/main/java/gwt/material/design/demo/client/application/" + link + ".java";
        Window.open(java, "_blank", "");
    });

    chipXml.getElement().getStyle().setCursor(Style.Cursor.POINTER);
    chipXml.addClickHandler(clickEvent -> {
        String xml = "https://github.com/GwtMaterialDesign/gwt-material-demo/tree/master/src/main/java/gwt/material/design/demo/client/application/" + link + ".ui.xml";
        Window.open(xml, "_blank", "");
    });

    chipSpecification.getElement().getStyle().setCursor(Style.Cursor.POINTER);
    chipSpecification.addClickHandler(clickEvent -> Window.open(specification, "_blank", ""));
    chipInstallApp.getElement().getStyle().setCursor(Style.Cursor.POINTER);

    ThemeManager.register(chipXml, ThemeManager.DARKER_SHADE);
    ThemeManager.register(chipXml.getLetterLabel(), ThemeManager.LIGHTER_SHADE);
    ThemeManager.register(chipJava, ThemeManager.DARKER_SHADE);
    ThemeManager.register(chipJava.getLetterLabel(), ThemeManager.LIGHTER_SHADE);
    ThemeManager.register(chipSpecification, ThemeManager.DARKER_SHADE);
    ThemeManager.register(chipSpecification.getLetterLabel(), ThemeManager.LIGHTER_SHADE);
    ThemeManager.register(chipInstallApp, ThemeManager.DARKER_SHADE);
    ThemeManager.register(chipInstallApp.getLetterLabel(), ThemeManager.LIGHTER_SHADE);

    ThemeManager.register(titlePanel);

    footerCopyRightLabel.setText("© " + getFormat("yyyy").format(new Date()) + " Copyright GWT Material");
}
 
Example 20
/**
 * Shows de popup
 */
public void show() {
	setText(GeneralComunicator.i18nExtension("confirm.label"));
	int left = (Window.getClientWidth() - 300) / 2;
	int top = (Window.getClientHeight() - 125) / 2;
	setPopupPosition(left, top);
	super.show();
}
 
Example 21
Source Project: EasyML   Source File: DBController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show file preview popup panel.
 * 
 * @param path  File hdfs path 
 * @param fileId  File id
 */
public static void showPreviewPopup(final String path,String fileId){

	//Download dataset from corresponding dataset module
	if(path.contains("null"))
	{
		Window.alert("No results have been produced yet!");
		return;
	}
	final PreviewPopupPanel previewPopup = new PreviewPopupPanel(path);
	datasetSrv.loadFile(path, new AsyncCallback<Dataset>() {

		@Override
		public void onFailure(Throwable caught) {
			Window.alert("Loading data failed!");
			logger.info(caught.getMessage());
		}
		@Override
		public void onSuccess(Dataset result) {
			if (result == null)
				return;
			previewPopup.setDataset(result);
			previewPopup.getSavebtn().setVisible(true);
			previewPopup.getRefreshBtn().setVisible(true);
			previewPopup.getUploadSubmitButton().setVisible(true);
			previewPopup.getDesc().setText("File information - " + result.getName());
		}
	});
	// Set the current data's resource path
	previewPopup.setSourceUrl( path );
	previewPopup.center();
}
 
Example 22
Source Project: cuba   Source File: CubaScrollTableWidget.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void showContextMenu(Event event) {
    if (_delegate.contextMenuEnabled && enabled && (_delegate.customContextMenu != null || actionKeys != null)) {
        // Show context menu if there are registered action handlers
        int left = WidgetUtil.getTouchOrMouseClientX(event)
                + Window.getScrollLeft();
        int top = WidgetUtil.getTouchOrMouseClientY(event)
                + Window.getScrollTop();

        selectRowForContextMenuActions(event);

        showContextMenu(left, top);
    }
}
 
Example 23
Source Project: EasyML   Source File: AppController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Redirect to url
 * @param url target url
 */
public static void redirect(String url) {
	String href = Window.Location.getHref();
	logger.info("[href]" + href);
	int splitIdx = href.lastIndexOf('/');
	String base_url = href.substring(0, splitIdx);
	logger.info("[base_url]" + base_url);
	Window.Location.replace(base_url + "/" + url);
}
 
Example 24
Source Project: swellrt   Source File: ColorHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show popup with a color picker and set/clear the color on the range.
 *
 * @param editor the editor
 * @param button the button
 * @param suffix the key suffix
 * @param allowNone the allow none color (in background color)
 */
private static void showPopup(final EditorContext editor, ToolbarClickButton button,
    final String suffix, boolean allowNone) {
  FocusedRange focusedRange = editor.getSelectionHelper().getSelectionRange();
  if (focusedRange == null) {
    // Lets try to focus
    editor.focus(false);
  }
  focusedRange = editor.getSelectionHelper().getSelectionRange();
  if (focusedRange == null) {
    Window.alert(ComplexColorPicker.messages.selectSomeText());
    return;
  }
  final Range range = focusedRange.asRange();
  final ColorPopup popup = new ColorPopup(button.getButton().hackGetWidget().getElement(), allowNone);
  popup.show(new OnColorChooseListener() {
    @Override
    public void onColorChoose(String color) {
      EditorAnnotationUtil.
          setAnnotationOverRange(editor.getDocument(), editor.getCaretAnnotations(),
              StyleAnnotationHandler.key(suffix), color, range.getStart(), range.getEnd());
      popup.hide();
      editor.focus(false);
    }

    @Override
    public void onNoneColorChoose() {
      EditorAnnotationUtil.
      clearAnnotationsOverRange(editor.getDocument(), editor.getCaretAnnotations(),
          new String[] {StyleAnnotationHandler.key(suffix)}, range.getStart(), range.getEnd());
      popup.hide();
      editor.focus(false);
    }});
}
 
Example 25
/**
 * Shows the popup 
 */
public void show() {
	initButtons();
	int left = (Window.getClientWidth() - 500) / 2;
	int top = (Window.getClientHeight() - 300) / 2;
	setPopupPosition(left, top);
	setText(Main.i18n("categories.folder.select.label"));

	// Resets to initial tree value
	folderSelectTree.reset();
	super.show();
}
 
Example 26
@Override
public Widget createWidget() {

    VerticalPanel panel = new VerticalPanel();
    panel.add(new ContentHeaderLabel("Access Control"));
    
    ContentDescription description = new ContentDescription(Console.CONSTANTS.sso_access_control_description());

    String text = "<span title=\"" + Console.CONSTANTS.sso_access_control_service_title()
            + "\">" + Console.CONSTANTS.sso_access_control_service_title() + "</span>: <a href=\"" 
            + BootstrapContext.retrieveSsoAuthUrl() + "\" target=\"_blank\">" + BootstrapContext.retrieveSsoAuthUrl() 
            + "</a>";

    Anchor userProfileAnchor = new Anchor(Console.CONSTANTS.sso_access_control_user_profile());
    userProfileAnchor.addClickHandler(clickEvent -> {
        String userMgmt = SSOUtils.getSsoUserManagementUrl();
        Window.Location.replace(userMgmt);
    });
    
    ContentDescription ssoLink = new ContentDescription(text);
    panel.add(description);
    panel.add(userProfileAnchor);
    panel.add(ssoLink);

    VerticalPanel outerPanel = new VerticalPanel();
    outerPanel.setStyleName("rhs-content-panel");
    outerPanel.add(panel);

    DefaultTabLayoutPanel tabLayoutPanel = new DefaultTabLayoutPanel(40, Style.Unit.PX);
    tabLayoutPanel.addStyleName("default-tabpanel");
    tabLayoutPanel.add(outerPanel, "Access Control");
    return tabLayoutPanel;
}
 
Example 27
Source Project: unitime   Source File: UniTimeConfirmationDialog.java    License: Apache License 2.0 5 votes vote down vote up
public static void alert(boolean useDefault, String message) {
	if (useDefault) {
		Window.alert(message);
	} else {
		alert(message);
	}
}
 
Example 28
Source Project: core   Source File: SearchTool.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public static String getShortcut() {
    if (Window.Navigator.getPlatform().toLowerCase().contains("mac")) {
        return Console.CONSTANTS.search_tooltip_osx();
    } else {
        return Console.CONSTANTS.search_tooltip_other();
    }
}
 
Example 29
/**
 * Shows de popup
 */
public void show() {
	url.setText("http://");
	int left = (Window.getClientWidth() - 300) / 2;
	int top = (Window.getClientHeight() - 125) / 2;
	setPopupPosition(left, top);
	super.show();
}
 
Example 30
/**
 * Add new status message
 *
 * @param text The text
 * @param actual The actual status
 */
public void addStatus(String text, int actual) {
	HTML tmpHTML;

	// We've jumped normally due to errors, must mark as incorrect
	if (this.actual + 1 < actual) {
		Window.alert("Current error: " + this.actual + ", New error: " + actual);

		for (int i = this.actual + 1; i < actual; i++) {
			tmpHTML = new HTML("&nbsp;" + Main.get().startUp.getStatusMsg(i));
			tmpHTML.setStyleName("okm-Input-Error");
			tmpHTML.setWordWrap(false);
			status.add(tmpHTML);
			scrollPanel.ensureVisible(tmpHTML);
			table.setWidget(0, i, new Image(OKMBundleResources.INSTANCE.loadedErrorIcon()));
		}
	}

	tmpHTML = new HTML("&nbsp;" + text);
	tmpHTML.setWordWrap(false);
	msgList.add(tmpHTML);
	if (msgList.size() > 11) {
		status.remove((HTML) msgList.remove(0)); // Only shows 10 messages on panel, when arrives 10 remove the first
	}
	status.add(tmpHTML);
	scrollPanel.ensureVisible(tmpHTML);
	table.setWidget(0, actual, new Image(OKMBundleResources.INSTANCE.loadedIcon()));
	this.actual = actual;
}