1 11 package org.eclipse.jdt.internal.ui.jarpackager; 12 13 import java.util.Arrays ; 14 15 import org.eclipse.core.resources.IFile; 16 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.layout.GridData; 19 import org.eclipse.swt.widgets.Composite; 20 import org.eclipse.swt.widgets.Control; 21 import org.eclipse.swt.widgets.Shell; 22 23 import org.eclipse.jface.dialogs.IDialogConstants; 24 import org.eclipse.jface.dialogs.MessageDialog; 25 import org.eclipse.jface.viewers.TableViewer; 26 27 import org.eclipse.ui.PlatformUI; 28 29 import org.eclipse.jdt.ui.ProblemsLabelDecorator; 30 31 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 32 33 import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; 34 import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; 35 import org.eclipse.jdt.internal.ui.viewsupport.ListContentProvider; 36 37 45 public class ConfirmSaveModifiedResourcesDialog extends MessageDialog { 46 47 private static String TITLE= JarPackagerMessages.ConfirmSaveModifiedResourcesDialog_title; 49 private static String MESSAGE= JarPackagerMessages.ConfirmSaveModifiedResourcesDialog_message; 50 51 private TableViewer fList; 52 private IFile[] fUnsavedFiles; 53 54 public ConfirmSaveModifiedResourcesDialog(Shell parentShell, IFile[] unsavedFiles) { 55 super( 56 parentShell, 57 TITLE, 58 null, 59 MESSAGE, 60 QUESTION, 61 new String [] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 62 0); 63 fUnsavedFiles= unsavedFiles; 64 } 65 66 protected Control createCustomArea(Composite parent) { 67 fList= new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); 68 fList.setContentProvider(new ListContentProvider()); 69 AppearanceAwareLabelProvider lprovider= new AppearanceAwareLabelProvider( 70 AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, 71 AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS 72 ); 73 lprovider.addLabelDecorator(new ProblemsLabelDecorator()); 74 fList.setLabelProvider(lprovider); 75 fList.setInput(Arrays.asList(fUnsavedFiles)); 76 Control control= fList.getControl(); 77 GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); 78 data.widthHint= convertWidthInCharsToPixels(20); 79 data.heightHint= convertHeightInCharsToPixels(5); 80 control.setLayoutData(data); 81 applyDialogFont(control); 82 return control; 83 } 84 85 86 89 protected void configureShell(Shell newShell) { 90 super.configureShell(newShell); 91 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CONFIRM_SAVE_MODIFIED_RESOURCES_DIALOG); 92 } 93 94 95 } 96 | Popular Tags |