]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/compare/CompareDialog.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / compare / CompareDialog.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2011 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 *******************************************************************************/
11package org.eclipse.jdt.internal.ui.compare;
12
13import java.util.ResourceBundle;
14
15import org.eclipse.swt.SWT;
16import org.eclipse.swt.graphics.Image;
17import org.eclipse.swt.layout.GridData;
18import org.eclipse.swt.widgets.Composite;
19import org.eclipse.swt.widgets.Control;
20import org.eclipse.swt.widgets.Shell;
21
22import org.eclipse.jface.dialogs.IDialogConstants;
23import org.eclipse.jface.viewers.Viewer;
24
25import org.eclipse.ui.PlatformUI;
26
27import org.eclipse.compare.CompareConfiguration;
28import org.eclipse.compare.CompareUI;
29import org.eclipse.compare.CompareViewerSwitchingPane;
30import org.eclipse.compare.structuremergeviewer.ICompareInput;
31
32import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
33
34
35class CompareDialog extends ResizableDialog {
36
37 class ViewerSwitchingPane extends CompareViewerSwitchingPane {
38
39 ViewerSwitchingPane(Composite parent, int style) {
40 super(parent, style, false);
41 }
42
43 @Override
44 protected Viewer getViewer(Viewer oldViewer, Object input) {
45 if (input instanceof ICompareInput)
46 return CompareUI.findContentViewer(oldViewer, (ICompareInput)input, this, fCompareConfiguration);
47 return null;
48 }
49
50 @Override
51 public void setImage(Image image) {
52 // don't show icon
53 }
54 }
55
56 private CompareViewerSwitchingPane fContentPane;
57 private CompareConfiguration fCompareConfiguration;
58 private ICompareInput fInput;
59
60
61 CompareDialog(Shell parent, ResourceBundle bundle) {
62 super(parent, bundle);
63
64 fCompareConfiguration= new CompareConfiguration();
65 fCompareConfiguration.setLeftEditable(false);
66 fCompareConfiguration.setRightEditable(false);
67 }
68
69 void compare(ICompareInput input) {
70
71 fInput= input;
72
73 fCompareConfiguration.setLeftLabel(fInput.getLeft().getName());
74 fCompareConfiguration.setLeftImage(fInput.getLeft().getImage());
75
76 fCompareConfiguration.setRightLabel(fInput.getRight().getName());
77 fCompareConfiguration.setRightImage(fInput.getRight().getImage());
78
79 if (fContentPane != null)
80 fContentPane.setInput(fInput);
81
82 open();
83 }
84
85 /* (non Javadoc)
86 * Creates SWT control tree.
87 */
88 @Override
89 protected synchronized Control createDialogArea(Composite parent2) {
90
91 Composite parent= (Composite) super.createDialogArea(parent2);
92
93 getShell().setText(JavaCompareUtilities.getString(fBundle, "title")); //$NON-NLS-1$
94
95 fContentPane= new ViewerSwitchingPane(parent, SWT.BORDER | SWT.FLAT);
96 fContentPane.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
97 | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
98
99 if (fInput != null)
100 fContentPane.setInput(fInput);
101
102 applyDialogFont(parent);
103 return parent;
104 }
105
106 /* (non-Javadoc)
107 * Method declared on Dialog.
108 */
109 @Override
110 protected void createButtonsForButtonBar(Composite parent) {
111 String buttonLabel= JavaCompareUtilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$
112 createButton(parent, IDialogConstants.CANCEL_ID, buttonLabel, false);
113 }
114
115 /*
116 * @see org.eclipse.jface.window.Window#configureShell(Shell)
117 */
118 @Override
119 protected void configureShell(Shell newShell) {
120 super.configureShell(newShell);
121 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.COMPARE_DIALOG);
122 }
123}