Skip to content

Commit

Permalink
TEIIDDES-2570
Browse files Browse the repository at this point in the history
 * fixed edit/delete button enablements
 * fixed single UC issue
 * added back Key/Constraint tabs to virtual table editor
  • Loading branch information
blafond committed Mar 23, 2016
1 parent 3e8c81f commit a040ac8
Show file tree
Hide file tree
Showing 7 changed files with 584 additions and 449 deletions.
Expand Up @@ -334,6 +334,7 @@ private void validate() {
setMessage(editedConstraint.getStatus().getMessage(), IMessageProvider.WARNING);
} else if (editedConstraint.getStatus().getSeverity() == IStatus.ERROR) {
setErrorMessage(editedConstraint.getStatus().getMessage());
enable = false;
}
}

Expand Down
Expand Up @@ -14,6 +14,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
Expand Down Expand Up @@ -95,18 +96,18 @@ public class RelationalTableEditorPanel extends RelationalEditorPanel implements
private TabItem indexesTab;

// table property widgets
private Button materializedCB, supportsUpdateCB, isSystemTableCB, includePrimaryKeyCB, includeUniqueConstraintCB;
private Button materializedCB, supportsUpdateCB, isSystemTableCB, includePrimaryKeyCB;
private Button findTableReferenceButton;
private Label materializedTableLabel;
private Text cardinalityText, materializedTableText,
primaryKeyNameText, uniqueConstraintNameText,
primaryKeyNISText, uniqueConstraintNISText,
primaryKeyNameText,
primaryKeyNISText,
nativeQueryHelpText;
private StyledTextEditor nativeQueryTextEditor;

// column widgets
private Button addColumnButton, deleteColumnButton, upColumnButton, downColumnButton;
private Button changePkColumnsButton, changeUcColumnsButton, addFKButton, editFKButton, deleteFKButton;
private Button changePkColumnsButton, addFKButton, editFKButton, deleteFKButton;
private Button addUCButton, editUCButton, deleteUCButton;
private Button addIndexButton, deleteIndexButton, editIndexButton;
private TableViewerBuilder columnsViewer;
Expand All @@ -125,13 +126,12 @@ public class RelationalTableEditorPanel extends RelationalEditorPanel implements
*/
public RelationalTableEditorPanel(Composite parent, RelationalDialogModel dialogModel, IDialogStatusListener statusListener) {
super(parent, dialogModel, statusListener);

MULTIPLICITY_LIST = new ArrayList<String>();
for( String str : MULTIPLICITY.AS_ARRAY ) {
MULTIPLICITY_LIST.add(str);
}

synchronizeUI();
finishedStartup = true;
}

@Override
Expand Down Expand Up @@ -159,9 +159,6 @@ protected void createPanel(Composite parent) {
createForeignKeysTab(tabFolder);
createIndexesTab(tabFolder);
createNativeQueryTab(tabFolder);

finishedStartup = true;

}

private void createGeneralPropertiesTab(TabFolder folderParent) {
Expand Down Expand Up @@ -252,6 +249,7 @@ private void createNativeQueryTab(TabFolder folderParent) {

@Override
protected void synchronizeExtendedUI() {

synchronizePropertiesTab();
synchronizeColumnsTab();
synchronizePrimaryKeyTab();
Expand All @@ -264,6 +262,7 @@ protected void synchronizeExtendedUI() {
setNativeQueryEnablement(! isRelationalView() );
setKeyTabsEnablement(! isRelationalView());
}

}

/**
Expand Down Expand Up @@ -398,7 +397,14 @@ private void synchronizeUniqueConstraintTab() {
}
}

uniqueConstraintTab.setImage(RelationalUiUtil.getRelationalImage(TYPES.UC, getRelationalReference().getModelType(), getRelationalReference().getUniqueContraint().getStatus()));
// Find highest severity status
IStatus ucStatus = Status.OK_STATUS;
for( RelationalUniqueConstraint constraint : getRelationalReference().getUniqueConstraints() ) {
if( constraint.getStatus().getSeverity() > ucStatus.getSeverity() ) {
ucStatus = constraint.getStatus();
}
}
uniqueConstraintTab.setImage(RelationalUiUtil.getRelationalImage(TYPES.UC, getRelationalReference().getModelType(), ucStatus));
}
}

Expand Down Expand Up @@ -454,15 +460,34 @@ private void setNativeQueryEnablement(boolean enable) {

private void setKeyTabsEnablement(boolean enable) {
addFKButton.setEnabled(enable);
editFKButton.setEnabled(enable);
deleteFKButton.setEnabled(enable);
editFKButton.setEnabled(false);
deleteFKButton.setEnabled(false);
includePrimaryKeyCB.setEnabled(enable);
addUCButton.setEnabled(enable);
editUCButton.setEnabled(enable);
deleteUCButton.setEnabled(enable);
editUCButton.setEnabled(false);
deleteUCButton.setEnabled(false);
addIndexButton.setEnabled(enable);
editIndexButton.setEnabled(enable);
deleteIndexButton.setEnabled(enable);
editIndexButton.setEnabled(false);
deleteIndexButton.setEnabled(false);
// Update buttons
{
IStructuredSelection selection = (IStructuredSelection)uniqueConstraintsViewer.getSelection();
boolean value = ! selection.isEmpty();
editUCButton.setEnabled(value);
deleteUCButton.setEnabled(value);
}
{
IStructuredSelection selection = (IStructuredSelection)fkViewer.getSelection();
boolean value = ! selection.isEmpty();
editFKButton.setEnabled(value);
deleteFKButton.setEnabled(value);
}
{
IStructuredSelection selection = (IStructuredSelection)indexesViewer.getSelection();
boolean value = ! selection.isEmpty();
editIndexButton.setEnabled(value);
deleteIndexButton.setEnabled(value);
}
}

private Composite createPropertiesPanel(Composite parent) {
Expand Down Expand Up @@ -778,7 +803,7 @@ public void widgetSelected(SelectionEvent e) {

EditUniqueConstraintDialog dialog = new EditUniqueConstraintDialog(getShell(), getRelationalReference(), uc, true);

int result = dialog.open();
dialog.open();

handleInfoChanged();

Expand All @@ -787,6 +812,7 @@ public void widgetSelected(SelectionEvent e) {
}

});
this.editUCButton.setEnabled(false);

this.deleteUCButton = new Button(buttonPanel, SWT.PUSH);
this.deleteUCButton.setText(UILabelUtil.getLabel(UiLabelConstants.LABEL_IDS.DELETE));
Expand All @@ -806,12 +832,14 @@ public void widgetSelected(SelectionEvent e) {
}
if( uc != null ) {
getRelationalReference().removeUniqueConstraint(uc);
deleteFKButton.setEnabled(false);
deleteUCButton.setEnabled(false);
editUCButton.setEnabled(false);
handleInfoChanged();
}
}

});
this.deleteUCButton.setEnabled(false);

this.uniqueConstraintsViewer = new TableViewerBuilder(thePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, HEIGHT_HINT_80).applyTo(this.uniqueConstraintsViewer.getTableComposite());
Expand All @@ -826,6 +854,19 @@ public void widgetSelected(SelectionEvent e) {
this.uniqueConstraintsViewer.add(row);
}
}

this.uniqueConstraintsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

@Override
public void selectionChanged(SelectionChangedEvent event) {
// Update buttons
IStructuredSelection selection = (IStructuredSelection)uniqueConstraintsViewer.getSelection();
boolean enable = ! selection.isEmpty();
editUCButton.setEnabled(enable);
deleteUCButton.setEnabled(enable);

}
});

return thePanel;
}
Expand Down Expand Up @@ -901,6 +942,7 @@ public void widgetSelected(SelectionEvent e) {
}

});
this.editFKButton.setEnabled(false);

this.deleteFKButton = new Button(buttonPanel, SWT.PUSH);
this.deleteFKButton.setText(UILabelUtil.getLabel(UiLabelConstants.LABEL_IDS.DELETE));
Expand All @@ -926,6 +968,7 @@ public void widgetSelected(SelectionEvent e) {
}

});
this.deleteFKButton.setEnabled(false);

this.fkViewer = new TableViewerBuilder(thePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, HEIGHT_HINT_80).applyTo(this.fkViewer.getTableComposite());
Expand All @@ -941,6 +984,19 @@ public void widgetSelected(SelectionEvent e) {
}
}

this.fkViewer.addSelectionChangedListener(new ISelectionChangedListener() {

@Override
public void selectionChanged(SelectionChangedEvent event) {
// Update buttons
IStructuredSelection selection = (IStructuredSelection)fkViewer.getSelection();
boolean enable = ! selection.isEmpty();
editFKButton.setEnabled(enable);
deleteFKButton.setEnabled(enable);

}
});

return thePanel;
}

Expand Down Expand Up @@ -1010,6 +1066,7 @@ public void widgetSelected(SelectionEvent e) {
}

});
this.editIndexButton.setEnabled(false);

this.deleteIndexButton = new Button(buttonPanel, SWT.PUSH);
this.deleteIndexButton.setText(UILabelUtil.getLabel(UiLabelConstants.LABEL_IDS.DELETE));
Expand All @@ -1020,7 +1077,7 @@ public void widgetSelected(SelectionEvent e) {
public void widgetSelected(SelectionEvent e) {
RelationalIndex index = null;

IStructuredSelection selection = (IStructuredSelection)fkViewer.getSelection();
IStructuredSelection selection = (IStructuredSelection)indexesViewer.getSelection();
for( Object obj : selection.toArray()) {
if( obj instanceof RelationalIndex ) {
index = (RelationalIndex) obj;
Expand All @@ -1035,6 +1092,7 @@ public void widgetSelected(SelectionEvent e) {
}

});
this.deleteIndexButton.setEnabled(false);

this.indexesViewer = new TableViewerBuilder(thePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, HEIGHT_HINT_80).applyTo(this.indexesViewer.getTableComposite());
Expand All @@ -1049,6 +1107,19 @@ public void widgetSelected(SelectionEvent e) {
this.indexesViewer.add(row);
}
}

this.indexesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

@Override
public void selectionChanged(SelectionChangedEvent event) {
// Update buttons
IStructuredSelection selection = (IStructuredSelection)indexesViewer.getSelection();
boolean enable = ! selection.isEmpty();
editIndexButton.setEnabled(enable);
deleteIndexButton.setEnabled(enable);

}
});

return thePanel;
}
Expand Down Expand Up @@ -1277,7 +1348,7 @@ public boolean canFinish() {
if( !validationPerformed && this.getRelationalReference().getName() != null ) {
return true;
} else if( validationPerformed) {
return true;
return this.getRelationalReference().getName() != null;
}

return false;
Expand Down Expand Up @@ -1606,8 +1677,6 @@ class SelectColumnsDialog extends TitleAreaDialog {

private Set<RelationalColumn> selectedColumns = new HashSet<RelationalColumn>();

private boolean isPrimaryKeyColumns = false;

//=============================================================
// Constructors
//=============================================================
Expand All @@ -1620,7 +1689,6 @@ class SelectColumnsDialog extends TitleAreaDialog {
public SelectColumnsDialog(Shell parent, RelationalTable theTable, boolean isPrimaryKeyColumns) {
super(parent);
this.theTable = theTable;
this.isPrimaryKeyColumns = isPrimaryKeyColumns;
}

@Override
Expand Down Expand Up @@ -1704,23 +1772,13 @@ public Object[] getChildren(Object parentElement) {

this.columnDataViewer.setInput(this.theTable);

if( isPrimaryKeyColumns ) {
for( RelationalColumn col : this.theTable.getPrimaryKey().getColumns() ) {
for( TableItem item : columnDataViewer.getTable().getItems() ) {
if( item.getData() == col ) {
item.setChecked(true);
}
}
}
} else {
for( RelationalColumn col : this.theTable.getUniqueContraint().getColumns() ) {
for( TableItem item : columnDataViewer.getTable().getItems() ) {
if( item.getData() == col ) {
item.setChecked(true);
}
}
}
}
for( RelationalColumn col : this.theTable.getPrimaryKey().getColumns() ) {
for( TableItem item : columnDataViewer.getTable().getItems() ) {
if( item.getData() == col ) {
item.setChecked(true);
}
}
}

setMessage(Messages.selectColumnsMessage);
return composite;
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.teiid.designer.relational.ui.Messages;
import org.teiid.designer.relational.ui.edit.RelationalEditorPanel;
import org.teiid.designer.ui.common.eventsupport.IDialogStatusListener;
import org.teiid.designer.ui.common.util.WidgetFactory;
import org.teiid.designer.ui.common.widget.ScrollableTitleAreaDialog;

/**
Expand Down Expand Up @@ -68,7 +69,6 @@ protected void constrainShellSize() {
@Override
protected Control createDialogArea(Composite parent) {
Composite pnlOuter = (Composite) super.createDialogArea(parent);

this.setTitle(dialogModel.getDialogTitle());
this.setMessage(dialogModel.getHelpText());

Expand Down
Expand Up @@ -87,7 +87,7 @@ public List<RelationalColumn> getColumns() {
* @param columns Sets columns to the specified value.
*/
public void setColumns( Collection<RelationalColumn> columns ) {
this.columns = new ArrayList(columns);
this.columns = new ArrayList<RelationalColumn>(columns);
handleInfoChanged();
}

Expand Down
Expand Up @@ -13,7 +13,7 @@
* @since 8.0
*/
@SuppressWarnings("javadoc")
public class Messages extends NLS {
public class Messages extends org.teiid.designer.relational.ui.Messages {
public static String Browse;
public static String Edit;
public static String EditColumnTitle;
Expand Down Expand Up @@ -77,7 +77,6 @@ public class Messages extends NLS {
public static String uniqueLabel;
public static String filterConditionLabel;
public static String referencedColumnsLabel;
public static String indexesLabel;
public static String indexLabel;
public static String tableSelectionTitle;
public static String selectExistingTableForIndexInitialMessage;
Expand All @@ -86,9 +85,7 @@ public class Messages extends NLS {
public static String materializedLabel;
public static String tableReferenceLabel;
public static String systemTableLabel;
public static String foreignKeysLabel;
public static String primaryKeyLabel;
public static String uniqueConstraintLabel;

public static String globalTempTableLabel;

public static String nameLabel;
Expand All @@ -103,12 +100,10 @@ public class Messages extends NLS {
public static String nameInSourceLabel;
public static String cardinalityLabel;
public static String supportsUpdateLabel;
public static String columnsLabel;
public static String columnNameLabel;
public static String dataTypeLabel;
public static String lengthLabel;
public static String procedureLabel;
public static String parametersLabel;
public static String parameterNameLabel;
public static String isFunctionLabel;
public static String directionLabel;
Expand Down

0 comments on commit a040ac8

Please sign in to comment.