Skip to content
Snippets Groups Projects
Commit 9a9ca8e4 authored by buczekp's avatar buczekp
Browse files

[LMS-900] minor: enabled Move up/down buttons only when a row is selected, added disabled tooltips

SVN: 11545
parent a09bdbdc
No related branches found
No related tags found
No related merge requests found
...@@ -3,9 +3,13 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid; ...@@ -3,9 +3,13 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.extjs.gxt.ui.client.Events;
import com.extjs.gxt.ui.client.Style.Scroll; import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode; import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.ComponentEvent; import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionEvent;
import com.extjs.gxt.ui.client.event.SelectionListener; import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore; import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Record; import com.extjs.gxt.ui.client.store.Record;
...@@ -77,6 +81,30 @@ class ColumnSettingsChooser ...@@ -77,6 +81,30 @@ class ColumnSettingsChooser
// target.setFeedback(Feedback.INSERT); // target.setFeedback(Feedback.INSERT);
} }
private void enableButtonOnGridSelectedItem(final Button button, final String enabledTitle)
{
final String disabledTitle = "Select a table row first.";
button.disable();
button.setTitle(disabledTitle);
grid.getSelectionModel().addListener(Events.SelectionChange,
new Listener<SelectionEvent<ModelData>>()
{
public void handleEvent(SelectionEvent<ModelData> se)
{
if (se.selection.size() == 1)
{
button.enable();
button.setTitle(enabledTitle);
} else
{
button.disable();
button.setTitle(disabledTitle);
}
}
});
}
private static ListStore<ColumnDataModel> createStore(List<ColumnDataModel> list) private static ListStore<ColumnDataModel> createStore(List<ColumnDataModel> list)
{ {
ListStore<ColumnDataModel> store = new ListStore<ColumnDataModel>(); ListStore<ColumnDataModel> store = new ListStore<ColumnDataModel>();
...@@ -111,12 +139,14 @@ class ColumnSettingsChooser ...@@ -111,12 +139,14 @@ class ColumnSettingsChooser
add(new AdapterToolItem(createLink(Selectable.FILTER, false))); add(new AdapterToolItem(createLink(Selectable.FILTER, false)));
add(new FillToolItem()); add(new FillToolItem());
Button up = new Button("Move Up"); Button up = new Button("Move Up");
up.setTitle("Move selected column to the left");
up.addSelectionListener(moveSelectedItem(-1)); up.addSelectionListener(moveSelectedItem(-1));
enableButtonOnGridSelectedItem(up,
"Move selected column to the left in modified table.");
add(new AdapterToolItem(up)); add(new AdapterToolItem(up));
Button down = new Button("Move Down"); Button down = new Button("Move Down");
down.setTitle("Move selected column to the right");
down.addSelectionListener(moveSelectedItem(+1)); down.addSelectionListener(moveSelectedItem(+1));
enableButtonOnGridSelectedItem(down,
"Move selected column to the right in modified table.");
add(new AdapterToolItem(down)); add(new AdapterToolItem(down));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment