Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java @ 1306:2e57776f77b5
#300 Synchronized the ThemePanel's layer order with the internal order of the Map.
flys-client/trunk@2940 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 11 Oct 2011 13:25:18 +0000 |
parents | d9cb362b8b34 |
children | a95e82d6bcc1 |
line wrap: on
line source
package de.intevation.flys.client.client.ui.chart; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.grid.events.RowContextClickEvent; import com.smartgwt.client.widgets.grid.events.RowContextClickHandler; import com.smartgwt.client.widgets.menu.Menu; import com.smartgwt.client.widgets.menu.MenuItem; import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; import com.smartgwt.client.widgets.menu.events.ClickHandler; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.Theme; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.shared.model.FacetRecord; import de.intevation.flys.client.shared.model.CollectionItemAttribute; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.ui.ThemePanel; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.ui.CollectionView; import de.intevation.flys.client.client.services.FeedService; import de.intevation.flys.client.client.services.FeedServiceAsync; import de.intevation.flys.client.client.services.CollectionItemAttributeService; import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ChartThemePanel extends ThemePanel { /** The interface that provides i18n messages. */ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); /** The collection */ protected Collection collection; /** The collection view*/ protected CollectionView view; /** The service used to get collection item attributes. */ protected CollectionItemAttributeServiceAsync itemAttributeService = GWT.create(CollectionItemAttributeService.class); public static final String GRID_FIELD_ACTIVE = "active"; public static final String GRID_FIELD_NAME = "name"; public static final String GRID_FIELD_ACTIONS = "actions"; FeedServiceAsync feedService = GWT.create( de.intevation.flys.client.client.services.FeedService.class); public ChartThemePanel(Collection collection, OutputMode mode) { super(collection, mode); this.collection = collection; initGrid(); initLayout(); updateGrid(); } /** * Initializes the layout of this panel. */ protected void initLayout() { setWidth100(); setHeight100(); VLayout layout = new VLayout(); layout.setWidth100(); layout.setHeight100(); layout.addMember(list); layout.addMember(navigation); addChild(layout); } /** * Initializes the components (columns) of the theme grid. */ protected void initGrid() { list.setCanEdit(true); list.setCanSort(false); list.setShowRecordComponents(false); list.setShowRecordComponentsByCell(true); list.setShowHeader(true); list.setShowHeaderContextMenu(false); list.setWidth100(); list.setHeight100(); list.addEditCompleteHandler(this); list.addRowContextClickHandler(new RowContextClickHandler() { public void onRowContextClick(RowContextClickEvent event) { FacetRecord record = (FacetRecord) event.getRecord(); Menu menu = createContextMenu(record); list.setContextMenu(menu); menu.showContextMenu(); event.cancel(); } }); ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20); active.setType(ListGridFieldType.BOOLEAN); ListGridField name = new ListGridField( GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); name.setType(ListGridFieldType.TEXT); list.setFields(active, name); } protected Menu createContextMenu(final FacetRecord record) { Menu menu = new Menu(); MenuItem properties = new MenuItem(MSG.properties()); properties.addClickHandler(new ClickHandler() { public void onClick(MenuItemClickEvent evt) { GWT.log("clicked properties"); getItemAttributes(record); } }); menu.addItem(properties); return menu; } @Override public void activateTheme(Theme theme, boolean active) { theme.setActive(active ? 1 : 0); } protected void getItemAttributes(final FacetRecord record) { Config config = Config.getInstance(); String url = config.getServerUrl(); String locale = config.getLocale(); String artifact = record.getTheme().getArtifact(); itemAttributeService.getCollectionItemAttribute( this.collection, artifact, url, locale, new AsyncCallback<CollectionItemAttribute>() { public void onFailure (Throwable caught) { GWT.log("Could not get Collection item attributes."); } public void onSuccess(CollectionItemAttribute cia) { GWT.log("Successfully loaded collectionitem attributes."); StyleEditorWindow win = new StyleEditorWindow( collection, cia, record); win.setCollectionView(view); win.show(); } }); } public void setCollectionView (CollectionView view) { this.view = view; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :