KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > compare > JavaCompareWithEditionActionImpl


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.jdt.internal.ui.compare;
12
13 import org.eclipse.core.resources.IFile;
14
15 import org.eclipse.jface.dialogs.MessageDialog;
16 import org.eclipse.jface.viewers.ISelection;
17
18 import org.eclipse.ui.PlatformUI;
19
20 import org.eclipse.compare.CompareConfiguration;
21 import org.eclipse.compare.CompareUI;
22
23 import org.eclipse.team.ui.TeamUI;
24 import org.eclipse.team.ui.history.HistoryPageCompareEditorInput;
25
26 import org.eclipse.jdt.core.IMember;
27
28 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
29
30
31 /**
32  * Provides "Replace from local history" for Java elements.
33  */

34 class JavaCompareWithEditionActionImpl extends JavaHistoryActionImpl {
35     
36     private static boolean USE_MODAL_COMPARE = false;
37     
38     JavaCompareWithEditionActionImpl() {
39         super(false);
40     }
41     
42     public void run(ISelection selection) {
43                 
44         IMember input= getEditionElement(selection);
45         if (input == null) {
46             MessageDialog.openInformation(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_invalidSelectionMessage);
47             return;
48         }
49         
50         JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance();
51         final IFile file= pageSource.getFile(input);
52         if (file == null) {
53             MessageDialog.openError(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_internalErrorMessage);
54             return;
55         }
56         
57         if (USE_MODAL_COMPARE) {
58             CompareConfiguration cc = new CompareConfiguration();
59             cc.setLeftEditable(false);
60             cc.setRightEditable(false);
61             HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input);
62             ci.setTitle(CompareMessages.JavaCompareWithEditionActionImpl_0);
63             ci.setHelpContextId(IJavaHelpContextIds.COMPARE_ELEMENT_WITH_HISTORY_DIALOG);
64             CompareUI.openCompareDialog(ci);
65         } else {
66             TeamUI.showHistoryFor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, pageSource);
67         }
68     }
69 }
70
71
Popular Tags