ImgButton : How to tell SmartGWT to not concatene state on the name of file source? - gwt

private ImgButton button = new ImgButton();
...
button.setSrc("iconName.jpg");
GWT or SmartGWT, I cannot tell exactly, generate state word to concatene it on the name of file.
Example to clarify :
On focus, iconName.jpg become iconName_Focus.jpg
On mouse down click, iconName.jpg become iconName_Down.jpg
On over, iconName.jpg become iconName_Over.jpg
Because these images are custom images, I want to tell GWT to take a default image when I didn't provide the corresponding image.
For example, when over event is fire and iconName_Over.jpg does not exist then use iconName.jpg.

Use the setShow{State} or setShow{State}Icon methods accordingly. For example for disabling the mouse down state, use setShowDown(Boolean.FALSE). For not showing a different icon when the mouse goes down on the button, use the setShowDownIcon(Boolean.FALSE). The rest of the actions have accordingly named methods you can look up at the ImgButton's javadoc page.

Related

My question is about Ability for an author to reorder each tab within the component dialog in aem

enter image description here
I want to know how to provide the numbering for each tab, so that author can provide the number as per their requirement.
This is the strangest requirement I ever heard of. You can sure do that, but it didn't make much sense of doing it system wide as one author can feel the dialog one way, other in completely different. The only reasonable solution is to use javascript to reorder the tabs in the way an author want and than save the settings for this specific component in his user profile. You can start implementing it by creating a clientlib with the category cq.authoring.dialog. In your JS you have to listen to specific dialog loading event as shown below. I think this should be enough and it's a good starting point.
// necessary as no granite or coral ui event is triggered, when the dialog is opened
// in a fullscreen mode the dialog is opened under specific url for serving devices with low screen resolution
if (location.href.match(/mnt\/override/)) {
$(window).on('load', function(e) {
setTimeout(doSomething, 100);
});
} else {
$(document).on('dialog-ready', function(e) {
Coral.commons.ready(function(){
setTimeout(doSomething, 100);
});
});
}
You can use granite:rel to define specific identifiers in the dialog definition and use save them later in the user settings. You can define drag & drop events using the tab selector [role="tab"].
This is not trivially possible. Decide upfront about the order when building the component, provide meaningful labels and go with that. Touch UI does not provide the feature you need.

Get notified when user jumps to a marker (annotation) in Eclipse

I'm currently writing a plugin for the Eclipse IDE. In this plugin, I defined my own type of resource marker (IMarker). Using the standard Eclipse means like the "Next annotation"/"Previous annotation" buttons, the user has the possibility to navigate between these markers. I also wrote a view which shows some detail information for a single marker. This view shall be updated when the user navigates to a marker. Can I register some kind of listener/observer that will be notified when the user selects/jumps to a marker? If so, how? If not, what are my alternatives?
The Next Annotation action ends up calling the ITextEditorExtension4.gotAnnotation method. The usually implementation for this is in AbstractTextEditor. This just calls finds the annotation and calls the selectAndReveal method.
So there does not seem to be any special listener you can use for this. Normal selection events should be generated so you could use the ISelectionService selection listener but you will have to work out if the selection is for your marker.

GWT Editors for readonly and edit mode

GWT's Editor framework is really handy and it can not only be used for editing POJOs but also for read-only display.
However I am not entirely sure what the best practice is for doing inline edits.
Let's assume I have a PersonProxy and I have one Presenter-View pair for displaying and editing the PersonProxy. This Presenter-View should by default display the PersonProxy in read-only mode and if the user presses on a edit button it should allow the user to edit the PersonProxy object.
The solution I came up with was to create two Editors (PersonEditEditor and PersonDisplayEditor) that both added via UiBinder to the View. The PersonEditEditor contains
ValueBoxEditorDecorators and the PersonDisplayEditor contains normal Labels.
Initially I display the PersonDisplayEditor and hide PersonEditEditor.
In the View I create two RequestFactoryEditorDriver for each Editor and make it accessable from the Presenter via the View interface. I also define a setState() method in the View interface.
When the Presenter is displayed for the first time I call PersonDisplayDriver.display() and setState(DISPLAYING).
When the user clicks on the Edit button I call PersonEditDriver.edit() and setState(EDITING) from my Presenter.
setState(EDITING) will hide the PersonDisplayEditor and make the PersonEditEditor visible.
I am not sure if this is the best approach. If not what's the recommended approach for doing inline edits? What's the best way to do unit-testing on the Editors?
If you can afford developing 2 distinct views, then go with it, it gives you the most flexibility.
What we did in our app, where we couldn't afford the cost of developing and maintaining two views, was to bake the two states down into our editors, e.g. a custom component that can be either a label or a text box (in most cases, we simply set the text box to read-only and applied some styling to hide the box borders).
To detect which mode we're in, because we use RequestFactoryEditorDriver (like you do), we have our editors implement HasRequestContext: receiving a null value here means the driver's display() method was used, so we're in read-only mode. An alternative would be to use an EditorVisitor along with some HasReadOnly interface (which BTW is exactly what RequestFactoryEditorDriver does to pass the RequestContext down to HasRequestContext editors).
Yes,Presenter-View pair should be. But Here two ways to achieve this feature if you like to go with:
1) Integrate Edit/View code design in one ui.xml i.e.Edit code in EDitHorizonatlPanel and View code in ViewHorizontalPanel.The panel has different id. By using id, show/hide panel with display method. if getView().setState() ==Displaying then show ViewHorizontalPanel and if getView().setState()==Editing then show EditHorizontalPanel.
2) Instead of using labels, Use textboxes only. set Enable property is false when you need it in view mode otherwise true
You have created two Presenter/view but I think if Edit/View function has similar code so no need to rewrite similar code again and again for view purpose.
If a big project has so many Edit/View function and you will create such type of multiple View/Presenter than your project size become so huge unnecessary.
I think that whatever I have suggest that might be not good approach but a way should be find out which help to avoid code replication.

Customizing GtkFileChooser

GTK+ noob question here:
Would it be possible to customize the GtkFileChooserButton or GtkFileChooserDialog to remove the 'Places' section (on the left) and the 'Location' entry box on the top?
What I'm essentially trying to do is to allow the user to select files only from a particular folder (which I set using gtk_file_chooser_set_current_folder ) and disable navigating to other locations on the file system.
This is the standard file chooser dialog :
This is what I need:
It doesn't look like that is possible with the standard file chooser dialog. For example, here is a document discussing why such a thing would be useful and how it could be implemented, but the idea never made it to fruition.
What you can do, perhaps, is write your own dialog that implements the GtkFileChooser interface, based on the GtkFileChooserDialog code, but hides the location bar and bookmarks list.
You can get a handle on the individual children by finding out where there are with gtkparasite and then accessing them with get_children.
Make sure to use .show() instead of .run() for inspecting the dialog with gtkparasite. If you use .run() the dialog is shown in modal mode so you can't inspect it.
For example I hide the Path and Places widgets with the statements below:
dialog = gtk.FileChooserDialog("Open***", None, gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN, gtk.RESPONSE_OK))
dialog.set_show_hidden(True)
dialog.set_default_response(gtk.RESPONSE_OK)
vbox = dialog.get_children()[0].get_children()[0].get_children( [0].get_children()[0]
vbox.get_children()[0].hide()
vbox.get_children()[2].get_children()[0].hide()
Of course this is not an exposed API so it can always break from underlying changes.
Hope it makes sense ...
Tried to post an image but I am a new user ....

How to enable save action in Eclipse toolbar?

I am working under Eclipse plug-in development. I have implemented two view parts to view and change some objects. Each view part implements ISaveablePart to save modified objects and enable save button on toolbar.
The problem is: when I select my objects in Project Explorer, Save button isn't enabled, only Save All is enabled.
So I'd like to know is there any ability to enable Save button in this case?
You must first implement ISaveablePart, as you have mentioned above.
You have to fire an event (see IWorkbenchPartConstants.PROP_DIRTY), which will in turn ask your editor whether it's dirty (ISaveablePart#isDirty()). If the answer is true, then the save button will be enabled.
See FormEditor#editorDirtyStateChanged() for an example.