Пример #1
0
  /** Popup the view source dialog, showing the given content. */
  public static void showSource(final String content, String name) {
    Constants constants = GWT.create(Constants.class);
    int windowWidth = Window.getClientWidth() / 2;
    int windowHeight = Window.getClientHeight() / 2;
    final FormStylePopup pop =
        new FormStylePopup(images.viewSource(), constants.ViewingSourceFor0(name), windowWidth);

    String[] rows = content.split("\n");

    FlexTable table = new FlexTable();
    for (int i = 0; i < rows.length; i++) {

      table.setHTML(i, 0, "<span style='color:grey;'>" + (i + 1) + ".</span>");
      table.setHTML(i, 1, "<span style='color:green;' >|</span>");
      table.setHTML(i, 2, addSyntaxHilights(rows[i]));
    }

    ScrollPanel scrollPanel = new ScrollPanel(table);

    scrollPanel.setHeight(windowHeight + "px");
    scrollPanel.setWidth(windowWidth + "px");

    pop.addRow(scrollPanel);

    LoadingPopup.close();

    pop.show();
  }
Пример #2
0
 private void createPackageAction(final String name, final String descr) {
   LoadingPopup.showMessage(constants.CreatingPackagePleaseWait());
   RepositoryServiceFactory.getPackageService()
       .createPackage(
           name,
           descr,
           "package",
           new GenericCallback<java.lang.String>() {
             public void onSuccess(String uuid) {
               RulePackageSelector.currentlySelectedPackage = name;
               LoadingPopup.close();
               eventBus.fireEvent(new RefreshModuleListEvent());
             }
           });
 }
Пример #3
0
  /** Actually build the source, and display it. */
  public static void doBuildSource(final String uuid, final String name) {
    LoadingPopup.showMessage(constants.AssemblingPackageSource());

    Scheduler scheduler = Scheduler.get();
    scheduler.scheduleDeferred(
        new Command() {
          public void execute() {
            RepositoryServiceFactory.getPackageService()
                .buildPackageSource(
                    uuid,
                    new GenericCallback<java.lang.String>() {
                      public void onSuccess(String content) {
                        showSource(content, name);
                      }
                    });
          }
        });
  }
Пример #4
0
  /** This should popup a view of the chosen historical version. */
  private void showVersion(final String versionUUID) {

    LoadingPopup.showMessage(constants.LoadingVersionFromHistory());

    if (isPackage) {
      ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
      moduleService.loadModule(
          versionUUID,
          new GenericCallback<Module>() {
            public void onSuccess(Module conf) {
              Image image = new Image(images.snapshot());
              image.setAltText(ConstantsCore.INSTANCE.Snapshot());
              final FormStylePopup pop =
                  new FormStylePopup(
                      image,
                      constants.VersionNumber0Of1(conf.getVersionNumber(), conf.getName()),
                      800);

              ModuleEditorWrapper ed = new ModuleEditorWrapper(conf, clientFactory, eventBus, true);
              ed.setWidth("100%");
              ed.setHeight("100%");
              // pop.addRow( restore );
              pop.addRow(ed);
              pop.show();

              // LoadingPopup.close();
            }
          });
    } else {
      AssetServiceAsync assetService = GWT.create(AssetService.class);
      assetService.loadRuleAsset(
          versionUUID,
          new GenericCallback<Asset>() {

            public void onSuccess(final Asset asset) {
              asset.setReadonly(true);
              // asset.metaData.name = metaData.name;
              Image image = new Image(images.snapshot());
              image.setAltText(ConstantsCore.INSTANCE.Snapshot());
              final FormStylePopup pop =
                  new FormStylePopup(
                      image,
                      constants.VersionNumber0Of1(asset.getVersionNumber(), asset.getName()),
                      800);

              Button restore = new Button(constants.RestoreThisVersion());
              restore.addClickHandler(
                  new ClickHandler() {

                    public void onClick(ClickEvent event) {
                      restore(
                          (Widget) event.getSource(),
                          versionUUID,
                          new Command() {
                            public void execute() {
                              eventBus.fireEvent(
                                  new RefreshAssetEditorEvent(
                                      asset.getMetaData().getModuleName(), uuid));
                              // fire after check-in event
                              eventBus.fireEvent(new AfterAssetEditorCheckInEvent(uuid, null));
                              pop.hide();
                            }
                          });
                    }
                  });

              RuleViewerWrapper viewer =
                  new RuleViewerWrapper(clientFactory, eventBus, asset, true);
              viewer.setWidth("100%");
              viewer.setHeight("100%");

              pop.addRow(restore);
              pop.addRow(viewer);
              pop.show();
            }
          });
    }
  }
Пример #5
0
  /** This will display a dialog for creating a snapshot. */
  public static void showSnapshotDialog(final String packageName, final Command refreshCmd) {
    LoadingPopup.showMessage(constants.LoadingExistingSnapshots());
    final FormStylePopup form =
        new FormStylePopup(images.snapshot(), constants.CreateASnapshotForDeployment());
    form.addRow(new HTML(constants.SnapshotDescription()));

    final VerticalPanel vert = new VerticalPanel();
    form.addAttribute(constants.ChooseOrCreateSnapshotName(), vert);
    final List<RadioButton> radioList = new ArrayList<RadioButton>();
    final TextBox newName = new TextBox();
    final String newSnapshotText = constants.NEW() + ": ";

    RepositoryServiceFactory.getPackageService()
        .listSnapshots(
            packageName,
            new GenericCallback<SnapshotInfo[]>() {
              public void onSuccess(SnapshotInfo[] result) {
                for (int i = 0; i < result.length; i++) {
                  RadioButton existing =
                      new RadioButton("snapshotNameGroup", result[i].getName()); // NON-NLS
                  radioList.add(existing);
                  vert.add(existing);
                }
                HorizontalPanel newSnap = new HorizontalPanel();

                final RadioButton newSnapRadio =
                    new RadioButton("snapshotNameGroup", newSnapshotText); // NON-NLS
                newSnap.add(newSnapRadio);
                newName.setEnabled(false);
                newSnapRadio.addClickHandler(
                    new ClickHandler() {
                      public void onClick(ClickEvent event) {
                        newName.setEnabled(true);
                      }
                    });

                newSnap.add(newName);
                radioList.add(newSnapRadio);
                vert.add(newSnap);

                LoadingPopup.close();
              }
            });

    final TextBox comment = new TextBox();
    form.addAttribute(constants.Comment(), comment);

    Button create = new Button(constants.CreateNewSnapshot());
    form.addAttribute("", create);

    create.addClickHandler(
        new ClickHandler() {
          String name = "";

          public void onClick(ClickEvent event) {
            boolean replace = false;
            for (RadioButton but : radioList) {
              if (but.getValue()) {
                name = but.getText();
                if (!but.getText().equals(newSnapshotText)) {
                  replace = true;
                }
                break;
              }
            }
            if (name.equals(newSnapshotText)) {
              name = newName.getText();
            }

            if (name.equals("")) {
              Window.alert(constants.YouHaveToEnterOrChoseALabelNameForTheSnapshot());
              return;
            }

            LoadingPopup.showMessage(constants.PleaseWaitDotDotDot());
            RepositoryServiceFactory.getPackageService()
                .createPackageSnapshot(
                    packageName,
                    name,
                    replace,
                    comment.getText(),
                    new GenericCallback<java.lang.Void>() {
                      public void onSuccess(Void v) {
                        Window.alert(constants.TheSnapshotCalled0WasSuccessfullyCreated(name));
                        form.hide();
                        if (refreshCmd != null) {
                          refreshCmd.execute();
                        }
                        LoadingPopup.close();
                      }
                    });
          }
        });
    form.show();
  }