i have a Part with toolbar and there is also a TableViewer.
Int toolbar i have an edit button, which should be active only when a row in table viewer is selected.
i have added a condition to handler's canExecute method.
i can see that this method executes when i click some buttons, but it does not execute when selection in TableViewer is changed, so it does not recognize that the edit button in toolbar should activate.
Maybe i can trigger an exucution of #CanExecute when selection in TableViewer is changed or maybe there is another way?
You can execute the handler using:
#Inject
ECommandService commandService;
#Inject
EHandlerService handlerService;
...
ParameterizedCommand command = commandService.createCommand("command id", Collections.emptyMap());
if (handlerService.canExecute(command)) {
handlerService.executeHandler(command);
}
"command id" is the id of the command that your handler is handling.
You can request that the tool bar be updated using:
#Inject
IEventBroker eventBroker;
...
eventBroker.send(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, UIEvents.ALL_ELEMENT_ID);
Related
I have created multipage HTML editor in which one tab has text editor. I have set the global action handler to the action bar for undo / redo actions in the source editor. Whenever I am adding something in the source editor then undo it, it is not returning the same code in the first attempt. It is completing in the second attempt. Can anyone help me to solve this issue.
In the main editor override the setFocus() method and in this method call the following method of source editor.
public void setUndoRedoActionHandlers() {
final IActionBars actionBars = getEditorSite().getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
mUndoAction);
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),
mRedoAction);
actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
mDeleteAction);
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.DELETE_LINE, mDeleteLineAction);
actionBars.updateActionBars();
}
Thanks
Are you sure that you set global actions by overriding setFocus()? Look at this : https://wiki.eclipse.org/FAQ_How_do_I_enable_global_actions_such_as_Cut,_Paste,_and_Print_in_my_editor%3F
It says they need to be set inside method setActiveEditor()
The reason I guess why you are seeing it working second time is - When the first time you click your editor gets focus and setFocus is called and only then the global actions are set. Then second time it will work because the actions are now set.
I have a form in Dynamics AX which displays a table of two columns in a grid. I also have a button on the form. I am overriding the clicked method of the button to update the Address field of the table. For example, here's my X++ code:
void clicked()
{
AddressTable addr;
ttsBegin;
select forUpdate addr where addr.addressID == 1;
addr.Address = "new address";
addr.update();
ttsCommit;
super();
// reload table here
}
What I would like to do is to add a code to the clicked function which will reload (re-select) the updated records and show them in the form without a need of reopening the window or refreshing it using F5 (for example).
I went through forums and AX documentation and found a few methods like refresh and reread, but they are FormDataSource class methods and I failed to make it happen inside the clicked handler above.
So, what I really want to accomplish programaticallyis what F5 does behind the scenes when clicked on an open form.
Maybe just addressTable_ds.research(true); will do the job.
See also Refresh Issue on the form when the dialog closes.
i had this task: I have Presenter/View Couple (lets call it ItemListPresenter) showing a Celltable. Now i wanted to edit an item by double-clicking it (or pressing a button, whatever). Then a popup dialog should appear (Lets call it PopupWidget), letting me edit my item properties.
i found a solution how to do it, but i am not sure it is the "right" way. Since i am trying to learn the philosophy behind GWT/GWTP, i would appreciate if you could give me hints what i did right and what i did wrong:
In the onbind method of ItemListPresenter, i wire the CellTable with a DoubleClick handler:
getView().getCellTable().setSelectionModel(selectionModel);
getView().getCellTable().addDomHandler(new DoubleClickHandler() {
#Override
public void onDoubleClick(final DoubleClickEvent event) {
DeviceDto selectedDeviceDto = selectionModel.getSelectedObject();
//TODO: Figure out how to best handle editing of DeviceDto
if (selectedDeviceDto != null) {
devicesDialog.setCurrentDeviceDTO(selectedDeviceDto);
addToPopupSlot(devicesDialog);
}
} }, DoubleClickEvent.getType());
What does not feel right is setting the object i want to edit (selectedDeviceDto) in the Dialog Presenter Widget. Is this the "right" way?
My popup presenter which is defined as
public class DeviceEditDialogPresenterWidget extends PresenterWidget<DeviceEditDialogPresenterWidget.MyView> implements
DeviceEditDialogUiHandlers {
is still ugly, since i just set every property into a text box and after editing, i recollect the properties and rebuild the object. This is messy and i guess i should GWT Editors for that. However, when i click the "Save" Button in the dialog, an UiHandler is triggered:
#UiHandler("okButton")
void okButtonClicked(ClickEvent event) {
DeviceDto dev = new DeviceDto(idBox.getText(), deviceIdBox.getText(), typeBox.getText(), firmwareVersionBox.getText(), userBox.getText(), statusBox.getText());
getUiHandlers().updateDevice(dev);
hide();
}
This triggers my DeviceEditDialogPresenterWidget, which itself fires and event:
#Override
public void updateDevice(DeviceDto device) {
eventBus.fireEvent(new DeviceUpdatedEvent(device));
}
This event is caught by a handler in the "mother" presenter with the CellTable, which is wired in the onBind method again:
addRegisteredHandler(DeviceUpdatedEvent.TYPE, new DeviceUpdatedEvent.DeviceUpdatedHandler() {
#Override
public void onDeviceUpdatedEvent(DeviceUpdatedEvent event) {
updateDevice(event.getDevice());
}
});
I would really like to avoid going down a road of messy mistakes, so any hints would be appreciated.
Thanks
Arthur
PresenterWidgets are usually designed to have a setter which is used to set a Model or DTO that the PresenterWidget works on (the same way you did it).
Alternatively you can avoid a PresenterWidget and use an Editor (extends Composite) that you manually add to a PopupPanel or DialogBox in your ListItemEditor.
This way you avoid the complexity of a PresenterWidget. But you have to handle the clicks (i.e. save button) from the ListItemPresenter. I would always try to start small (use a composite) and if you realize that you might need the functionality also in other places, create a PresenterWidget.
Also you don't need the updateDevice method because you pass a reference to your DTO. You only need to fresh the CellTable.
But apart from that your approach looks fine.
I have an application where the user can modify an entity, say customer, by modifying a bunch of text-boxes, list-boxes, date-pickers and check-boxes. I also have 2 buttons, save and cancel. I would like to enable the save button if an actual change was made (i.e. one of the input widgets has been modified). Obviously, this can be done in a "brute-force" way by manually adding a change listener to every widget. Or a slight improvement could be to define lists of widgets and add listeners in a for loop.
I am curious whether anyone has a more elegant solution?
Thanks,
Matyas
If you use UiBinder you can use something like:
#UiField TextBox textBoxA;
#UiField TextBox textBoxB;
#UiField TextBox textBoxC;
#UiField DatePicker datPickerA;
#UiField RadioButton radioButton;
...
#UiHandler(value={"textBoxA", "textBoxB", "textBoxC", "datePickerA"})
void somethingChanged(ChangeEvent e) {
// Enable your save button.
}
#UiHandler("radioButton")
void somethingClicked(ClickEvent e) {
// Enable your save button.
}
I have an AutoCompleteTextView control serviced by an 'OnClick' Listener. It extracts a list of items from a database and populates the array adapter attached to the control. When I enter sufficient text to isolate an entry in the adapter list (usually about 2 characters) and I select the identified item, the adapterview's 'OnItemClick' Listener is invoked and I am able to identify the selected item, set the text in the AutoCompleteTextView, and execute its performCompletion() method. When this routine completes, the virtual keyboard remains in place. When I 'Tab' away from the control I receive a NullPointerException!
Any suggestions appreciated ...
PS: this display is generated programmatically.
You can use the snippet below to hide the keyboard.
private static void hideSoftKeyboard (View view) {
InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);
}