| /******************************************************************************* |
| * Copyright (c) 2000, 2017 IBM Corporation and others. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.dltk.internal.ui.workingsets; |
| |
| import java.util.ArrayList; |
| import java.util.Arrays; |
| import java.util.List; |
| |
| import org.eclipse.jface.action.Action; |
| import org.eclipse.jface.dialogs.IDialogConstants; |
| import org.eclipse.ui.IWorkbenchPartSite; |
| import org.eclipse.ui.IWorkingSet; |
| |
| public class ConfigureWorkingSetAction extends Action { |
| |
| private final IWorkbenchPartSite fSite; |
| private WorkingSetModel fWorkingSetModel; |
| |
| public ConfigureWorkingSetAction(IWorkbenchPartSite site) { |
| super(WorkingSetMessages.ConfigureWorkingSetAction_label); |
| fSite = site; |
| } |
| |
| public void setWorkingSetModel(WorkingSetModel model) { |
| fWorkingSetModel = model; |
| } |
| |
| @Override |
| public void run() { |
| List<IWorkingSet> workingSets = new ArrayList<>( |
| Arrays.asList(fWorkingSetModel.getAllWorkingSets())); |
| IWorkingSet[] activeWorkingSets = fWorkingSetModel |
| .getActiveWorkingSets(); |
| WorkingSetConfigurationDialog dialog = new WorkingSetConfigurationDialog( |
| fSite.getShell(), |
| workingSets.toArray(new IWorkingSet[workingSets.size()]), |
| activeWorkingSets); |
| dialog.setSelection(activeWorkingSets); |
| if (dialog.open() == IDialogConstants.OK_ID) { |
| IWorkingSet[] selection = dialog.getSelection(); |
| fWorkingSetModel.setActiveWorkingSets(selection); |
| } |
| } |
| } |