Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8d73df0261da41d220737439ccd7ae42bf3eeed7 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*******************************************************************************
 * 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.config.wizard;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osee.ats.internal.AtsPlugin;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.ats.workflow.ATSXWidgetOptionResolver;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener;
import org.eclipse.osee.framework.ui.skynet.widgets.XText;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

/**
 * @author Donald G. Dunne
 */
public class AtsConfigWizardPage1 extends WizardPage {
   private WorkPage page;

   public AtsConfigWizardPage1(AtsConfigWizard actionWizard) {
      super("Create New ATS Configuration", "Create ATS Configuration", null);
      setMessage("Enter configuration information.");
   }

   private final XModifiedListener xModListener = new XModifiedListener() {
      @Override
      public void widgetModified(XWidget widget) {
         getContainer().updateButtons();
      }
   };

   public String getNamespace() throws OseeCoreException {
      return (String) getXWidget(CONFIG_NAMESPACE).getData();
   }

   public String getTeamDefName() throws OseeCoreException {
      return (String) getXWidget(TEAMDEF_NAME).getData();
   }

   public List<String> getActionableItems() throws OseeCoreException {
      List<String> aias = new ArrayList<String>();
      for (String aia : ((String) getXWidget(ACTIONABLE_ITEMS).getData()).split(",")) {
         aia = aia.replaceAll("^ *", "");
         aia = aia.replaceAll(" *$", "");
         if (!aia.equals("")) {
            aias.add(aia);
         }
      }
      return aias;
   }

   public List<String> getVersions() throws OseeCoreException {
      List<String> versions = new ArrayList<String>();
      for (String version : ((String) getXWidget(VERSIONS).getData()).split(",")) {
         version = version.replaceAll("^ *", "");
         version = version.replaceAll(" *$", "");
         if (!version.equals("")) {
            versions.add(version);
         }
      }
      return versions;
   }

   public String getWorkflowId() throws OseeCoreException {
      return (String) getXWidget(WORKFLOW_ID).getData();
   }

   private static String CONFIG_NAMESPACE = "Configuration Namespace";
   private static String TEAMDEF_NAME = "Team Definition Name";
   private static String ACTIONABLE_ITEMS = "Actionable Item(s) (comma delim)";
   private static String VERSIONS = "Versions (comma delim)";
   private static String WORKFLOW_ID = "Workflow Id (blank to create default)";

   @Override
   public void createControl(Composite parent) {

      try {
         String xWidgetXml = "<WorkPage>" +
         //
         "<XWidget displayName=\"" + CONFIG_NAMESPACE + "\" required=\"true\" xwidgetType=\"XText\"/>" +
         //
         "<XWidget displayName=\"" + TEAMDEF_NAME + "\" required=\"true\" xwidgetType=\"XText\"/>" +
         //
         "<XWidget displayName=\"" + ACTIONABLE_ITEMS + "\" required=\"true\" xwidgetType=\"XText\"/>" +
         //
         "<XWidget displayName=\"" + VERSIONS + "\" required=\"false\" xwidgetType=\"XText\"/>" +
         //
         "<XWidget displayName=\"" + WORKFLOW_ID + "\" required=\"false\" xwidgetType=\"XText\"/>" +
         //
         "</WorkPage>";
         Composite comp = new Composite(parent, SWT.NONE);
         comp.setLayout(new GridLayout(1, false));
         comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

         page = new WorkPage(xWidgetXml, ATSXWidgetOptionResolver.getInstance());
         page.createBody(null, comp, null, xModListener, true);

         Button populateExampleButton = new Button(comp, SWT.PUSH);
         populateExampleButton.setText("Populate with example entries");
         populateExampleButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
               super.widgetSelected(e);
               String namespace = "org.trex.saw.labs" + AtsUtil.getAtsDeveloperIncrementingNum();
               try {
                  ((XText) getXWidget(CONFIG_NAMESPACE)).set(namespace);
                  ((XText) getXWidget(TEAMDEF_NAME)).set("SAW Labs");
                  ((XText) getXWidget(ACTIONABLE_ITEMS)).set("Lab Station, Lab Computer, Lab Fire System");
                  ((XText) getXWidget(VERSIONS)).set("SAW 1.0, SAW 2.0, SAW 3.0");
                  ((XText) getXWidget(WORKFLOW_ID)).setText("osee.ats.teamWorkflow");
               } catch (OseeCoreException ex) {
                  OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
               }
            }
         });
         setControl(comp);
         ((XText) getXWidget(CONFIG_NAMESPACE)).setFocus();
         ((XText) getXWidget(WORKFLOW_ID)).setText("osee.ats.teamWorkflow");

      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
      }
   }

   public XWidget getXWidget(String attrName) throws OseeCoreException {
      if (page == null) {
         throw new OseeArgumentException("WorkPage == null");
      }
      return page.getLayoutData(attrName).getXWidget();
   }

   @Override
   public boolean isPageComplete() {
      if (!page.isPageComplete().isTrue()) {
         return false;
      }

      return true;
   }

}

Back to the top