]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/workbench/dialogs/ResourceListDialog.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / dialogs / ResourceListDialog.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 /*
13  * 7.6.2006
14  */
15 package org.simantics.ui.workbench.dialogs;
16
17 import org.eclipse.jface.viewers.ILabelProvider;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Shell;
21 import org.simantics.db.Resource;
22
23 /**
24  * ResourceListDialog
25  * @author Toni Kalajainen
26  */
27 public class ResourceListDialog extends ElementListSelectionDialog {
28     
29     public static final String DEFAULT_LABEL_SUFFIX = " (? = any character, * = any String)";
30     
31     public ResourceListDialog(Shell parent, ILabelProvider labelProvider) {
32         super(parent, labelProvider);
33     }
34
35     public ResourceListDialog(Shell parent, String title, String label, ILabelProvider labelProvider) {
36         this(parent, labelProvider);
37         this.setTitle(title);
38         this.setMessage(label);
39     }
40
41     public ResourceListDialog(Shell parent, String title, ILabelProvider labelProvider) {
42         this(parent, labelProvider);
43         this.setTitle(title);
44         this.setMessage(title+DEFAULT_LABEL_SUFFIX);
45     }
46     
47     @Override
48     protected Control createDialogArea(Composite parent) {
49         return super.createDialogArea(parent);
50     }
51     
52     public Resource[] getResultResources()
53     {
54         Object res[] = getResult();
55         Resource result[] = new Resource[res.length];
56         for (int i=0; i<res.length; i++)
57             result[i] = (Resource) res[i];
58         return result;
59     }
60
61     public Resource getSingleResultResource()
62     {
63         return (Resource) getSingleResult();
64     }
65     
66     public Object getSingleResult()
67     {
68         Object res[] = getResult();
69         if (res==null) return null;
70         if (res.length!=1) return null;
71         return res[0];
72     }
73     
74 }