Custom native blackberry calendar event - blackberry

How can I create a custom event on the native blackberry calendar which I can read, write and modify. I am able to add a custom menu field on the calendar but from there I want to add a custom event on the calendar with custom fields.

EventList eventList = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.WRITE_ONLY);
_event = eventList.createEvent();
_event.addString(Event.SUMMARY, PIMItem.ATTR_NONE,"Event Name");
_event.addDate(Event.START, PIMItem.ATTR_NONE, "Event Date in long format");
RepeatRule rule = new RepeatRule();
rule.setInt(RepeatRule.FREQUENCY,RepeatRule.YEARLY);// There is many options in RepeatRule like Daily,Weakly,Monthly,Yearly, ect...
_event.setRepeat(rule);
_event.commit();

Related

How to set different select items in Vaadin Grid Pro's editComponent based on row item

I have Grid Pro displaying Products. A single column is configured as an EditColumn of type 'select' (dropdown/combobox). I'm trying to set the items for this component based on the Product of that row. Is this possible using the 'select' editColumn?
I tried to achieve what I want using the grid's 'addCellEditStartedListener' event, but I can't seems to access the editComponent from CellEditStartedEvent..
thx!
Yes, the this is missing feature in CellEditStartedEvent. As an alternative you can use custom editor in your edit column, as then you have reference to the field you are using, see example
// Use custom editor
EmailField emailField = new EmailField();
emailField.setWidth("100%");
emailField.addThemeName("grid-pro-editor");
grid.addEditColumn(Person::getEmail)
.custom(emailField, (item, newValue) -> {
item.setEmail(newValue);
}).setHeader("E-mail ");
// Use edit started listener to set the field conditionally enabled
grid.addCellEditStartedListener(event -> {
if (!event.getItem().isSubscriber()) {
emailField.setReadOnly(true);
} else {
emailField.setReadOnly(false);
}
});
Full code here: https://cookbook.vaadin.com/grid-pro-conditional-edit

How to highlight multiple components for drag and drop file upload (Vaadin)

I'm using Vaadin to build my front-end and I want to upload files by simply dragging them from the desktop into the browser.
There are several components that can receive the file on the same page. So I used the DragAndDropWrapper on these components and implemented the DropHandler. When the user drags the file over one of the components, its style changes.
But I also would like the styles of all the components that can receive the file to get changed when a file is dragged over areas that cannot receive it, this way indicating the places the user can drop the file. Meanwhile, if the file is dragged over a receptor component only the style of this component should change again.
Is it possible to implement this using only Vaadin?
Its possible. Add to the body of your page ondragover and ondragleave listener and style your multiple components when event fires. SSCCE:
#com.vaadin.annotations.JavaScript("summer.js")
public class Valo4UI extends UI
{
#Override
protected void init(VaadinRequest request)
{
VerticalLayout layout = new VerticalLayout();
Panel panel = new Panel("Login");
panel.setSizeUndefined();
panel.setContent(layout);
TextField username = new TextField();
username.setStyleName("canReceiveFile");
layout.addComponent(username);
TextField password = new TextField();
password.setStyleName("canReceiveFile");
layout.addComponent(password);
Button ok = new Button("Login");
ok.setStyleName("canReceiveFile");
layout.addComponent(ok);
setContent(panel);
JavaScript.getCurrent().execute("initDragStyling()");
}
...
}
summer.js:
function ohItsSummer(){
var summerTable = document.getElementsByClassName("canReceiveFile");
for(var i=0; i<summerTable.length; i++){
summerTable[i].style.borderColor = 'orange';
}
}
function itsReallyHot(){
var summerTable = document.getElementsByClassName("canReceiveFile");
for(var i=0; i<summerTable.length; i++){
summerTable[i].style.borderColor = 'inherit';
}
}
function initDragStyling(){
document.body.setAttribute("ondragover","ohItsSummer()");
document.body.setAttribute("ondragleave","itsReallyHot()");
}

Approach for designing View in vaadin 7

I am newbie to vaadin. I have to develop PoC on vaadin. Service layer is already written using spring. As a part of Poc I have to develop a screen below.
When request comes to my UI class, it will call my View using navigator. This view consists of one tabsheet and each tab have its own functionality and depends on other tab values too. First tab is search tab. It displays all the records came from db in the tab content area(Table/Grid addon. I dont know what to use). Each record have access to other two tabs. The other two tabs has fields to map each record's property. As of now, i have taken dummy data to display.
I wrote the view like this . But I am confused weather this approach is correct or not.
#VaadinView(UserView.NAME)
public class UserView extends VerticalLayout implements View {
public static final String NAME = "user";
public UserView(){
// For Tabs
TabSheet tabs = new TabSheet();
// first tab component
VerticalLayout layout = new VerticalLayout();
// for search fields
HorizontalLayout searchArea = new HorizontalLayout();
FormLayout searchAreaName = new FormLayout();
TextField name = new TextField("name");
FormLayout searchAreaEmail = new FormLayout();
TextField email = new TextField("email");
searchAreaName.addComponent(name);
searchAreaEmail.addComponent(email);
searchArea.addComponent(searchAreaName);
searchArea.addComponent(searchAreaEmail);
// for search table
BeanContainer<String, test.User> users = new BeanContainer<String, User>(
User.class);
users.setBeanIdProperty("userId");
users.addBean(new User("sudheer", "sudheer#kewil.com", "1"));
users.addBean(new User("sridhar", "sridhar#kewil.com", "2"));
users.addBean(new User("ranga", "ranga#kewil.com", "3"));
Table table = new Table("", users);
table.setSizeFull();
table.setPageLength(6);
layout.addComponent(searchArea);
layout.addComponent(table);
Tab tabOne = tabs.addTab(layout, "User Search", null);
// second tab component
VerticalLayout userLayout = new VerticalLayout();
userLayout.addComponent(new TextField("user name"));
userLayout.addComponent(new TextField("email"));
tabs.addTab(userLayout, "main details", null);
// tab change event
addComponent(tabs);
tabs.setHeight("50%");
tabs.setWidth("50%");
setComponentAlignment(tabs, Alignment.MIDDLE_CENTER);
}
#Override
public void enter(ViewChangeEvent event) {
}
}
I haven't implemented pagination also. Before going forward, I would like to know any other best approaches to go ahead.
Any suggestions would help me very much. Thanks in advance.
Anybody.. please help me out. I am going blindly with my appproach
Here is what I do in such cases:
Use the Blackboard event bus to fire events. These events carry a payload that essentially is the id of the record clicked/selected.
The other tabs or views are registered as a listener of this event. When the event is fired, the listeners extract the record/entity id from the payload, fetch the entity object from the back-end, and display it accordingly.
This approach ensures loosely-coupled components.
I hope it helps.

jQuery Fullcalendar: trigger a "create" event using Capybara

I want to trigger a "create" event in jQuery Fullcalendar using Capybara, but I don't know which element to click. I'm not sure whether this is possible with Capybara anyway...
I've created a demo where if a user clicks on a calendar day a new calendar event is created.
See the dayclick callback code:
dayClick: function(date, allDay, jsEvent, view) {
if (allDay) {
alert('Clicked on the entire day: ' + date);
}else{
alert('Clicked on the slot: ' + date);
}
// change the day's background to highlight the fact that its been clicked
$(this).css('background-color', 'red');
// Create a new event for the day that was clicked
var myEvent = {
title:"my new event",
allDay: true,
start: date,
end: date
};
cal.fullCalendar( 'renderEvent', myEvent );
}
You can then click on a date in jQuery Fullcalendar (which will trigger the creation of a new event when the above code is in place) using Capybara as follows:
page.find(:css, "td[data-date='2013-11-06']").click()
Note that you'll need to tailor the CSS to choose exactly which FullCalendar day (i.e. TD element) to click, but this is just an example.
See the Caybara documentation here for how to do this.

How can I get the JqueryUI datepicker show "Today" in the input box

When the user selects today in the datepicker, I want the associated input box to show the word "Today".
Is there any reasonable way to accomplish this?
You could attach a .change() handler to the input that checks the selected date when the value is changed, and updates the value with "Today" if necessary.
Try it out: http://jsfiddle.net/gn4Fj/
$('input').datepicker()
.change(function() {
var today = new Date().getDate();
var val = new Date(this.value).getDate();
if(today === val)
this.value = "Today";
});
Are you looking the showButtonPanel: true option?

Resources