Skip to main content
summaryrefslogtreecommitdiffstats
blob: 19a215d7bb88298b5155d9d3fa16299d6b442171 (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
/*******************************************************************************
 * 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.artifact.annotation;

import java.util.logging.Level;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.annotation.ArtifactAnnotation;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.swt.ALayout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;

/**
 * @author Donald G. Dunne
 */
public class AnnotationComposite extends Composite {

   public AnnotationComposite(Composite parent, int style, Artifact artifact) {
      this(null, parent, style, artifact);
   }

   public AnnotationComposite(FormToolkit toolkit, Composite parent, int style, Artifact artifact) {
      super(parent, style);

      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 4;
      setLayoutData(gd);
      setLayout(ALayout.getZeroMarginLayout(2, false));

      for (ArtifactAnnotation.Type type : ArtifactAnnotation.Type.getOrderedTypes()) {
         for (ArtifactAnnotation notify : artifact.getAnnotations()) {
            if (notify.getType() != type) {
               continue;
            }
            if (notify.getType() == ArtifactAnnotation.Type.None) {
               OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, new OseeStateException(
                  "None is an invalid annotation type - " + artifact.getGuid()));
               continue;
            }
            Label iconLabel = toolkit != null ? toolkit.createLabel(this, "") : new Label(this, SWT.NONE);
            iconLabel.setImage(ArtifactImageManager.getAnnotationImage(notify.getType()));

            Label alertLabel = toolkit != null ? toolkit.createLabel(this, "") : new Label(this, SWT.NONE);
            alertLabel.setText(notify.getType().name() + ": " + notify.getContent());
         }
      }
      if (toolkit != null) {
         toolkit.adapt(this);
      }
   }
}

Back to the top