1 11 package org.eclipse.ltk.internal.ui.refactoring.history; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.ltk.core.refactoring.history.RefactoringHistory; 16 17 import org.eclipse.ltk.internal.ui.refactoring.IRefactoringHelpContextIds; 18 19 import org.eclipse.swt.SWT; 20 import org.eclipse.swt.layout.GridData; 21 import org.eclipse.swt.layout.GridLayout; 22 import org.eclipse.swt.widgets.Composite; 23 24 import org.eclipse.jface.dialogs.Dialog; 25 import org.eclipse.jface.dialogs.IDialogSettings; 26 import org.eclipse.jface.wizard.IWizardPage; 27 import org.eclipse.jface.wizard.WizardPage; 28 29 import org.eclipse.ui.PlatformUI; 30 31 import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryControlConfiguration; 32 33 38 public final class RefactoringHistoryOverviewPage extends WizardPage { 39 40 41 private final static String PAGE_NAME= "historyOverviewPage"; 43 44 private static final String SETTING_SORT= "org.eclipse.ltk.ui.refactoring.sortRefactorings"; 46 47 private final RefactoringHistoryControlConfiguration fControlConfiguration; 48 49 50 private SortableRefactoringHistoryControl fHistoryControl= null; 51 52 53 private final RefactoringHistory fRefactoringHistory; 54 55 67 public RefactoringHistoryOverviewPage(final RefactoringHistory history, final String title, final String description, final RefactoringHistoryControlConfiguration configuration) { 68 super(PAGE_NAME); 69 Assert.isNotNull(history); 70 Assert.isNotNull(configuration); 71 Assert.isNotNull(title); 72 Assert.isNotNull(description); 73 fRefactoringHistory= history; 74 fControlConfiguration= configuration; 75 setTitle(title); 76 setDescription(description); 77 } 78 79 82 public boolean canFlipToNextPage() { 83 return !fRefactoringHistory.isEmpty(); 84 } 85 86 89 public void createControl(final Composite parent) { 90 initializeDialogUnits(parent); 91 final Composite composite= new Composite(parent, SWT.NULL); 92 composite.setLayout(new GridLayout()); 93 composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); 94 fHistoryControl= new SortableRefactoringHistoryControl(composite, fControlConfiguration) { 95 96 protected void createBottomButtonBar(final Composite control) { 97 } 99 }; 100 fHistoryControl.createControl(); 101 boolean sortProjects= false; 102 final IDialogSettings settings= getWizard().getDialogSettings(); 103 if (settings != null) 104 sortProjects= settings.getBoolean(SETTING_SORT); 105 if (sortProjects) 106 fHistoryControl.sortByProjects(); 107 else 108 fHistoryControl.sortByDate(); 109 fHistoryControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); 110 setControl(composite); 111 Dialog.applyDialogFont(composite); 112 PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IRefactoringHelpContextIds.REFACTORING_HISTORY_WIZARD_PAGE); 113 } 114 115 118 public IWizardPage getNextPage() { 119 return getWizard().getNextPage(this); 120 } 121 122 125 public IWizardPage getPreviousPage() { 126 return getWizard().getPreviousPage(this); 127 } 128 129 132 public void performFinish() { 133 final IDialogSettings settings= getWizard().getDialogSettings(); 134 if (settings != null) 135 settings.put(SETTING_SORT, fHistoryControl.isSortByProjects()); 136 } 137 138 141 public void setPageComplete(final boolean complete) { 142 super.setPageComplete(true); 143 } 144 145 148 public void setVisible(boolean visible) { 149 fHistoryControl.setInput(fRefactoringHistory); 150 super.setVisible(visible); 151 } 152 } 153 | Popular Tags |