blob: d1cbbee72123f3706ae5d68cd2c3c0ae184b6e9b (
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
|
/*******************************************************************************
* Copyright (c) 2012 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.util.widgets;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.ats.core.client.branch.AtsBranchManagerCore;
import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
/**
* @author Shawn F. Cook
*/
public class XWorkingBranchButtonCreate extends XWorkingBranchButtonAbstract {
public static String WIDGET_NAME = "XWorkingBranchButtonCreate";
@Override
protected void initButton(final Button button) {
button.setToolTipText("Create Working Branch");
button.setImage(ImageManager.getImage(FrameworkImage.BRANCH));
button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
disableAll = true;
refreshEnablement(button);
// Create working branch
Result result = AtsBranchManagerCore.createWorkingBranch_Validate(getTeamArt());
if (result.isFalse()) {
AWorkbench.popup(result);
return;
}
try {
IOseeBranch parentBranch = AtsBranchManagerCore.getConfiguredBranchForWorkflow(getTeamArt());
// Retrieve parent branch to create working branch from
if (!MessageDialog.openConfirm(
Displays.getActiveShell(),
"Create Working Branch",
"Create a working branch from parent branch\n\n\"" + parentBranch.getName() + "\"?\n\n" + "NOTE: Working branches are necessary when OSEE Artifact changes " + "are made during implementation.")) {
disableAll = false;
refreshEnablement(button);
return;
}
AtsBranchManagerCore.createWorkingBranch_Create(getTeamArt(), true);
} catch (Exception ex) {
OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
}
disableAll = false;
refreshEnablement(button);
}
});
}
@Override
protected void refreshEnablement(Button button) {
button.setEnabled(!disableAll && !isWorkingBranchCreationInProgress() && !isWorkingBranchCommitInProgress() && !isWorkingBranchInWork() && !isCommittedBranchExists());
}
}
|