Skip to main content
summaryrefslogtreecommitdiffstats
blob: 839b63426fcde83cf7d99199b5fa60a8e10b1e66 (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
/*******************************************************************************
 * 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.util;

import java.util.Collection;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ChangeBranchArchivedStateDialog;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ChangeBranchStateDialog;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ChangeBranchTypeDialog;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.TreeItem;

/**
 * @author Megumi Telles
 */
public class PromptChangeUtil {

   public static boolean promptChangeBranchType(final Collection<TreeItem> branches) throws OseeCoreException {
      ChangeBranchTypeDialog ld = new ChangeBranchTypeDialog(Displays.getActiveShell());
      int result = ld.open();
      if (result == 0) {
         BranchType type = ld.getSelection();
         for (TreeItem item : branches) {
            Branch branch = (Branch) item.getData();
            BranchManager.updateBranchType(null, branch.getId(), branch.getGuid(), type);
         }
         return true;
      }
      return false;
   }

   public static boolean promptChangeBranchState(final Collection<TreeItem> branches) throws OseeCoreException {
      ChangeBranchStateDialog ld = new ChangeBranchStateDialog(Displays.getActiveShell());
      int result = ld.open();
      if (result == 0) {
         BranchState state = ld.getSelection();
         for (TreeItem item : branches) {
            Branch branch = (Branch) item.getData();
            BranchManager.updateBranchState(null, branch.getId(), branch.getGuid(), state);
         }
         return true;
      }
      return false;
   }

   public static boolean promptChangeBranchArchivedState(final Collection<TreeItem> branches) throws OseeCoreException {
      ChangeBranchArchivedStateDialog ld = new ChangeBranchArchivedStateDialog(Displays.getActiveShell());
      int result = ld.open();
      if (result == 0) {
         BranchArchivedState state = ld.getSelection();
         for (TreeItem item : branches) {
            Branch branch = (Branch) item.getData();
            BranchManager.updateBranchArchivedState(null, branch.getId(), branch.getGuid(), state);
         }
         return true;
      }
      return false;
   }

}

Back to the top