public AliveDashboardMediator(Shell shell, DashboardPart dashboardPart) {
    this.dashboardPart = dashboardPart;
    state = new AliveDashboardState();
    locations = new HashMap<String, ActionContainer>();
    contributions = new HashMap<DashboardActionDescriptor, IFigure>();
    this.shell = shell;

    IConfigurationElement[] config =
        Platform.getExtensionRegistry()
            .getConfigurationElementsFor("net.sf.ictalive.aliveclipse.dashboard.actions");
    for (IConfigurationElement ce : config)
      try {

        Object o = ce.createExecutableExtension("class");
        if (o instanceof PluggedInDashboardAction<?>) {
          PluggedInDashboardAction<AliveDashboardState> pluggedInAction =
              (PluggedInDashboardAction<AliveDashboardState>) o;
          if (pluggedInAction.dashboardActionId() == null)
            Plugin.getDefault()
                .getLog()
                .log(
                    Plugin.createError(
                        "IDashboardAction plugin has null dashboardActionId.", null));
          else pluggedInActions.put(pluggedInAction.dashboardActionId(), pluggedInAction);
        }
      } catch (CoreException e1) {
        e1.printStackTrace();
      }
  }
 // GMF action plugins, not used by Alive
 public void removeDashboardAction(DashboardActionDescriptor descriptor) {
   IFigure actionFigure = contributions.remove(descriptor);
   if (actionFigure == null) {
     return; // not contributed; just ignore
   }
   ActionContainer location = locations.get(descriptor.getLocation());
   if (location == null) {
     Plugin.getDefault()
         .getLog()
         .log(
             Plugin.createError(
                 "Unknown ALIVE Dashboard location: " + descriptor.getLocation(),
                 null)); //$NON-NLS-1$
     return;
   }
   location.removeAction(actionFigure, descriptor.isStandard());
 }
 // GMF action plugins, not used by Alive
 public void addDashboardAction(DashboardActionDescriptor descriptor) {
   ActionContainer location = locations.get(descriptor.getLocation());
   if (location == null) {
     Plugin.getDefault()
         .getLog()
         .log(
             Plugin.createError(
                 "Unknown ALIVE Dashboard location: " + descriptor.getLocation(),
                 null)); //$NON-NLS-1$
     return;
   }
   InternalDashboardAction<AliveDashboardState> action = descriptor.createDashboardAction();
   if (action == null) {
     return;
   }
   IFigure actionFigure = createLinkFigure(descriptor.getLabel(), action);
   location.addAction(actionFigure, descriptor.isStandard());
   contributions.put(descriptor, actionFigure);
 }
Beispiel #4
0
  @Override
  public void setActive(boolean active) {
    super.setActive(active);
    if (active && !loaded) {
      try {
        IFile wsFile = ((IFileEditorInput) getEditorInput()).getFile();
        File file = wsFile.getLocation().toFile();

        text.setText(print(file));
      } catch (Exception e) {
        Plugin.getDefault()
            .getLog()
            .log(
                new Status(
                    IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error outputing JAR content display.", e));
      } finally {
        loaded = true;
      }
    }
  }
  public void setView(AliveDashboardFigure view) {
    this.view = view;

    view.viewSelectionButtonFigure.addMouseListener(
        new MouseListener() {

          public void mouseDoubleClicked(MouseEvent me) {}

          public void mousePressed(MouseEvent me) {}

          public void mouseReleased(MouseEvent me) {
            ViewSelectionDialog viewSelectionDialog = new ViewSelectionDialog();
            viewSelectionDialog.open(
                AliveDashboardMediator.this, AliveDashboardMediator.this.dashboardPart);
          }
        });

    view.organisationFigure.addAction(
        createLinkFigure(Messages.DashboardMediator_Select, new SelectOrganisationAction()));
    view.ontologyFigure.addAction(
        createLinkFigure(Messages.DashboardMediator_Select, new SelectOntologyAction()));
    view.taskFigure.addAction(
        createLinkFigure(Messages.DashboardMediator_Select, new SelectTaskAction()));
    view.actionFigure.addAction(
        createLinkFigure(Messages.DashboardMediator_Select, new SelectActionAction()));
    view.masFigure.addAction(
        createLinkFigure(Messages.DashboardMediator_Select, new SelectMASAction()));
    view.planFigure.addAction(
        createLinkFigure(Messages.DashboardMediator_Select, new SelectPlanAction()));
    view.organisationFigure.addAction(
        createLinkFigure(
            Messages.DashboardMediator_Edit,
            new EditFileDashboardAction<AliveDashboardState>() {
              @Override
              protected URI getURI() {
                return state.getOrganisation();
              }
            }));
    view.taskFigure.addAction(
        createLinkFigure(
            Messages.DashboardMediator_Edit,
            new EditFileDashboardAction<AliveDashboardState>() {
              @Override
              protected URI getURI() {
                return state.getTask();
              }
            }));
    view.actionFigure.addAction(
        createLinkFigure(
            Messages.DashboardMediator_Edit,
            new EditFileDashboardAction<AliveDashboardState>() {
              @Override
              protected URI getURI() {
                return state.getAction();
              }
            }));
    view.masFigure.addAction(
        createLinkFigure(
            Messages.DashboardMediator_Edit,
            new EditFileDashboardAction<AliveDashboardState>() {
              @Override
              protected URI getURI() {
                return state.getMAS();
              }
            }));
    view.planFigure.addAction(
        createLinkFigure(
            Messages.DashboardMediator_Edit,
            new EditFileDashboardAction<AliveDashboardState>() {
              @Override
              protected URI getURI() {
                return state.getPlan();
              }
            }));

    view.organisationFigure.setMediator(this);
    view.ontologyFigure.setMediator(this);
    view.taskFigure.setMediator(this);
    view.actionFigure.setMediator(this);
    view.masFigure.setMediator(this);
    view.agentsFigure.setMediator(this);
    view.planFigure.setMediator(this);

    // for modelFigures, the label and actionId are specified in the figure itself on creation.
    for (BoxFigure<AliveDashboardState> boxFigure : view.allBoxFigures)
      for (ActionSpecification labelActionId : boxFigure.getLabelActionIds())
        boxFigure.addAction(
            createLinkFigure(
                labelActionId.getLabel(),
                new PluginDashboardAction<AliveDashboardState>(
                    labelActionId.getActionId(),
                    false))); // box actions do not prompt a resource save

    for (FlowActionFigure flowActionFigure : view.allFlowActionFigures)
      for (ActionSpecification labelActionId : flowActionFigure.getLabelActionIds())
        flowActionFigure.addAction(
            createLinkFigure(
                labelActionId.getLabel(),
                new PluginDashboardAction<AliveDashboardState>(
                    labelActionId.getActionId(), true))); // flow actions do prompt a resource save

    for (DashboardActionDescriptor descriptor :
        Plugin.getDefault().getDashboardActionRegistry().getDescriptors()) {
      addDashboardAction(descriptor);
    }

    Image logoImage = Plugin.getDefault().getImageRegistry().get(Plugin.PLAY_BUTTON_IMAGE);
    if (logoImage != null) {
      view.enactmentFigure.setIcon(logoImage);
      view.enactmentFigureBU.setIcon(logoImage);
    }

    updateStatus();
  }