KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > jarpackager > ConfirmSaveModifiedResourcesDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.jarpackager;
12
13 import java.util.Arrays JavaDoc;
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 /**
38  * This dialog displays a list of <code>IFile</code> and asks
39  * the user to confirm saving all of them.
40  * <p>
41  * This concrete dialog class can be instantiated as is.
42  * It is not intended to be subclassed.
43  * </p>
44  */

45 public class ConfirmSaveModifiedResourcesDialog extends MessageDialog {
46     
47     // String constants for widgets
48
private static String JavaDoc TITLE= JarPackagerMessages.ConfirmSaveModifiedResourcesDialog_title;
49     private static String JavaDoc 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 JavaDoc[] { 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     /*
87      * @see org.eclipse.jface.window.Window#configureShell(Shell)
88      */

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