Skip to content

Commit

Permalink
TEIIDDES-1743
Browse files Browse the repository at this point in the history
TEIIDDES-1480
TEIIDDES-1348
- moved VDB Description to it's own tab
- Changed VDB Properties tab to Properties tab and added "User Defined" properties entry table on right
- Changed VDB Translator panel buttons from actions/toolbar to simple Composite with Buttons to prevent layout issues
- Added "Allowed Languages" property editing
- Tweaked Vdb, VdbElement classes to accommodate expanded property support
  • Loading branch information
blafond authored and Paul Richardson committed Jun 3, 2013
1 parent 2edf8f7 commit 55d0d2b
Show file tree
Hide file tree
Showing 16 changed files with 1,571 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.teiid.core.designer.TeiidDesignerRuntimeException;

/**
Expand Down Expand Up @@ -40,6 +43,11 @@ public class StringUtilities {
* The String "\n"
*/
public static final String NEW_LINE = "\n"; //$NON-NLS-1$

/**
* A Comma.
*/
public static String COMMA = ","; //$NON-NLS-1$

/**
* The name of the System property that specifies the string that should be used to separate lines. This property is a standard
Expand Down Expand Up @@ -213,6 +221,37 @@ public static String lowerCaseFirstChar( final String value ) {
firstChar = firstChar.toLowerCase();
return (firstChar + value.substring(1));
}

/**
* Parses a comma-separated list into an array of strings into an array of strings
* Values can contain whitespace, but whitespace at the beginning and end of each value is trimmed.
* @return array of Strings
* @param csvList a string of comma separated values
*/
public static String[] parseCommaDelimitedString(String csvString) {
String[] result = parseList(csvString, COMMA);
for (int i = 0; i < result.length; i++) {
result[i] = result[i].trim();
}

return result;
}

/**
* Parses a delimited string using the specified delimiter.
* @param list a string of token separated values
* @param delimiter the delimiter character(s). Each character in the string is a single delimiter.
* @return an array of strings
*/
public static String[] parseList(String delimitedString, String delimiter) {
List<String> result = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(delimitedString, delimiter);
while (tokenizer.hasMoreTokens()) {
result.add(tokenizer.nextToken());
}

return result.toArray(new String[0]);
}

public static String removeChars( final String value,
final char[] chars ) {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ interface Images extends UiConstants.Images {
String REMOVE_MODEL = CTOOL16 + "remove-model.png"; //$NON-NLS-1$
String REMOVE_ROLE = CTOOL16 + "remove-role.png"; //$NON-NLS-1$
String REMOVE_TRANSLATOR = CTOOL16 + "remove-translator.png"; //$NON-NLS-1$
String ADD = CTOOL16 + "add.png"; //$NON-NLS-1$
String REMOVE = CTOOL16 + "remove.png"; //$NON-NLS-1$
String EDIT = CTOOL16 + "edit.png"; //$NON-NLS-1$
String RESTORE_DEFAULT_VALUE = CTOOL16 + "restore-default-value.png"; //$NON-NLS-1$

String VDB_ICON = OBJ16 + "VDB.gif"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
Expand All @@ -60,8 +58,6 @@
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
Expand All @@ -72,10 +68,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
Expand All @@ -95,7 +88,6 @@
import org.teiid.designer.ui.common.table.DefaultTableProvider;
import org.teiid.designer.ui.common.table.TableAndToolBar;
import org.teiid.designer.ui.common.table.TextColumnProvider;
import org.teiid.designer.ui.common.text.StyledTextEditor;
import org.teiid.designer.ui.common.util.UiUtil;
import org.teiid.designer.ui.common.util.WidgetFactory;
import org.teiid.designer.ui.common.util.WidgetUtil;
Expand All @@ -119,7 +111,9 @@
import org.teiid.designer.vdb.ui.VdbUiConstants.Images;
import org.teiid.designer.vdb.ui.VdbUiPlugin;
import org.teiid.designer.vdb.ui.editor.panels.DataRolesPanel;
import org.teiid.designer.vdb.ui.editor.panels.DescriptionPanel;
import org.teiid.designer.vdb.ui.editor.panels.ModelDetailsPanel;
import org.teiid.designer.vdb.ui.editor.panels.PropertiesPanel;
import org.teiid.designer.vdb.ui.translators.TranslatorOverridesPanel;


Expand Down Expand Up @@ -160,8 +154,6 @@ public final class VdbEditor extends EditorPart implements IResourceChangeListen
static final String CONFIRM_OVERWRITE_USERFILE_MESSAGE = i18n("confirmOverwriteUserFileMessage"); //$NON-NLS-1$
static final String CONFIRM_OVERWRITE_UDFJAR_MESSAGE = i18n("confirmOverwriteUdfJarMessage"); //$NON-NLS-1$
static final String INFORM_DATA_ROLES_ON_ADD_MESSAGE = i18n("informDataRolesExistOnAddMessage"); //$NON-NLS-1$
static final String INVALID_INTEGER_INPUT_TITLE = i18n("invalidQueryTimeoutValueTitle"); //$NON-NLS-1$
static final String INVALID_INTEGER_INPUT_MESSAGE = i18n("invalidQueryTimeoutValueMessage"); //$NON-NLS-1$

static final int MODELS_PANEL_WIDTH_HINT = 300; // Models Panel Overall Width
static final int MODELS_PANEL_IMAGE_COL_WIDTH = 50; // Image Cols Width
Expand All @@ -174,7 +166,7 @@ static String i18n( final String id ) {
}

Vdb vdb;
StyledTextEditor textEditor;

TableAndToolBar<VdbModelEntry> modelsGroup;
ModelDetailsPanel modelDetailsPanel;
TableAndToolBar<VdbEntry> otherFilesGroup;
Expand All @@ -186,6 +178,8 @@ static String i18n( final String id ) {
DataRolesPanel dataRolesPanel;
VdbDataRoleResolver dataRoleResolver;
TranslatorOverridesPanel pnlTranslatorOverrides;
PropertiesPanel propertiesPanel;
DescriptionPanel descriptionPanel;

boolean disposed = false;

Expand Down Expand Up @@ -338,7 +332,7 @@ public boolean isEditable( final VdbEntry element ) {
public void setValue( final VdbEntry element,
final Boolean value ) {
IPreferenceStore prefStore = VdbUiPlugin.singleton.getPreferenceStore();
// set value to true if preferene not found
// set value to true if preference not found
boolean showWarningDialog = "".equals(prefStore.getString(SYNCHRONIZE_WITHOUT_WARNING)) ? true //$NON-NLS-1$
: !prefStore.getBoolean(SYNCHRONIZE_WITHOUT_WARNING);
boolean synchronize = !showWarningDialog;
Expand Down Expand Up @@ -490,77 +484,6 @@ void packModelsGroup() {
modelsGroup.getTable().getColumn(0).getColumn().setWidth(col1Width);
}

@SuppressWarnings({ "unchecked", "rawtypes" })
private void createDataRolesControl( Composite parent ) {
dataRolesPanel = new DataRolesPanel(parent, this);
}

private void createDescriptionControl( Composite parent ) {
Composite panel = WidgetFactory.createPanel(parent, SWT.NONE, GridData.FILL_BOTH, 1, 2);
panel.setLayout(new GridLayout(2, false));

Group propertiesGroup = WidgetFactory.createGroup(panel, i18n("properties"), SWT.FILL, 1, 2); //$NON-NLS-1$
GridData gd_1 = new GridData(GridData.FILL_VERTICAL);
gd_1.widthHint = 220;
propertiesGroup.setLayoutData(gd_1);

Label label = new Label(propertiesGroup, SWT.NONE);
label.setText(i18n("queryTimeoutLabel")); //$NON-NLS-1$

final Text queryTimeoutText = new Text(propertiesGroup, SWT.BORDER | SWT.SINGLE);
queryTimeoutText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
queryTimeoutText.setText(Integer.toString(vdb.getQueryTimeout()));
queryTimeoutText.addModifyListener(new ModifyListener() {

@Override
public void modifyText(ModifyEvent e) {
try {
int valueInSecs = Integer.parseInt(queryTimeoutText.getText());
if (valueInSecs > -1) {
getVdb().setQueryTimeout(valueInSecs);
}
} catch (NumberFormatException ex) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
VdbEditor.INVALID_INTEGER_INPUT_TITLE,
INVALID_INTEGER_INPUT_MESSAGE);
queryTimeoutText.setText(Integer.toString(vdb.getQueryTimeout()));
}

}
});

Group descriptionGroup = WidgetFactory.createGroup(panel, i18n("description"), GridData.FILL_BOTH, 1, 1); //$NON-NLS-1$

this.textEditor = new StyledTextEditor(descriptionGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
final GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 1;

this.textEditor.setLayoutData(gridData);
this.textEditor.setText(vdb.getDescription());
this.textEditor.getDocument().addDocumentListener(new IDocumentListener() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
*/
@Override
public void documentAboutToBeChanged( final DocumentEvent event ) {
// nothing to do
}

/**
* {@inheritDoc}
*
* @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
*/
@Override
public void documentChanged( final DocumentEvent event ) {
getVdb().setDescription(textEditor.getText());
}

});
}

private void createEditorBottom( Composite parent ) {
Composite pnlBottom = new Composite(parent, SWT.BORDER);
pnlBottom.setLayout(new GridLayout());
Expand All @@ -575,9 +498,20 @@ private void createEditorBottom( Composite parent ) {
pnlRoles.setLayout(new GridLayout());
pnlRoles.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
rolesTab.setControl(pnlRoles);
createDataRolesControl(pnlRoles);
new DataRolesPanel(pnlRoles, this);
}

{ // properties tab
CTabItem propertiesTab = new CTabItem(tabFolder, SWT.NONE);
propertiesTab.setText(i18n("propertiesTab")); //$NON-NLS-1$
propertiesTab.setToolTipText(i18n("propertiesTabToolTip")); //$NON-NLS-1$
Composite pnlProperties = new Composite(tabFolder, SWT.NONE);
pnlProperties.setLayout(new GridLayout());
pnlProperties.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
propertiesTab.setControl(pnlProperties);
propertiesPanel = new PropertiesPanel(pnlProperties, this);
}

{ // description tab
CTabItem descriptionTab = new CTabItem(tabFolder, SWT.NONE);
descriptionTab.setText(i18n("descriptionTab")); //$NON-NLS-1$
Expand All @@ -586,7 +520,7 @@ private void createEditorBottom( Composite parent ) {
pnlDescription.setLayout(new GridLayout());
pnlDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
descriptionTab.setControl(pnlDescription);
createDescriptionControl(pnlDescription);
descriptionPanel = new DescriptionPanel(pnlDescription, this);
}

{ // translator overrides tab
Expand Down Expand Up @@ -1808,7 +1742,9 @@ public void dispose() {
if (vdb != null) try {
vdb.removeChangeListener(vdbListener);
vdb.close();
if (textEditor != null) textEditor.dispose();
if( descriptionPanel != null ) {
descriptionPanel.close();
}
} catch (final Exception err) {
VdbUiConstants.Util.log(err);
WidgetUtil.showError(err);
Expand Down

0 comments on commit 55d0d2b

Please sign in to comment.