Skip to main content
summaryrefslogtreecommitdiffstats
blob: a7f059c96cf4a9c10078f0e790cce1d5d574df53 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*******************************************************************************
 * 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.framework.ui.skynet.blam;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.IActionContributor;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.ui.IEditorSite;

/**
 * @author Roberto E. Escobar
 */
public class BlamEditorActionBarContributor implements IActionContributor {

   private final BlamEditor editor;
   private Action executeBlamAction;
   private Action bugAction;

   public BlamEditorActionBarContributor(BlamEditor editor) {
      this.editor = editor;
   }

   @Override
   public void contributeToToolBar(IToolBarManager manager) {
      manager.add(getExecuteBlamAction());
      manager.add(getAtsBugAction());
   }

   //   OseeAts.addButtonToEditorToolBar(editor, this, SkynetGuiPlugin.getInstance(), form.getToolBarManager(),
   //         BlamEditor.EDITOR_ID, "BLAM Editor");
   public final Action getAtsBugAction() {
      if (bugAction == null) {
         IEditorSite site = editor.getEditorSite();
         bugAction =
            OseeUiActions.createBugAction(SkynetGuiPlugin.getInstance(), editor, site.getId(), site.getRegisteredName());
      }
      return bugAction;
   }

   public final Action getExecuteBlamAction() {
      if (executeBlamAction == null) {
         executeBlamAction = new ExecuteBlamAction();
      }
      return executeBlamAction;
   }

   private final class ExecuteBlamAction extends Action {
      public ExecuteBlamAction() {
         super("Run BLAM in Job", IAction.AS_PUSH_BUTTON);
         setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.RUN_EXC));
         setToolTipText("Executes the BLAM Operation");
      }

      @Override
      public void run() {
         try {
            editor.executeBlam();
         } catch (Exception ex) {
            OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
         }
      }
   }
}

Back to the top