KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > actions > RestoreRemovedItemsAction


1 /*******************************************************************************
2  * Copyright (c) 2007 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.team.internal.ui.synchronize.actions;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.compare.structuremergeviewer.IDiffElement;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.team.internal.core.subscribers.WorkingSetFilteredSyncInfoCollector;
18 import org.eclipse.team.internal.ui.Utils;
19 import org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage;
20 import org.eclipse.team.ui.synchronize.*;
21
22 public class RestoreRemovedItemsAction extends SynchronizeModelAction {
23
24     public RestoreRemovedItemsAction(ISynchronizePageConfiguration configuration) {
25         super(null, configuration);
26         Utils.initAction(this, "action.restoreRemovedFromView."); //$NON-NLS-1$
27
}
28     
29     protected SynchronizeModelOperation getSubscriberOperation(
30             ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
31         return new SynchronizeModelOperation(configuration, elements) {
32             public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
33                 restoreRemovedItems();
34             }
35             protected boolean canRunAsJob() {
36                 return false;
37             }
38             /**
39              * Remove the sync info contained in the given set from the view.
40              * @param set the sync info set
41              */

42             private void restoreRemovedItems() {
43                 ISynchronizePage page = getConfiguration().getPage();
44                 if (page instanceof SubscriberParticipantPage) {
45                     WorkingSetFilteredSyncInfoCollector collector = ((SubscriberParticipantPage)page).getCollector();
46                     collector.reset();
47                 }
48             }
49         };
50     }
51     
52     public boolean isEnabled(){
53         return true;
54     }
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#needsToSaveDirtyEditors()
58      */

59     protected boolean needsToSaveDirtyEditors() {
60         return false;
61     }
62
63 }
Popular Tags