Пример #1
0
  public NewPackageWizard(ClientFactory clientFactory, EventBus eventBus) {
    super(images.newexWiz(), constants.CreateANewPackage());
    this.eventBus = eventBus;
    nameBox = new TextBox();
    descBox = new TextBox();

    newPackageLayout.addAttribute(constants.NameColon(), nameBox);
    newPackageLayout.addAttribute(constants.DescriptionColon(), descBox);

    nameBox.setTitle(constants.PackageNameTip());

    RadioButton newPackage = new RadioButton("action", constants.CreateNewPackageRadio());
    RadioButton importPackage = new RadioButton("action", constants.ImportFromDrlRadio());

    newPackage.setValue(true);
    newPackageLayout.setVisible(true);

    newPackage.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            newPackageLayout.setVisible(true);
            importLayout.setVisible(false);
          }
        });

    this.setAfterShow(
        new Command() {
          public void execute() {
            nameBox.setFocus(true);
          }
        });

    importLayout.setVisible(false);
    importPackage.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            newPackageLayout.setVisible(false);
            importLayout.setVisible(true);
          }
        });

    VerticalPanel ab = new VerticalPanel();
    ab.add(newPackage);
    ab.add(importPackage);
    addAttribute("", ab);

    addRow(newPackageLayout);
    addRow(importLayout);

    importLayout.addAttribute(constants.DRLFileToImport(), newImportWidget(this));

    importLayout.addRow(new HTML("<br/><b>" + constants.NoteNewPackageDrlImportWarning() + "</b>"));
    importLayout.addRow(new HTML(constants.ImportDRLDesc1()));
    importLayout.addRow(new HTML(constants.ImportDRLDesc2()));
    importLayout.addRow(new HTML(constants.ImportDRLDesc3()));

    HorizontalPanel hp = new HorizontalPanel();
    Button create = new Button(constants.CreatePackage());
    create.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            if (PackageNameValidator.validatePackageName(nameBox.getText())) {
              createPackageAction(nameBox.getText(), descBox.getText());
              hide();
            } else {
              nameBox.setText("");
              Window.alert(constants.PackageNameCorrectHint());
            }
          }
        });
    hp.add(create);

    Button cancel = new Button(constants.Cancel());
    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            hide();
          }
        });
    hp.add(cancel);

    newPackageLayout.addAttribute("", hp);
  }
Пример #2
0
  public PackageBuilderWidget(final PackageConfigData conf, ClientFactory clientFactory) {

    this.conf = conf;
    this.clientFactory = clientFactory;

    // UI above the results table
    FormStyleLayout layout = new FormStyleLayout();
    final VerticalPanel container = new VerticalPanel();
    final VerticalPanel buildResults = new VerticalPanel();

    RadioButton wholePackageRadioButton = new RadioButton("action", constants.BuildWholePackage());
    RadioButton builtInSelectorRadioButton =
        new RadioButton("action", constants.BuildPackageUsingBuiltInSelector());
    RadioButton customSelectorRadioButton =
        new RadioButton("action", constants.BuildPackageUsingCustomSelector());
    wholePackageRadioButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(true);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(false);
            buildMode = "buildWholePackage";
          }
        });
    builtInSelectorRadioButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(true);
            customSelectorLayout.setVisible(false);
            buildMode = "BuiltInSelector";
          }
        });
    customSelectorRadioButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(true);
            buildMode = "customSelector";
          }
        });

    VerticalPanel verticalPanel = new VerticalPanel();

    HorizontalPanel wholePackageRadioButtonPanel = new HorizontalPanel();
    wholePackageRadioButtonPanel.add(wholePackageRadioButton);
    wholePackageRadioButtonPanel.add(
        new InfoPopup(constants.BuildWholePackage(), constants.BuildWholePackageTip()));
    verticalPanel.add(wholePackageRadioButtonPanel);

    HorizontalPanel builtInSelectorRadioButtonPanel = new HorizontalPanel();
    builtInSelectorRadioButtonPanel.add(builtInSelectorRadioButton);
    builtInSelectorRadioButtonPanel.add(
        new InfoPopup(constants.BuiltInSelector(), constants.BuiltInSelectorTip()));
    verticalPanel.add(builtInSelectorRadioButtonPanel);

    HorizontalPanel customSelectorRadioButtonPanel = new HorizontalPanel();
    customSelectorRadioButtonPanel.add(customSelectorRadioButton);
    customSelectorRadioButtonPanel.add(
        new InfoPopup(constants.CustomSelector(), constants.SelectorTip()));
    verticalPanel.add(customSelectorRadioButtonPanel);

    layout.addAttribute("", verticalPanel);
    wholePackageRadioButton.setValue(true);

    buildWholePackageLayout.setVisible(true);
    builtInSelectorLayout.setVisible(false);
    customSelectorLayout.setVisible(false);

    // Build whole package layout
    layout.addRow(buildWholePackageLayout);

    // Built-in selector layout
    builtInSelectorLayout.addRow(
        new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingFollowingAssets() + "</i>"));

    HorizontalPanel builtInSelectorStatusPanel = new HorizontalPanel();
    final CheckBox enableStatusCheckBox = new CheckBox();
    enableStatusCheckBox.setValue(false);
    builtInSelectorStatusPanel.add(enableStatusCheckBox);
    builtInSelectorStatusPanel.add(
        new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingBuiltInSelectorStatus() + " </i>"));
    final ListBox statusOperator = new ListBox();
    String[] vals = new String[] {"=", "!="};
    for (int i = 0; i < vals.length; i++) {
      statusOperator.addItem(vals[i], vals[i]);
    }
    builtInSelectorStatusPanel.add(statusOperator);

    final TextBox statusValue = new TextBox();
    statusValue.setTitle(constants.WildCardsSearchTip());
    builtInSelectorStatusPanel.add(statusValue);

    builtInSelectorLayout.addRow(builtInSelectorStatusPanel);

    HorizontalPanel builtInSelectorCatPanel = new HorizontalPanel();
    final CheckBox enableCategoryCheckBox = new CheckBox();
    enableCategoryCheckBox.setValue(false);
    builtInSelectorCatPanel.add(enableCategoryCheckBox);
    builtInSelectorCatPanel.add(
        new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingBuiltInSelectorCat() + " </i>"));
    final ListBox catOperator = new ListBox();
    String[] catVals = new String[] {"=", "!="};
    for (int i = 0; i < catVals.length; i++) {
      catOperator.addItem(catVals[i], catVals[i]);
    }
    builtInSelectorCatPanel.add(catOperator);
    final CategoryExplorerWidget catChooser =
        new CategoryExplorerWidget(
            new CategorySelectHandler() {
              public void selected(String selectedPath) {}
            });
    ScrollPanel catScroll = new ScrollPanel(catChooser);
    catScroll.setAlwaysShowScrollBars(true);
    catScroll.setSize("300px", "130px");

    builtInSelectorCatPanel.add(catScroll);
    builtInSelectorLayout.addRow(builtInSelectorCatPanel);

    layout.addRow(builtInSelectorLayout);

    // Custom selector layout
    customSelectorLayout.setVisible(false);
    HorizontalPanel customSelectorPanel = new HorizontalPanel();
    customSelectorPanel.add(
        new HTML(
            "&nbsp;&nbsp;<i>"
                + constants.BuildPackageUsingCustomSelectorSelector()
                + " </i>")); // NON-NLS

    final ListBox customSelector = new ListBox();
    customSelector.setTitle(constants.WildCardsSearchTip());
    customSelectorPanel.add(customSelector);
    loadCustomSelectorList(customSelector);

    customSelectorLayout.addRow(customSelectorPanel);
    layout.addRow(customSelectorLayout);

    final Button b = new Button(constants.BuildPackage());
    b.setTitle(constants.ThisWillValidateAndCompileAllTheAssetsInAPackage());
    b.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            doBuild(
                buildResults,
                statusOperator.getValue(statusOperator.getSelectedIndex()),
                statusValue.getText(),
                enableStatusCheckBox.getValue(),
                catOperator.getValue(catOperator.getSelectedIndex()),
                catChooser.getSelectedPath(),
                enableCategoryCheckBox.getValue(),
                customSelector.getSelectedIndex() != -1
                    ? customSelector.getValue(customSelector.getSelectedIndex())
                    : null);
          }
        });
    HorizontalPanel buildStuff = new HorizontalPanel();
    buildStuff.add(b);

    layout.addAttribute(constants.BuildBinaryPackage(), buildStuff);
    layout.addRow(
        new HTML("<i><small>" + constants.BuildingPackageNote() + "</small></i>")); // NON-NLS
    container.add(layout);

    // The build results
    container.add(buildResults);

    // UI below the results table
    layout = new FormStyleLayout();
    Button snap = new Button(constants.CreateSnapshotForDeployment());
    snap.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            showSnapshotDialog(conf.getName(), null);
          }
        });
    layout.addAttribute(constants.TakeSnapshot(), snap);
    container.add(layout);

    initWidget(container);
  }
Пример #3
0
  private Widget newImportWidget(final FormStylePopup parent) {

    final FormPanel uploadFormPanel = new FormPanel();
    uploadFormPanel.setAction(GWT.getModuleBaseURL() + "package");
    uploadFormPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadFormPanel.setMethod(FormPanel.METHOD_POST);

    VerticalPanel panel = new VerticalPanel();
    uploadFormPanel.setWidget(panel);

    final FileUpload upload = new FileUpload();
    upload.setName(HTMLFileManagerFields.CLASSIC_DRL_IMPORT);
    panel.add(upload);

    HorizontalPanel hp = new HorizontalPanel();
    Button create = new Button(constants.Import());
    ClickHandler okClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            if (Window.confirm(constants.ImportMergeWarning())) {
              uploadFormPanel.submit();
            }
          }
        };
    create.addClickHandler(okClickHandler);
    hp.add(create);

    Button cancel = new Button(constants.Cancel());
    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            parent.hide();
          }
        });
    hp.add(cancel);
    panel.add(hp);

    final FormStylePopup packageNamePopup =
        new FormStylePopup(images.packageLarge(), constants.PackageName());
    HorizontalPanel packageNamePanel = new HorizontalPanel();
    packageNamePopup.addRow(new Label(constants.ImportedDRLContainsNoNameForThePackage()));

    final TextBox packageName = new TextBox();
    packageNamePanel.add(new Label(constants.PackageName() + ":"));
    packageNamePanel.add(packageName);
    Button uploadWithNameButton = new Button(constants.OK());
    uploadWithNameButton.addClickHandler(okClickHandler);

    packageNamePanel.add(uploadWithNameButton);
    packageNamePopup.addRow(packageNamePanel);
    uploadFormPanel.addSubmitCompleteHandler(
        new SubmitCompleteHandler() {
          public void onSubmitComplete(SubmitCompleteEvent event) {
            if (event.getResults().indexOf("OK") > -1) { // NON-NLS
              LoadingPopup.close();
              Window.alert(constants.PackageWasImportedSuccessfully());

              eventBus.fireEvent(new RefreshModuleListEvent());
              parent.hide();
              if (packageNamePopup != null) {
                packageNamePopup.hide();
              }
            } else if (event.getResults().indexOf("Missing package name.") > -1) {
              LoadingPopup.close();
              packageNamePopup.show();
            } else {
              ErrorPopup.showMessage(constants.UnableToImportIntoThePackage0(event.getResults()));
            }
            LoadingPopup.close();
          }
        });

    uploadFormPanel.addSubmitHandler(
        new SubmitHandler() {
          public void onSubmit(SubmitEvent event) {
            if (upload.getFilename().length() == 0) {
              LoadingPopup.close();
              Window.alert(constants.YouDidNotChooseADrlFileToImport());
              event.cancel();
            } else if (!upload.getFilename().endsWith(".drl")) { // NON-NLS
              LoadingPopup.close();
              Window.alert(constants.YouCanOnlyImportDrlFiles());
              event.cancel();
            } else if (packageName.getText() != null && !packageName.getText().equals("")) {
              LoadingPopup.showMessage(constants.ImportingDRLPleaseWait());
              uploadFormPanel.setAction(
                  uploadFormPanel.getAction() + "?packageName=" + packageName.getText());
            } else {
              LoadingPopup.showMessage(constants.CreatingPackagePleaseWait());
            }
          }
        });

    return uploadFormPanel;
  }
Пример #4
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();
  }