X-Git-Url: http://secure.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/EntityPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/EntityPropertyPage.java deleted file mode 100644 index 6937c1b..0000000 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/EntityPropertyPage.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.quantum.properties; - -import com.quantum.model.Column; -import com.quantum.model.Entity; -import com.quantum.model.Index; -import com.quantum.view.bookmark.EntityNode; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.dialogs.PropertyPage; - -public class EntityPropertyPage extends PropertyPage { - - protected Control createContents(Composite parent) { - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL); - data.grabExcessHorizontalSpace = true; - composite.setLayoutData(data); - - Label label = new Label(composite, SWT.NONE); - label.setText("Name:"); - - Entity entity = getEntity(); - - Label name = new Label(composite, SWT.NONE); - name.setText(entity.getName()); - - label = new Label(composite, SWT.NONE); - label.setText("Schema:"); - - Label schema = new Label(composite, SWT.NONE); - schema.setText(entity.getSchema()); - - if (!Entity.SEQUENCE_TYPE.equals(getEntity().getType())) { - TabFolder tabFolder = new TabFolder(parent, SWT.NONE); - layout = new GridLayout(); - tabFolder.setLayout(layout); - data = new GridData(GridData.FILL_BOTH); - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - data.verticalAlignment = GridData.FILL; - data.horizontalSpan = 2; - data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; - tabFolder.setLayoutData(data); - - createColumnsTab(tabFolder); - createIndexesTab(tabFolder); - } - - return composite; - } - - private Entity getEntity() { - Entity entity = - ((EntityNode) getElement()).getEntity(); - return entity; - } - - private void createColumnsTab(TabFolder tabFolder) { - TabItem columnsTab = new TabItem(tabFolder, SWT.NONE); - columnsTab.setText("Columns"); - - Table table = new Table(tabFolder, SWT.FULL_SELECTION | SWT.MULTI); - table.setLinesVisible(true); - table.setHeaderVisible(true); - - GridLayout layout = new GridLayout(); - layout.marginWidth = 5; - layout.marginHeight = 5; - table.setLayout(layout); - GridData data = new GridData(GridData.FILL); - data.horizontalAlignment = GridData.FILL_HORIZONTAL; - data.verticalAlignment = GridData.FILL_VERTICAL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - table.setLayoutData(data); - - String[] columnNames = { "Name", "Type", "Size", "Digits", - "Primary Key", "Nullable", "Remarks" }; - - for (int i = 0, length = columnNames.length; i < length; i++) { - TableColumn column = new TableColumn(table, SWT.NONE); - column.setText(columnNames[i]); - } - for (int i = 0, length = columnNames.length; i < length; i++) { - table.getColumn(i).pack(); - } - - Column[] columns = getEntity().getColumns(); - for (int i = 0, length = columns.length; i < length; i++) { - TableItem item = new TableItem(table, SWT.NONE); - item.setText(new String[] { - columns[i].getName(), - columns[i].getTypeName(), - String.valueOf(columns[i].getSize()), - columns[i].getNumberOfFractionalDigits() == 0 ? "" : - String.valueOf(columns[i].getNumberOfFractionalDigits()), - columns[i].isPrimaryKey() ? "Yes" : "No", - columns[i].isNullable() ? "Yes" : "No", - columns[i].getRemarks() }); - } - - for (int i = 0, length = columnNames.length; i < length; i++) { - table.getColumn(i).pack(); - } - - data = new GridData(GridData.FILL); - data.horizontalAlignment = GridData.FILL_HORIZONTAL; - data.verticalAlignment = GridData.FILL_VERTICAL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - table.setLayoutData(data); - - columnsTab.setControl(table); - } - - private void createIndexesTab(TabFolder tabFolder) { - TabItem indexesTab = new TabItem(tabFolder, SWT.NONE); - indexesTab.setText("Indexes"); - - Table table = new Table(tabFolder, SWT.FULL_SELECTION | SWT.MULTI); - table.setLinesVisible(true); - table.setHeaderVisible(true); - - GridLayout layout = new GridLayout(); - layout.marginWidth = 5; - layout.marginHeight = 5; - table.setLayout(layout); - GridData data = new GridData(GridData.FILL); - data.horizontalAlignment = GridData.FILL_HORIZONTAL; - data.verticalAlignment = GridData.FILL_VERTICAL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - table.setLayoutData(data); - - String[] columnNames = { "Name", "Column", "Ascending" }; - - for (int i = 0, length = columnNames.length; i < length; i++) { - TableColumn column = new TableColumn(table, SWT.NONE); - column.setText(columnNames[i]); - } - for (int i = 0, length = columnNames.length; i < length; i++) { - table.getColumn(i).pack(); - } - - Index[] indexes = getEntity().getIndexes(); - for (int i = 0, length = indexes.length; i < length; i++) { - for (int j = 0, numberOfColumns = indexes[i].getNumberOfColumns(); - j < numberOfColumns; j++) { - - TableItem item = new TableItem(table, SWT.NONE); - item.setText(new String[] { - j == 0 ? indexes[i].getName() : "", - indexes[i].getColumnName(j), - indexes[i].isAscending(j) ? "Yes" - : (indexes[i].isDescending(j)) ? "No" : "" }); - } - } - - for (int i = 0, length = columnNames.length; i < length; i++) { - table.getColumn(i).pack(); - } - - data = new GridData(GridData.FILL); - data.horizontalAlignment = GridData.FILL_HORIZONTAL; - data.verticalAlignment = GridData.FILL_VERTICAL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - table.setLayoutData(data); - - indexesTab.setControl(table); - } - -} \ No newline at end of file