All prefs for xampp administrated in external tools plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / externaltools / variable / SpecificFileResourceComponent.java
1 package net.sourceforge.phpdt.externaltools.variable;
2
3 /**********************************************************************
4 Copyright (c) 2002 IBM Corp. and others. All rights reserved.
5 This file is made available under the terms of the Common Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/cpl-v10.html
8  
9 Contributors:
10 **********************************************************************/
11
12 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsModelMessages;
13
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.jface.dialogs.IMessageProvider;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.layout.GridData;
19 import org.eclipse.swt.widgets.Label;
20
21 /**
22  * Visual component to edit the resource type variable
23  * value for the file location. Variable is limited to a specific
24  * <code>IFile</code> resource.
25  * <p>
26  * This class is not intended to be extended by clients.
27  * </p>
28  */
29 public class SpecificFileResourceComponent extends ResourceComponent {
30
31         /**
32          * Creates an instance
33          */
34         public SpecificFileResourceComponent() {
35                 super();
36         }
37
38         /* (non-Javadoc)
39          * Method declared on ResourceComponent.
40          */
41         protected void createSelectedResourceOption() {
42                 // Do not present this option...
43         }
44         
45         /* (non-Javadoc)
46          * Method declared on ResourceComponent.
47          */
48         protected void createSpecificResourceOption() {
49                 Label label = new Label(mainGroup, SWT.NONE);
50                 GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
51                 label.setLayoutData(data);
52                 label.setFont(mainGroup.getFont());
53                 label.setText(ExternalToolsModelMessages.getString("ResourceComponent.specificResLabel")); //$NON-NLS-1$
54         }
55
56         /* (non-Javadoc)
57          * Method declared on ResourceComponent.
58          */
59         protected boolean validateResourceListSelection() {
60                 if (resourceList == null)
61                         return true;
62                         
63                 IStructuredSelection sel = (IStructuredSelection) resourceList.getSelection();
64                 IResource resource = (IResource) sel.getFirstElement();
65                 if (resource == null || resource.getType() != IResource.FILE) {
66                         getPage().setMessage(ExternalToolsModelMessages.getString("ResourceComponent.selectionRequired"), IMessageProvider.WARNING); //$NON-NLS-1$
67                         setIsValid(false);
68                         return false;
69                 }
70                 
71                 return true;
72         }
73 }