private void fireWindowDownload(
        String base64Data, String filename, String mimeTypeFromBase64Data) {
      String newFilename = StringUtils.isEmpty(filename) ? "download.bin" : filename;
      String newMimeType =
          StringUtils.isEmpty(mimeTypeFromBase64Data)
              ? "application/octet-stream"
              : mimeTypeFromBase64Data;

      if (Blob.isSupported() && DownloadWindow.isSupported()) {
        Blob blob = FileUtils.fromDataURI(base64Data);
        DownloadWindow.createIfSupported().openSaveAsWindow(blob, newFilename);
      } else if (org.cruxframework.crux.core.client.file.URL.isSupported()) {
        Blob blob = FileUtils.fromDataURI(base64Data);
        Anchor anchor =
            createDownloadAnchor(
                org.cruxframework.crux.core.client.file.URL.createObjectURL(blob), newFilename);
        clickElement(anchor.getElement());
      } else if (hasHTML5DownloadAttributeSupport()) {
        Anchor anchor = createDownloadAnchor(base64Data, newFilename);
        clickElement(anchor.getElement());
      } else {
        // Note that encodeURIComponent produces UTF-8 encoded text. The mime type should contain
        // the charset=UTF-8 parameter. In case you don't want the data to be encoded as UTF-8
        // you could use escape(data) instead.
        // Javascript: window.open("data:"+mimetype+","+encodeURIComponent(data), '_blank', '');
        // Is it working? If is not, read:
        // http://stackoverflow.com/questions/607176/java-equivalent-to-javascripts-encodeuricomponent-that-produces-identical-outpu
        Window.open(
            "data:" + newMimeType,
            URL.encodeQueryString(Base64Utils.ensurePlainBase64(base64Data)),
            "_blank");
      }
    }
  protected List<? extends MenuItem> getDashboardsViews() {
    final List<MenuItem> result = new ArrayList<>(2);

    result.add(
        MenuFactory.newSimpleItem(constants.Process_Dashboard())
            .perspective("DashboardPerspective")
            .endMenu()
            .build()
            .getItems()
            .get(0));
    result.add(
        MenuFactory.newSimpleItem(constants.Business_Dashboard())
            .respondsWith(
                () ->
                    Window.open(
                        DashboardURLBuilder.getDashboardURL(
                            "/dashbuilder/workspace",
                            null,
                            LocaleInfo.getCurrentLocale().getLocaleName()),
                        "_blank",
                        ""))
            .endMenu()
            .build()
            .getItems()
            .get(0));

    return result;
  }
Example #3
0
 @Override
 public void onClick(ClickEvent event) {
   if (event.getSource() == btnExportXML) {
     String url = GWT.getModuleBaseURL() + EXPORT_XML_URL;
     Window.open(url, "_blank", "");
   }
   hide();
 }
Example #4
0
 protected void exportAsSvg() {
   GWT.log("exportAsSvg()");
   SVGModel model = getActiveModel();
   String markup = model.getMarkup();
   String url = "data:image/svg+xml;base64," + base64encode(markup);
   String title = ((SVGNamedElementModel) model.getRoot()).getName();
   com.google.gwt.user.client.Window.open(url, title, "");
 }
 public void onCellClick(CellClickEvent event) {
   ListGridField gridField = AttributeListGrid.this.getField(event.getColNum());
   if (gridField.getName().equals(attributeInfo.getName())) {
     ListGridRecord record = event.getRecord();
     String value = record.getAttribute(attributeInfo.getName());
     Window.open(value, "urlWindow", null);
   }
 }
 @Override
 public boolean handle(WizardAction action, WizardController controller) {
   if (action instanceof PublishWizardAction) {
     PublishWizardAction importWizardAction = (PublishWizardAction) action;
     switch (importWizardAction) {
       case NEW_PUBLISH:
         publishBus.fireEvent(new ResetWizardEvent());
         break;
       case DOWNLOAD_CODELIST:
         if (codelistDownloadUrl != null) Window.open(codelistDownloadUrl, "_blank", "");
         break;
       case DOWNLOAD_REPORT:
         Window.open(REPORT_DOWNLOAD_URL, "_blank", "");
         break;
     }
   }
   return false;
 }
 public void downloadFullJobLogs(String sessionId, String jobId) {
   String url =
       SchedulerConfig.get().getRestPublicUrlIfDefinedOrOverridden()
           + "/scheduler/jobs/"
           + jobId
           + "/log/full?sessionid="
           + sessionId;
   Window.open(url, "_blank", "");
 }
Example #8
0
  @Test
  public void open() {
    // Arrange
    mockedHandler.open(EasyMock.eq("url"), EasyMock.eq("name"), EasyMock.eq("features"));
    EasyMock.expectLastCall();
    EasyMock.replay(mockedHandler);

    // Act
    Window.open("url", "name", "features");

    // Assert
    EasyMock.verify(mockedHandler);
  }
 /** Share the data by using Twister. */
 private void onTwisterShareEvent() {
   MixpanelUtil.Click_On_Twitter();
   if (AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.PROFILE_PAGE)) {
     if (socialDo.getIsSearchShare()) {
       triggerShareDataEvent(PlayerDataLogEvents.TWITTER, false);
       Window.open(
           "http://twitter.com/intent/tweet?text="
               + "Gooru - "
               + socialDo.getTitle().replaceAll("\\+", "%2B")
               + ": "
               + socialDo.getBitlylink(),
           "_blank",
           "width=600,height=300");
     } else {
       triggerShareDataEvent(PlayerDataLogEvents.TWITTER, false);
       //				Window.open("http://twitter.com/intent/tweet?text=" + "Check out
       // "+socialDo.getTitle().replaceAll("\\+", "%2B")+ "'s Gooru Profile Page - " +
       // socialDo.getBitlylink(), "_blank", "width=600,height=300");
       Window.open(
           "http://twitter.com/intent/tweet?text="
               + getEncodedUrl(i18n.GL1085_1())
               + socialDo.getBitlylink(),
           "_blank",
           "width=600,height=300");
     }
   } else {
     triggerShareDataEvent(PlayerDataLogEvents.TWITTER, false);
     Window.open(
         "http://twitter.com/intent/tweet?text="
             + "Gooru - "
             + socialDo.getTitle().replaceAll("\\+", "%2B")
             + ": "
             + socialDo.getBitlylink(),
         "_blank",
         "width=600,height=300");
   }
 }
 public void openFile(final RepositoryFile repositoryFile, final FileCommand.COMMAND mode) {
   PerspectiveManager.getInstance().setPerspective(PerspectiveManager.OPENED_PERSPECTIVE);
   String fileNameWithPath = repositoryFile.getPath();
   if (mode == FileCommand.COMMAND.EDIT) {
     editFile();
   } else if (mode == FileCommand.COMMAND.SCHEDULE_NEW) {
     ScheduleHelper.createSchedule(repositoryFile);
   } else if (mode == FileCommand.COMMAND.SHARE) {
     (new ShareFileCommand()).execute();
   } else {
     String url = null;
     String extension = ""; // $NON-NLS-1$
     if (fileNameWithPath.lastIndexOf(".") > 0) { // $NON-NLS-1$
       extension =
           fileNameWithPath.substring(fileNameWithPath.lastIndexOf(".") + 1); // $NON-NLS-1$
     }
     if (!executableFileExtensions.contains(extension)) {
       url =
           getPath()
               + "api/repos/"
               + pathToId(fileNameWithPath)
               + "/content"; //$NON-NLS-1$ //$NON-NLS-2$
     } else {
       ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(fileNameWithPath);
       url =
           getPath()
               + "api/repos/"
               + pathToId(fileNameWithPath)
               + "/"
               + (plugin != null && (plugin.getCommandPerspective(mode) != null)
                   ? plugin.getCommandPerspective(mode)
                   : "generatedContent"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     if (mode == FileCommand.COMMAND.NEWWINDOW) {
       Window.open(
           url,
           "_blank",
           "menubar=yes,location=no,resizable=yes,scrollbars=yes,status=no"); //$NON-NLS-1$
       // //$NON-NLS-2$
     } else {
       contentTabPanel.showNewURLTab(
           repositoryFile.getTitle(), repositoryFile.getTitle(), url, true);
       addRecent(fileNameWithPath, repositoryFile.getTitle());
     }
   }
 }
Example #11
0
 public static void postOnFacebook(
     String titleName, String shareLink, String description, String thumbnailUrl) {
   String faceBookFeedUrl = AppClientFactory.getLoggedInUser().getSettings().getFacebookFeedUrl();
   String appId = AppClientFactory.getLoggedInUser().getSettings().getFacebookAppId();
   faceBookFeedUrl =
       faceBookFeedUrl
           + "?app_id="
           + appId
           + "&display=popup&name="
           + getEncodedUrl(titleName)
           + "&link="
           + shareLink
           + "&picture="
           + getEncodedUrl(thumbnailUrl)
           + "&description="
           + getEncodedUrl(description)
           + "&redirect_uri="
           + getEncodedUrl("https://www.facebook.com/");
   // +"&actions="+getEncodedUrl(actions);
   Window.open(faceBookFeedUrl, "_blank", "width=626,height=436");
 }
  @UiHandler("gpxButton")
  public void onGPXClicked(SelectionEvent<Item> event) {
    if (deviceCombo.getValue() == null) {
      new AlertMessageBox(i18n.error(), i18n.errFillFields()).show();
    } else {
      DateTimeFormat jsonTimeFormat =
          ApplicationContext.getInstance().getFormatterUtil().getRequestTimeFormat();

      Window.open(
          "/traccar/export/gpx"
              + "?deviceId="
              + (deviceCombo.getValue() == null ? null : deviceCombo.getValue().getId())
              + "&from="
              + jsonTimeFormat.format(getCombineDate(fromDate, fromTime)).replaceFirst("\\+", "%2B")
              + "&to="
              + jsonTimeFormat.format(getCombineDate(toDate, toTime)).replaceFirst("\\+", "%2B")
              + "&filter="
              + !disableFilter.getValue()
              + "&snapToRoads="
              + snapToRoads.getValue(),
          "_blank",
          null);
    }
  }
Example #13
0
  @Override
  public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) {
    ConnectorMap paintableMap = ConnectorMap.get(getConnection());
    getWidget().rendering = true;
    getWidget().id = getConnectorId();
    boolean firstPaint = getWidget().connection == null;
    getWidget().connection = client;

    getWidget().immediate = getState().immediate;
    getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY);
    String newTheme = uidl.getStringAttribute("theme");
    if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) {
      // Complete page refresh is needed due css can affect layout
      // calculations etc
      getWidget().reloadHostPage();
    } else {
      getWidget().theme = newTheme;
    }
    // this also implicitly removes old styles
    String styles = "";
    styles += getWidget().getStylePrimaryName() + " ";
    if (ComponentStateUtil.hasStyles(getState())) {
      for (String style : getState().styles) {
        styles += style + " ";
      }
    }
    if (!client.getConfiguration().isStandalone()) {
      styles += getWidget().getStylePrimaryName() + "-embedded";
    }
    getWidget().setStyleName(styles.trim());

    getWidget().makeScrollable();

    clickEventHandler.handleEventHandlerRegistration();

    // Process children
    int childIndex = 0;

    // Open URL:s
    boolean isClosed = false; // was this window closed?
    while (childIndex < uidl.getChildCount()
        && "open".equals(uidl.getChildUIDL(childIndex).getTag())) {
      final UIDL open = uidl.getChildUIDL(childIndex);
      final String url = client.translateVaadinUri(open.getStringAttribute("src"));
      final String target = open.getStringAttribute("name");
      if (target == null) {
        // source will be opened to this browser window, but we may have
        // to finish rendering this window in case this is a download
        // (and window stays open).
        Scheduler.get()
            .scheduleDeferred(
                new Command() {
                  @Override
                  public void execute() {
                    VUI.goTo(url);
                  }
                });
      } else if ("_self".equals(target)) {
        // This window is closing (for sure). Only other opens are
        // relevant in this change. See #3558, #2144
        isClosed = true;
        VUI.goTo(url);
      } else {
        String options;
        boolean alwaysAsPopup = true;
        if (open.hasAttribute("popup")) {
          alwaysAsPopup = open.getBooleanAttribute("popup");
        }
        if (alwaysAsPopup) {
          if (open.hasAttribute("border")) {
            if (open.getStringAttribute("border").equals("minimal")) {
              options = "menubar=yes,location=no,status=no";
            } else {
              options = "menubar=no,location=no,status=no";
            }

          } else {
            options =
                "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes";
          }

          if (open.hasAttribute("width")) {
            int w = open.getIntAttribute("width");
            options += ",width=" + w;
          }
          if (open.hasAttribute("height")) {
            int h = open.getIntAttribute("height");
            options += ",height=" + h;
          }

          Window.open(url, target, options);
        } else {
          open(url, target);
        }
      }
      childIndex++;
    }
    if (isClosed) {
      // don't render the content, something else will be opened to this
      // browser view
      getWidget().rendering = false;
      return;
    }

    // Handle other UIDL children
    UIDL childUidl;
    while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {
      String tag = childUidl.getTag().intern();
      if (tag == "actions") {
        if (getWidget().actionHandler == null) {
          getWidget().actionHandler = new ShortcutActionHandler(getWidget().id, client);
        }
        getWidget().actionHandler.updateActionMap(childUidl);
      } else if (tag == "notifications") {
        for (final Iterator<?> it = childUidl.getChildIterator(); it.hasNext(); ) {
          final UIDL notification = (UIDL) it.next();
          VNotification.showNotification(client, notification);
        }
      }
    }

    if (uidl.hasAttribute("focused")) {
      // set focused component when render phase is finished
      Scheduler.get()
          .scheduleDeferred(
              new Command() {
                @Override
                public void execute() {
                  ComponentConnector paintable =
                      (ComponentConnector) uidl.getPaintableAttribute("focused", getConnection());

                  final Widget toBeFocused = paintable.getWidget();
                  /*
                   * Two types of Widgets can be focused, either implementing
                   * GWT HasFocus of a thinner Vaadin specific Focusable
                   * interface.
                   */
                  if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) {
                    final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget =
                        (com.google.gwt.user.client.ui.Focusable) toBeFocused;
                    toBeFocusedWidget.setFocus(true);
                  } else if (toBeFocused instanceof Focusable) {
                    ((Focusable) toBeFocused).focus();
                  } else {
                    VConsole.log("Could not focus component");
                  }
                }
              });
    }

    // Add window listeners on first paint, to prevent premature
    // variablechanges
    if (firstPaint) {
      Window.addWindowClosingHandler(getWidget());
      Window.addResizeHandler(getWidget());
    }

    if (uidl.hasAttribute("scrollTo")) {
      final ComponentConnector connector =
          (ComponentConnector) uidl.getPaintableAttribute("scrollTo", getConnection());
      scrollIntoView(connector);
    }

    if (uidl.hasAttribute(UIConstants.LOCATION_VARIABLE)) {
      String location = uidl.getStringAttribute(UIConstants.LOCATION_VARIABLE);
      int fragmentIndex = location.indexOf('#');
      if (fragmentIndex >= 0) {
        getWidget().currentFragment = location.substring(fragmentIndex + 1);
      }
      if (!getWidget().currentFragment.equals(History.getToken())) {
        History.newItem(getWidget().currentFragment, true);
      }
    }

    if (firstPaint) {
      // Queue the initial window size to be sent with the following
      // request.
      getWidget().sendClientResized();
    }
    getWidget().rendering = false;
  }
 public void openTabInNewWindow() {
   Window.open(getCurrentUrl(), "_blank", ""); // $NON-NLS-1$ //$NON-NLS-2$
 }
  /**
   * @function openResurceLink
   * @created_date : Jan 2, 2014
   * @description To open original resource link in new tab.
   * @parm(s) : @param ClickEvent
   * @return : void
   * @throws : <Mentioned if any exceptions>
   */
  @UiHandler("btnResourceLink")
  public void openResurceLink(ClickEvent event) {
    MixpanelUtil.mixpanelEvent("Player_Click_Linked_Out_Resource");

    Window.open(collectionItemDo.getResource().getUrl(), "_blank", "");
  }
 @UiHandler("btnDemoStarter")
 void onDemoStarter(ClickEvent e) {
   Window.open(IMaterialConstants.DEMO_STARTER, "_blank", "");
 }
 @UiHandler("btnMaven")
 void onGoToMaven(ClickEvent e) {
   Window.open(IMaterialConstants.MAVEN_LINK, "_blank", "");
 }
 @Override
 public void execute() {
   Window.open(
       "https://groups.google.com/forum/#!forum/mitappinventortest", "_ai2", "scrollbars=1");
 }
 @Override
 public void execute() {
   Window.open("http://something.example.com", "_blank", "scrollbars=1");
 }
 @Override
 public void execute() {
   Window.open("http://appinventor.mit.edu/explore/ai2/tutorials", "_ai2", "scrollbars=1");
 }
 @Override
 public void execute() {
   Window.open(
       "http://appinventor.mit.edu/explore/ai2/support/troubleshooting", "_ai2", "scrollbars=1");
 }
 @Override
 public void execute() {
   Window.open("http://appinventor.mit.edu/explore/get-started", "_ai2", "scrollbars=1");
 }
Example #23
0
 @Override
 public void handleEvent(BaseEvent be) {
   com.google.gwt.user.client.Window.open(url, "", "");
 }
 @UiHandler("btnSourceStarter")
 void onSourceStarter(ClickEvent e) {
   Window.open(IMaterialConstants.SOURCE_STARTER, "_blank", "");
 }
Example #25
0
 @Override
 public boolean openURI(String URI) {
   Window.open(URI, "_blank", null);
   return true;
 }
 @UiHandler("btnDownloadGWTMaterial")
 void onDownloadGWTMaterial(ClickEvent e) {
   Window.open(IMaterialConstants.DOWNLOAD_GWT_MATERIAL, "_blank", "");
 }