private void showFieldChange() {
   final FormStylePopup pop = new FormStylePopup();
   pop.setModal(false);
   String[] fields =
       this.sce.getFieldCompletions(
           FieldAccessorsAndMutators.MUTATOR, this.editingCol.getFactType());
   final ListBox box = new ListBox();
   for (int i = 0; i < fields.length; i++) {
     box.addItem(fields[i]);
   }
   pop.addAttribute(constants.Field(), box);
   Button b = new Button(constants.OK());
   pop.addAttribute("", b);
   b.addClickHandler(
       new ClickHandler() {
         public void onClick(ClickEvent w) {
           editingCol.setFactField(box.getItemText(box.getSelectedIndex()));
           editingCol.setType(
               sce.getFieldType(editingCol.getFactType(), editingCol.getFactField()));
           makeLimitedValueWidget();
           doFieldLabel();
           pop.hide();
         }
       });
   pop.show();
 }
  /** 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();
  }
  /** This will show a popup of error messages in compilation. */
  public static void showBuilderErrors(BuilderResult[] results) {
    FormStylePopup pop = new FormStylePopup("images/package_builder.png", "Validation results");
    if (results == null || results.length == 0) {
      pop.addRow(new HTML("<img src='images/tick_green.gif'/><i>Item validated.</i>"));
    } else {
      FlexTable errTable = new FlexTable();
      errTable.setStyleName("build-Results");
      for (int i = 0; i < results.length; i++) {
        int row = i;
        final BuilderResult res = results[i];
        errTable.setWidget(row, 0, new Image("images/error.gif"));
        if (res.assetFormat.equals("package")) {
          errTable.setText(row, 1, "[package configuration problem] " + res.message);
        } else {
          errTable.setText(row, 1, "[" + res.assetName + "] " + res.message);
        }
      }
      ScrollPanel scroll = new ScrollPanel(errTable);
      // scroll.setAlwaysShowScrollBars(true);
      // scroll.setSize("100%","25em");
      scroll.setWidth("100%");
      // scroll.setScrollPosition( 100 );
      // errTable.setWidth( "60%" );
      pop.addRow(scroll);
      //            pop.setWidth( "70%" );
      //            pop.setHeight( "50%" );

    }
    pop.show();
    LoadingPopup.close();
  }
  protected void showAddFieldPopup(ClickEvent w) {
    final SuggestionCompletionEngine completions = this.getModeller().getSuggestionCompletions();
    final FormStylePopup popup = new FormStylePopup(images.newexWiz(), constants.AddAField());

    final ListBox box = new ListBox();
    box.addItem("...");

    for (int i = 0; i < fieldCompletions.length; i++) {
      box.addItem(fieldCompletions[i]);
    }

    box.setSelectedIndex(0);

    popup.addAttribute(constants.AddField(), box);
    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());

            String fieldType = completions.getFieldType(variableClass, fieldName);
            model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
          }
        });

    popup.show();
  }
  public WorkingSetSelectorPopup(RuleModeller m, RuleAsset a) {
    this.modeller = m;
    this.asset = a;

    pop = new FormStylePopup();
    Constants constants = ((Constants) GWT.create(Constants.class));
    pop.setTitle(constants.SelectWorkingSets());
    Grid g = buildDoubleList(null);

    RepositoryServiceFactory.getAssetService()
        .listAssets(
            asset.getMetaData().getPackageUUID(),
            new String[] {AssetFormats.WORKING_SET},
            0,
            -1,
            "workingsetList",
            new GenericCallback<TableDataResult>() {

              public void onSuccess(TableDataResult result) {

                for (int i = 0; i < result.data.length; i++) {
                  if (WorkingSetManager.getInstance()
                      .isWorkingSetActive(
                          asset.getMetaData().getPackageName(), result.data[i].id)) {
                    selectedFacts.addItem(result.data[i].getDisplayName(), result.data[i].id);
                  } else {
                    availableFacts.addItem(result.data[i].getDisplayName(), result.data[i].id);
                  }
                }
              }
            });

    Button save = new Button(constants.SaveAndClose());
    save.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String[] wsUUIDs = new String[selectedFacts.getItemCount()];
            for (int i = 0; i < selectedFacts.getItemCount(); i++) {
              wsUUIDs[i] = selectedFacts.getValue(i);
            }

            WorkingSetManager.getInstance()
                .applyWorkingSets(
                    asset.getMetaData().getPackageName(),
                    wsUUIDs,
                    new Command() {
                      public void execute() {
                        LoadingPopup.close();
                        pop.hide();
                        modeller.refreshWidget();
                        modeller.verifyRule(null, true);
                      }
                    });
          }
        });

    pop.addRow(g);
    pop.addRow(save);
  }
Beispiel #6
0
  private void showEditor(final String dependencyPath) {
    final FormStylePopup editor = new FormStylePopup(images.management(), "Edit Dependency");
    /*		editor.addRow(new HTML("<i>" + "Choose the version you want to depend on"
    				+ "</i>"));
    */
    editor.addAttribute("Dependency Path: ", new Label(parseDependencyPath(dependencyPath)[0]));
    final VersionChooser versionChoose =
        new VersionChooser(
            parseDependencyPath(dependencyPath)[1],
            conf.uuid,
            parseDependencyAssetName(parseDependencyPath(dependencyPath)[0]),
            new Command() {
              public void execute() {
                table.refresh();
              }
            });
    editor.addAttribute("Dependency Version: ", versionChoose);

    HorizontalPanel hp = new HorizontalPanel();
    Button save = new Button("Use selected version");
    hp.add(save);
    save.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            String selectedVersion = versionChoose.getSelectedVersionName();
            if (Window.confirm(
                "Are you sure you want to use version: " + selectedVersion + " as dependency?")) {
              RepositoryServiceFactory.getService()
                  .updateDependency(
                      conf.uuid,
                      encodeDependencyPath(
                          DependencyWidget.parseDependencyPath(dependencyPath)[0], selectedVersion),
                      new GenericCallback<Void>() {
                        public void onSuccess(Void v) {
                          editor.hide();
                          table.refresh();
                        }
                      });
            }
          }
        });

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

    editor.addAttribute("", hp);
    editor.show();
  }
  protected void showChangePattern(ClickEvent w) {

    final ListBox pats = this.loadPatterns();
    if (pats.getItemCount() == 0) {
      showNewPatternDialog();
      return;
    }
    final FormStylePopup pop = new FormStylePopup();
    Button ok = new Button("OK");
    HorizontalPanel hp = new HorizontalPanel();
    hp.add(pats);
    hp.add(ok);

    pop.addAttribute(constants.ChooseExistingPatternToAddColumnTo(), hp);
    pop.addAttribute("", new HTML(constants.ORwithEmphasis()));

    Button createPattern = new Button(constants.CreateNewFactPattern());
    createPattern.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            pop.hide();
            showNewPatternDialog();
          }
        });
    pop.addAttribute("", createPattern);

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            String[] val = pats.getValue(pats.getSelectedIndex()).split("\\s"); // NON-NLS
            editingCol.setFactType(val[0]);
            editingCol.setBoundName(val[1]);
            editingCol.setFactField(null);
            makeLimitedValueWidget();
            doPatternLabel();
            doFieldLabel();
            pop.hide();
          }
        });

    pop.show();
  }
Beispiel #8
0
  public static void showNewSnapshot(final Command refreshCmd) {
    final FormStylePopup pop =
        new FormStylePopup(
            DroolsGuvnorImages.INSTANCE.snapshot(), Constants.INSTANCE.NewSnapshot());
    final RulePackageSelector sel = new RulePackageSelector();

    pop.addAttribute(Constants.INSTANCE.ForPackage(), sel);
    Button ok = new Button(Constants.INSTANCE.OK());
    pop.addAttribute("", ok);
    pop.show();

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            pop.hide();
            String pkg = sel.getSelectedPackage();
            PackageBuilderWidget.showSnapshotDialog(pkg, refreshCmd);
          }
        });
  }
  protected void showNewPatternDialog() {
    final FormStylePopup pop = new FormStylePopup();
    pop.setTitle(constants.NewFactSelectTheType());
    final ListBox types = new ListBox();
    for (int i = 0; i < sce.getFactTypes().length; i++) {
      types.addItem(sce.getFactTypes()[i]);
    }
    pop.addAttribute(constants.FactType(), types);
    final TextBox binding = new TextBox();
    pop.addAttribute(constants.Binding(), binding);

    Button ok = new Button(constants.OK());
    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            editingCol.setBoundName(binding.getText());
            editingCol.setFactType(types.getItemText(types.getSelectedIndex()));
            editingCol.setFactField(null);
            makeLimitedValueWidget();
            doPatternLabel();
            doFieldLabel();
            pop.hide();
          }
        });
    pop.addAttribute("", ok);

    pop.show();
  }
Beispiel #10
0
  public void openAssetsToMultiView(MultiViewRow[] rows) {

    String blockingAssetName = null;
    final String[] uuids = new String[rows.length];
    final String[] names = new String[rows.length];

    for (int i = 0; i < rows.length; i++) {
      // Check if any of these assets are already opened.
      if (explorerViewCenterPanel.showIfOpen(rows[i].uuid)) {
        blockingAssetName = rows[i].name;
        break;
      }
      uuids[i] = rows[i].uuid;
      names[i] = rows[i].name;
    }

    if (blockingAssetName != null) {
      FormStylePopup popup =
          new FormStylePopup(
              images.information(),
              constants.Asset0IsAlreadyOpenPleaseCloseItBeforeOpeningMultiview(blockingAssetName));
      popup.show();
      return;
    }

    MultiViewEditor multiview = new MultiViewEditor(rows, createEditEvent());

    multiview.setCloseCommand(
        new Command() {
          public void execute() {
            explorerViewCenterPanel.close(Arrays.toString(uuids));
          }
        });

    explorerViewCenterPanel.addTab(Arrays.toString(names), multiview, uuids);
  }
  private void doPermissionEditor(final String userName, final Map<String, List<String>> perms) {
    final FormStylePopup editor =
        new FormStylePopup(images.management(), constants.EditUser0(userName));
    editor.addRow(new HTML("<i>" + constants.UserAuthenticationTip() + "</i>"));
    // now render the actual permissions...
    VerticalPanel vp = new VerticalPanel();
    editor.addAttribute("", doPermsPanel(perms, vp));

    HorizontalPanel hp = new HorizontalPanel();
    Button save = new Button(constants.SaveChanges());
    hp.add(save);
    editor.addAttribute("", hp);
    save.addClickHandler(createClickHandlerForSaveButton(userName, perms, editor));

    Button cancel = new Button(constants.Cancel());
    hp.add(cancel);
    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            editor.hide();
          }
        });
    editor.show();
  }
  private void showTypeChoice(Widget w, final VerifyField con) {
    final FormStylePopup form = new FormStylePopup(images.newexWiz(), constants.FieldValue());

    Button lit = new Button(constants.LiteralValue());
    lit.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            con.setNature(FieldData.TYPE_LITERAL);
            doTypeChosen(form);
          }
        });
    form.addAttribute(
        constants.LiteralValue() + ":",
        widgets(lit, new InfoPopup(constants.LiteralValue(), constants.LiteralValTip())));

    form.addRow(new HTML("<hr/>"));
    form.addRow(new SmallLabel(constants.AdvancedOptions()));

    // If we are here, then there must be a bound variable compatible with
    // me

    Button variable = new Button(constants.BoundVariable());
    variable.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            con.setNature(FieldData.TYPE_VARIABLE);
            doTypeChosen(form);
          }
        });
    form.addAttribute(
        constants.AVariable(),
        widgets(variable, new InfoPopup(constants.ABoundVariable(), constants.BoundVariableTip())));

    form.show();
  }
 public void show() {
   pop.show();
 }
 private void doTypeChosen(final FormStylePopup form) {
   refreshEditor();
   form.hide();
 }
Beispiel #15
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;
  }
Beispiel #16
0
  public void openAdministrationSelection(int id) {

    switch (id) {
      case 0:
        if (!explorerViewCenterPanel.showIfOpen(CATMAN)) {
          explorerViewCenterPanel.addTab(
              constants.CategoryManager(), new CategoryManager(), CATMAN);
        }
        break;
      case 1:
        if (!explorerViewCenterPanel.showIfOpen(ARCHMAN)) {
          explorerViewCenterPanel.addTab(
              constants.ArchivedManager(), new ArchivedAssetManager(), ARCHMAN);
        }
        break;

      case 2:
        if (!explorerViewCenterPanel.showIfOpen(STATEMAN)) {
          explorerViewCenterPanel.addTab(constants.StateManager(), new StateManager(), STATEMAN);
        }
        break;
      case 3:
        if (!explorerViewCenterPanel.showIfOpen(BAKMAN)) {
          explorerViewCenterPanel.addTab(constants.ImportExport(), new BackupManager(), BAKMAN);
        }
        break;

      case 4:
        if (!explorerViewCenterPanel.showIfOpen(ERROR_LOG)) {
          explorerViewCenterPanel.addTab(constants.EventLog(), new LogViewer(), ERROR_LOG);
        }
        break;
      case 5:
        if (!explorerViewCenterPanel.showIfOpen(SECURITY_PERMISSIONS)) {
          explorerViewCenterPanel.addTab(
              constants.UserPermissionMappings(), new PermissionViewer(), SECURITY_PERMISSIONS);
        }
        break;
      case 6:
        Frame aboutInfoFrame = new Frame("../AboutInfo.html"); // NON-NLS

        FormStylePopup aboutPop = new FormStylePopup();
        aboutPop.setWidth(600 + "px");
        aboutPop.setTitle(constants.About());
        String hhurl = GWT.getModuleBaseURL() + "webdav";
        aboutPop.addAttribute(constants.WebDAVURL() + ":", new SmallLabel("<b>" + hhurl + "</b>"));
        aboutPop.addAttribute(constants.Version() + ":", aboutInfoFrame);
        aboutPop.show();
        break;

      case 7:
        if (!explorerViewCenterPanel.showIfOpen(RULE_VERIFIER_MANAGER)) {
          explorerViewCenterPanel.addTab(
              constants.RulesVerificationManager(),
              new RuleVerifierManager(),
              RULE_VERIFIER_MANAGER);
        }
        break;
      case 8:
        if (!explorerViewCenterPanel.showIfOpen(REPOCONFIG))
          explorerViewCenterPanel.addTab(
              constants.RepositoryConfig(), new RepoConfigManager(), REPOCONFIG);
        break;
      case 9:
        if (!explorerViewCenterPanel.showIfOpen(WORKSPACES))
          explorerViewCenterPanel.addTab(
              constants.Workspaces(), new WorkspaceManager(), WORKSPACES);
        break;
      case 10:
        openPerspectivesManager();
        break;
    }
  }
  /** 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();
  }