1 package com.quantum.properties;
3 import com.quantum.Messages;
4 import com.quantum.QuantumPlugin;
5 import com.quantum.model.Entity;
6 import com.quantum.model.EntityHolder;
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;
22 public abstract class BaseEntityPropertyPage extends PropertyPage {
24 class BasicContentProvider implements IStructuredContentProvider {
26 public Object[] getElements(Object inputElement) {
27 return (inputElement instanceof Object[]) ? (Object[]) inputElement : null;
29 public void dispose() {
31 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
34 protected Control createContents(Composite parent) {
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));
42 Label label = new Label(composite, SWT.NONE);
43 label.setText(Messages.getString(BaseEntityPropertyPage.class, "name"));
45 Entity entity = getEntity();
47 Label name = new Label(composite, SWT.NONE);
48 name.setText(entity.getName());
50 label = new Label(composite, SWT.NONE);
51 label.setText(Messages.getString(BaseEntityPropertyPage.class, "schema"));
53 Label schema = new Label(composite, SWT.NONE);
54 schema.setText(entity.getSchema());
56 createInformationArea(composite);
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(QuantumPlugin.getImage("warning.gif"));
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()));
78 protected abstract void createInformationArea(Composite composite);
80 protected Entity getEntity() {
82 ((EntityHolder) getElement()).getEntity();
88 protected void setColumnWidths(Table table) {
89 for (int i = 0, length = table.getColumnCount(); i < length; i++) {
90 table.getColumn(i).pack();