Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 1, 2021. It is now read-only.

Commit

Permalink
Load relations from the server on supplying the ID
Browse files Browse the repository at this point in the history
  • Loading branch information
systemed committed Apr 2, 2011
1 parent cfa7574 commit 06f04c4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion net/systemeD/halcyon/connection/XMLConnection.as
Expand Up @@ -48,7 +48,7 @@ package net.systemeD.halcyon.connection {

override public function loadEntity(entity:Entity):void {
var url:String=Connection.apiBaseURL + entity.getType() + "/" + entity.id;
if (entity is Relation || entity is Way) url+="/full";
if (entity is Way) url+="/full";
sendLoadRequest(new URLRequest(url));
}

Expand Down
40 changes: 40 additions & 0 deletions net/systemeD/potlatch2/RelationLoaderPanel.mxml
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:potlatch2="net.systemeD.potlatch2.*"
title="Load Relation" width="350" height="200"
showCloseButton="true" close="PopUpManager.removePopUp(this);">

<mx:HBox>
<mx:Label text="Relation ID: " />
<mx:TextInput id="requestedID" restrict="0-9" />
</mx:HBox>
<mx:ControlBar>
<mx:Spacer width="100%"/>
<mx:Button label="Load" click="loadRelation();" styleName="titleWindowButton" />
</mx:ControlBar>
<mx:Script><![CDATA[
import net.systemeD.halcyon.*;
import net.systemeD.halcyon.connection.*;
import net.systemeD.potlatch2.*;
import mx.managers.PopUpManager;
// ** FIXME: should automatically focus on id field (like the Changeset dialogue)
public function loadRelation():void {
var conn:Connection = Connection.getConnectionInstance();
var id:uint = uint(requestedID.text);
if (requestedID.text) {
var rel:Relation=conn.getRelation(id);
if (!rel) {
rel = conn.createRelation({}, [], MainUndoStack.getGlobalStack().addAction);
rel.renumber(id,1);
}
conn.loadEntity(rel);
// add an eventListener of some sort to pop up the panel again once it's loaded
}
PopUpManager.removePopUp(this);
}
]]></mx:Script>
</mx:TitleWindow>

8 changes: 8 additions & 0 deletions net/systemeD/potlatch2/RelationSelectPanel.mxml
Expand Up @@ -80,13 +80,21 @@
panel.setRelation(relation);
PopUpManager.centerPopUp(panel);
}
public function closeAndLoadRelation():void {
PopUpManager.removePopUp(this);
var panel:RelationLoaderPanel = RelationLoaderPanel(
PopUpManager.createPopUp(Application(Application.application), RelationLoaderPanel, true));
PopUpManager.centerPopUp(panel);
}
]]></mx:Script>
<mx:Text id="warning" text="" />
<mx:List width="100%" height="100%" id="relationSelector" verticalScrollPolicy="on" allowMultipleSelection="true" >
</mx:List>
<mx:ControlBar>
<mx:Button label="New Relation..." click="closeAndNewRelation();" styleName="titleWindowButton" />
<mx:Button label="Load Relation..." click="closeAndLoadRelation();" styleName="titleWindowButton" />
<mx:Spacer width="100%"/>
<mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItems.length>0}" styleName="titleWindowButton" />
</mx:ControlBar>
Expand Down

0 comments on commit 06f04c4

Please sign in to comment.