blob: 92f4e6f99d1297076a63cd960ac34a0187803cb2 (
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
|
/*******************************************************************************
* 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.branch;
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.model.Branch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.model.BranchEvent;
import org.eclipse.osee.framework.skynet.core.event.model.BranchEventType;
import org.eclipse.osee.framework.ui.plugin.util.CommandHandler;
import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers;
/**
* @author Jeff C. Phillips
*/
public class ToggleFavoriteBranchHandler extends CommandHandler {
public static final String COMMAND_ID =
"org.eclipse.osee.framework.ui.skynet.commandHandlers.branch.ToggleFavoriteBranchHandler";
@Override
public Object executeWithException(ExecutionEvent event, IStructuredSelection selection) throws OseeCoreException {
Branch selectedBranch = Handlers.getBranchesFromStructuredSelection(selection).iterator().next();
UserManager.getUser().toggleFavoriteBranch(selectedBranch);
OseeEventManager.kickBranchEvent(this,
new BranchEvent(BranchEventType.FavoritesUpdated, selectedBranch));
return null;
}
@Override
public boolean isEnabledWithException(IStructuredSelection structuredSelection) {
List<? extends IOseeBranch> branches = Handlers.getBranchesFromStructuredSelection(structuredSelection);
return branches.size() == 1;
}
}
|