Skip to content

Commit

Permalink
Merge pull request #140 from elvisisking/TEIIDDES-1665
Browse files Browse the repository at this point in the history
TEIIDDES-1665 Dialog Title for 'Create User Defined Function' is wrong
  • Loading branch information
blafond committed Apr 23, 2013
2 parents 200a243 + f753480 commit a18dd6a
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
Expand Down Expand Up @@ -44,21 +47,43 @@ public EditRelationalObjectDialog(Shell parentShell, RelationalReference relatio
this.modelFile = file;
setShellStyle(getShellStyle() | SWT.RESIZE);
}


/**
* @see org.eclipse.jface.window.Window#constrainShellSize()
*/
@Override
protected void configureShell( Shell shell ) {
super.configureShell(shell);
protected void constrainShellSize() {
super.constrainShellSize();

final Shell shell = getShell();
shell.setText(RelationalObjectEditorFactory.getDialogTitle(relationalObject));

{ // center on parent
final Shell parentShell = (Shell)shell.getParent();
final Rectangle parentBounds = parentShell.getBounds();
final Point parentCenter = new Point(parentBounds.x + (parentBounds.width/2), parentBounds.y + parentBounds.height/2);

final Rectangle r = shell.getBounds();
final Point shellLocation = new Point(parentCenter.x - r.width/2, parentCenter.y - r.height/2);

shell.setBounds(Math.max(0, shellLocation.x), Math.max(0, shellLocation.y), r.width, r.height);
}
}

/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite mainPanel = (Composite)super.createDialogArea(parent);
((GridLayout)mainPanel.getLayout()).marginHeight=10;
((GridLayout)mainPanel.getLayout()).marginWidth=10;
Composite pnlOuter = (Composite) super.createDialogArea(parent);

Composite mainPanel = new Composite(pnlOuter, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.marginLeft = 20;
gridLayout.marginRight = 20;
mainPanel.setLayout(gridLayout);
mainPanel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));

this.setTitle(RelationalObjectEditorFactory.getDialogTitle(relationalObject));
this.setMessage(RelationalObjectEditorFactory.getInitialMessage(relationalObject));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
Expand Down Expand Up @@ -118,23 +120,19 @@ public RelationalProcedureEditorPanel(Composite parent, RelationalProcedure proc
@Override
protected void createPanel(Composite parent) {
Composite thePanel = WidgetFactory.createPanel(parent, SWT.NONE, 1, 1);
thePanel.setLayout(new GridLayout(1, false));
thePanel.setLayout(new GridLayout());
GridData panelGD = new GridData(GridData.FILL_BOTH);
panelGD.heightHint = 550;
panelGD.widthHint = 550;
thePanel.setLayoutData(panelGD);

this.procedure = (RelationalProcedure)getRelationalReference();
// Spacer label
new Label(thePanel, SWT.NONE);
{
helpText = new Text(thePanel, SWT.WRAP | SWT.READ_ONLY);
helpText = new Text(thePanel, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
helpText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
helpText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
helpText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
((GridData)helpText.getLayoutData()).horizontalSpan = 1;
((GridData)helpText.getLayoutData()).heightHint = 20;
((GridData)helpText.getLayoutData()).widthHint = 360;
helpText.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
((GridData)helpText.getLayoutData()).horizontalIndent = 20;
((GridData)helpText.getLayoutData()).heightHint = (3 * helpText.getLineHeight());
}
createNameGroup(thePanel);

Expand Down Expand Up @@ -212,7 +210,13 @@ protected void synchronizeUI() {
synchronizing = true;

helpText.setText(RelationalObjectEditorFactory.getHelpText(procedure));


// size help text
final GC gc = new GC(helpText);
final FontMetrics fm = gc.getFontMetrics();
((GridData)helpText.getLayoutData()).widthHint = (80 * fm.getAverageCharWidth());
gc.dispose();

if( procedure.getName() != null ) {
if( WidgetUtil.widgetValueChanged(this.nameText, procedure.getName()) ) {
this.nameText.setText(procedure.getName());
Expand Down Expand Up @@ -639,11 +643,6 @@ Composite createPropertiesPanel(Composite parent) {
Composite thePanel = WidgetFactory.createPanel(parent, SWT.NONE, 1, 2);
thePanel.setLayout(new GridLayout(2, false));
GridData panelGD = new GridData(GridData.FILL_BOTH);
if( this.procedure.isFunction() ) {
panelGD.heightHint = 300;
} else {
panelGD.heightHint = 400;
}
thePanel.setLayoutData(panelGD);

Label label = new Label(thePanel, SWT.NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ createRelationalSourceFunctionInitialMessage = Provide unique name, properties a
createRelationalSourceFunctionHelpText=This wizard allows creating a complete relational source function \
including parameters and function-specific properties.

createRelationalUserDefinedFunctionTitle = Create Relational User Defined Function
createRelationalUserDefinedFunctionTitle = Create User Defined Function
createRelationalUserDefinedFunctionInitialMessage = Provide unique name, properties and desired parameters and result set
createRelationalUserDefinedFunctionHelpText=This wizard allows creating a complete relational user defined function \
createRelationalUserDefinedFunctionHelpText=This wizard allows creating a complete user defined function \
including parameters and function-specific properties like the function's java class and method.

createRelationalIndexActionText = Index...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
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.Shell;
import org.teiid.designer.relational.model.RelationalReference;
import org.teiid.designer.relational.ui.edit.IDialogStatusListener;
import org.teiid.designer.relational.ui.edit.RelationalEditorPanel;
import org.teiid.designer.relational.ui.edit.RelationalObjectEditorFactory;
import org.teiid.designer.transformation.ui.Messages;

/**
Expand All @@ -46,21 +50,43 @@ public EditRelationalObjectDialog(Shell parentShell, RelationalReference relatio
this.modelFile = file;
setShellStyle(getShellStyle() | SWT.RESIZE);
}


/**
* @see org.eclipse.jface.window.Window#constrainShellSize()
*/
@Override
protected void configureShell( Shell shell ) {
super.configureShell(shell);
protected void constrainShellSize() {
super.constrainShellSize();

final Shell shell = getShell();
shell.setText(RelationalObjectEditorFactory.getDialogTitle(relationalObject));

{ // center on parent
final Shell parentShell = (Shell)shell.getParent();
final Rectangle parentBounds = parentShell.getBounds();
final Point parentCenter = new Point(parentBounds.x + (parentBounds.width/2), parentBounds.y + parentBounds.height/2);

final Rectangle r = shell.getBounds();
final Point shellLocation = new Point(parentCenter.x - r.width/2, parentCenter.y - r.height/2);

shell.setBounds(Math.max(0, shellLocation.x), Math.max(0, shellLocation.y), r.width, r.height);
}
}

/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite mainPanel = (Composite)super.createDialogArea(parent);
((GridLayout)mainPanel.getLayout()).marginHeight=10;
((GridLayout)mainPanel.getLayout()).marginWidth=10;
Composite pnlOuter = (Composite) super.createDialogArea(parent);

Composite mainPanel = new Composite(pnlOuter, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.marginLeft = 20;
gridLayout.marginRight = 20;
mainPanel.setLayout(gridLayout);
mainPanel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));

this.setTitle(RelationalObjectEditorFactory.getDialogTitle(relationalObject));
this.setMessage(RelationalObjectEditorFactory.getInitialMessage(relationalObject));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
Expand Down Expand Up @@ -130,23 +132,19 @@ public ViewProcedureEditorPanel(Composite parent, RelationalViewProcedure viewPr
@Override
protected void createPanel(Composite parent) {
Composite thePanel = WidgetFactory.createPanel(parent, SWT.NONE, 1, 1);
thePanel.setLayout(new GridLayout(1, false));
thePanel.setLayout(new GridLayout());
GridData panelGD = new GridData(GridData.FILL_BOTH);
panelGD.heightHint = 550;
panelGD.widthHint = 550;
thePanel.setLayoutData(panelGD);

this.viewProcedure = (RelationalViewProcedure)getRelationalReference();
// Spacer label
new Label(thePanel, SWT.NONE);
{
helpText = new Text(thePanel, SWT.WRAP | SWT.READ_ONLY);
helpText = new Text(thePanel, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
helpText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
helpText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
helpText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
((GridData)helpText.getLayoutData()).horizontalSpan = 1;
((GridData)helpText.getLayoutData()).heightHint = 20;
((GridData)helpText.getLayoutData()).widthHint = 360;
helpText.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
((GridData)helpText.getLayoutData()).horizontalIndent = 20;
((GridData)helpText.getLayoutData()).heightHint = (3 * helpText.getLineHeight());
}
createNameGroup(thePanel);

Expand Down Expand Up @@ -220,10 +218,20 @@ protected void synchronizeUI() {
this.viewProcedure = (RelationalViewProcedure)getRelationalReference();
}
synchronizing = true;

helpText.setText(Messages.createRelationalViewProcedureHelpText);

if( viewProcedure.getName() != null ) {

if (this.viewProcedure.isFunction()) {
helpText.setText(Messages.createRelationalViewUserDefinedFunctionHelpText);
} else {
helpText.setText(Messages.createRelationalViewProcedureHelpText);
}

// size help text
final GC gc = new GC(helpText);
final FontMetrics fm = gc.getFontMetrics();
((GridData)helpText.getLayoutData()).widthHint = (80 * fm.getAverageCharWidth());
gc.dispose();

if( viewProcedure.getName() != null ) {
if( WidgetUtil.widgetValueChanged(this.nameText, viewProcedure.getName()) ) {
this.nameText.setText(viewProcedure.getName());
}
Expand Down Expand Up @@ -646,11 +654,6 @@ Composite createPropertiesPanel(Composite parent) {
Composite thePanel = WidgetFactory.createPanel(parent, SWT.NONE, 1, 2);
thePanel.setLayout(new GridLayout(2, false));
GridData panelGD = new GridData(GridData.FILL_BOTH);
if( this.viewProcedure.isFunction() ) {
panelGD.heightHint = 300;
} else {
panelGD.heightHint = 400;
}
thePanel.setLayoutData(panelGD);
Label label = new Label(thePanel, SWT.NONE);
label.setText(Messages.updateCountLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ createRelationalViewProcedureExceptionMessage = Error creating relational proced
createRelationalViewProcedureHelpText=This wizard allows creating a complete relational view procedure \
including SQL definition.

createRelationalViewUserDefinedFunctionTitle = Create Relational View Table User Defined Function
createRelationalViewUserDefinedFunctionTitle = Create User Defined Function
createRelationalViewUserDefinedFunctionInitialMessage = Provide unique name, properties and desired parameters and result set
createRelationalViewUserDefinedFunctionHelpText=This wizard allows creating a complete relational virtual user defined function \
createRelationalViewUserDefinedFunctionHelpText=This wizard allows creating a complete user defined function \
including parameters and function-specific properties like the function's java class and method.

createRelationalViewIndexActionText = Index...
Expand Down

0 comments on commit a18dd6a

Please sign in to comment.