private DynamicForm createSummaryForm() {

    DynamicForm form = new DynamicForm();
    form.setWidth100();
    form.setColWidths("20%", "40%", "40%");
    form.setNumCols(3);
    form.setAutoHeight();
    form.setWrapItemTitles(false);
    form.setExtraSpace(10);
    form.setIsGroup(true);
    form.setGroupTitle(MSG.common_title_summary());
    form.setPadding(5);

    CanvasItem actionItem = new CanvasItem("actions");
    actionItem.setColSpan(1);
    actionItem.setRowSpan(4);
    actionItem.setShowTitle(false);
    actionItem.setCanvas(getActionLayout());

    StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version());
    versionItem.setValue(version.getVersion());

    StaticTextItem liveDeploymentsItem =
        new StaticTextItem("deployments", MSG.view_bundle_deployments());
    liveDeploymentsItem.setValue(version.getBundleDeployments().size());

    StaticTextItem filesItems = new StaticTextItem("files", MSG.view_bundle_files());
    filesItems.setValue(version.getBundleFiles().size());

    StaticTextItem descriptionItem =
        new StaticTextItem("description", MSG.common_title_description());
    descriptionItem.setValue(version.getDescription());

    form.setFields(versionItem, actionItem, liveDeploymentsItem, filesItems, descriptionItem);
    return form;
  }
Example #2
0
  private DynamicForm buildEditForm() {
    editForm = new LocatableDynamicForm(extendLocatorId("Editor"));
    editForm.setMargin(5);
    editForm.setAutoWidth();
    editForm.setNumCols(canEditName() ? 12 : 10);

    TextItem nameItem = null;
    if (dashboardContainer.supportsDashboardNameEdit()) {
      nameItem = new TextItem("name", MSG.common_title_dashboard_name());
      nameItem.setValue(storedDashboard.getName());
      nameItem.setLength(200);
      nameItem.setWrapTitle(false);
      nameItem.addBlurHandler(
          new BlurHandler() {
            public void onBlur(BlurEvent blurEvent) {
              FormItem nameItem = blurEvent.getItem();
              String name = (String) nameItem.getValue();
              String trimmedName = (name == null) ? "" : name.trim();
              if (dashboardContainer.isValidDashboardName(trimmedName)) {
                storedDashboard.setName(trimmedName);
                save();
                dashboardContainer.updateDashboardNames();
              } else {
                // TODO: i18n
                Message message =
                    new Message(
                        "There is already a dashboard named '"
                            + trimmedName
                            + "'. Please specify a name that is not already in use.",
                        Message.Severity.Error,
                        EnumSet.of(Message.Option.Transient));
                CoreGUI.getMessageCenter().notify(message);
                nameItem.setValue(storedDashboard.getName());
              }
            }
          });
    }

    final StaticTextItem numColItem = new StaticTextItem();
    numColItem.setTitle(MSG.common_title_columns());
    numColItem.setValue(storedDashboard.getColumns());

    ButtonItem addColumn = new ButtonItem("addColumn", MSG.common_title_add_column());
    addColumn.setAutoFit(true);
    addColumn.setStartRow(false);
    addColumn.setEndRow(false);

    final ButtonItem removeColumn =
        new ButtonItem("removeColumn", MSG.common_title_remove_column());
    removeColumn.setAutoFit(true);
    removeColumn.setStartRow(false);
    removeColumn.setEndRow(false);
    removeColumn.setDisabled(storedDashboard.getColumns() == 1);

    addColumn.addClickHandler(
        new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
          public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
            portalLayout.addMember(new PortalColumn());
            numColItem.setValue(storedDashboard.getColumns() + 1);
            storedDashboard.setColumns(storedDashboard.getColumns() + 1);
            removeColumn.setDisabled(storedDashboard.getColumns() == 1);
            save();
          }
        });

    removeColumn.addClickHandler(
        new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
          public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {

            Canvas[] columns = portalLayout.getMembers();
            int numColumns = columns.length;
            if (numColumns > 0) {
              PortalColumn lastColumn = (PortalColumn) columns[numColumns - 1];
              for (Canvas portletWindow : lastColumn.getMembers()) {
                storedDashboard.removePortlet(((PortletWindow) portletWindow).getStoredPortlet());
              }
              portalLayout.removeMember(lastColumn);
              numColItem.setValue(numColumns - 1);
              storedDashboard.setColumns(storedDashboard.getColumns() - 1);
              removeColumn.setDisabled(storedDashboard.getColumns() == 1);
              save();
            }
          }
        });

    // build the menu of valid portlets for this context, sorted by portlet name
    final Menu addPortletMenu = new LocatableMenu(editForm.extendLocatorId("PortletMenu"));
    LinkedHashMap<String, String> valueMap;

    switch (context.getType()) {
      case SubsystemView:
        valueMap = PortletFactory.getGlobalPortletMenuMap();
        break;

      case ResourceGroup:
        valueMap = processPortletNameMapForGroup(this.groupComposite);
        // In addition to the group-specific portlets, make the global portlets available
        valueMap.putAll(PortletFactory.getGlobalPortletMenuMap());
        break;

      case Resource:
        valueMap = processPortletNameMapForResource(this.resourceComposite);
        // In addition to the resource-specific portlets, make the global portlets available
        valueMap.putAll(PortletFactory.getGlobalPortletMenuMap());
        break;

      default:
        throw new IllegalStateException("Unsupported context [" + context + "]");
    }
    for (Iterator<String> i = valueMap.keySet().iterator(); i.hasNext(); ) {
      String portletKey = i.next();
      String portletName = valueMap.get(portletKey);
      MenuItem menuItem = new MenuItem(portletName);
      menuItem.setAttribute("portletKey", portletKey);
      addPortletMenu.addItem(menuItem);
    }

    addPortlet =
        new LocatableIMenuButton(
            editForm.extendLocatorId("AddPortlet"), MSG.common_title_add_portlet(), addPortletMenu);
    addPortlet.setIcon("[skin]/images/actions/add.png");
    addPortlet.setAutoFit(true);

    addPortletMenu.addItemClickHandler(
        new ItemClickHandler() {
          public void onItemClick(ItemClickEvent itemClickEvent) {
            String key = itemClickEvent.getItem().getAttribute("portletKey");
            String name = itemClickEvent.getItem().getTitle();
            addPortlet(key, name);
          }
        });

    CanvasItem addCanvas = new CanvasItem();
    addCanvas.setShowTitle(false);
    addCanvas.setCanvas(addPortlet);
    addCanvas.setStartRow(false);
    addCanvas.setEndRow(false);

    ColorButtonItem picker = new ColorButtonItem("colorButton", MSG.common_title_background());
    picker.setStartRow(false);
    picker.setEndRow(false);
    picker.setCurrentColor(
        storedDashboard.getConfiguration().getSimpleValue(Dashboard.CFG_BACKGROUND, "white"));
    picker.setColorSelectedHandler(
        new ColorSelectedHandler() {
          @Override
          public void onColorSelected(ColorSelectedEvent event) {
            String selectedColor = event.getColor();
            if (selectedColor != null) {
              setBackgroundColor(selectedColor);
              storedDashboard
                  .getConfiguration()
                  .put(new PropertySimple(Dashboard.CFG_BACKGROUND, selectedColor));
              save();
            }
          }
        });

    // refresh interval
    LocatableMenu refreshMenu = new LocatableMenu("AutoRefreshMenu");
    refreshMenu.setShowShadow(true);
    refreshMenu.setShadowDepth(10);
    refreshMenu.setAutoWidth();
    refreshMenu.setHeight(15);
    ClickHandler menuClick =
        new ClickHandler() {
          @Override
          public void onClick(MenuItemClickEvent event) {
            String selection = event.getItem().getTitle();
            refreshInterval = 0;
            if (selection != null) {
              if (selection.equals(STOP)) {
                refreshInterval = STOP_VALUE;
              } else if (selection.equals(REFRESH1)) {
                refreshInterval = REFRESH1_VALUE;
              } else if (selection.equals(REFRESH5)) {
                refreshInterval = REFRESH5_VALUE;
              } else if (selection.equals(REFRESH10)) {
                refreshInterval = REFRESH10_VALUE;
              } else { // unable to locate value disable refresh
                refreshInterval = STOP_VALUE; //
              }
              UserSessionManager.getUserPreferences()
                  .setPageRefreshInterval(refreshInterval, new UpdatePortletRefreshCallback());
            }
          }
        };

    String[] refreshIntervals = {STOP, REFRESH1, REFRESH5, REFRESH10};
    Integer[] refreshValues = {STOP_VALUE, REFRESH1_VALUE, REFRESH5_VALUE, REFRESH10_VALUE};
    refreshMenuMappings = new HashMap<Integer, String>();
    refreshMenuItems = new MenuItem[refreshIntervals.length];
    int retrievedRefreshInterval = REFRESH1_VALUE;
    if (null != UserSessionManager.getUserPreferences()) {
      retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
    }
    for (int i = 0; i < refreshIntervals.length; i++) {
      MenuItem item = new MenuItem(refreshIntervals[i], "");
      item.addClickHandler(menuClick);
      refreshMenuMappings.put(refreshValues[i], refreshIntervals[i]);
      if (retrievedRefreshInterval == refreshValues[i]) {
        item.setIcon(ImageManager.getAvailabilityIcon(true));
      }
      refreshMenuItems[i] = item;
    }

    refreshMenu.setItems(refreshMenuItems);
    refreshMenuButton =
        new LocatableIMenuButton(
            "AutoRefreshButton", MSG.common_title_change_refresh_time(), refreshMenu);
    refreshMenu.setAutoHeight();
    refreshMenuButton.getMenu().setItems(refreshMenuItems);
    refreshMenuButton.setWidth(140);
    refreshMenuButton.setShowTitle(true);
    refreshMenuButton.setTop(0);
    refreshMenuButton.setIconOrientation("left");

    CanvasItem refreshCanvas = new CanvasItem();
    refreshCanvas.setShowTitle(false);
    refreshCanvas.setCanvas(refreshMenuButton);
    refreshCanvas.setStartRow(false);
    refreshCanvas.setEndRow(false);

    if (null != nameItem) {
      editForm.setItems(
          nameItem, addCanvas, numColItem, addColumn, removeColumn, picker, refreshCanvas);
    } else {
      editForm.setItems(addCanvas, numColItem, addColumn, removeColumn, picker, refreshCanvas);
    }

    updateRefreshMenu();
    this.refreshMenuButton.markForRedraw();

    markForRedraw();

    // attempt to initialize
    editForm.markForRedraw();
    markForRedraw();

    return editForm;
  }
Example #3
0
 private void disableCanvasItem(CanvasItem obj, boolean disabled) {
   if (obj.isDrawn()) {
     obj.setDisabled(disabled);
   }
 }
Example #4
0
  private void buildInstallInfoCanvas(AgentInstallInfo info) {
    DynamicForm infoForm = new DynamicForm();
    infoForm.setMargin(20);
    infoForm.setWidth100();
    infoForm.setHeight100();

    HeaderItem infoHeader = new HeaderItem();
    infoHeader.setValue(MSG.view_remoteAgentInstall_installInfo());

    StaticTextItem version = new StaticTextItem("version", MSG.common_title_version());
    version.setValue(info.getVersion());

    StaticTextItem path = new StaticTextItem("path", MSG.common_title_path());
    path.setValue(info.getPath());

    StaticTextItem owner = new StaticTextItem("owner", MSG.common_title_owner());
    owner.setValue(info.getOwner());

    StaticTextItem config = new StaticTextItem("config", MSG.common_title_configuration());
    config.setValue(info.getConfigurationStartString());

    CanvasItem listCanvas = new CanvasItem();
    listCanvas.setShowTitle(false);
    listCanvas.setColSpan(2);

    VLayout listLayout = new VLayout(0);
    listLayout.setWidth100();
    listLayout.setHeight100();

    ListGrid listGrid =
        new ListGrid() {
          @Override
          protected Canvas getExpansionComponent(ListGridRecord record) {
            Canvas canvas = super.getExpansionComponent(record);
            canvas.setPadding(5);
            return canvas;
          }
        };
    listGrid.setWidth100();
    listGrid.setHeight100();
    listGrid.setCanExpandRecords(true);
    listGrid.setExpansionMode(ExpansionMode.DETAIL_FIELD);
    listGrid.setDetailField("result");
    ListGridField step = new ListGridField("description", MSG.view_remoteAgentInstall_step());
    ListGridField result = new ListGridField("result", MSG.view_remoteAgentInstall_result());
    ListGridField resultCode =
        new ListGridField("resultCode", MSG.view_remoteAgentInstall_resultCode(), 90);
    ListGridField duration = new ListGridField("duration", MSG.common_title_duration(), 90);
    listGrid.setFields(step, result, resultCode, duration);
    listGrid.setData(getStepRecords(info));

    listLayout.addMember(listGrid);
    listCanvas.setCanvas(listLayout);

    // Replace the current info with just the install steps
    for (Canvas canvas : this.getChildren()) {
      canvas.markForDestroy();
    }

    createAgentStatusTextItem();
    infoForm.setFields(infoHeader, version, path, owner, config, agentStatusText, listCanvas);

    addMember(infoForm);

    this.setMembersMargin(1);
    this.markForRedraw();
  }
  private void prepareDetailsSection(SectionStack stack, ServerPlugin plugin) {
    DynamicForm form = new DynamicForm();
    form.setMargin(10);
    form.setWidth100();
    form.setWrapItemTitles(false);
    form.setNumCols(4);

    StaticTextItem nameItem = new StaticTextItem("name", MSG.common_title_name());
    nameItem.setValue(plugin.getName());

    StaticTextItem displayNameItem =
        new StaticTextItem("displayName", MSG.common_title_display_name());
    displayNameItem.setValue(plugin.getDisplayName());

    StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version());
    versionItem.setValue(plugin.getVersion());

    StaticTextItem md5Item = new StaticTextItem("MD5", "MD5");
    md5Item.setValue(plugin.getMD5());

    StaticTextItem pathItem = new StaticTextItem("path", MSG.common_title_path());
    pathItem.setValue(plugin.getPath());

    StaticTextItem ampsItem =
        new StaticTextItem("ampsVersion", "AMPS " + MSG.common_title_version());
    ampsItem.setValue(plugin.getAmpsVersion());

    StaticTextItem descItem = new StaticTextItem("desc", MSG.common_title_description());
    descItem.setValue(plugin.getDescription());

    StaticTextItem mtimeItem = new StaticTextItem("mtime", MSG.common_title_lastUpdated());
    mtimeItem.setValue(
        TimestampCellFormatter.format(
            Long.valueOf(plugin.getMtime()), TimestampCellFormatter.DATE_TIME_FORMAT_MEDIUM));

    StaticTextItem kindItem = new StaticTextItem("kind", MSG.common_title_kind());
    switch (plugin.getDeployment()) {
      case AGENT:
        kindItem.setValue(MSG.view_admin_plugins_agent());
        break;
      case SERVER:
        kindItem.setValue(MSG.view_admin_plugins_server());
        break;
    }

    CanvasItem enabledItem = new CanvasItem("enabled", MSG.common_title_enabled());
    Img img = new Img(ImageManager.getAvailabilityIcon(plugin.isEnabled()), 16, 16);
    enabledItem.setCanvas(img);

    StaticTextItem typeItem = new StaticTextItem("type", MSG.common_title_type());
    typeItem.setValue(plugin.getType());

    form.setItems(
        displayNameItem,
        nameItem,
        versionItem,
        ampsItem,
        md5Item,
        kindItem,
        descItem,
        pathItem,
        mtimeItem,
        enabledItem,
        typeItem);

    SectionStackSection section = new SectionStackSection(MSG.common_title_details());
    section.setExpanded(true);
    section.setItems(form);

    detailsSection = section;
    ++initSectionCount;

    return;
  }