blob: faee9ec7d4186dae492645ca432342f11143fa34 (
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
|
/*******************************************************************************
* 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.commandHandlers;
import java.util.List;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osee.framework.core.data.IOseeBranch;
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.ui.plugin.util.CommandHandler;
import org.eclipse.osee.framework.ui.skynet.ArtifactExplorer;
/**
* @author Roberto E. Escobar
*/
public class OpenArtifactExplorerHandler extends CommandHandler {
private List<Branch> getSelectedBranches(IStructuredSelection selection) {
return Handlers.getBranchesFromStructuredSelection(selection);
}
@Override
public boolean isEnabledWithException(IStructuredSelection structuredSelection) {
List<Branch> selectedBranches = getSelectedBranches(structuredSelection);
boolean isEnabled = !selectedBranches.isEmpty();
for (Branch branch : selectedBranches) {
if (branch.getBranchType() == BranchType.MERGE || !branch.getBranchState().matches(BranchState.CREATED,
BranchState.MODIFIED)) {
isEnabled = false;
break;
}
}
return isEnabled;
}
@Override
public Object executeWithException(ExecutionEvent event, IStructuredSelection selection) {
List<? extends IOseeBranch> branches = getSelectedBranches(selection);
if (!branches.isEmpty()) {
ArtifactExplorer.exploreBranch(branches.iterator().next());
}
return null;
}
}
|