Skip to main content
summaryrefslogtreecommitdiffstats
blob: fcdbb1590c35716bcf6ad6290ade4c7fc3c23f8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.actions;

import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osee.ats.core.client.review.ReviewManager;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
import org.eclipse.osee.framework.ui.swt.ImageManager;

/**
 * @author Donald G. Dunne
 */
public class ReloadAction extends AbstractAtsAction {

   private final AbstractWorkflowArtifact sma;

   public ReloadAction(AbstractWorkflowArtifact sma) {
      super();
      String title = "Reload \"" + sma.getArtifactTypeName() + "\"";
      setText(title);
      setToolTipText(getText());
      this.sma = sma;
   }

   @Override
   public void runWithException()  {
      Set<Artifact> relatedArts = new HashSet<>();
      relatedArts.add(sma);
      if (sma.isTeamWorkflow()) {
         relatedArts.addAll(ReviewManager.getReviews((TeamWorkFlowArtifact) sma));
      }
      if (sma instanceof TeamWorkFlowArtifact) {
         relatedArts.addAll(((TeamWorkFlowArtifact) sma).getTaskArtifacts());
      }
      ArtifactQuery.reloadArtifacts(relatedArts);
      // Don't need to re-open editor cause event handler will do that
   }

   @Override
   public ImageDescriptor getImageDescriptor() {
      return ImageManager.getImageDescriptor(PluginUiImage.REFRESH);
   }

}

Back to the top