Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 5442f2c17ba0b446cd243bce278330c7906a0d43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*******************************************************************************
 * Copyright (c) 2003, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.dialogs;

import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;

public class FilteredFileSelectionDialog extends ElementTreeSelectionDialog {
	protected String[] fExtensions;
	/**
	 * FilteredFileSelectionDialog constructor comment.
	 * 
	 * @param parent
	 *            Shell
	 * @parent extensions String[]
	 */
	public FilteredFileSelectionDialog(Shell parent, String[] extensions) {
		this(parent, null, null, extensions, false);
	}
	/**
	 * FilteredFileSelectionDialog constructor comment.
	 * 
	 * @param parent
	 *            Shell
	 * @param title
	 *            String
	 * @param message
	 *            String
	 * @parent extensions String[]
	 * @param allowMultiple
	 *            boolean
	 */
	public FilteredFileSelectionDialog(Shell parent, String title, String message, String[] extensions, boolean allowMultiple) {
		super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
		setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);

		setTitle(title);
		if (title == null)
			setTitle(J2EEUIMessages.getResourceString("File_Selection_UI_")); //$NON-NLS-1$
		if (message == null)
			message = J2EEUIMessages.getResourceString("Select_a_file__UI_"); //$NON-NLS-1$
		setMessage(message);
		setAllowMultiple(true);
		setExtensions(extensions);
		addFilter(new TypedFileViewerFilter(extensions));
		setValidator(new TypedElementSelectionValidator(new Class[]{IFile.class}, allowMultiple));

	}
	public String[] getExtensions() {
		return fExtensions;
	}
	public void setExtensions(String[] extensions) {
		fExtensions = extensions;
	}

	public void setHelp(String helpCode) {
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this.getParentShell(), helpCode); //$NON-NLS-1$
	}

}

Back to the top