Can't override blueprint function - unreal-engine4

I've got BaseCharacter blueprint and blueprint PlayerCharacter with BaseCharacter as parent. I'm trying to override function but child event doesn't get invoked. I create event in child class by clicking functions -> override
Parent class
Child class

Related

How can I refresh a Panel from another ListView in Apache Wicket?

I have a panel (say AlertPanel) which needs to be refreshed for some condition when a listView renders.
I am thinking to update the AlertPanel in onBeforeRender() lifecycle method of listview.
I have tried to override onBeforeRender() like this-
#Override
protected void onBeforeRender() {
super.onBeforeRender();
// update alert panel with some API of Component here
// I can get panel object like this 'this.getPage().get("alertPanel");'
}
Once I have this.getPage().get("alertPanel"), I don't know what API of org.apache.wicket.markup.html.panel.Panel to call so that I can refresh/repaint AlertPanel
If the rendering has started (and it seems it has - onBeforeRender()) then you won't be able to replace any components.
You should move your logic to the ACTION phase, e.g. onClick(), onSubmit(), etc. In such action method broadcast an event: send(getPage(), Broadcast.DEPTH, new SomeCustomEvent()). Then either in the AlertPanel's parent you should override #onEvent(IEvent) and when the event payload is SomeCustomEvent then do the replacement.
For more info read: https://ci.apache.org/projects/wicket/guide/7.x/single.html#_wicket_events_infrastructure
There are two ways:
1) the complex one: use listeners
2) or use method overriding, like this:
AlertPanel alertPanel = new AlertPanel();
alertPanel.setOutputMarkupId(true);
ListView list = new MyListView(){
#Override
protected onMyEvent(AjaxRequestTarget target){
target.add(alertPanel);
}
}
page.add(alertPanel,list);
onMyEvent() method of MyListView can be abstract and have to be called where you want to update the alertPanel inside of MyListView (e.g. when button pressed in some of rows)

'active' class not added when Spine.js controller stack used

I have two very simple Spine.js controllers:
class ListController extends Spine.Controller
className: 'list'
constructor: () ->
super
class DetailController extends Spine.Controller
className: 'detail'
constructor: () ->
super
controller stack
class Application extends Spine.Stack
className: 'mystack'
controllers:
list: ListController
detail: DetailController
and corresponding HTML markup
<div class="mystack">
<div class="list">list</div>
<div class="detail">detail</div>
</div>
My problem is that when controller stack instantiated
app = new Application()
app.list.active()
there is no active class added to the div.list element. Divs remain unchanged.
What is wrong with that?
I've just got it so I'll describe basic working example. There are several issues with the code above (caused by my misunderstanding of how Spine.js controller stack works :-)
First, appropriate HTML element have to be associated with every controller managed by the stack. When controller stack instantiates the controller it passes only stack (i.e. itself) instance as parameter to the constructor. So controller constructor have to take it into account (e.g. like the following):
class ListController extends Spine.Controller
constructor: (parameters) ->
#stack = parameters.stack
#el = $ #stack.settings.listSelector
super
class DetailController extends Spine.Controller
constructor: (parameters) ->
#stack = parameters.stack
#el = $ #stack.settings.detailSelector
super
and the stack:
class Application extends Spine.Stack
settings:
listSelector: '.list'
detailSelector: '.detail'
controllers:
list: ListController
detail: DetailController
default:
'list'
then the controller stack could be instantiated:
app = new Application
el: $ '.mystack'
ListController will be active (i.e. corresponding div has active class added) by default and anytime later you can call #stack.detail.active() or #stack.list.active() from controller instance method to activate required controller and 'hide' (i.e. remove active class) the other(s).
EDIT:
We discussed the issue with #aschmid00. In fact, controller constructor doesn't have to set its own property #stack manually. It is done automatically when base constructor called by super. But in case of this question #el have to be set before base constructor called due to the events delegation etc.

GWT : Do I make event and event handler class?

I have gwt-project that is comunication to database.
Application design mvp pattern and view has a input form, a grid and many buttons.
According to gwt tutorial, each event has a event class, a event handler class and initialize event handler class in presenter.
So, Do I make event and event handler class if the number of events are uncountable?
[Example package] :
src/com/example/event/${A Lot Of Event}
src/com/example/event/${A Lot Of Event Handler}
src/com/example/presenter/${A Presenter}
src/com/example/view/${A View}
I like to put the event handler (and optionally the has handlers interface, if you make one) as inner classes (okay, interfaces) of the event itself. Usually looks something like this:
public class MyAppEvent extends GwtEvent<MyAppEventHandler> {
//... event guts, dispatch, getAssociatedType, etc
public interface MyAppEventHandler extends EventHandler {
void onMyAppEventHappened(MyAppEvent event);
}
// and optionally, if you only register handlers through add methods
public interface HasMyAppEventHandlers {
void addMyAppEventHandler(MyAppEventHandler handler);
}
}

calling a child page component from parent page component in wicket

I have a problem which I tried to explained in the Image.I hope that will help all to understand what I need.
My Base Page is like this (menuNavPanel is the tree panel):
<div class="colContainer">
<div class="leftColumn" >
<div wicket:id="menuNavPanel"></div>
</div>
<div class="rightColumn">
<wicket:child/>
</div>
</div>
And Ny BIA Page which is a child of Base Page is like this:
<wicket:extend>
<div wicket:id="bodyPanel"></div>
</wicket:extend>
in my Tree Panel, when I click on a node the code is this:
#Override
protected void onNodeLinkClicked(AjaxRequestTarget target, TreeNode node) {
super.onNodeLinkClicked(target, node);
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
Unit unitObject =(Unit) treeNode.getUserObject();
// I want to call bodyPanel fo child page passing the unitObject param
}
Now, How can I call bodyPanel fo child page passing the unitObject param from the tree panel of the parent page?
Am I been able to express my problem? Hoping to get some help :)
Instead of doing the override method, upgrade to Wicket 1.5 and utilize the new event bus to communicate between your components. You can create a custom, type-safe, event that is specific to your component's use case: for example "ItemAddedToShoppingCart" or "GlobalThermoNuclearWarStarted".
The linked article in the 1.5 migration guide provides enough information on how to set up things.
I'm not sure I understand que question correctly. Your BasePage defines a left column with the TreePanel and lets subclasses expand themselves inside the right column div. You usually put a BodyPanel inside BasePages's subclasses. And now you want to invoke a BodyPanel's method on some event on the TreePanel.
You could do it with an overridable method on BasePage, which would be called in TreePanel through getPage(). Your child pages would override that method, and its implementation would call the BodyPanel they're holding.
public class BasePage ... {
// Hook
public void treePanelSelected(Object someObject) { }
...
}
public class ChildPage extends BasePage ... {
BodyPanel bodyPanel;
#Override
public void treePanelSelected(Object someObject) {
bodyPanel.selectionChanged/(someObject);
}
...
}
public class TreePanel ... {
...
#Override
protected void onNodeLinkClicked(AjaxRequestTarget target, TreeNode node) {
super.onNodeLinkClicked(target, node);
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
Unit unitObject =(Unit) treeNode.getUserObject();
((BasePage)getPage()).treePanelSelected(unitObject);
}
}
From my ignorance on your specific needs and details of implementation, I don't see why is subclassing the BasePage necessary. You could add the BodyPanel right there in the BasePage and control it from the same class.
Thanks all, After reviewing all the nice options I finally opted out for the event bus way defined by martijn. What I did is I have created an event payload and connected the panels for the talking. I also needed to pass the selected Id / entity to the receiving panel.
Is there a way to set a compound property model of the receiving panel according to the model of the tree element so that I don't need to do the model manually ?
I did like this for the time being:
public class TreeNodeClickUpdate {
private final AjaxRequestTarget target;
private final long selectedId;
/**
* Constructor
*
* #param target
* #param selectedId
*/
public TreeNodeClickUpdate(AjaxRequestTarget target, long selectedId)
{
this.target = target;
this.selectedId = selectedId;
}
/** #return ajax request target */
public AjaxRequestTarget getTarget()
{
return target;
}
public long getSelectedId() {
return selectedId;
}
}
On the sender side I've done like this:
send(getPage(), Broadcast.BREADTH,
new TreeNodeClickUpdate(target, unitObject.getId()));
And on the receiving end I got it like this:
#Override
public void onEvent(IEvent<?> event) {
super.onEvent(event);
if (event.getPayload() instanceof TreeNodeClickUpdate)
{
TreeNodeClickUpdate update = (TreeNodeClickUpdate)event.getPayload();
setSelectedId(update.getSelectedId()); //sets to id field of panel
update.getTarget().add(this);
}
}
and for just as an example in my receiving panel, to get the value I have created a label like this:
label = new Label("label",new PropertyModel<BiaHomePanel>(this,"selectedId"));
Later, in reality I want to get information from the entity and show in form. Is there a nice way to pass models in a better way or I should pass as a parameter in event payload.
There are two ways to do this. One is cleaner, but requires more code. The other is quick and dirty.
Method 1: (Good)
Since your parent page is being extended, you can provide an abstract method in the parent like
protected abstract WebMarkupContainer getBodyPanel();
that is implemented in your child page and returns the appropriate panel. Then, you can call that method from the panel in your parent page. This is similar to the overrideable method suggested by the other user.
Method 2: (Bad)
The Wicket Component Hierarchy is shared between the parent and child pages. So, if you make sure that your bodyPanel has a unique wicketId and is added directly to the root of the page, you can probably just call
get("bodyPanelId");
and it will return the proper panel.
When I was facing the problem, I thought of two ways to solve this (pre 1.5):
a) implement a variation of the observer pattern to notify other component of events like outlined here: Realising complex cross-component ajax actions in wicket - The observer way
b) using wicket visitors to traverse the component tree doing the same.
I decided to go for variant a) but this introduces coupling from your component to your page-implementation which leads to problems when testing panels on their own. So maybe b) might be the better idea but since my application is running quite smoothly with a) implemented and the next big step will be switching over to 1.5 and the event bus, I haven't yet tried b).

Widget notifying other widget(s)

How should widgets in GWT inform other widgets to refresh themselfs or perform some other action.
Should I use sinkEvent / onBrowserEvent?
And if so is there a way to create custom Events?
I have solved this problem using the Observer Pattern and a central Controller. The central controller is the only class that has knowledge of all widgets in the application and determines the way they fit together. If someone changes something on widget A, widget A fires an event. In the eventhandler you call the central controller through the 'notifyObservers()' call, which informes the central controller (and optionally others, but for simplicity I'm not going into that) that a certain action (passing a 'MyEvent' enum instance) has occurred.
This way, application flow logic is contained in a single central class and widgets don't need a spaghetti of references to eachother.
It's a very open ended question - for example, you could create your own static event Handler class which widgets subscribe themselves to. e.g:
Class newMessageHandler {
void update(Widget caller, Widget subscriber) {
...
}
}
customEventHandler.addEventType("New Message", newMessageHandler);
Widget w;
customEventHandler.subscribe(w, "New Message");
...
Widget caller;
// Fire "New Message" event for all widgets which have
// subscribed
customEventHandler.fireEvent(caller, "New Message");
Where customEventHandler keeps track of all widgets subscribing to each named event, and calls the update method on the named class, which could then call any additional methods you want. You might want to call unsubscribe in the destructor - but you could make it as fancy as you want.
So here is my (sample) implementation,
first let's create a new event:
import java.util.EventObject;
import com.google.gwt.user.client.ui.Widget;
public class NotificationEvent extends EventObject {
public NotificationEvent(String data) {
super(data);
}
}
Then we create an event handler interface:
import com.google.gwt.user.client.EventListener;
public interface NotificationHandler extends EventListener {
void onNotification(NotificationEvent event);
}
If we now have a widget implementing the NotificationHanlder, we can
trigger the event by calling:
((NotificationHandler)widget).onNotification(event);