コード例 #1
0
  private void prepareControlsSection(final SectionStack stack, final ServerPlugin plugin) {
    PluginKey pluginKey = PluginKey.createServerPluginKey(plugin.getType(), plugin.getName());

    pluginManager.getServerPluginControlDefinitions(
        pluginKey,
        new AsyncCallback<ArrayList<ServerPluginControlDefinition>>() {
          public void onSuccess(ArrayList<ServerPluginControlDefinition> result) {
            if (result != null && !result.isEmpty()) {
              SectionStackSection section =
                  new SectionStackSection(MSG.view_admin_plugins_serverControls());
              section.setExpanded(false);
              section.addItem(new ServerPluginControlView(plugin, result));

              controlsSection = section;
            }
            ++initSectionCount;
          }

          public void onFailure(Throwable caught) {
            CoreGUI.getErrorHandler().handleError(MSG.view_admin_plugins_loadFailure(), caught);
          }
        });
  }
コード例 #2
0
  private void prepareScheduledJobsSection(final SectionStack stack, final ServerPlugin plugin) {
    final PluginKey pluginKey = PluginKey.createServerPluginKey(plugin.getType(), plugin.getName());

    pluginManager.getServerPluginScheduledJobsDefinition(
        pluginKey,
        new AsyncCallback<ConfigurationDefinition>() {
          public void onSuccess(ConfigurationDefinition def) {
            if (def != null) {
              EnhancedVLayout layout = new EnhancedVLayout();

              ToolStrip buttons = new ToolStrip();
              buttons.setWidth100();
              buttons.setExtraSpace(10);
              buttons.setMembersMargin(5);
              buttons.setLayoutMargin(5);

              final IButton saveButtonSJ = new EnhancedIButton(MSG.common_button_save());
              buttons.addMember(saveButtonSJ);

              final IButton resetButtonSJ = new EnhancedIButton(MSG.common_button_reset());
              buttons.addMember(resetButtonSJ);

              Configuration config = plugin.getScheduledJobsConfiguration();
              final ConfigurationEditor editorSJ = new ConfigurationEditor(def, config);
              editorSJ.setOverflow(Overflow.AUTO);
              editorSJ.addPropertyValueChangeListener(
                  new PropertyValueChangeListener() {
                    public void propertyValueChanged(PropertyValueChangeEvent event) {
                      if (event.isInvalidPropertySetChanged()) {
                        Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
                        if (invalidPropertyNames.isEmpty()) {
                          saveButtonSJ.enable();
                        } else {
                          saveButtonSJ.disable();
                        }
                      }
                    }
                  });

              resetButtonSJ.addClickHandler(
                  new ClickHandler() {
                    public void onClick(ClickEvent event) {
                      editorSJ.reset();
                    }
                  });

              saveButtonSJ.addClickHandler(
                  new ClickHandler() {
                    public void onClick(ClickEvent event) {
                      if (!editorSJ.validate()) {
                        Message msg =
                            new Message(
                                MSG.view_admin_plugins_serverConfig_badSettings(),
                                Severity.Warning,
                                EnumSet.of(Message.Option.Transient));
                        CoreGUI.getMessageCenter().notify(msg);
                        return;
                      }
                      pluginManager.updateServerPluginScheduledJobs(
                          pluginKey,
                          editorSJ.getConfiguration(),
                          new AsyncCallback<Void>() {
                            public void onSuccess(Void result) {
                              Message m =
                                  new Message(MSG.view_admin_plugins_serverConfig_settingsSaved());
                              CoreGUI.getMessageCenter().notify(m);
                            }

                            public void onFailure(Throwable caught) {
                              CoreGUI.getErrorHandler()
                                  .handleError(
                                      MSG.view_admin_plugins_serverConfig_saveFailed(), caught);
                            }
                          });
                    }
                  });

              layout.addMember(buttons);
              layout.addMember(editorSJ);

              SectionStackSection section =
                  new SectionStackSection(MSG.view_admin_plugins_serverScheduleJobs());
              section.setExpanded(false);
              section.setItems(layout);

              scheduledJobsSection = section;
            }

            ++initSectionCount;
          }

          @Override
          public void onFailure(Throwable caught) {
            CoreGUI.getErrorHandler().handleError(MSG.view_admin_plugins_loadFailure(), caught);
          }
        });
    return;
  }