Can we create a Child (with interface MyView extends PopupView) that inherit a PresenterWidget (with interface MyView extends View) (GWTP)? - gwtp

In GWTP, is there any way that we can create a Child (that has "interface MyView extends PopupView") that inherit a PresenterWidget (that has "interface MyView extends View")?
Here is my problem. I have a need to prompt (in a form of PopupView) user to enter shipping address if they didn't have one.
Of course, there is a UserShippingAddressPresenter presenter widget that is not a popup & locates in profile page.
public class UserShippingAddressPresenter extends
PresenterWidget<UserShippingAddressPresenter.MyView> {
public interface MyView extends View {
////...... more code///
}
}
Now I want to have a PopupUserShippingAddressPresenter that has exactly Gui & functionality like the UserShippingAddressPresenter, but it is a Popup like this
public class UserShippingAddressPopupPresenter extends
PresenterWidget<UserShippingAddressPresenter.MyView> {
public interface MyView extends PopupView {
////...... more code///
}
}
So This is the logic that i think it works but it didn't. That is I will use eclipse to create UserShippingAddressPopupPresenter with interface MyView extends PopupView then in UserShippingAddressPopupView I tried to setInSlot userShiopingAddress like the following
public class UserShippingAddressPopupView extends PopupViewImpl implements
UserShippingAddressPopupPresenter.MyView {
#Override
public void setInSlot(Object slot, Widget content){
if(slot==ProfilePresenter.SLOT_userShippingAddress){
userShippingAddressHTMLPanel.clear();
if(content!=null){
userShippingAddressHTMLPanel.add(content);
}
}
else{
super.setInSlot(slot, content);
}
}
}
in UserShippingAddressPopupPresenter
public class UserShippingAddressPopupPresenter extends
PresenterWidget<UserShippingAddressPopupPresenter.MyView> {
public static final Object SLOT_userShippingAddress=new Object();
public interface MyView extends PopupView {}
#Inject UserShippingAddressPresenter userShippingAddressPresenter;
#Override
protected void onReveal() {
super.onReveal();
setInSlot( SLOT_userShippingAddress, userShippingAddressPresenter);
}
}
After running, it showed a very small box in the middle of the page.
I tried onReset instead of onReveal but it didn't work either.
Can u find a better solution?

My logic is ok, it's working. I fixed it, the problem is that "if(slot==ProfilePresenter.SLOT_userShippingAddress){" is wrong, correct should be "if(slot==PopupUserShippingAddressPresenter.SLOT_userShippingAddress){"

Related

How to find all dependencies between two classes using VS Enterprise Code Map?

If I pull a class A and class B onto a Code Map, VSE (Visual Studio Enterprise) will map the direct calls of class A calling methods in class B.
So,
public class A
{
public void DoSomething()
{
b.DoSomethingElse();
}
}
This will map. But if it's something like:
public class A
{
public void DoSomething()
{
d.DoManyThings();
}
}
public class D
{
public void DoManyThings()
{
c.DoThings();
}
}
public class C
{
public void DoThings()
{
b.DoSomethingElse();
}
}
public class B
{
public void DoSomethingElse()
{
// imagine code here
}
}
Then the Code Map won't map between class A and class B automatically. The only way I've found to show those dependencies is to go to each method and click "Show Methods This Calls".
Is there a way to get VSE make the Code Map all those dependencies initially without having to investigate every method?

Scrollable Layout in Vaadin Flow

In Vaadin Flow, there exists no Component that is essentially a Scrollable Layout.
In Vaadin 8, this was done by the Panel.
Is there a way to achieve a scrollable Component in Vaadin Flow?
Edit: I have now published an add-on here that provides the class VerticalScrollLayout, and also the class HorizontalScrollLayout. If there are suggestions for improvements, feel free to contact me or comment here.
Yes it is possible, although there is no existing Component that does it automatically.
The way to go is placing a VerticalLayout (for a vertical scroll bar) inside another component, and setting the display property of that VerticalLayout from flex to block. (credits to Diego Sanz Villafruela in the vaadin forum)
I have made my own VerticalScrollLayout class that does it all for you, so that using it in a view is as easy as using a simple VerticalLayout
public class VerticalScrollLayout extends VerticalLayout {
private VerticalLayout content;
public VerticalScrollLayout(){
preparePanel();
}
public VerticalScrollLayout(Component... children){
preparePanel();
this.add(children);
}
private void preparePanel() {
setWidth("100%");
setHeight("100%");
getStyle().set("overflow", "auto");
content = new VerticalLayout();
content.getStyle().set("display", "block");
content.setWidth("100%");
content.setPadding(false);
super.add(content);
}
public VerticalLayout getContent(){
return content;
}
#Override
public void add(Component... components){
content.add(components);
}
#Override
public void remove(Component... components){
content.remove(components);
}
#Override
public void removeAll(){
content.removeAll();
}
#Override
public void addComponentAsFirst(Component component) {
content.addComponentAtIndex(0, component);
}
}
There is now an official component for scrolling:
https://vaadin.com/docs/latest/components/scroller

Class subclass type with a public method

I don't understand why in Subclass definition a public method is involved
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
Source code of the RecyclerView.ViewHolder
public abstract static class ViewHolder {
public ViewHolder(View itemView) {
if (itemView == null) {
throw new IllegalArgumentException("itemView may not be null");
}
this.itemView = itemView;
}
Your question is why does the following code appear to call a public method ViewHolder within RecylcerView. Here is your code, with a slight rename to make things clearer:
class MyClass(itemView: View) : RecyclerView.ViewHolder(itemView)
And what is missing from your description is showing the outer class:
class RecyclerView { // outer/containing class
static class ViewHolder { // nested class
public ViewHolder(ViewItem view) { // constructor
// ... constructor body
}
}
}
Now looking at that nesting, to talk about the ViewHolder class you need to reference it as RecyclerView.ViewHolder. Then if you want to construct an instance of that you must add the constructor parameters, for example in Java:
new RecyclerView.ViewHolder(view);
In Kotin when you descend from a class, your constructor must call the super constructor and the short hand for that is to do it in the declaration.
class MyClass(ViewItem view) : RecyclerView.ViewHolder(view) {
// ...class body
}
This says MyClass descends from ViewHolder which is a nested class of RecyclerView and the constructor parameter coming into MyClass constructor is being passed into the super constructor of ViewHolder.
This is the same as Java:
class MyClass extends RecyclerView.ViewHolder {
public MyClass(ViewItem view) {
super(view);
}
}
You can also import the nested static class directly, then drop the RecyclerView prefix, but it is a bit clearer to leave it.

How to delegate third-party components in react-native ios

I have following react native component in android.
parent class contains some common settings,
and some template code (eg. setData).
android version
parent component
public abstract class ParentComponent<T extends Chart, U extends Entry> extends SimpleViewManager {
#ReactProp(name = "commonSettings")
public void setCommonSettings(T chart, ReadableMap propMap) {
// do common settings
}
abstract U createEntry(ReadableMap value);
#ReactProp(name = "data")
public void setData(Chart chart, ReadableArray values) {
for (int i = 0; i < values(); i++) {
chart.addEntry(values.getMap(i));
}
}
}
child component A
public class FooComponent extends ParentComponent<FooChart, FooEntry> {
#Override
public String getName() {
return "FooChart";
}
#Override
protected View createViewInstance(ThemedReactContext reactContext) {
return new FooChart(reactContext);
}
#ReactProp(name = "fooSettings")
public void setFooSettings(FooChart chart, ReadableMap propMap) {
// do foo settings
}
#Override
FooEntry createEntry(ReadableMap value) {
return xxxxx;
}
}
child component B
public class BarComponent extends ParentComponent<BarChart, BarEntry> {
#Override
public String getName() {
return "BarChart";
}
#Override
protected View createViewInstance(ThemedReactContext reactContext) {
return new BarChart(reactContext);
}
#ReactProp(name = "barSettings")
public void setBarSettings(FooChart chart, ReadableMap propMap) {
// do foo settings
}
#Override
BarEntry createEntry(ReadableMap value) {
return xxxxx;
}
}
But How should I implement these in ios?
I am quite new to oc & swift developing, here are my doubts.
In ios, there need a RCTViewManager that return a UIView instance.
what shoud be the UIView instance?
I don't want to inherit FooChart & BarChart, delegate is what I need.
So should I create a custom UIView, initialize a fooChart and holds its reference, then self.addSubView(fooChart) ?
How to share the common settings and template code? Extension ?
Do I have to duplicate RCT_EXPORT_VIEW_PROPERTY(commonSettings, NSDictionary) in both FooChartViewManager and BarChartViewManager?
I tried to define class ParentComponentManagerSwift: RCTViewManager,
and declare RCT_EXPORT_VIEW_PROPERTY(commonSettings, NSDictionary) there,
and class FooComponentManagerSwift: ParentComponentManager, but it doesn't work.
But our components do inherit bunch of exports like backgroundColor/width/height which declared in RCTViewManager?
1) If FooChart & BarChart is a subclass of UIView, then you can initialize FooChart & BarChart, set delegate and return it directly
- (UIView *)view {
FooChart *chart = [FooChart new];
chart.delegate = self;
return chart;
}
2) You can share common settings and template code using inheritance
3) You can either duplicate exports or create some macros that will combine common exports.
Components actually do not inherit exports. All components have RCTViewManager exports + own exports, but its done without using inheritance.

error when adding GPS library admob

the error is :
The type AdListener cannot be a superinterface of FlyingPanda; a superinterface must be an interface
public class FlyingPanda extends Activity implements AdListener {
where is the problem i try to replace the implements kyeword by extends but the error still there.
need you help plz
According to the docs,
You can no longer implement AdListener from your Activity or class
You can use it as an anonymous inner class:
For Interstitial ads:
interstitalAd.setAdListener(new AdListener() {
public void onAdLoaded() {}
public void onAdFailedToLoad(int errorcode) {}
// Only implement methods you need.
});
And for banner ads
adView.setAdListener(new AdListener() {
public void onAdLoaded() {}
public void onAdFailedToLoad(int errorcode) {}
// Only implement methods you need.
});