Пример #1
0
  private void showAddNewComment() {
    newCommentLayout.clear();
    final TextArea comment = new TextArea();
    comment.setWidth("100%");
    newCommentLayout.add(comment);

    Button ok = new Button(constants.OK());
    Button cancel = new Button(constants.Cancel());

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            sendNewComment(comment.getText());
          }
        });

    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showNewCommentButton();
          }
        });

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(ok);
    hp.add(cancel);

    newCommentLayout.add(hp);

    comment.setFocus(true);
  }
  public WorkspaceManager() {
    PrettyFormLayout form = new PrettyFormLayout();
    form.addHeader(
        GuvnorImages.INSTANCE.WorkspaceManager(),
        new HTML("<b>" + constants.ManageWorkspaces() + "</b>"));
    form.startSection(constants.Workspaces());

    form.addAttribute("", buildDoubleList());

    HorizontalPanel hPanel = new HorizontalPanel();
    Button create = new Button(constants.AddWorkspace());
    create.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            WorkspaceEditor newCat =
                new WorkspaceEditor(
                    new Command() {
                      public void execute() {
                        refreshWorkspaceList();
                      }
                    });

            newCat.show();
          }
        });

    Button remove = new Button(constants.DeleteSelectedWorkspace());
    remove.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToRemove());
              return;
            }
            removeWorkspace();
          }
        });

    Button updateWorkspace = new Button(constants.UpdateSelectedWorkspace());
    updateWorkspace.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToUpdate());
              return;
            }

            updateWorkspace();
          }
        });
    hPanel.add(create);
    hPanel.add(remove);
    hPanel.add(updateWorkspace);

    form.addAttribute("", hPanel);

    form.endSection();
    initWidget(form);
  }
Пример #3
0
  private void showNewCommentButton() {
    newCommentLayout.clear();

    HorizontalPanel hp = new HorizontalPanel();

    Button createNewComment = new Button(constants.AddADiscussionComment());
    createNewComment.setEnabled(!this.readOnly);
    hp.add(createNewComment);

    if (UserCapabilities.INSTANCE.hasCapability(Capability.SHOW_ADMIN)) {
      Button adminClearAll = new Button(constants.EraseAllComments());
      adminClearAll.setEnabled(!readOnly);
      hp.add(adminClearAll);
      adminClearAll.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent sender) {
              if (Window.confirm(constants.EraseAllCommentsWarning())) {
                assetService.clearAllDiscussionsForAsset(
                    artifact.getUuid(),
                    new GenericCallback<java.lang.Void>() {
                      public void onSuccess(Void v) {
                        updateCommentList(new ArrayList<DiscussionRecord>());
                      }
                    });
              }
            }
          });
    }

    final String feedURL =
        GWT.getModuleBaseURL()
            + "feed/discussion?package="
            + ((Asset) artifact).getMetaData().getModuleName()
            + "&assetName="
            + URL.encode(artifact.getName())
            + "&viewUrl="
            + Util.getSelfURL();
    Image image = new Image(images.feed());
    image.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            Window.open(feedURL, "_blank", null);
          }
        });
    hp.add(image);

    newCommentLayout.add(hp);

    newCommentLayout.setCellHorizontalAlignment(hp, HasHorizontalAlignment.ALIGN_RIGHT);
    createNewComment.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showAddNewComment();
          }
        });
  }
Пример #4
0
  private Widget appendComment(DiscussionRecord r) {
    SmallLabel hrd =
        new SmallLabel(constants.smallCommentBy0On1Small(r.author, new Date(r.timestamp)));
    hrd.addStyleName("discussion-header");
    commentList.add(hrd);

    String[] parts = r.note.split("\n");

    if (parts.length > 0) {
      StringBuilder txtBuilder = new StringBuilder();
      for (int i = 0; i < parts.length; i++) {
        txtBuilder.append(parts[i]);
        if (i != parts.length - 1) {
          txtBuilder.append("<br/>");
        }
      }
      HTML hth = new HTML(txtBuilder.toString());
      hth.setStyleName("form-field");
      commentList.add(hth);
    } else {
      Label lbl = new Label(r.note);
      lbl.setStyleName("form-field");
      commentList.add(lbl);
    }

    commentList.add(new HTML("<br/>"));
    return hrd;
  }
  private void updateWorkspace() {
    String name =
        availableWorkspacesListBox.getItemText(availableWorkspacesListBox.getSelectedIndex());

    List<String> selectedModulesList = new ArrayList<String>(selectedModulesListBox.getItemCount());
    for (int i = 0; i < selectedModulesListBox.getItemCount(); i++) {
      selectedModulesList.add(selectedModulesListBox.getItemText(i));
    }
    List<String> availableModuleList =
        new ArrayList<String>(availableModulesListBox.getItemCount());
    for (int i = 0; i < availableModulesListBox.getItemCount(); i++) {
      availableModuleList.add(availableModulesListBox.getItemText(i));
    }
    availableModuleList.removeAll(selectedModulesList);
    LoadingPopup.showMessage(constants.LoadingStatuses());

    repositoryService.updateWorkspace(
        name,
        selectedModulesList.toArray(new String[selectedModulesList.size()]),
        availableModuleList.toArray(new String[availableModuleList.size()]),
        new GenericCallback<java.lang.Void>() {
          public void onSuccess(Void v) {
            Window.alert(constants.WorkspaceUpdated());
            refreshWorkspaceList();
          }
        });
  }
Пример #6
0
  public DiscussionWidget(final Artifact artifact, boolean readOnly) {
    this.artifact = artifact;
    this.readOnly = readOnly;

    DecoratedDisclosurePanel discussionPanel = new DecoratedDisclosurePanel(constants.Discussion());
    discussionPanel.setWidth("100%");

    commentList.setWidth("100%");
    VerticalPanel discussionLayout = new VerticalPanel();
    discussionLayout.setWidth("90%");

    newCommentLayout.setWidth("100%");
    refreshDiscussion();
    showNewCommentButton();

    discussionLayout.add(newCommentLayout);
    discussionLayout.add(commentList);

    discussionPanel.setContent(discussionLayout);

    pushNotify =
        new ServerPushNotification() {
          public void messageReceived(PushResponse response) {
            if ("discussion".equals(response.messageType)
                && artifact.getUuid().equals(response.message)) {
              System.err.println("Refreshing discussion...");
              refreshDiscussion();
            }
          }
        };

    PushClient.instance().subscribe(pushNotify);

    initWidget(discussionPanel);
  }
 private void refreshWorkspaceList() {
   LoadingPopup.showMessage(constants.LoadingWorkspaces());
   repositoryService.listWorkspaces(
       new GenericCallback<String[]>() {
         public void onSuccess(String[] workspaces) {
           availableWorkspacesListBox.clear();
           for (String workspace : workspaces) {
             availableWorkspacesListBox.addItem(workspace);
           }
           LoadingPopup.close();
         }
       });
 }
  private void refreshModuleList(String selectedWorkspaceName) {
    if (selectedWorkspaceName == null || "".equals(selectedWorkspaceName)) {
      return;
    }

    LoadingPopup.showMessage(constants.LoadingWorkspaces());
    moduleService.listModules(
        selectedWorkspaceName,
        new GenericCallback<Module[]>() {
          public void onSuccess(Module[] packageConfigData) {
            selectedModulesListBox.clear();
            for (Module p : packageConfigData) {
              selectedModulesListBox.addItem(p.getName());
            }
            LoadingPopup.close();
          }
        });

    LoadingPopup.showMessage(constants.LoadingWorkspaces());
    moduleService.listModules(
        new GenericCallback<Module[]>() {
          public void onSuccess(Module[] packageConfigData) {
            availableModulesListBox.clear();
            for (Module p : packageConfigData) {
              boolean isSelected = false;
              for (int i = 0; i < selectedModulesListBox.getItemCount(); i++) {
                if (p.getName().equals(selectedModulesListBox.getItemText(i))) {
                  isSelected = true;
                }
              }
              if (!isSelected) {
                availableModulesListBox.addItem(p.getName());
              }
            }
            LoadingPopup.close();
          }
        });
  }
Пример #9
0
  private void doActions() {
    VerticalPanel actions = new VerticalPanel();
    Image add = GuvnorImages.INSTANCE.NewItem();
    add.setAltText(ConstantsCore.INSTANCE.AssetCategoryEditorAddNewCategory());
    add.setTitle(constants.AddANewCategory());

    add.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            doOKClick();
          }
        });

    actions.add(add);
    layout.setWidget(0, 1, actions);
  }
Пример #10
0
  public void checkin(final boolean closeAfter) {
    final CheckinPopup pop = new CheckinPopup(constants.CheckInChanges());
    pop.setCommand(
        new Command() {

          public void execute() {
            String comment = pop.getCheckinComment();
            for (RuleViewer ruleViewer : ruleViews.values()) {
              doCheckin(ruleViewer.getAssetEditor(), ruleViewer.asset, comment, false);
            }
            if (closeAfter) {
              close();
            }
          }
        });
    pop.show();
  }
Пример #11
0
 /**
  * In some cases we will want to flush the package dependency stuff for suggestion completions.
  * The user will still need to reload the asset editor though.
  */
 public void flushSuggestionCompletionCache(final String packageName, Asset asset) {
   if (AssetFormats.isPackageDependency(asset.getFormat())) {
     LoadingPopup.showMessage(constants.RefreshingContentAssistance());
     eventBus.fireEvent(
         new RefreshModuleDataModelEvent(
             packageName,
             new Command() {
               public void execute() {
                 // Some assets depend on the SuggestionCompletionEngine. This event is to notify
                 // them that the
                 // SuggestionCompletionEngine has been changed, they need to refresh their UI to
                 // represent the changes.
                 eventBus.fireEvent(new RefreshSuggestionCompletionEngineEvent(packageName));
                 LoadingPopup.close();
               }
             }));
   }
 }
Пример #12
0
  private void loadData(FlexTable list) {
    for (int i = 0; i < data.getCategories().length; i++) {
      final int idx = i;

      list.setWidget(i, 0, new SmallLabel(data.getCategories()[i]));
      if (!readOnly) {

        Image del = GuvnorImages.INSTANCE.Trash();
        del.setTitle(constants.RemoveThisCategory());
        del.addClickHandler(
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                removeCategory(idx);
              }
            });
        list.setWidget(i, 1, del);
      }
    }
  }
Пример #13
0
  private void restore(Widget w, final String versionUUID, final Command refresh) {

    final CheckinPopup pop = new CheckinPopup(constants.RestoreThisVersionQ());
    pop.setCommand(
        new Command() {
          public void execute() {
            AssetServiceAsync assetService = GWT.create(AssetService.class);
            assetService.restoreVersion(
                versionUUID,
                uuid,
                pop.getCheckinComment(),
                new GenericCallback<Void>() {
                  public void onSuccess(Void v) {
                    refresh.execute();
                  }
                });
          }
        });
    pop.show();
  }
Пример #14
0
  private void performCheckIn(String comment, final boolean closeAfter, final Asset asset) {
    asset.setCheckinComment(comment);
    final boolean[] saved = {false};

    if (!saved[0]) LoadingPopup.showMessage(constants.SavingPleaseWait());
    RepositoryServiceFactory.getAssetService()
        .checkinVersion(
            asset,
            new GenericCallback<String>() {

              public void onSuccess(String uuid) {
                if (uuid == null) {
                  ErrorPopup.showMessage(
                      constants.FailedToCheckInTheItemPleaseContactYourSystemAdministrator());
                  return;
                }

                if (uuid.startsWith("ERR")) { // NON-NLS
                  ErrorPopup.showMessage(uuid.substring(5));
                  return;
                }

                flushSuggestionCompletionCache(asset.getMetaData().getModuleName(), asset);
                /*                        if ( editor instanceof DirtyableComposite ) {
                    ((DirtyableComposite) editor).resetDirty();
                }*/

                LoadingPopup.close();
                saved[0] = true;

                // showInfoMessage( constants.SavedOK() );
                if (!closeAfter) {
                  eventBus.fireEvent(
                      new RefreshAssetEditorEvent(asset.getMetaData().getModuleName(), uuid));
                }

                // fire after check-in event
                eventBus.fireEvent(new AfterAssetEditorCheckInEvent(uuid, MultiViewEditor.this));
              }
            });
  }
Пример #15
0
  public VersionBrowser(
      ClientFactory clientFactory, EventBus eventBus, String uuid, boolean isPackage) {
    this.clientFactory = clientFactory;
    this.eventBus = eventBus;
    this.uuid = uuid;
    this.isPackage = isPackage;

    HorizontalPanel wrapper = new HorizontalPanel();

    ClickHandler clickHandler =
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            clickLoadHistory();
          }
        };
    layout = new FlexTable();
    ClickableLabel vh = new ClickableLabel(constants.VersionHistory1(), clickHandler);
    layout.setWidget(0, 0, vh);
    layout.getCellFormatter().setStyleName(0, 0, "metadata-Widget"); // NON-NLS
    FlexCellFormatter formatter = layout.getFlexCellFormatter();
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);

    refresh = new ImageButton(images.refresh());

    refresh.addClickHandler(clickHandler);

    layout.setWidget(0, 1, refresh);
    formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);

    wrapper.setStyleName("version-browser-Border");

    wrapper.add(layout);

    layout.setWidth("100%");
    wrapper.setWidth("100%");

    initWidget(wrapper);
  }
  private Grid buildDoubleList() {
    Grid grid = new Grid(2, 5);

    availableWorkspacesListBox = new ListBox();
    availableWorkspacesListBox.setVisibleItemCount(10);
    availableWorkspacesListBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent arg0) {
            String selectedWorkspaceName =
                availableWorkspacesListBox.getItemText(
                    availableWorkspacesListBox.getSelectedIndex());
            refreshModuleList(selectedWorkspaceName);
          }
        });
    // availableWorkspaces.setWidth( "30%" );

    refreshWorkspaceList();

    try {
      availableModulesListBox.setVisibleItemCount(10);
      selectedModulesListBox.setVisibleItemCount(10);

      Grid btnsPanel = new Grid(2, 1);

      btnsPanel.setWidget(
          0,
          0,
          new Button(
              ">",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(availableModulesListBox, selectedModulesListBox);
                }
              }));

      btnsPanel.setWidget(
          1,
          0,
          new Button(
              "&lt;",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(selectedModulesListBox, availableModulesListBox);
                }
              }));

      grid.setWidget(0, 0, new SmallLabel(constants.Workspaces()));
      grid.setWidget(0, 2, new SmallLabel("Workspace: Available Modules"));
      grid.setWidget(0, 3, new SmallLabel(""));
      grid.setWidget(0, 4, new SmallLabel("Workspace: Selected Modules"));
      grid.setWidget(1, 0, availableWorkspacesListBox);
      grid.setWidget(1, 2, availableModulesListBox);
      grid.setWidget(1, 3, btnsPanel);
      grid.setWidget(1, 4, selectedModulesListBox);

      grid.getColumnFormatter().setWidth(0, "25%");
      grid.getColumnFormatter().setWidth(1, "10%");
      grid.getColumnFormatter().setWidth(2, "25%");
      grid.getColumnFormatter().setWidth(3, "15%");
      grid.getColumnFormatter().setWidth(4, "25%");
      return grid;
    } finally {
      // sce.setFilteringFacts( filteringFact );
    }
  }
Пример #17
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();
            }
          });
    }
  }