1 11 package org.eclipse.jdt.internal.ui.compare; 12 13 import java.util.ResourceBundle ; 14 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.graphics.*; 17 import org.eclipse.swt.layout.GridData; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.swt.widgets.Composite; 20 import org.eclipse.swt.widgets.Control; 21 22 import org.eclipse.jface.dialogs.*; 23 import org.eclipse.jface.viewers.Viewer; 24 25 import org.eclipse.ui.PlatformUI; 26 27 import org.eclipse.compare.*; 28 import org.eclipse.compare.structuremergeviewer.ICompareInput; 29 30 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 31 32 33 class CompareDialog extends ResizableDialog { 34 35 class ViewerSwitchingPane extends CompareViewerSwitchingPane { 36 37 ViewerSwitchingPane(Composite parent, int style) { 38 super(parent, style, false); 39 } 40 41 protected Viewer getViewer(Viewer oldViewer, Object input) { 42 if (input instanceof ICompareInput) 43 return CompareUI.findContentViewer(oldViewer, (ICompareInput)input, this, fCompareConfiguration); 44 return null; 45 } 46 47 public void setImage(Image image) { 48 } 50 } 51 52 private CompareViewerSwitchingPane fContentPane; 53 private CompareConfiguration fCompareConfiguration; 54 private ICompareInput fInput; 55 56 57 CompareDialog(Shell parent, ResourceBundle bundle) { 58 super(parent, bundle); 59 60 fCompareConfiguration= new CompareConfiguration(); 61 fCompareConfiguration.setLeftEditable(false); 62 fCompareConfiguration.setRightEditable(false); 63 } 64 65 void compare(ICompareInput input) { 66 67 fInput= input; 68 69 fCompareConfiguration.setLeftLabel(fInput.getLeft().getName()); 70 fCompareConfiguration.setLeftImage(fInput.getLeft().getImage()); 71 72 fCompareConfiguration.setRightLabel(fInput.getRight().getName()); 73 fCompareConfiguration.setRightImage(fInput.getRight().getImage()); 74 75 if (fContentPane != null) 76 fContentPane.setInput(fInput); 77 78 open(); 79 } 80 81 84 protected synchronized Control createDialogArea(Composite parent2) { 85 86 Composite parent= (Composite) super.createDialogArea(parent2); 87 88 getShell().setText(JavaCompareUtilities.getString(fBundle, "title")); 90 fContentPane= new ViewerSwitchingPane(parent, SWT.BORDER | SWT.FLAT); 91 fContentPane.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL 92 | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); 93 94 if (fInput != null) 95 fContentPane.setInput(fInput); 96 97 applyDialogFont(parent); 98 return parent; 99 } 100 101 104 protected void createButtonsForButtonBar(Composite parent) { 105 String buttonLabel= JavaCompareUtilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); createButton(parent, IDialogConstants.CANCEL_ID, buttonLabel, false); 107 } 108 109 112 protected void configureShell(Shell newShell) { 113 super.configureShell(newShell); 114 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.COMPARE_DIALOG); 115 } 116 } 117 | Popular Tags |