private void buildPerspective(final PanelDefinition panel) {
   for (PanelDefinition child : panel.getChildren()) {
     final PanelDefinition target =
         panelManager.addWorkbenchPanel(panel, child, child.getPosition());
     addChildren(target);
   }
 }
  /**
   * Adds the given part to the view returned by {@link #getPanelView()}, ignoring the given {@code
   * contextId}. Subclasses that care about context id's will override this method.
   */
  @Override
  public void addPart(final WorkbenchPartPresenter part, final String contextId) {

    // special case: when new perspectives are being built up based on definitions,
    // our definition will already say it contains the given part! We should not try to add it
    // again.
    if (!definition.getParts().contains(part.getDefinition())) {
      definition.addPart(part.getDefinition());
    }
    getPanelView().addPart(part.getPartView());
  }
  PerspectiveDefinition buildPerspective() {
    PerspectiveDefinition perspective =
        new PerspectiveDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName());
    perspective.setName("Preferences");

    final PanelDefinition actionsBar =
        new PanelDefinitionImpl(StaticWorkbenchPanelPresenter.class.getName());
    actionsBar.setHeight(80);
    actionsBar.addPart(
        new PartDefinitionImpl(
            new DefaultPlaceRequest(PreferencesCentralActionsScreen.IDENTIFIER)));

    perspective.getRoot().insertChild(CompassPosition.SOUTH, actionsBar);

    return perspective;
  }
 private void addChildren(final PanelDefinition panel) {
   Set<PartDefinition> parts = panel.getParts();
   for (PartDefinition part : parts) {
     final PlaceRequest place = clonePlaceAndMergeParameters(part.getPlace());
     part.setPlace(place);
     placeManager.goTo(part, panel);
   }
   buildPerspective(panel);
 }
 /**
  * This base implementation should be sufficient for most panels. It modifies the panel definition
  * and adds the child view to this panel's view. In case the requested position is already in use
  * for this panel, this method will throw an {@link IllegalStateException}. Subclasses may
  * override and implement some other collision avoidance strategy.
  */
 @Override
 public void addPanel(final WorkbenchPanelPresenter child, final Position position) {
   if (childPanels.containsKey(position)) {
     throw new IllegalStateException("This panel already has a " + position + " child");
   }
   definition.insertChild(position, child.getDefinition());
   getPanelView().addPanel(child.getDefinition(), child.getPanelView(), position);
   childPanels.put(position, child);
   child.setParent(this);
 }
  @Perspective
  public PerspectiveDefinition getPerspective() {
    final PerspectiveDefinition perspective =
        new PerspectiveDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName());
    perspective.setName(constants.Administration());

    perspective
        .getRoot()
        .addPart(new PartDefinitionImpl(new DefaultPlaceRequest("RepositoriesEditor")));

    final PanelDefinition west =
        new PanelDefinitionImpl(SimpleWorkbenchPanelPresenter.class.getName());
    west.setWidth(300);
    west.setMinWidth(200);
    west.addPart(new PartDefinitionImpl(new DefaultPlaceRequest("FileExplorer")));

    perspective.getRoot().insertChild(CompassPosition.WEST, west);

    return perspective;
  }
 @Override
 public boolean removePanel(WorkbenchPanelPresenter child) {
   Position position = positionOf(child);
   if (position == null) {
     return false;
   }
   getPanelView().removePanel(child.getPanelView());
   definition.removeChild(position);
   childPanels.remove(position);
   child.setParent(null);
   return true;
 }
 @Override
 public void setDefinition(final PanelDefinition definition) {
   this.definition = definition;
   view.setElementId(definition.getElementId());
 }
 private boolean contains(final PartDefinition part) {
   return definition.getParts().contains(part);
 }
 @Override
 public boolean removePart(final PartDefinition part) {
   view.removePart(part);
   return definition.removePart(part);
 }