Skip to content

Commit

Permalink
TEIIDDES-2075 Improvements to properties table status and messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Apr 17, 2014
1 parent aebc2e9 commit c2da47d
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public class Messages extends NLS {
public static String dataSourcePropertiesPanel_valueColText;
public static String dataSourcePropertiesPanel_resetButton;
public static String dataSourcePropertiesPanel_resetTooltip;
public static String dataSourcePropertiesPanel_applyButton;
public static String dataSourcePropertiesPanel_applyTooltip;
public static String dataSourcePropertiesPanel_invalidPropertyMsg;
public static String dataSourcePropertiesPanel_applyPropertyChangesMsg;
public static String dataSourcePropertiesPanel_validPropertyTooltip;
public static String dataSourcePropertiesPanel_invalidPropertyTooltip;
public static String dataSourcePropertiesPanelOk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ createDataSourcePanel_jndiName=JNDI Name:
createDataSourcePanel_driver=Driver:
createDataSourcePanel_driversGroupTxt=Available Drivers
createDataSourcePanel_dataSourcePropertiesGroupTxt=Data Source Properties
editDataSourcePanelEnterChanges=Edit the Data Source properties
editDataSourcePanelEnterChanges=Click on a property value if you wish to change it.

dataSourcePropertiesPanel_nameColText=Name
dataSourcePropertiesPanel_valueColText=Value
dataSourcePropertiesPanel_resetButton=Reset
dataSourcePropertiesPanel_resetTooltip=Restore the original value
dataSourcePropertiesPanel_applyButton=Apply
dataSourcePropertiesPanel_applyTooltip=Apply the current property changes
dataSourcePropertiesPanel_invalidPropertyMsg=One or more property has an invalid value
dataSourcePropertiesPanel_applyPropertyChangesMsg=Click on the next property to edit, or click 'Apply' to accept changes.
dataSourcePropertiesPanel_validPropertyTooltip=The value for {0}
dataSourcePropertiesPanel_invalidPropertyTooltip=Enter a valid value for {0}
dataSourcePropertiesPanelOk=Data Source Properties OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ private void updateStatus() {
// Validate the properties
if(panelStatus.isOK()) {
panelStatus = this.propertiesPanel.getStatus();
if(panelStatus.isOK()) {
panelStatus = new Status(IStatus.OK, PLUGIN_ID, Messages.createDataSourcePanelOk);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.EventObject;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewerEditor;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
Expand All @@ -22,9 +26,12 @@
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TableViewerEditor;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
Expand Down Expand Up @@ -68,6 +75,7 @@ public final class DataSourcePropertiesPanel extends Composite implements UiCons

private List<DataSourcePropertiesPanelListener> listeners = new ArrayList<DataSourcePropertiesPanelListener>();
private Button resetButton;
private Button applyButton;
private Text propDescriptionText;

/**
Expand Down Expand Up @@ -122,6 +130,21 @@ public void widgetSelected(SelectionEvent e) {
}

});

applyButton = new Button(panel, SWT.PUSH);
applyButton.setText(Messages.dataSourcePropertiesPanel_applyButton);
applyButton.setToolTipText(Messages.dataSourcePropertiesPanel_applyTooltip);
applyButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
applyButton.setEnabled(false);
applyButton.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
applyButton.setEnabled(false);
firePropertyChanged();
}

});
}

/*
Expand Down Expand Up @@ -209,6 +232,28 @@ public void inputChanged( Viewer viewer,
// Add editing support if its not readonly
if(!isReadOnly) {
column.setEditingSupport(new DataSourcePropertyEditingSupport(this.propertiesViewer,this));

ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(this.propertiesViewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
// Enable editor with single mouse click
if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION) {
EventObject source = event.sourceEvent;
if (source instanceof MouseEvent) {
Object eventSource = event.getSource();
if(eventSource instanceof ViewerCell && ((ViewerCell)eventSource).getColumnIndex()==1) {
applyButton.setEnabled(true);
firePropertyChanged();
return true;
}
}
}
applyButton.setEnabled(false);
firePropertyChanged();
return false;
}
};
TableViewerEditor.create(this.propertiesViewer, activationSupport, ColumnViewerEditor.DEFAULT);
}
column.getColumn().pack();

Expand Down Expand Up @@ -268,6 +313,8 @@ private void handleResetProperty() {
prop.reset();
this.propertiesViewer.refresh();
this.resetButton.setEnabled(false);
this.applyButton.setEnabled(false);
firePropertyChanged();
}

/**
Expand Down Expand Up @@ -565,6 +612,10 @@ public IStatus getStatus() {
}
}

if(applyButton.isEnabled()) {
resultStatus = new Status(IStatus.ERROR, PLUGIN_ID, Messages.dataSourcePropertiesPanel_applyPropertyChangesMsg);
}

return resultStatus;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ private void updateState() {
if(status.isOK()) {
getButton(OK).setEnabled(true);
setErrorMessage(null);
setMessage(status.getMessage());
} else {
getButton(OK).setEnabled(false);
setErrorMessage(status.getMessage());
Expand Down

0 comments on commit c2da47d

Please sign in to comment.