Пример #1
0
  @Inject
  public ColumnServerView(final PlaceManager placeManager, PreviewContentFactory contentFactory) {
    super();
    this.placeManager = placeManager;
    this.contentFactory = contentFactory;

    contentCanvas = new LayoutPanel();

    splitlayout = new SplitLayoutPanel(2);
    columnManager = new ColumnManager(splitlayout, FinderColumn.FinderId.CONFIGURATION);

    config =
        new FinderColumn<FinderItem>(
            FinderColumn.FinderId.CONFIGURATION,
            "Configuration",
            new FinderColumn.Display<FinderItem>() {

              @Override
              public boolean isFolder(FinderItem data) {
                return data.isFolder();
              }

              @Override
              public SafeHtml render(String baseCss, FinderItem data) {
                return TEMPLATE.item(baseCss, data.getTitle());
              }

              @Override
              public String rowCss(FinderItem data) {
                return data.getTitle().equals("Subsystems") ? "no-menu" : "";
              }
            },
            new ProvidesKey<FinderItem>() {
              @Override
              public Object getKey(FinderItem item) {
                return item.getTitle();
              }
            },
            NameTokens.ServerProfile);

    config.setPreviewFactory(
        new PreviewFactory<FinderItem>() {
          @Override
          public void createPreview(FinderItem data, AsyncCallback<SafeHtml> callback) {
            SafeHtmlBuilder html = new SafeHtmlBuilder();
            html.appendHtmlConstant("<div class='preview-content'><h2>")
                .appendEscaped(data.getTitle())
                .appendHtmlConstant("</h2>");
            html.appendEscaped(resolveDescriptionFor(data.getTitle()));
            html.appendHtmlConstant("</div>");
            callback.onSuccess(html.toSafeHtml());
          }
        });

    config.setMenuItems(
        new MenuDelegate<FinderItem>(
            "View",
            new ContextualCommand<FinderItem>() {
              @Override
              public void executeOn(FinderItem item) {
                item.getCmd().execute();
              }
            }));

    configLinks = new ArrayList<>();

    configLinks.add(
        new FinderItem(
            "Subsystems",
            new Command() {
              @Override
              public void execute() {
                // noop
              }
            },
            true));

    configLinks.add(
        new FinderItem(
            "Interfaces",
            new Command() {
              @Override
              public void execute() {
                placeManager.revealRelativePlace(new PlaceRequest(NameTokens.InterfacePresenter));
              }
            },
            false));

    configLinks.add(
        new FinderItem(
            "Socket Binding",
            new Command() {
              @Override
              public void execute() {
                placeManager.revealRelativePlace(
                    new PlaceRequest(NameTokens.SocketBindingPresenter));
              }
            },
            false));

    configLinks.add(
        new FinderItem(
            "Paths",
            new Command() {
              @Override
              public void execute() {
                placeManager.revealRelativePlace(
                    new PlaceRequest(NameTokens.PathManagementPresenter));
              }
            },
            false));

    configLinks.add(
        new FinderItem(
            "System Properties",
            new Command() {
              @Override
              public void execute() {
                placeManager.revealRelativePlace(new PlaceRequest(NameTokens.PropertiesPresenter));
              }
            },
            false));

    subsystems =
        new FinderColumn<SubsystemLink>(
            FinderColumn.FinderId.CONFIGURATION,
            "Subsystem",
            new FinderColumn.Display<SubsystemLink>() {

              @Override
              public boolean isFolder(SubsystemLink data) {
                return data.isFolder();
              }

              @Override
              public SafeHtml render(String baseCss, SubsystemLink data) {
                return TEMPLATE.item(baseCss, data.getTitle());
              }

              @Override
              public String rowCss(SubsystemLink data) {
                return data.isFolder() ? "no-menu" : "";
              }
            },
            new ProvidesKey<SubsystemLink>() {
              @Override
              public Object getKey(SubsystemLink item) {
                return item.getToken();
              }
            },
            NameTokens.ServerProfile);

    subsystems.setValueProvider(
        new ValueProvider<SubsystemLink>() {
          @Override
          public String get(SubsystemLink item) {
            return item.getTitle();
          }
        });

    subsystems.setMenuItems(
        new MenuDelegate<SubsystemLink>(
            "View",
            new ContextualCommand<SubsystemLink>() {
              @Override
              public void executeOn(final SubsystemLink link) {
                Scheduler.get()
                    .scheduleDeferred(
                        new Scheduler.ScheduledCommand() {
                          @Override
                          public void execute() {
                            placeManager.revealRelativePlace(new PlaceRequest(link.getToken()));
                          }
                        });
              }
            }));

    subsystems.setPreviewFactory(
        new PreviewFactory<SubsystemLink>() {
          @Override
          public void createPreview(SubsystemLink data, AsyncCallback<SafeHtml> callback) {
            PreviewContent content = PreviewContent.INSTANCE;
            ExternalTextResource resource =
                (ExternalTextResource) content.getResource(data.getToken().replace("-", "_"));
            if (resource != null) {
              contentFactory.createContent(resource, callback);
            } else {
              SafeHtmlBuilder builder = new SafeHtmlBuilder();
              String icon = "icon-folder-close-alt";
              builder.appendHtmlConstant(
                  "<center><i class='"
                      + icon
                      + "' style='font-size:48px;top:100px;position:relative'></i></center>");
              callback.onSuccess(builder.toSafeHtml());
            }
          }
        });

    subsystColWidget = subsystems.asWidget();

    configColWidget = config.asWidget();

    columnManager.addWest(configColWidget);
    columnManager.addWest(subsystColWidget);
    columnManager.add(contentCanvas);

    columnManager.setInitialVisible(1);

    // event handler

    config.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent selectionChangeEvent) {
            columnManager.reduceColumnsTo(1);
            if (config.hasSelectedItem()) {
              FinderItem item = config.getSelectedItem();
              columnManager.updateActiveSelection(configColWidget);

              clearNestedPresenter();

              if ("Subsystems".equals(item.getTitle())) {

                columnManager.appendColumn(subsystColWidget);
                presenter.loadSubsystems();
              }
            } else {
              startupContent();
            }
          }
        });

    subsystems.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent event) {

            if (subsystems.hasSelectedItem()) {

              final SubsystemLink link = subsystems.getSelectedItem();
              columnManager.updateActiveSelection(subsystColWidget);

              if (link.isFolder()) {
                // hb: some trickery with regard to nested presenters
                // it needs to be relative, but should not append to existing hirarchies
                List<PlaceRequest> next = new ArrayList<PlaceRequest>(2);
                next.add(placeManager.getCurrentPlaceHierarchy().get(0));
                next.add(new PlaceRequest(link.getToken()));
                placeManager.revealPlaceHierarchy(next);
              } else {
                clearNestedPresenter();
              }
            }
          }
        });
  }
Пример #2
0
  @Override
  public void toggleScrolling(boolean enforceScrolling, int requiredWidth) {

    columnManager.toogleScrolling(enforceScrolling, requiredWidth);
  }