I am using Vaadin 20 Flow (Java) and want to assign an icon/image (.ico or .png) to my web app. This icon should be displayed besides the page title and should be used as an icon when the page is bookmarked.
I know that it was possible to assign these icons through implementing the interface PageConfigurator. However, this functional interface is now deprecated. Does anyone know how to implement such a favicon in the new Vaadin versions?
Use AppShellConfigurer:
AppShellConfigurator is a replacement of the obsolete PageConfigurator interface.
public class AppShell implements AppShellConfigurator {
#Override
public void configurePage(AppShellSettings settings) {
// ...
settings.addFavIcon("icon", "icons/icon-192.png", "192x192");
settings.addLink("shortcut icon", "icons/favicon.ico");
// ...
}
}
Related
The ZK setLabel() function of Button widget does not work; when the code runs to the line like foobutton.setLabel(mystring), the button disappears from the browser.
In the eclipse IDE, if I hover on the setLabel() function, the IDE shows this message:
If label is changed, the whole component is invalidate.Thus, you want to smart-update, you have to override this method.
Using ZK 8.5.0
Inside the controller class, I declare:
#Wire
Button delSelectedMonitor;
Inside the controller, I implement a class which implements EventListener:
public class onClickHolderEditMode implements EventListener{
public void onEvent(Event event) throws Exception {
clickedDivEditMode = (Div) event.getTarget();
clickedDivIdEditMode = clickedDivEditMode.getId().split(myUtil.monitorholderString)[1];
String curName = getCamNameById(clickedDivIdEditMode);
delSelectedMonitor.setLabel("DELETE:"+clickedDivIdEditMode+","+curName);
}
}
event binding:
tmpdiv.addEventListener("onClick", new onClickHolderEditMode());
My expectation is that when someone clicks the tmpdiv, the button delSelectedMonitor will change its label according to the property of tmpdiv. However as I say previously, the button is just disappearing.
https://www.zkoss.org/wiki/ZK_Client-side_Reference/General_Control/Widget_Customization
I have tried the section "Specify Your Own Widget Class" at the above website link, but the browser will be pending.
Please help, thank you.
I would prefer a different approach.
Why not use a
<button label="#load(vm.xyz)" ... />
(I wrote using MVVM pattern) and modify variable xyz in clicking action?
Check out http://books.zkoss.org/zk-mvvm-book/8.0/syntax/load.html for implementing guide.
Newbie at netbeans-platform.
How can I save my state from one execution to the next.
The netbeans platform elegantly remembers the state and position of all my windows. How can I add to that state some of my own data? Very much like Netbeans saves what projects are open and reopens them when it starts up, along with their state.
Ass suggested here I added the following to my TopComponent but it doesn't work. getPersistenceType is called but neither writeExternal n'or readExternal are called.
#Override
public int getPersistenceType() {
return TopComponent.PERSISTENCE_ALWAYS;
}
#Override
public void writeExternal(ObjectOutput oo) throws IOException {
super.writeExternal(oo);
}
#Override
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
super.readExternal(oi);
}
Comments here suggest tapping into readProperties and writeProperties but that doesn't feel right to me. I am not wanting to store Properties, I want to store State.
Some years ago I blogged about this, using the Session Storage feature of the Swing Application Framework in a NetBeans Platform application:
http://puces-blog.blogspot.ch/2009/04/netbeans-platform-meets-swing.html
The following 3 classes should provide the integration into the NetBeans Platform:
ModuleApplicationContext.java
ModuleLocalStorage.java
Modules.java
The referenced XProperties and JXTable you only need if you want support for SwingX classes such as JXTable.
To use this feature in your own module you need to initialize the context in your ModuleInstall class:
public class Installer extends ModuleInstall {
private static ModuleApplicationContext applicationContext;
#Override
public void restored() {
applicationContext = new ModuleApplicationContext(Modules.getModuleInfo(
Installer.class));
}
public static ModuleApplicationContext getApplicationContext() {
return applicationContext;
}
}
For a given contentPane you can then store the GUI session state using:
Installer.getApplicationContext().getSessionStorage().save(
getContentPanel(), SESSION_STORAGE_XML);
and restore the state using:
Installer.getApplicationContext().getSessionStorage().
restore(getContentPanel(), SESSION_STORAGE_XML);
Note: you need to set the component names of the relevant components
You can find the complete sample here: http://sourceforge.net/p/puces-samples/code/HEAD/tree/tags/sessionstate-1.0/
Also note however that development of the Swing Application Framework (JSR-296) has been withdrawn.
There is a fork called Better Swing Application Framework, but I haven't used it yet.
I also had some problems with this but finally I could fix it.
Annotate Your topcomponent class with #TopComponent.Description and set the right persistence type inside the annotation.
Your topcomponent class has to be serializable so,
every fields inside the topcompent have to be serializable or transient.
You can implement Your custom serialization with readExtern/writeExternal but it is not necessary, You can remove them.
If it still does not work check the log after You closed Your netbeans app and You will see why the platform could not serialize Your topComponent.
I am a little confused about tags. I know from wicket 1.5 there was a change of head render strategy from parent->child to child->parent.
Now I use wicket 6.9 and I have simple menu panel which I want to use some jquery effects.
I want to use the same jquery (for example for google) file for whole application.
I cannot use jquery link only in main page, because in while rendering menu panel there is " $(document).ready" and it is not recognized. Reading some forum i found opinion that panel should contain jquery itselft - it is reasonable, because it can be reusable independently.
So now my page consist:
<head>
...
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
...
</head>
And my menu panel consist the same. As a result in rendered html I load jquery.js twice.
How should I resolve it? I want to load it only once. I know i can back to old strategy and do application.getResourcesSettings().setHeaderItemComparator() but as i read it is not the best solution.
I can found such class like PriorityHeaderItem in wicket, but documentation is very poor for wicket and did not found any example of use it.
Best regards
Since wicket 1.6 jQuery is now the javascript library used by the framework. So you may see jQuery twice because of the one you included and the wicket version? If you want to override the jQuery version you can create a Resource Reference and then set it in your init method of the Application class.
First you need the resource reference file and put the js file in same package structure.
public final class JQueryResourceReference extends JavaScriptResourceReference {
private static final JQueryResourceReference INSTANCE = new JQueryResourceReference();
private JQueryResourceReference() {
super(JQueryResourceReference.class, "jquery.js");
}
public static JQueryResourceReference get() {
return INSTANCE;
}
}
Then in the application init method do this:
public MyApplication extends AuthenticatedWebApplication {
#Override
protected void init() {
super.init();
getJavaScriptLibrarySettings().setJQueryReference(JQueryResourceReference.get());
....
}
....
}
I am developing an Eclipse plug-in that shows custom multi-line markers in Eclipse's own AbstractTextEditor.
Here is what I have so far:
a custom marker with the super type "org.eclipse.core.resources.textmarker"
an annotationType (org.eclipse.ui.editors.annotationTypes)
a markerAnnotationSpecification (org.eclipse.ui.editors.markerAnnotationSpecification)
This is all working well, my markers show up in the editor. But I need to customize the way they are drawn on the VerticalRuler, so they do not only show up as an icon, but as a vertical line spanning the affected source lines.
I know, that this can be done with Annotations by implementing IAnnotationPresentation and overwriting paint().
But how can I do this for markers?
Edit: Here is a screenshot of what I am trying to achieve:
I solved this by contributing a RulerColumn (extension point org.eclipse.ui.workbench.texteditor.rulerColumns) and configuring markerAnnotationSpecification to not include verticalRulerPreferenceKey and verticalRulerPreferenceValue (so it will not be shown on the default AnnotationRulerColumn).
In case someone also finds the documentation on how to best implement IContributedRulerColumn a bit sparse: it seems the way to go is to subclass AbstractContributedRulerColumn and have the methods delegate to a subclass of AbstractRulerColumn.
For example:
public class MyRulerColumn extends AbstractContributedRulerColumn {
private IVerticalRulerColumn delegate = new AbstractRulerColumn() { … }
public void setModel(IAnnotationModel model) {
delegate.setModel(model);
}
…
}
Customizing the appearance is then as easy as overwriting one of the paint… methods in the delegate.
I am writing a Eclipse RCP Plug-in for displaying the properties of objects displayed in application editor.
My plug-in extends PageBookView. Every time, i select a new object is opened on the ApplicationEditor(which is Canvas widget),i create a new page & save the old page.
ApplicationEditor extends EditorPart. It fires propertyChange events when the objects (on the active editor changes). All i want is to add listener to applicationEditor. When the required event fires, i have to update my page.
Let me put it in a simmple way.
public Class MyPage implements IPage implements **WHICH_LISTENER**
{
public MyPage(ApplicationEditor editor)
{
this.addPropertyChangeListener(editor);
}
. . . . . .
}
Which Listener should i implement to refresh the page by propertyChange().?
PS: Thanks in advance for your precious advices. Feel free to question me for further clarity in the Question! I cannot change the editor design or code, as i am trying to contribute to an open source project OpenVXML.
Your approach of notifying UI-Elements is not optimal. Your UI-Elements should register listeners to the objects which are changing. The question which listener to implement to the editor depends on which object the editor is listen to. In your case the PageBookView needs a reference to ApplicationEditor to register itself, which is not good, because 1. the PageBookView has an unneccessary dependency to the editor and 2) the editor is not responsible for propagating changes, but the object itself. I would do the following.
Your Editor:
public class MyEditor extends EditorPart implements PropertyChangeListener
public void init(IEditorSite site, IEditorInput input) {
// Getting the input and setting it to the editor
this.object = input.getObject();
// add PropertyChangeListener
this.object.addPropertyChangeListener(this)
}
public void propertyChanged(PropertyChangeEvents) {
// some element of the model has changed. Perform here the UI things to react properly on the change.
}
}
The same thing needs to be done on your pageBook.
public class MyPropertyView extends PageBook implements PropertyChangeListener{
initModel() {
// you have to pass the model from the editor to the depending pageBook.
this.model = getModelFromEditor()
this.object.addPropertyChangeListener(this)
}
public void propertyChanged(PropertyChangeEvents) {
// some element of the model has changed. Perform here the UI things to react properly on the change.
}
}
As you can see both UI Elements are reacting directly to the changes in the model.
Another way of displaying objects in an editor is to use ProperyViews, for an further description see http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html
A time ago, I've written a simple example for all this notification stuff in Eclipse see here.
HTH Tom