Scrollable Layout in Vaadin Flow - scrollview

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

Related

Showing link inside custom hover (Eclipse plugin development)

I have a custom hover inside CDT editor (see the linked SO question) and now I want to show link inside my IAnnotationHover hover:
public class MyAwesomeHover implements IAnnotationHover {
#Override
public String getHoverInfo(ISourceViewer sw, int ln) {
return "<a href='www.stackoverflow.com'>so</a>"
}
}
Unfortunately the link is not shown - the hover window shows only simple text (i.e "so"). Other HTML elements I tried work OK (ul, li, p, font ...). Can anyone help me please?
As was mentioned in the comments, the RevisionHover was a good starting point. The magic is in implementing the IAnnotationHoverExtension and creation of a custom AbstractReusableInformationControlCreator. I am posting a code snippet with solution that worked for me.
public class MyHover implements IAnnotationHover, IAnnotationHoverExtension {
...
#Override
public IInformationControlCreator getHoverControlCreator() {
return new MyCreator();
}
...
#Override
public Object getHoverInfo(ISourceViewer sv, ILineRange lr, int vnl) {
return "<a href='www.stackoverflow.com'>so</a>";
}
...
private final class MyCreator extends AbstractReusableInformationControlCreator {
protected IInformationControl doCreateInformationControl(Shell parent) {
BrowserInformationControl control =
new BrowserInformationControl(
parent,
JFaceResources.DIALOG_FONT,
false);
control.addLocationListener(
new LocationAdapter() {
#Override
public void changing(LocationEvent ev) {
if (ev.location.startsWith("file:")) {
// !This opens the link!
openUrl(ev.location)
}
}
});
return control;
}
}
}

NullPointerException on Google Banner Ads

my app get crashing frequently due to NullPointerException and Native crash and thus I am losing my play store rank day by day. someone please help me on this.. is there any way if banner ad is not ready, can I show native ad (optional question)?
NullPointerException at: mAdView.loadAd(new AdRequest.Builder().build());
My app build version 26.0.1 and using Android Studio 3.0 Beta 2.
my code:
public class B1 extends Fragment {
public B1() {
// Required empty public constructor
}
private AdView mAdView;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_b1, container, false);
//Banner
mAdView = rootView.findViewById(R.id.adView);
mAdView.loadAd(new AdRequest.Builder().build());
mAdView.setAdListener(new AdListener() {
#Override
public void onAdLoaded() {
mAdView.setVisibility(View.VISIBLE);
}
#Override
public void onAdFailedToLoad(int error) {
mAdView.setVisibility(View.GONE);
}
});
return rootView;
}
}
The banner is ready. Your findViewById is returning null. Make sure rootView actually contains the AdView R.id.adView

Can we create a Child (with interface MyView extends PopupView) that inherit a PresenterWidget (with interface MyView extends View) (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){"

How to add the OnShareTargetActivated() method manually in a windows 8 C# blank application?

I have created a Windows8 blank xaml application.And now i want to make this application as a Share Target.I have followed the instructions at below link and able to make it as a Target app.
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh973053
But where do i add the following method (OnShareTargetActivated) in my blank xaml application ?When i manually add this method in mainpage.xaml.cs , it shows the errors"
"Project.MainPage.OnShareTargetActivated(Windows.ApplicationModel.Activation.ShareTargetActivatedEventArgs)' is a new virtual member in sealed class "
"Project.MainPage.OnShareTargetActivated(Windows.ApplicationModel.Activation.ShareTargetActivatedEventArgs)': no suitable method found to override "
protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
// Code to handle activation goes here.
}
It goes in the class that inherits from Windows.UI.Xaml.Application. Typically App.cs.
E.g.
sealed partial class App : Application
{
public App()
{
this.InitializeComponent();
}
//...
protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
var rootFrame = new Frame();
rootFrame.Navigate(typeof(MainPage), args.ShareOperation);
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
}

Save option in RCP Product

Iam developing a RCP application which consists of views and editors. I can change the values and edit the values of some parameters in editor. When a value has been changed, i need to make the editor dirty as well as would also like to enable the save button. Till now, i have not implemented my save button. Could anyone guide me how to make the save button enabled as well as how can i make an editor dirty when some modifications happen in editor.
Thanks in advance. Any help will be greatly appreciated.
Regards,
Girish
Here is an overview of the Form editor logic, hop it will help you.
public class TestEditor extends FormEditor {
#Override
protected void addPages() {
// this method is called when the editor is being created
// to add the necessary pages
// page classes should be like following
// class TestEditorPage extends FormPage
try {
TestEditorPage pageTest = new TestEditorPage(this);
addPage(pageTest);
} catch (PartInitException e) {
}
}
#Override
public void doSave(IProgressMonitor monitor) {
// this method will be called on save action
// (or Ctrl + s shortcut)
}
#Override
public void doSaveAs() {
// this method will be called on save-as
//call (or Ctrl + Shift + s shortcut)
}
#Override
public boolean isSaveAsAllowed() {
// put here the call to the logic that
// check if the save is allowed
return true;
}
#Override
public boolean isDirty() {
// Here the call for the logic that
// defines if the editor is dirty or not
return true;
}
}