diff options
| author | François Rey | 2013-05-20 12:33:15 +0000 |
|---|---|---|
| committer | Matthias Sohn | 2013-05-20 16:59:22 +0000 |
| commit | 71011505937a3e8b70e6c7e754b24f9f63c90993 (patch) | |
| tree | fed3655f93fa59b8e63f16c780ef268e67104530 | |
| parent | fba31ed7bb17b78cfefc347c2a1ce5c1ea1dc937 (diff) | |
| download | egit-71011505937a3e8b70e6c7e754b24f9f63c90993.tar.gz egit-71011505937a3e8b70e6c7e754b24f9f63c90993.tar.xz egit-71011505937a3e8b70e6c7e754b24f9f63c90993.zip | |
Commit dialog: make message section resizable to augment file list area
A sash has been added above the file section and below a new composite
containing message and person areas.
Bug: 343712
Change-Id: I75ab194b908c19e857f4ff660d7e568f2b907bc1
Signed-off-by: François Rey <eclipse.org@francois.rey.name>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| -rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java | 336 |
1 files changed, 184 insertions, 152 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java index a4f36df88d..cbf1622089 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java @@ -8,6 +8,7 @@ * Copyright (C) 2012, Daniel Megert <daniel_megert@ch.ibm.com> * Copyright (C) 2012, Robin Stocker <robin@nibor.org> * Copyright (C) 2012, IBM Corporation (Markus Keller <markus_keller@ch.ibm.com>) + * Copyright (C) 2013, François Rey <eclipse.org_@_francois_._rey_._name> * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -89,6 +90,7 @@ import org.eclipse.jgit.lib.IndexDiff; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.ModifyEvent; @@ -650,149 +652,55 @@ public class CommitDialog extends TitleAreaDialog { toolkit.paintBordersFor(container); GridLayoutFactory.swtDefaults().applyTo(container); - Section messageSection = toolkit.createSection(container, - ExpandableComposite.TITLE_BAR - | ExpandableComposite.CLIENT_INDENT); - messageSection.setText(UIText.CommitDialog_CommitMessage); - Composite messageArea = toolkit.createComposite(messageSection); - GridLayoutFactory.fillDefaults().spacing(0, 0) - .extendedMargins(2, 2, 2, 2).applyTo(messageArea); - toolkit.paintBordersFor(messageArea); - GridDataFactory.fillDefaults().grab(true, true).applyTo(messageSection); - - Composite headerArea = new Composite(messageSection, SWT.NONE); - GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(2) - .applyTo(headerArea); - - ToolBar messageToolbar = new ToolBar(headerArea, SWT.FLAT - | SWT.HORIZONTAL); - GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL) - .grab(true, false).applyTo(messageToolbar); - - addMessageDropDown(headerArea); - - messageSection.setTextClient(headerArea); - - final CommitProposalProcessor commitProposalProcessor = new CommitProposalProcessor() { - @Override - protected Collection<String> computeFileNameProposals() { - return getFileList(); - } - - @Override - protected Collection<String> computeMessageProposals() { - return CommitMessageHistory.getCommitHistory(); - } - }; - commitText = new CommitMessageArea(messageArea, commitMessage, SWT.NONE) { - @Override - protected CommitProposalProcessor getCommitProposalProcessor() { - return commitProposalProcessor; - } - }; - commitText - .setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); - messageSection.setClient(messageArea); - Point size = commitText.getTextWidget().getSize(); - int minHeight = commitText.getTextWidget().getLineHeight() * 3; - commitText.setLayoutData(GridDataFactory.fillDefaults() - .grab(true, true).hint(size).minSize(size.x, minHeight) - .align(SWT.FILL, SWT.FILL).create()); + final SashForm sashForm= new SashForm(container, SWT.VERTICAL + | SWT.FILL); + toolkit.adapt(sashForm, true, true); + sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true) + .create()); + createMessageAndPersonArea(sashForm); + filesSection = createFileSection(sashForm); + sashForm.setWeights(new int[] { 50, 50 }); - UIUtils.addBulbDecorator(commitText.getTextWidget(), - UIText.CommitDialog_ContentAssist); - - Composite personArea = toolkit.createComposite(container); - toolkit.paintBordersFor(personArea); - GridLayoutFactory.swtDefaults().numColumns(2).applyTo(personArea); - GridDataFactory.fillDefaults().grab(true, false).applyTo(personArea); - - toolkit.createLabel(personArea, UIText.CommitDialog_Author) - .setForeground( - toolkit.getColors().getColor(IFormColors.TB_TOGGLE)); - authorText = toolkit.createText(personArea, null); - authorText - .setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); - authorText.setLayoutData(GridDataFactory.fillDefaults() - .grab(true, false).create()); - - toolkit.createLabel(personArea, UIText.CommitDialog_Committer) - .setForeground( - toolkit.getColors().getColor(IFormColors.TB_TOGGLE)); - committerText = toolkit.createText(personArea, null); - committerText.setLayoutData(GridDataFactory.fillDefaults() - .grab(true, false).create()); - if (committer != null) - committerText.setText(committer); - - amendingItem = new ToolItem(messageToolbar, SWT.CHECK); - amendingItem.setSelection(amending); - if (amending) - amendingItem.setEnabled(false); // if already set, don't allow any - // changes - else if (!amendAllowed) - amendingItem.setEnabled(false); - amendingItem.setToolTipText(UIText.CommitDialog_AmendPreviousCommit); - Image amendImage = UIIcons.AMEND_COMMIT.createImage(); - UIUtils.hookDisposal(amendingItem, amendImage); - amendingItem.setImage(amendImage); - - signedOffItem = new ToolItem(messageToolbar, SWT.CHECK); - - signedOffItem.setToolTipText(UIText.CommitDialog_AddSOB); - Image signedOffImage = UIIcons.SIGNED_OFF.createImage(); - UIUtils.hookDisposal(signedOffItem, signedOffImage); - signedOffItem.setImage(signedOffImage); - - changeIdItem = new ToolItem(messageToolbar, SWT.CHECK); - Image changeIdImage = UIIcons.GERRIT.createImage(); - UIUtils.hookDisposal(changeIdItem, changeIdImage); - changeIdItem.setImage(changeIdImage); - changeIdItem.setToolTipText(UIText.CommitDialog_AddChangeIdLabel); - - final ICommitMessageComponentNotifications listener = new ICommitMessageComponentNotifications() { + applyDialogFont(container); + container.pack(); + commitText.setFocus(); + Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage(); + UIUtils.hookDisposal(parent, titleImage); + setTitleImage(titleImage); + setTitle(UIText.CommitDialog_Title); + setMessage(UIText.CommitDialog_Message, IMessageProvider.INFORMATION); - public void updateSignedOffToggleSelection(boolean selection) { - signedOffItem.setSelection(selection); - } + ModifyListener validator = new ModifyListener() { - public void updateChangeIdToggleSelection(boolean selection) { - changeIdItem.setSelection(selection); + public void modifyText(ModifyEvent e) { + updateMessage(); } }; + commitText.getDocument().addDocumentListener(new IDocumentListener() { - commitMessageComponent = new CommitMessageComponent(repository, listener); - commitMessageComponent.enableListers(false); - commitMessageComponent.setDefaults(); - commitMessageComponent.attachControls(commitText, authorText, committerText); - commitMessageComponent.setCommitMessage(commitMessage); - commitMessageComponent.setAuthor(author); - commitMessageComponent.setCommitter(committer); - commitMessageComponent.setAmending(amending); - commitMessageComponent.setFilesToCommit(getFileList()); - - amendingItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent arg0) { - commitMessageComponent.setAmendingButtonSelection(amendingItem.getSelection()); + public void documentChanged(DocumentEvent event) { + updateMessage(); } - }); - changeIdItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent arg0) { - commitMessageComponent.setChangeIdButtonSelection(changeIdItem.getSelection()); + public void documentAboutToBeChanged(DocumentEvent event) { + // Intentionally empty } }); + authorText.addModifyListener(validator); + committerText.addModifyListener(validator); + filesViewer.addCheckStateListener(new ICheckStateListener() { - signedOffItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent arg0) { - commitMessageComponent.setSignedOffButtonSelection(signedOffItem.getSelection()); + public void checkStateChanged(CheckStateChangedEvent event) { + updateMessage(); } }); - commitMessageComponent.updateUI(); - commitMessageComponent.enableListers(true); + updateFileSectionText(); + return container; + } - filesSection = toolkit.createSection(container, + private Section createFileSection(Composite container) { + Section filesSection = toolkit.createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT); GridDataFactory.fillDefaults().grab(true, true).applyTo(filesSection); @@ -948,45 +856,169 @@ public class CommitDialog extends TitleAreaDialog { filesViewer.setChecked(item, true); } } - - applyDialogFont(container); statCol.pack(); resourceCol.pack(); - container.pack(); - commitText.setFocus(); - Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage(); - UIUtils.hookDisposal(parent, titleImage); - setTitleImage(titleImage); - setTitle(UIText.CommitDialog_Title); - setMessage(UIText.CommitDialog_Message, IMessageProvider.INFORMATION); + return filesSection; + } - ModifyListener validator = new ModifyListener() { + private Composite createMessageAndPersonArea(Composite container) { - public void modifyText(ModifyEvent e) { - updateMessage(); + Composite messageAndPersonArea = toolkit.createComposite(container); + GridDataFactory.fillDefaults().grab(true, true) + .applyTo(messageAndPersonArea); + GridLayoutFactory.swtDefaults().margins(0, 0).spacing(0, 0) + .applyTo(messageAndPersonArea); + + Section messageSection = toolkit.createSection(messageAndPersonArea, + ExpandableComposite.TITLE_BAR + | ExpandableComposite.CLIENT_INDENT); + messageSection.setText(UIText.CommitDialog_CommitMessage); + Composite messageArea = toolkit.createComposite(messageSection); + GridLayoutFactory.fillDefaults().spacing(0, 0) + .extendedMargins(2, 2, 2, 2).applyTo(messageArea); + toolkit.paintBordersFor(messageArea); + GridDataFactory.fillDefaults().grab(true, true).applyTo(messageSection); + GridLayoutFactory.swtDefaults().applyTo(messageSection); + + Composite headerArea = new Composite(messageSection, SWT.NONE); + GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(2) + .applyTo(headerArea); + + ToolBar messageToolbar = new ToolBar(headerArea, SWT.FLAT + | SWT.HORIZONTAL); + GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL) + .grab(true, false).applyTo(messageToolbar); + + addMessageDropDown(headerArea); + + messageSection.setTextClient(headerArea); + + final CommitProposalProcessor commitProposalProcessor = new CommitProposalProcessor() { + @Override + protected Collection<String> computeFileNameProposals() { + return getFileList(); + } + + @Override + protected Collection<String> computeMessageProposals() { + return CommitMessageHistory.getCommitHistory(); } }; - commitText.getDocument().addDocumentListener(new IDocumentListener() { + commitText = new CommitMessageArea(messageArea, commitMessage, SWT.NONE) { + @Override + protected CommitProposalProcessor getCommitProposalProcessor() { + return commitProposalProcessor; + } + }; + commitText + .setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + messageSection.setClient(messageArea); + Point size = commitText.getTextWidget().getSize(); + int minHeight = commitText.getTextWidget().getLineHeight() * 3; + commitText.setLayoutData(GridDataFactory.fillDefaults() + .grab(true, true).hint(size).minSize(size.x, minHeight) + .align(SWT.FILL, SWT.FILL).create()); - public void documentChanged(DocumentEvent event) { - updateMessage(); + UIUtils.addBulbDecorator(commitText.getTextWidget(), + UIText.CommitDialog_ContentAssist); + + Composite personArea = toolkit.createComposite(messageAndPersonArea); + toolkit.paintBordersFor(personArea); + GridLayoutFactory.swtDefaults().numColumns(2).applyTo(personArea); + GridDataFactory.fillDefaults().grab(true, false).applyTo(personArea); + + toolkit.createLabel(personArea, UIText.CommitDialog_Author) + .setForeground( + toolkit.getColors().getColor(IFormColors.TB_TOGGLE)); + authorText = toolkit.createText(personArea, null); + authorText + .setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + authorText.setLayoutData(GridDataFactory.fillDefaults() + .grab(true, false).create()); + + toolkit.createLabel(personArea, UIText.CommitDialog_Committer) + .setForeground( + toolkit.getColors().getColor(IFormColors.TB_TOGGLE)); + committerText = toolkit.createText(personArea, null); + committerText.setLayoutData(GridDataFactory.fillDefaults() + .grab(true, false).create()); + if (committer != null) + committerText.setText(committer); + + amendingItem = new ToolItem(messageToolbar, SWT.CHECK); + amendingItem.setSelection(amending); + if (amending) + amendingItem.setEnabled(false); // if already set, don't allow any + // changes + else if (!amendAllowed) + amendingItem.setEnabled(false); + amendingItem.setToolTipText(UIText.CommitDialog_AmendPreviousCommit); + Image amendImage = UIIcons.AMEND_COMMIT.createImage(); + UIUtils.hookDisposal(amendingItem, amendImage); + amendingItem.setImage(amendImage); + + signedOffItem = new ToolItem(messageToolbar, SWT.CHECK); + + signedOffItem.setToolTipText(UIText.CommitDialog_AddSOB); + Image signedOffImage = UIIcons.SIGNED_OFF.createImage(); + UIUtils.hookDisposal(signedOffItem, signedOffImage); + signedOffItem.setImage(signedOffImage); + + changeIdItem = new ToolItem(messageToolbar, SWT.CHECK); + Image changeIdImage = UIIcons.GERRIT.createImage(); + UIUtils.hookDisposal(changeIdItem, changeIdImage); + changeIdItem.setImage(changeIdImage); + changeIdItem.setToolTipText(UIText.CommitDialog_AddChangeIdLabel); + + final ICommitMessageComponentNotifications listener = new ICommitMessageComponentNotifications() { + + public void updateSignedOffToggleSelection(boolean selection) { + signedOffItem.setSelection(selection); } - public void documentAboutToBeChanged(DocumentEvent event) { - // Intentionally empty + public void updateChangeIdToggleSelection(boolean selection) { + changeIdItem.setSelection(selection); + } + }; + + commitMessageComponent = new CommitMessageComponent(repository, + listener); + commitMessageComponent.enableListers(false); + commitMessageComponent.setDefaults(); + commitMessageComponent.attachControls(commitText, authorText, + committerText); + commitMessageComponent.setCommitMessage(commitMessage); + commitMessageComponent.setAuthor(author); + commitMessageComponent.setCommitter(committer); + commitMessageComponent.setAmending(amending); + commitMessageComponent.setFilesToCommit(getFileList()); + + amendingItem.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent arg0) { + commitMessageComponent.setAmendingButtonSelection(amendingItem + .getSelection()); } }); - authorText.addModifyListener(validator); - committerText.addModifyListener(validator); - filesViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - updateMessage(); + changeIdItem.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent arg0) { + commitMessageComponent.setChangeIdButtonSelection(changeIdItem + .getSelection()); } }); - updateFileSectionText(); - return container; + signedOffItem.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent arg0) { + commitMessageComponent + .setSignedOffButtonSelection(signedOffItem + .getSelection()); + } + }); + + commitMessageComponent.updateUI(); + commitMessageComponent.enableListers(true); + + return messageAndPersonArea; } private static CellLabelProvider createStatusLabelProvider() { |
