KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > workingsets > ConfigureWorkingSetAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.workingsets;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Arrays JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.jface.action.Action;
18 import org.eclipse.jface.dialogs.IDialogConstants;
19
20 import org.eclipse.ui.IWorkbenchPartSite;
21 import org.eclipse.ui.IWorkingSet;
22
23 public class ConfigureWorkingSetAction extends Action {
24
25     private final IWorkbenchPartSite fSite;
26     private WorkingSetModel fWorkingSetModel;
27
28     public ConfigureWorkingSetAction(IWorkbenchPartSite site) {
29         super(WorkingSetMessages.ConfigureWorkingSetAction_label);
30         fSite= site;
31     }
32     
33     public void setWorkingSetModel(WorkingSetModel model) {
34         fWorkingSetModel= model;
35     }
36     
37     /**
38      * {@inheritDoc}
39      */

40     public void run() {
41         List JavaDoc workingSets= new ArrayList JavaDoc(Arrays.asList(fWorkingSetModel.getAllWorkingSets()));
42         IWorkingSet[] activeWorkingSets= fWorkingSetModel.getActiveWorkingSets();
43         WorkingSetConfigurationDialog dialog= new WorkingSetConfigurationDialog(
44             fSite.getShell(),
45             (IWorkingSet[])workingSets.toArray(new IWorkingSet[workingSets.size()]),
46             activeWorkingSets);
47         dialog.setSelection(activeWorkingSets);
48         if (dialog.open() == IDialogConstants.OK_ID) {
49             IWorkingSet[] selection= dialog.getSelection();
50             fWorkingSetModel.setActiveWorkingSets(selection);
51         }
52     }
53 }
54
Popular Tags