Added list selection box for file creation from wiki links
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / properties / BaseEntityPropertyPage.java
1 package com.quantum.properties;
2
3 import com.quantum.ImageStore;
4 import com.quantum.Messages;
5 import com.quantum.model.Entity;
6 import com.quantum.model.EntityHolder;
7
8 import org.eclipse.jface.viewers.IStructuredContentProvider;
9 import org.eclipse.jface.viewers.Viewer;
10 import org.eclipse.swt.SWT;
11 import org.eclipse.swt.layout.GridData;
12 import org.eclipse.swt.layout.GridLayout;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Control;
15 import org.eclipse.swt.widgets.Label;
16 import org.eclipse.swt.widgets.Table;
17 import org.eclipse.ui.dialogs.PropertyPage;
18
19 /**
20  * @author BC
21  */
22 public abstract class BaseEntityPropertyPage extends PropertyPage {
23
24         class BasicContentProvider implements IStructuredContentProvider {
25         
26                 public Object[] getElements(Object inputElement) {
27                         return (inputElement instanceof Object[]) ? (Object[]) inputElement : null; 
28                 }
29                 public void dispose() {
30                 }
31                 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
32                 }
33         }
34     protected Control createContents(Composite parent) {
35
36         Composite composite = new Composite(parent, SWT.NONE);
37         GridLayout layout = new GridLayout();
38         layout.numColumns = 2;
39         composite.setLayout(layout);
40         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
41
42                 Label label = new Label(composite, SWT.NONE);
43         label.setText(Messages.getString(BaseEntityPropertyPage.class, "name"));
44
45         Entity entity = getEntity();
46
47         Label name = new Label(composite, SWT.NONE);
48         name.setText(entity.getName());
49
50         label = new Label(composite, SWT.NONE);
51         label.setText(Messages.getString(BaseEntityPropertyPage.class, "schema"));
52
53         Label schema = new Label(composite, SWT.NONE);
54         schema.setText(entity.getSchema());
55         
56         createInformationArea(composite);
57         
58         return composite;
59     }   
60         /**
61          * @param composite
62          */
63         protected void createErrorMessage(Composite composite, Exception e) {
64                 Label icon = new Label(composite, SWT.NONE);
65                 icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
66                 icon.setImage(ImageStore.getImage(ImageStore.WARNING));
67                 
68                 Label error = new Label(composite, SWT.NONE);
69                 error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
70                 error.setText(Messages.getString(BaseEntityPropertyPage.class, "error") 
71                                 + (e.getMessage() == null ? "" : "\n" + e.getMessage()));
72         }
73
74
75     /**
76          * @param composite
77          */
78         protected abstract void createInformationArea(Composite composite);
79
80         protected Entity getEntity() {
81         Entity entity =
82             ((EntityHolder) getElement()).getEntity();
83         return entity;
84     }
85         /**
86          * @param table
87          */
88         protected void setColumnWidths(Table table) {
89                 for (int i = 0, length = table.getColumnCount(); i < length; i++) {
90                     table.getColumn(i).pack();
91                 }
92         }
93
94 }
95