Mercurial > hg > STI-GWT
view src/econnect/wp3_3/client/core/ApplicationGrid.java @ 11:f0365f1b90ec
- added new link to DARIAH datasheet editor
- added clear data link to http://dev2.dariah.eu/e4d/
git-svn-id: http://dev.dariah.eu/svn/repos/eu.dariah.de/ap1/sti-gwt-dariah-geobrowser@94 f2b5be40-def6-11e0-8a09-b3c1cc336c6b
author | StefanFunk <StefanFunk@f2b5be40-def6-11e0-8a09-b3c1cc336c6b> |
---|---|
date | Wed, 12 Sep 2012 10:24:10 +0000 |
parents | 517a6422d1bd |
children | fef6080e83ad |
line wrap: on
line source
package econnect.wp3_3.client.core; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.ServiceDefTarget; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.FileUpload; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HasVerticalAlignment; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.MenuItem; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Window; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.OptGroupElement; import com.google.gwt.dom.client.OptionElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.VerticalAlign; import com.google.gwt.user.client.ui.MenuBar; import com.google.gwt.user.client.ui.RootPanel; import econnect.wp3_3.client.services.FlickrService; import econnect.wp3_3.client.services.FlickrServiceAsync; import econnect.wp3_3.client.widgets.map.Map; import econnect.wp3_3.client.widgets.table.StiTable; import econnect.wp3_3.client.widgets.timeplot.Timeplot; import econnect.wp3_3.shared.DataElement; /** * Implementation of the Main Grid of the application where all widgets except tables will be embedded */ public class ApplicationGrid extends Grid { /** * The Java map object */ private Map map; /** * The Java timeplot object */ private Timeplot plot; /** * The Javascript core object */ private StiCore core; /** * The Object that holds the history bar */ private MenuBar history; /** * The actual history index */ private int historyIndex; /** * The list of history items */ private ArrayList<MenuItem> historyItems; /** * The image representing the back button */ private Image back; /** * The image representing the forward button */ private Image forward; /** * The logo image */ private Image logo; /** * The label image for the history */ private Image historyLabel; private int width; private Grid links; /** * Constructor for the main grid of the application * * @param core object to allow interaction with all javascript components */ public ApplicationGrid( StiCore stiCore, StiTable table ){ int minWidth = 800; int minHeight = 600; int ph = 112; int docWidth = Document.get().getClientWidth(); int height = (new Double(Document.get().getClientHeight()*0.5+ph)).intValue(); int width = (new Double(height*4/3)).intValue(); if( height < minHeight ){ height = minHeight; width = minWidth; } this.width = width; this.core = stiCore; this.historyItems = new ArrayList<MenuItem>(); this.resize(2,2); this.setCellSpacing(0); this.setCellPadding(0); this.getElement().getStyle().setPosition(Position.ABSOLUTE); this.getElement().getStyle().setPropertyPx("left", (docWidth-width)/2); this.getElement().getStyle().setPropertyPx("top", 120-39); this.getElement().getStyle().setZIndex(1); this.getCellFormatter().getElement(0,1).setClassName("cellStyleTop"); this.getCellFormatter().getElement(1,0).setClassName("cellStyleLeft"); RootPanel.get("mainContainer").add(this); final ApplicationConstants constants = (ApplicationConstants) GWT.create(ApplicationConstants.class); final StiConstants textConstants = (StiConstants) GWT.create(StiConstants.class); final Grid headerGrid = new Grid(1,2); headerGrid.setWidth("100%"); ArrayList<String> kmlLabels = new ArrayList<String>(); ArrayList<Integer> kmlSources = new ArrayList<Integer>(); ArrayList<Integer> kmlCategories = new ArrayList<Integer>(); ArrayList<Integer> kmlLocations = new ArrayList<Integer>(); if( !Window.Location.getParameter("kml1").equals("undefined") ){ kmlLabels.add(core.hexToAscii(Window.Location.getParameter("kml1"))); kmlSources.add(new Integer(Window.Location.getParameter("source1"))); kmlCategories.add(new Integer(-1)); kmlLocations.add(new Integer(-1)); } if( !Window.Location.getParameter("kml2").equals("undefined") ){ kmlLabels.add(core.hexToAscii(Window.Location.getParameter("kml2"))); kmlSources.add(new Integer(Window.Location.getParameter("source2"))); kmlCategories.add(new Integer(-1)); kmlLocations.add(new Integer(-1)); } if( !Window.Location.getParameter("kml3").equals("undefined") ){ kmlLabels.add(core.hexToAscii(Window.Location.getParameter("kml3"))); kmlSources.add(new Integer(Window.Location.getParameter("source3"))); kmlCategories.add(new Integer(-1)); kmlLocations.add(new Integer(-1)); } if( !Window.Location.getParameter("kml4").equals("undefined") ){ kmlLabels.add(core.hexToAscii(Window.Location.getParameter("kml4"))); kmlSources.add(new Integer(Window.Location.getParameter("source4"))); kmlCategories.add(new Integer(-1)); kmlLocations.add(new Integer(-1)); } int sources = core.getDatasources(); if( sources > 0 ){ final TextBox searchField = new TextBox(); final Image searchButton = new Image(constants.openImage()); searchButton.getElement().addClassName("vCenter"); final ListBox datasource = new ListBox(false); final List<ListBox> staticListBoxes = new ArrayList<ListBox>(); final ArrayList<ArrayList<int[]>> entries = new ArrayList<ArrayList<int[]>>(); for( int i=0; i<sources; i++ ){ try { if( core.hasItems(i) ){ try { ListBox staticData = new ListBox(); SelectElement select = staticData.getElement().cast(); OptionElement blank = Document.get().createOptionElement(); blank.setInnerText("select set ..."); select.appendChild(blank); int categories = core.getCategories(i); ArrayList<int[]> values = new ArrayList<int[]>(); for( int j=0; j<categories; j++ ){ try { OptGroupElement group = Document.get().createOptGroupElement(); group.setLabel(core.getCategory(i,j)); for (int k=0; k<core.getItemCount(i,j); k++) { OptionElement optElement = Document.get().createOptionElement(); optElement.setInnerText(core.getLabel(i,j,k)); for( int l=0; l<kmlLabels.size(); l++ ){ if( kmlLabels.get(l).equals(core.getLabel(i,j,k)) ){ kmlCategories.set(l,new Integer(j)); kmlLocations.set(l,new Integer(k)); } } group.appendChild(optElement); int[] pair = {j,k}; values.add(pair); } select.appendChild(group); } catch( Exception e ){ continue; } } entries.add(values); staticListBoxes.add(staticData); } catch( Exception e ){ continue; } } else { entries.add(null); staticListBoxes.add(null); } datasource.addItem(core.getDatasourceLabel(i)); } catch( Exception e ){ continue; } } if( datasource.getItemCount() > 0 ){ final Grid searchPanel = new Grid(1,3); searchPanel.setWidget(0, 0, datasource); if( staticListBoxes.get(0) == null ){ searchPanel.setWidget(0, 1, searchField); } else { searchPanel.setWidget(0, 1, staticListBoxes.get(0)); } searchPanel.setWidget(0, 2, searchButton); searchPanel.addStyleName("center"); headerGrid.setWidget(0, 0, searchPanel); datasource.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { int ds = datasource.getSelectedIndex(); if( ds == -1 ){ return; } if( staticListBoxes.get(ds) == null ){ searchPanel.setWidget(0, 1, searchField); } else { searchPanel.setWidget(0, 1, staticListBoxes.get(ds)); } } }); class LoadDataHandler implements ClickHandler, KeyUpHandler { public void onClick(ClickEvent event) { searchButton.setUrl(constants.openDisabledImage()); loadData(); } public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { searchButton.setUrl(constants.openDisabledImage()); loadData(); } } private void loadData() { int ds = datasource.getSelectedIndex(); if( core.isMaximumReached() ){ core.alert(textConstants.maxDatasources()); } else if( staticListBoxes.get(ds) != null ){ if( staticListBoxes.get(ds).getSelectedIndex() > 0 ){ int[] pair = entries.get(ds).get(staticListBoxes.get(ds).getSelectedIndex() - 1); core.openStaticKml(ds,pair[0],pair[1]); } } else if( !searchField.getText().equals("") ){ core.openDynamicKml( ds, searchField.getText() ); } searchButton.setUrl(constants.openImage()); } } LoadDataHandler handler = new LoadDataHandler(); searchButton.addClickHandler(handler); searchField.addKeyUpHandler(handler); } } Grid historyGrid = new Grid(1,3); historyLabel = new Image(constants.historyImage()); history = new MenuBar(true); history.setAnimationEnabled(true); history.addStyleName("zHigh"); addHistoryItem(0); historyGrid.setWidget(0, 1, historyLabel); headerGrid.setWidget(0, 1, historyGrid); historyLabel.setTitle(textConstants.history()); historyLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if( !RootPanel.get().remove(history) ){ RootPanel.get().add(history,0,0); historyLabel.setUrl(constants.historyOverImage()); int left = historyLabel.getAbsoluteLeft() + historyLabel.getOffsetWidth()/2 - history.getOffsetWidth()/2; int top = historyLabel.getAbsoluteTop() + historyLabel.getOffsetHeight(); RootPanel.get().setWidgetPosition(history,left,top); } else { historyLabel.setUrl(constants.historyImage()); } } }); historyLabel.getElement().addClassName("vCenter"); headerGrid.getCellFormatter().setHorizontalAlignment(0,0,HasHorizontalAlignment.ALIGN_LEFT); headerGrid.getCellFormatter().setHorizontalAlignment(0,1,HasHorizontalAlignment.ALIGN_RIGHT); back = new Image(constants.backwardDisabledImage()); back.getElement().addClassName("vCenter"); back.setTitle(textConstants.back()); forward = new Image(constants.forwardDisabledImage()); forward.getElement().addClassName("vCenter"); forward.setTitle(textConstants.forward()); historyGrid.setWidget(0, 0, back); historyGrid.setWidget(0, 2, forward); back.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if( historyIndex > 0 ){ core.switchThroughHistory(historyIndex-1); historyIndex--; setHistoryStyle(historyIndex+1,historyIndex); } } }); forward.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if( historyIndex < core.getHistoryLength()-1 ){ core.switchThroughHistory(historyIndex+1); historyIndex++; setHistoryStyle(historyIndex-1,historyIndex); } } }); this.setWidget(0, 1, headerGrid); Grid widgets = new Grid(2,1); this.setWidget(1, 1, widgets); widgets.setCellPadding(0); widgets.setCellSpacing(0); DivElement mapWindow = Document.get().createDivElement(); mapWindow.setId("mapWindow"); mapWindow.setClassName("mapWindow"); mapWindow.getStyle().setPropertyPx("height", height-ph); mapWindow.getStyle().setPropertyPx("width", width); mapWindow.getStyle().setProperty("position", "relative"); DivElement mapDiv = Document.get().createDivElement(); mapDiv.setId("map"); mapDiv.getStyle().setPropertyPx("height", height-ph); mapDiv.getStyle().setPropertyPx("width", width); mapDiv.getStyle().setProperty("position", "absolute"); mapWindow.appendChild(mapDiv); widgets.getCellFormatter().getElement(0,0).setInnerHTML(mapWindow.getString()); this.map = new Map(core,"mapWindow","map"); DivElement plotWindow = Document.get().createDivElement(); plotWindow.setId("plotWindow"); plotWindow.getStyle().setPropertyPx("width", width); plotWindow.getStyle().setPropertyPx("height", ph); DivElement plotDiv = Document.get().createDivElement(); plotDiv.setId("plot"); plotDiv.getStyle().setPropertyPx("width", width); plotWindow.appendChild(plotDiv); widgets.getCellFormatter().getElement(1,0).setInnerHTML(plotWindow.getString()); this.plot = new Timeplot(core,"plotWindow","plot"); final Grid controls = new Grid(4,1); controls.setCellSpacing(0); controls.setCellPadding(0); controls.addStyleName("center"); controls.setWidth("100%"); final Image mapControl = new Image(constants.globeImage()); mapControl.setTitle(textConstants.mapControls()); controls.setWidget(0, 0, mapControl); final Image plotControl = new Image(constants.timeImage()); plotControl.setTitle(textConstants.plotControls()); controls.setWidget(3, 0, plotControl); final Grid plotControls = this.plot.initPlotControls(); final Grid mapControls = this.map.initMapControls(); controls.setWidget(1, 0, mapControls); controls.setWidget(2, 0, plotControls); controls.getCellFormatter().getElement(0,0).getStyle().setHeight(25,Unit.PX); controls.getCellFormatter().getElement(1,0).getStyle().setVerticalAlign(VerticalAlign.TOP); controls.getCellFormatter().getElement(2,0).getStyle().setVerticalAlign(VerticalAlign.BOTTOM); controls.getCellFormatter().getElement(3,0).getStyle().setHeight(25,Unit.PX); this.setWidget(1,0,controls); controls.setSize("100%",height+"px"); this.logo = new Image(constants.logoImage()); this.logo.addStyleName("logo"); RootPanel.get().add(this.logo); RootPanel.get().setWidgetPosition(this.logo,(docWidth-width)/40,8); // Increased to 8 by DARIAH-DE SUBGOE sfu Grid linkList = new Grid(1,8); HTML informationLink = new HTML(" e4D – Info"); informationLink.setTitle("e4D - Info"); informationLink.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event) { Window.open("http://wp1187670.wp212.webpack.hosteurope.de/e4d/?page_id=2", "_blank", ""); } }); informationLink.setStyleName("headerLink"); linkList.setWidget(0, 0, informationLink); HTML helpLink = new HTML(" Help"); helpLink.setTitle("Help"); helpLink.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event) { Window.open("http://wp1187670.wp212.webpack.hosteurope.de/e4d/?page_id=23", "_blank", ""); } }); helpLink.setStyleName("headerLink"); linkList.setWidget(0, 1, helpLink); HTML contactLink = new HTML(" Contact"); contactLink.setTitle("Contact"); contactLink.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event) { Window.open("http://wp1187670.wp212.webpack.hosteurope.de/e4d/?page_id=4", "_blank", ""); } }); contactLink.setStyleName("headerLink"); linkList.setWidget(0, 2, contactLink); HTML clearLink = new HTML(" Clear Data"); clearLink.setTitle("Clear Data"); clearLink.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event) { // Changed to root URL for DARIAH-EU SUBGOE sfu // Window.Location.assign(Window.Location.getHref()); Window.open("http://dev2.dariah.eu/e4d/", "_self", ""); } }); clearLink.setStyleName("headerLink"); linkList.setWidget(0, 3, clearLink); HTML uploadLink = new HTML(" Upload Data"); uploadLink.setTitle("Upload Data"); uploadLink.setStyleName("headerLink"); uploadLink.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event) { Window.open("http://wp1187670.wp212.webpack.hosteurope.de/e4d/?page_id=11", "_blank", ""); } }); linkList.setWidget(0, 4, uploadLink); // Newly inserted by DARIAH-DE SUBGOE sfu HTML dataSheetLink = new HTML(" Data Editor"); dataSheetLink.setTitle("Data Editor"); dataSheetLink.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event) { Window.open("http://ref.dariah.eu/workflow/", "_blank", ""); } }); dataSheetLink.setStyleName("headerLink"); linkList.setWidget(0, 5, dataSheetLink); ClickHandler magneticClick = new ClickHandler(){ public void onClick(ClickEvent event) { if( core.getDataSets().length() > 0 ){ String link = Window.Location.getHref() + "?"; for( int i=0; i<core.getDataSets().length(); i++ ){ if( i>0 ){ link += "\n&"; } String name = core.getDataSets().get(i).getTermIdentifier(); link += "kml"+(i+1)+"="+core.asciiToHex(name); link += "&source"+(i+1)+"="+core.getDataSets().get(i).getSource(); } link += "\n&minTime=" + plot.getJsTimeplot().minTime(); link += "&maxTime=" + plot.getJsTimeplot().maxTime(); if( plot.getJsTimeplot().minSelTime() != null ){ link += "\n&minSelTime=" + plot.getJsTimeplot().minSelTime(); link += "&maxSelTime=" + plot.getJsTimeplot().maxSelTime(); } link += "\n&mapId=" + map.getJsMap().baseLayerIndex(); link += "&zoom=" + map.getJsMap().getZoom(); link += "¢erLon=" + map.getJsMap().centerLon(); link += "¢erLat=" + map.getJsMap().centerLat(); link += "&connections=" + map.getJsMap().getConnections(); Window.open(link,"_blank",""); core.alert("e4D Magnetic Link opened in new tab!\n(Currently considered are: loaded datasets, map settings, temporal range, temporal selection)\n\n"+link); } else { core.alert("Link could not be created; no datasets available."); } } }; HTML magneticLink = new HTML(" Magnetic Link"); magneticLink.setStyleName("headerLink"); magneticLink.addClickHandler(magneticClick); linkList.setWidget(0, 6, magneticLink); Image link = new Image(constants.linkImage()); link.addStyleName("link"); link.setTitle("Create Magnetic Link"); linkList.setWidget(0, 7, link); linkList.getElement().getStyle().setPosition(Position.ABSOLUTE); linkList.getElement().getStyle().setPropertyPx("left", 0); linkList.getElement().getStyle().setPropertyPx("top", 0); RootPanel.get().add(linkList); int left = this.getElement().getOffsetLeft() + this.getElement().getOffsetWidth() - linkList.getElement().getOffsetWidth(); RootPanel.get().setWidgetPosition(linkList,left,0); this.links = linkList; link.addClickHandler(magneticClick); core.setElements( this.getMap().getJsMap(), this.getPlot().getJsTimeplot() ); StiCore.exportStaticMethods(table,this,this.getPlot(),this.getMap()); table.setTop( this.getElement().getOffsetTop() + this.getElement().getOffsetHeight() + 40 ); for( int i=0; i<kmlLabels.size(); i++ ){ if( kmlSources.get(i).intValue() == 0 && kmlCategories.get(i) > -1 ){ core.openStaticKml(kmlSources.get(i), kmlCategories.get(i), kmlLocations.get(i)); } else if( kmlSources.get(i).intValue() < 4 ){ core.openDynamicKml(kmlSources.get(i),kmlLabels.get(i)); } else { core.alert("Unable to load \""+kmlLabels.get(i)+"\"!"); } } } public void setDefinedBounds(){ int zoom = 0; float cLon = 0, cLat = 0; int mapId = 0; if( !Window.Location.getParameter("zoom").equals("undefined") ){ zoom = new Integer(Window.Location.getParameter("zoom")).intValue(); } if( !Window.Location.getParameter("centerLon").equals("undefined") ){ cLon = new Float(Window.Location.getParameter("centerLon")).floatValue(); } if( !Window.Location.getParameter("centerLat").equals("undefined") ){ cLat = new Float(Window.Location.getParameter("centerLat")).floatValue(); } if( !Window.Location.getParameter("mapId").equals("undefined") ){ mapId = new Integer(Window.Location.getParameter("mapId")).intValue(); } if( zoom != 0 || cLon != 0 || cLat != 0 || mapId != 0 ){ this.getMap().getJsMap().configure(zoom, cLon, cLat, mapId); } String minSelTime = null, maxSelTime = null; if( !Window.Location.getParameter("minSelTime").equals("undefined") ){ minSelTime = Window.Location.getParameter("minSelTime"); } if( !Window.Location.getParameter("maxSelTime").equals("undefined") ){ maxSelTime = Window.Location.getParameter("maxSelTime"); } if( minSelTime != null && maxSelTime != null ){ this.getPlot().getJsTimeplot().selectTimerange(minSelTime,maxSelTime); } if( !Window.Location.getParameter("connections").equals("undefined") ){ int connections = new Integer(Window.Location.getParameter("connections")).intValue(); if( connections == 1 ){ this.getMap().getJsMap().setConnections(connections); this.getMap().setConImage(true); } } String minTime = null, maxTime = null; if( !Window.Location.getParameter("minTime").equals("undefined") ){ minTime = Window.Location.getParameter("minTime"); } if( !Window.Location.getParameter("maxTime").equals("undefined") ){ maxTime = Window.Location.getParameter("maxTime"); } if( minTime != null && maxTime != null ){ this.core.refineByTime(minTime,maxTime); } } /* public String asciiToHex(String text){ String[] ascii = { "!","#","$","%","&","'","(",")","*","+",",","/",":",";","=","?","@","[","]", " " }; String[] hex = { "%21","%23","%24","$","%26","%27","%28","%29","%2a","%2b","%2c","%2f","%3a","%3b","%3d","%3f","%40","%5b","%5d","%20"}; for( int i=0; i<ascii.length; i++ ){ text = text.replaceAll(ascii[i],hex[i]); } text = text.replaceAll("$","%25"); return text; } public String hexToAscii(String text){ String[] ascii = { "!","#","$","%","&","'","(",")","*","+",",","/",":",";","=","?","@","[","]", " " }; String[] hex = { "%21","%23","%24","%25","%26","%27","%28","%29","%2a","%2b","%2c","%2f","%3a","%3b","%3d","%3f","%40","%5b","%5d","%20"}; for( int i=0; i<ascii.length; i++ ){ text = text.replaceAll(hex[i],ascii[i]); } return text; } */ public void resize(){ int w = Document.get().getClientWidth(); RootPanel.get().setWidgetPosition(this.logo,(w-width)/2-40,8); RootPanel.get("mainContainer").setWidgetPosition(this,(w-width)/2,120-39); int left = this.getElement().getOffsetLeft() + this.getElement().getOffsetWidth() - this.links.getElement().getOffsetWidth(); RootPanel.get().setWidgetPosition(this.links,left,0); } /** * Sets the style of the history panel * * @param oldIndex last active history entry * @param newIndex actual active history entry */ public void setHistoryStyle( int oldIndex, int newIndex ){ final ApplicationConstants constants = (ApplicationConstants) GWT.create(ApplicationConstants.class); if( oldIndex == -1 ){ oldIndex = historyIndex; } if( newIndex == core.getHistoryLength()-1 ){ forward.setUrl(constants.forwardDisabledImage()); } else { forward.setUrl(constants.forwardImage()); } if( newIndex == 0 ){ back.setUrl(constants.backwardDisabledImage()); } else { back.setUrl(constants.backwardImage()); } MenuItem oldItem = (MenuItem) historyItems.get(oldIndex); oldItem.setHTML( oldItem.getHTML().replaceFirst("bold","normal") ); MenuItem newItem = (MenuItem) historyItems.get(newIndex); newItem.setHTML( newItem.getHTML().replaceFirst("normal","bold") ); } /** * Adds an item to the history panel * * @param index index in the corresponding javascript array source */ public void addHistoryItem( final int index ){ final ApplicationConstants constants = (ApplicationConstants) GWT.create(ApplicationConstants.class); for( int i=historyItems.size(); i>index; i-- ){ this.history.removeItem( (MenuItem) historyItems.get(i-1) ); this.historyItems.remove(i-1); } String text = "<span style='font-weight:bold;'>"; JsArray<DataSet> sets = core.getHistoryDataSets(index); for( int j=0; j<sets.length(); j++ ){ DataSet set = sets.get(j); text += set.getTermIdentifier(); if( j+1 < sets.length() ){ text += ", "; } } if( text.equals("<span style='font-weight:bold;'>") ){ text += "empty"; } else { text += " ("+(new Date()).toString()+")"; } text += "</span>"; MenuItem item = new MenuItem(text,true,new Command() { public void execute() { core.switchThroughHistory(index); setHistoryStyle(-1,index); historyIndex = index; RootPanel.get().remove(history); historyLabel.setUrl(constants.historyImage()); } }); historyItems.add(item); this.history.addItem(item); historyIndex = index; if( index > 0 ){ setHistoryStyle(index-1,index); } } /** * Getter for the Java timeplot element * * @return the Java timeplot element */ public Timeplot getPlot(){ return this.plot; } /** * Getter for the Java map element * * @return the Java map element */ public Map getMap(){ return this.map; } }