1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.jface.dialogs.Dialog; 15 import org.eclipse.jface.dialogs.IDialogSettings; 16 import org.eclipse.jface.util.IPropertyChangeListener; 17 import org.eclipse.jface.util.PropertyChangeEvent; 18 import org.eclipse.swt.SWT; 19 import org.eclipse.swt.graphics.Point; 20 import org.eclipse.swt.graphics.Rectangle; 21 import org.eclipse.swt.layout.GridData; 22 import org.eclipse.swt.layout.GridLayout; 23 import org.eclipse.swt.widgets.*; 24 import org.eclipse.team.internal.ui.dialogs.DetailsDialog; 25 26 29 public class ReleaseCommentDialog extends DetailsDialog { 30 31 CommitCommentArea commitCommentArea; 32 private IDialogSettings settings; 34 35 private static final int DEFAULT_WIDTH_IN_CHARS= 80; 36 37 private static final String HEIGHT_KEY = "width-key"; private static final String WIDTH_KEY = "height-key"; 40 46 public ReleaseCommentDialog(Shell parentShell, IResource[] resourcesToCommit, String proposedComment, int depth) { 47 super(parentShell, CVSUIMessages.ReleaseCommentDialog_title); 48 int shellStyle = getShellStyle(); 49 setShellStyle(shellStyle | SWT.RESIZE | SWT.MAX); 50 commitCommentArea = new CommitCommentArea(); 51 if (resourcesToCommit.length > 0) 53 commitCommentArea.setProject(resourcesToCommit[0].getProject()); 54 commitCommentArea.setProposedComment(proposedComment); 55 56 IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); 57 this.settings = workbenchSettings.getSection("ReleaseCommentDialog"); if (settings == null) { 59 this.settings = workbenchSettings.addNewSection("ReleaseCommentDialog"); } 61 } 62 63 66 protected boolean includeDetailsButton() { 67 return false; 68 } 69 70 73 protected boolean includeErrorMessage() { 74 return false; 75 } 76 77 80 protected void createMainDialogArea(Composite parent) { 81 getShell().setText(CVSUIMessages.ReleaseCommentDialog_title); 82 Composite composite = new Composite(parent, SWT.NULL); 83 composite.setLayout(new GridLayout()); 84 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 85 86 commitCommentArea.createArea(composite); 87 commitCommentArea.addPropertyChangeListener(new IPropertyChangeListener() { 88 public void propertyChange(PropertyChangeEvent event) { 89 if (event.getProperty() == CommitCommentArea.OK_REQUESTED) 90 okPressed(); 91 } 92 }); 93 94 Dialog.applyDialogFont(parent); 95 } 96 97 100 protected String getHelpContextId() { 101 return IHelpContextIds.RELEASE_COMMENT_DIALOG; 102 } 103 104 107 protected Point getInitialSize() { 108 try { 109 return new Point(settings.getInt(WIDTH_KEY), settings.getInt(HEIGHT_KEY)); 110 } catch(NumberFormatException e) { 111 final Point size= super.getInitialSize(); 112 size.x= convertWidthInCharsToPixels(DEFAULT_WIDTH_IN_CHARS); 113 size.y += convertHeightInCharsToPixels(8); 114 return size; 115 } 116 } 117 118 public String getComment() { 119 return commitCommentArea.getComment(true); 120 } 121 122 125 protected Composite createDropDownDialogArea(Composite parent) { 126 return null; 127 } 128 129 132 protected void updateEnablements() { 133 } 134 135 138 public boolean close() { 139 Rectangle bounds = getShell().getBounds(); 140 settings.put(HEIGHT_KEY, bounds.height); 141 settings.put(WIDTH_KEY, bounds.width); 142 return super.close(); 143 } 144 145 148 protected Control createContents(Composite parent) { 149 Control c = super.createContents(parent); 150 commitCommentArea.setFocus(); 151 return c; 152 } 153 } 154 | Popular Tags |