diff options
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java')
-rw-r--r-- | bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java | 474 |
1 files changed, 237 insertions, 237 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java index 353ca068f..1dad2c681 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java @@ -54,44 +54,44 @@ import org.eclipse.ui.part.PageBook; * a commit comment. */ public class CommitWizardCommitPage extends WizardPage implements IPropertyChangeListener { - - public static final String SHOW_COMPARE = "ShowCompare"; //$NON-NLS-1$ - private static final String H_WEIGHT_1 = "HWeight1"; //$NON-NLS-1$ - private static final String H_WEIGHT_2 = "HWeight2"; //$NON-NLS-1$ - private static final String V_WEIGHT_1 = "VWeight1"; //$NON-NLS-1$ - private static final String V_WEIGHT_2 = "VWeight2"; //$NON-NLS-1$ - + + public static final String SHOW_COMPARE = "ShowCompare"; //$NON-NLS-1$ + private static final String H_WEIGHT_1 = "HWeight1"; //$NON-NLS-1$ + private static final String H_WEIGHT_2 = "HWeight2"; //$NON-NLS-1$ + private static final String V_WEIGHT_1 = "VWeight1"; //$NON-NLS-1$ + private static final String V_WEIGHT_2 = "VWeight2"; //$NON-NLS-1$ + private final CommitCommentArea fCommentArea; - - private ISynchronizePageConfiguration fConfiguration; - - protected final CommitWizard fWizard; - + + private ISynchronizePageConfiguration fConfiguration; + + protected final CommitWizard fWizard; + private ParticipantPagePane fPagePane; - private PageBook bottomChild; + private PageBook bottomChild; private boolean fHasConflicts; private boolean fIsEmpty; - + private SashForm horizontalSash; private SashForm verticalSash; private Splitter placeholder; private boolean showCompare; - public CommitWizardCommitPage(IResource [] resources, CommitWizard wizard) { - - super(CVSUIMessages.CommitWizardCommitPage_0); - setTitle(CVSUIMessages.CommitWizardCommitPage_0); - setDescription(CVSUIMessages.CommitWizardCommitPage_2); - - fWizard= wizard; - fCommentArea= new CommitCommentArea(); - fCommentArea.setProposedComment(getProposedComment(resources)); - if (resources.length > 0) - fCommentArea.setProject(resources[0].getProject()); - fWizard.getDiffTree().addDiffChangeListener(new IDiffChangeListener() { + public CommitWizardCommitPage(IResource [] resources, CommitWizard wizard) { + + super(CVSUIMessages.CommitWizardCommitPage_0); + setTitle(CVSUIMessages.CommitWizardCommitPage_0); + setDescription(CVSUIMessages.CommitWizardCommitPage_2); + + fWizard= wizard; + fCommentArea= new CommitCommentArea(); + fCommentArea.setProposedComment(getProposedComment(resources)); + if (resources.length > 0) + fCommentArea.setProject(resources[0].getProject()); + fWizard.getDiffTree().addDiffChangeListener(new IDiffChangeListener() { @Override public void propertyChanged(IDiffTree tree, int property, IPath[] paths) { // ignore property changes @@ -101,34 +101,34 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang Utils.syncExec((Runnable) () -> updateEnablements(), CommitWizardCommitPage.this.getControl()); } }); - } - - @Override + } + + @Override public void createControl(Composite parent) { - initializeDialogUnits(parent); - Dialog.applyDialogFont(parent); - final PixelConverter converter= new PixelConverter(parent); - - final Composite composite= new Composite(parent, SWT.NONE); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DEFAULT)); - // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMMIT_COMMENT_PAGE); - - - horizontalSash = new SashForm(composite, SWT.HORIZONTAL); - horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - verticalSash = new SashForm(horizontalSash, SWT.VERTICAL); - verticalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + initializeDialogUnits(parent); + Dialog.applyDialogFont(parent); + final PixelConverter converter= new PixelConverter(parent); + + final Composite composite= new Composite(parent, SWT.NONE); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DEFAULT)); + // set F1 help + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMMIT_COMMENT_PAGE); + + + horizontalSash = new SashForm(composite, SWT.HORIZONTAL); + horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + verticalSash = new SashForm(horizontalSash, SWT.VERTICAL); + verticalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - createCommentArea(verticalSash, converter); + createCommentArea(verticalSash, converter); - placeholder = new Splitter(horizontalSash, SWT.VERTICAL /*any*/); - placeholder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + placeholder = new Splitter(horizontalSash, SWT.VERTICAL /*any*/); + placeholder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - createChangesArea(verticalSash, converter); + createChangesArea(verticalSash, converter); - IDialogSettings section = getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); + IDialogSettings section = getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); showCompare = section == null ? false : section.getBoolean(SHOW_COMPARE); int vWeight1 = 50; int vWeight2 = 50; @@ -157,75 +157,75 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang verticalSash.setWeights(new int[] {vWeight1, vWeight2}); horizontalSash.setWeights(new int[] {hWeight1, hWeight2}); - //fSashForm.setWeights(weights); - Dialog.applyDialogFont(parent); - setControl(composite); - - fCommentArea.setFocus(); - - validatePage(false); - } - - private void createCommentArea(Composite parent, PixelConverter converter) { - Composite c = new Composite(parent, SWT.NONE); - c.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create()); - - fCommentArea.createArea(c); - GridData gd = SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true); - fCommentArea.getComposite().setLayoutData(gd); - fCommentArea.addPropertyChangeListener(this); - - createPlaceholder(c); - } - - private void createChangesArea(Composite parent, PixelConverter converter) { - - ISynchronizeParticipant participant= fWizard.getParticipant(); - int size = fWizard.getDiffTree().getAffectedResources().length; - if (size > getFileDisplayThreshold()) { - // Create a page book to allow eventual inclusion of changes - bottomChild = new PageBook(parent, SWT.NONE); - bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, false)); - // Create composite for showing the reason for not showing the changes and a button to show them - Composite changeDesc = new Composite(bottomChild, SWT.NONE); - changeDesc.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); - SWTUtils.createLabel(changeDesc, NLS.bind(CVSUIMessages.CommitWizardCommitPage_1, new String[] { Integer.toString(size), Integer.toString(getFileDisplayThreshold()) })); - Button showChanges = new Button(changeDesc, SWT.PUSH); - showChanges.setText(CVSUIMessages.CommitWizardCommitPage_5); - showChanges.addSelectionListener(new SelectionAdapter() { - @Override + //fSashForm.setWeights(weights); + Dialog.applyDialogFont(parent); + setControl(composite); + + fCommentArea.setFocus(); + + validatePage(false); + } + + private void createCommentArea(Composite parent, PixelConverter converter) { + Composite c = new Composite(parent, SWT.NONE); + c.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create()); + + fCommentArea.createArea(c); + GridData gd = SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true); + fCommentArea.getComposite().setLayoutData(gd); + fCommentArea.addPropertyChangeListener(this); + + createPlaceholder(c); + } + + private void createChangesArea(Composite parent, PixelConverter converter) { + + ISynchronizeParticipant participant= fWizard.getParticipant(); + int size = fWizard.getDiffTree().getAffectedResources().length; + if (size > getFileDisplayThreshold()) { + // Create a page book to allow eventual inclusion of changes + bottomChild = new PageBook(parent, SWT.NONE); + bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, false)); + // Create composite for showing the reason for not showing the changes and a button to show them + Composite changeDesc = new Composite(bottomChild, SWT.NONE); + changeDesc.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + SWTUtils.createLabel(changeDesc, NLS.bind(CVSUIMessages.CommitWizardCommitPage_1, new String[] { Integer.toString(size), Integer.toString(getFileDisplayThreshold()) })); + Button showChanges = new Button(changeDesc, SWT.PUSH); + showChanges.setText(CVSUIMessages.CommitWizardCommitPage_5); + showChanges.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - showChangesPane(); - } - }); - showChanges.setLayoutData(new GridData()); - bottomChild.showPage(changeDesc); - // Hide compare pane - horizontalSash.setMaximizedControl(verticalSash); - } else { - final Composite composite= new Composite(parent, SWT.NONE); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); - composite.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); - - Control c = createChangesPage(composite, participant); - c.setLayoutData(SWTUtils.createHVFillGridData()); - } - } + showChangesPane(); + } + }); + showChanges.setLayoutData(new GridData()); + bottomChild.showPage(changeDesc); + // Hide compare pane + horizontalSash.setMaximizedControl(verticalSash); + } else { + final Composite composite= new Composite(parent, SWT.NONE); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + composite.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); + + Control c = createChangesPage(composite, participant); + c.setLayoutData(SWTUtils.createHVFillGridData()); + } + } - protected void showChangesPane() { - Control c = createChangesPage(bottomChild, fWizard.getParticipant()); - bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); - bottomChild.showPage(c); - // Restore compare pane. It has been hidden when file display threshold was reached. - if (showCompare) { - horizontalSash.setMaximizedControl(null); - } - Dialog.applyDialogFont(getControl()); - ((Composite)getControl()).layout(); - } + protected void showChangesPane() { + Control c = createChangesPage(bottomChild, fWizard.getParticipant()); + bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); + bottomChild.showPage(c); + // Restore compare pane. It has been hidden when file display threshold was reached. + if (showCompare) { + horizontalSash.setMaximizedControl(null); + } + Dialog.applyDialogFont(getControl()); + ((Composite)getControl()).layout(); + } - private Control createChangesPage(final Composite composite, ISynchronizeParticipant participant) { - fConfiguration= participant.createPageConfiguration(); + private Control createChangesPage(final Composite composite, ISynchronizeParticipant participant) { + fConfiguration= participant.createPageConfiguration(); CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(false); cc.setRightEditable(false); @@ -233,8 +233,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang Control control = input.createContents(composite); control.setLayoutData(new GridData(GridData.FILL_BOTH)); return control; - } - + } + private class CommitWizardParticipantPageCompareEditorInput extends ParticipantPageCompareEditorInput { public CommitWizardParticipantPageCompareEditorInput( @@ -259,11 +259,11 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang protected void setPageDescription(String title) { super.setPageDescription(TeamUIMessages.ParticipantPageSaveablePart_0); } - } - + } + private int getFileDisplayThreshold() { - return CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD); - } + return CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD); + } @Override public void dispose() { @@ -273,16 +273,16 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang fPagePane.dispose(); } - private void createPlaceholder(final Composite composite) { - final Composite placeholder= new Composite(composite, SWT.NONE); - placeholder.setLayoutData(new GridData(SWT.DEFAULT, convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_SPACING) /3)); - } - - public String getComment(Shell shell) { - return fCommentArea.getCommentWithPrompt(shell); - } - - @Override + private void createPlaceholder(final Composite composite) { + final Composite placeholder= new Composite(composite, SWT.NONE); + placeholder.setLayoutData(new GridData(SWT.DEFAULT, convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_SPACING) /3)); + } + + public String getComment(Shell shell) { + return fCommentArea.getCommentWithPrompt(shell); + } + + @Override public boolean isPageComplete() { /* if empty comment is not allowed (see bug 114678) */ final IPreferenceStore store = CVSUIPlugin.getPlugin() @@ -298,72 +298,72 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } return super.isPageComplete(); } - - @Override + + @Override public void setVisible(boolean visible) { - super.setVisible(visible); - expand(); - if (visible && fConfiguration != null) { - final Viewer viewer= fConfiguration.getPage().getViewer(); - viewer.refresh(); - } - updateEnablements(); - setFocus(); - } + super.setVisible(visible); + expand(); + if (visible && fConfiguration != null) { + final Viewer viewer= fConfiguration.getPage().getViewer(); + viewer.refresh(); + } + updateEnablements(); + setFocus(); + } - protected void expand() { - if (fConfiguration != null) { - final Viewer viewer= fConfiguration.getPage().getViewer(); - if (viewer instanceof TreeViewer) { - try { - viewer.getControl().setRedraw(false); - ((TreeViewer)viewer).expandAll(); - } finally { - viewer.getControl().setRedraw(true); - } - } - } - } - + protected void expand() { + if (fConfiguration != null) { + final Viewer viewer= fConfiguration.getPage().getViewer(); + if (viewer instanceof TreeViewer) { + try { + viewer.getControl().setRedraw(false); + ((TreeViewer)viewer).expandAll(); + } finally { + viewer.getControl().setRedraw(true); + } + } + } + } + /* * Expand the sync elements and update the page enablement */ protected void updateForModelChange() { - Control control = getControl(); - if (control == null || control.isDisposed()) return; + Control control = getControl(); + if (control == null || control.isDisposed()) return; expand(); updateEnablements(); } public void updateEnablements() { - if (fConfiguration != null) { - fHasConflicts = false; - fIsEmpty = false; - + if (fConfiguration != null) { + fHasConflicts = false; + fIsEmpty = false; + if (fWizard.hasConflicts()) { - fHasConflicts = true; - } + fHasConflicts = true; + } if (!fWizard.hasOutgoingChanges()) { - fIsEmpty = true; - } - } - + fIsEmpty = true; + } + } + validatePage(false); } boolean validatePage(boolean setMessage) { - if (fCommentArea != null && fCommentArea.getComment(false).length() == 0) { - final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore(); - final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); - if (MessageDialogWithToggle.NEVER.equals(value)) { - setPageComplete(false); - if (setMessage) - setErrorMessage(CVSUIMessages.CommitWizardCommitPage_3); - return false; - } - } - - if (fHasConflicts) { + if (fCommentArea != null && fCommentArea.getComment(false).length() == 0) { + final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore(); + final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); + if (MessageDialogWithToggle.NEVER.equals(value)) { + setPageComplete(false); + if (setMessage) + setErrorMessage(CVSUIMessages.CommitWizardCommitPage_3); + return false; + } + } + + if (fHasConflicts) { setErrorMessage(CVSUIMessages.CommitWizardCommitPage_4); setPageComplete(false); return false; @@ -374,67 +374,67 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang setPageComplete(false); return false; } - - setPageComplete(true); - setErrorMessage(null); - return true; - } - - public void setFocus() { - fCommentArea.setFocus(); - validatePage(true); - } - - @Override + + setPageComplete(true); + setErrorMessage(null); + return true; + } + + public void setFocus() { + fCommentArea.setFocus(); + validatePage(true); + } + + @Override protected IWizardContainer getContainer() { - return super.getContainer(); - } + return super.getContainer(); + } ResourceTraversal[] getTraversalsToCommit() { return fWizard.getParticipant().getContext().getScope().getTraversals(); - } + } - @Override + @Override public void propertyChange(PropertyChangeEvent event) { - - if (event.getProperty().equals(CommitCommentArea.OK_REQUESTED)) { - final IWizardContainer container= getContainer(); - if (container instanceof WizardDialog) { - final WizardDialog dialog= (WizardDialog)container; - if (getWizard().canFinish()) { - try { - getWizard().performFinish(); - } finally { - dialog.close(); - } - } - } - } - if (event.getProperty().equals(CommitCommentArea.COMMENT_MODIFIED)) { - validatePage(true); - } - } - + + if (event.getProperty().equals(CommitCommentArea.OK_REQUESTED)) { + final IWizardContainer container= getContainer(); + if (container instanceof WizardDialog) { + final WizardDialog dialog= (WizardDialog)container; + if (getWizard().canFinish()) { + try { + getWizard().performFinish(); + } finally { + dialog.close(); + } + } + } + } + if (event.getProperty().equals(CommitCommentArea.COMMENT_MODIFIED)) { + validatePage(true); + } + } + /* * Get a proposed comment by looking at the active change sets */ - private String getProposedComment(IResource[] resourcesToCommit) { - StringBuffer comment = new StringBuffer(); - ChangeSet[] sets = CVSUIPlugin.getPlugin().getChangeSetManager().getSets(); - Arrays.sort(sets, new ChangeSetComparator()); - int numMatchedSets = 0; - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (isUserSet(set) && containsOne(set, resourcesToCommit)) { - if(numMatchedSets > 0) comment.append(System.getProperty("line.separator")); //$NON-NLS-1$ - comment.append(set.getComment()); - numMatchedSets++; - } - } - return comment.toString(); - } - - private boolean isUserSet(ChangeSet set) { + private String getProposedComment(IResource[] resourcesToCommit) { + StringBuffer comment = new StringBuffer(); + ChangeSet[] sets = CVSUIPlugin.getPlugin().getChangeSetManager().getSets(); + Arrays.sort(sets, new ChangeSetComparator()); + int numMatchedSets = 0; + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (isUserSet(set) && containsOne(set, resourcesToCommit)) { + if(numMatchedSets > 0) comment.append(System.getProperty("line.separator")); //$NON-NLS-1$ + comment.append(set.getComment()); + numMatchedSets++; + } + } + return comment.toString(); + } + + private boolean isUserSet(ChangeSet set) { if (set instanceof ActiveChangeSet) { ActiveChangeSet acs = (ActiveChangeSet) set; return acs.isUserCreated(); @@ -443,7 +443,7 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } private boolean containsOne(ChangeSet set, IResource[] resourcesToCommit) { - for (int j = 0; j < resourcesToCommit.length; j++) { + for (int j = 0; j < resourcesToCommit.length; j++) { IResource resource = resourcesToCommit[j]; if (set.contains(resource)) { return true; @@ -455,14 +455,14 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } } return false; - } + } public void finish() { int[] hWeights = horizontalSash.getWeights(); int[] vWeights = verticalSash.getWeights(); IDialogSettings section = getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); - if (section == null) - section= getDialogSettings().addNewSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); + if (section == null) + section= getDialogSettings().addNewSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); if (showCompare) { section.put(H_WEIGHT_1, hWeights[0]); section.put(H_WEIGHT_2, hWeights[1]); @@ -481,6 +481,6 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } } - + } |