Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » rap calendar(problem in creating calender in rap application)
rap calendar [message #657824] Fri, 04 March 2011 09:01 Go to next message
marie Missing name is currently offline marie Missing nameFriend
Messages: 63
Registered: March 2011
Member
hi all,
I am facing a problem in creating calender dialog in rap application.
i have wriiten the code n getting compliation error
private void onPaint(PaintEvent event) {
Rectangle rect = getClientArea();
GC gc0 = event.gc;
Image image = new Image(m_Display, rect.width, rect.height); GC gc = new GC(image);


gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
gc.fillRectangle(rect);
int x = 0;
int y = 0;
for (int i = 0; i < 7; i++) {
if (i == 0)
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));
else
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));


String text = getDayName(i);
Point size = gc.stringExtent(text);
gc.drawText(text, x + (m_ColSize-size.x)/2, (m_RowSize-size.y)/2, true);
x += m_ColSize;


}
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
y += m_RowSize;
gc.drawLine(0, 0, rect.width, 0);
gc.drawLine(0, y - 1, rect.width, y - 1);
//


m_Calendar.set(Calendar.YEAR, m_Year);
m_Calendar.set(Calendar.MONTH, m_Month);
int day = 1;
while (true) {
m_Calendar.set(Calendar.DAY_OF_MONTH, day);
if (m_Calendar.get(Calendar.MONTH) != m_Month)

break;
int day_of_week = calendarDayToNormal(m_Calendar.get(Calendar.DAY_OF_WEEK));
Point p = getDayPoint(day);
if (day == m_Day) {

//gc.setForeground(m_Display.getSystemColor(SWT.COLOR_LIST_S ELECTION_TEXT));
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLUE));


gc.setBackground(m_Display.getSystemColor(SWT.COLOR_LIST_SEL ECTION));
}
else {
gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
if (day_of_week == 0)
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));

else
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
}
String text = ""+day;
Point size = gc.stringExtent(text);
gc.drawText(text, p.x + ((m_ColSize-size.x)/2), p.y + ((m_RowSize-size.y)/2), true);


day++;
}
gc0.drawImage(image, 0, 0);
gc.dispose();
image.dispose();

please help me to sovle this problem.
thanks in advance
Re: rap calendar [message #657840 is a reply to message #657824] Fri, 04 March 2011 09:44 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
currently, GC drawing is only supported on Canvas, but not on image -
see bug:
318900: Image class doesn't implement Drawable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318900
If you want to create a Calandar, you can use DateTime widget with
SWT.CALENDAR style flag or SWT.DATE | SWT.DROP_DOWN.
HTH,
Ivan

On 3/4/2011 11:01 AM, mamta wrote:
> hi all,
> I am facing a problem in creating calender dialog in rap application.
> i have wriiten the code n getting compliation error
> private void onPaint(PaintEvent event) {
> Rectangle rect = getClientArea();
> GC gc0 = event.gc;
> Image image = new Image(m_Display, rect.width,
> rect.height); GC gc = new GC(image);
>
>
>
> gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
> gc.fillRectangle(rect);
> int x = 0;
> int y = 0;
> for (int i = 0; i < 7; i++) {
> if (i == 0)
>
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));
> else
>
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
>
>
> String text = getDayName(i);
> Point size = gc.stringExtent(text);
> gc.drawText(text, x + (m_ColSize-size.x)/2,
> (m_RowSize-size.y)/2, true);
> x += m_ColSize;
>
>
> }
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
> y += m_RowSize;
> gc.drawLine(0, 0, rect.width, 0);
> gc.drawLine(0, y - 1, rect.width, y - 1);
> //
>
>
> m_Calendar.set(Calendar.YEAR, m_Year);
> m_Calendar.set(Calendar.MONTH, m_Month);
> int day = 1;
> while (true) {
> m_Calendar.set(Calendar.DAY_OF_MONTH, day);
> if (m_Calendar.get(Calendar.MONTH) != m_Month)
>
> break;
> int day_of_week =
> calendarDayToNormal(m_Calendar.get(Calendar.DAY_OF_WEEK));
> Point p = getDayPoint(day);
> if (day == m_Day) {
>
> //gc.setForeground(m_Display.getSystemColor(SWT.COLOR_LIST_S
> ELECTION_TEXT));
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLUE));
>
>
> gc.setBackground(m_Display.getSystemColor(SWT.COLOR_LIST_SEL ECTION));
> }
> else {
> gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
> if (day_of_week == 0)
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));
>
> else
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
> }
> String text = ""+day;
> Point size = gc.stringExtent(text);
> gc.drawText(text, p.x + ((m_ColSize-size.x)/2), p.y +
> ((m_RowSize-size.y)/2), true);
>
>
> day++;
> }
> gc0.drawImage(image, 0, 0);
> gc.dispose();
> image.dispose();
>
> please help me to sovle this problem.
> thanks in advance
Re: rap calendar [message #658656 is a reply to message #657840] Wed, 09 March 2011 12:03 Go to previous messageGo to next message
marie Missing name is currently offline marie Missing nameFriend
Messages: 63
Registered: March 2011
Member
thanks Ivan
bt i have another doubt
when i excute my rap application i m getting exception

org.eclipse.swt.SWTError: Not implemented [multiple displays]
at org.eclipse.swt.SWT.error(SWT.java:3349)
at org.eclipse.swt.widgets.Display.<init>(Display.java:231)
at com.tcs.adex.ui.security.dialogs.newObj.CreateUserInstanceDi alog.createDialogAreaCheckBox(CreateUserInstanceDialog.java: 361)
at com.tcs.adex.ui.security.dialogs.newObj.CreateUserInstanceDi alog.createDialogArea(CreateUserInstanceDialog.java:204)
at org.eclipse.jface.dialogs.TitleAreaDialog.createContents(Tit leAreaDialog.java:152)
at org.eclipse.jface.window.Window.create(Window.java:433)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1071)
at org.eclipse.jface.window.Window.open(Window.java:793)
at com.tcs.adex.ui.security.actions.CreateSecurityInstanceActio n.getUserInput(CreateSecurityInstanceAction.java:220)
at com.tcs.adex.ui.security.actions.CreateSecurityInstanceActio n.runHelper(CreateSecurityInstanceAction.java:89)
at com.tcs.adex.ui.security.actions.CreateSecurityInstanceActio n.runAction(CreateSecurityInstanceAction.java:77)
at com.tcs.mdd.common.ui.actions.AbstractAction$1.run(AbstractA ction.java:44)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:66)
at com.tcs.mdd.common.ui.actions.AbstractAction.run(AbstractAct ion.java:43)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:493 )
at org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:575)
at org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:492)
at org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:403)
at org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatc hEvent(UntypedEventAdapter.java:652)
at org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetS elected(UntypedEventAdapter.java:88)
at org.eclipse.swt.events.SelectionEvent.dispatchToObserver(Sel ectionEvent.java:196)
at org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:163)
at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.jav a:203)
at org.eclipse.swt.widgets.Display.runPendingMessages(Display.j ava:1130)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :1120)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2733)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:25 30)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:702)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:685)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:157)
at com.tcs.adex.ui.Application.createUI(Application.java:17)
at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createU I(EntryPointManager.java:92)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWT LifeCycle.java:242)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadCont roller.run(RWTLifeCycle.java:111)
at java.lang.Thread.run(Thread.java:595)
at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.jav a:102)


why this occur can anybody help me please

thanks in advance
Re: rap calendar [message #658660 is a reply to message #658656] Wed, 09 March 2011 12:17 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi mamta,
seems like you call new Display() several times. Use <some
control>.getDisplay() instead.
HTH,
Ivan

On 3/9/2011 2:03 PM, mamta wrote:
> thanks Ivan
> bt i have another doubt
> when i excute my rap application i m getting exception
>
> org.eclipse.swt.SWTError: Not implemented [multiple displays]
> at org.eclipse.swt.SWT.error(SWT.java:3349)
> at org.eclipse.swt.widgets.Display.<init>(Display.java:231)
> at com.tcs.adex.ui.security.dialogs.newObj.CreateUserInstanceDi
> alog.createDialogAreaCheckBox(CreateUserInstanceDialog.java: 361)
> at com.tcs.adex.ui.security.dialogs.newObj.CreateUserInstanceDi
> alog.createDialogArea(CreateUserInstanceDialog.java:204)
> at org.eclipse.jface.dialogs.TitleAreaDialog.createContents(Tit
> leAreaDialog.java:152)
> at org.eclipse.jface.window.Window.create(Window.java:433)
> at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1071)
> at org.eclipse.jface.window.Window.open(Window.java:793)
> at com.tcs.adex.ui.security.actions.CreateSecurityInstanceActio
> n.getUserInput(CreateSecurityInstanceAction.java:220)
> at com.tcs.adex.ui.security.actions.CreateSecurityInstanceActio
> n.runHelper(CreateSecurityInstanceAction.java:89)
> at com.tcs.adex.ui.security.actions.CreateSecurityInstanceActio
> n.runAction(CreateSecurityInstanceAction.java:77)
> at com.tcs.mdd.common.ui.actions.AbstractAction$1.run(AbstractA
> ction.java:44)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator
> .java:66)
> at com.tcs.mdd.common.ui.actions.AbstractAction.run(AbstractAct
> ion.java:43)
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:493 )
> at org.eclipse.jface.action.ActionContributionItem.handleWidget
> Selection(ActionContributionItem.java:575)
> at org.eclipse.jface.action.ActionContributionItem.access$2(Act
> ionContributionItem.java:492)
> at org.eclipse.jface.action.ActionContributionItem$5.handleEven
> t(ActionContributionItem.java:403)
> at org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatc
> hEvent(UntypedEventAdapter.java:652)
> at org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetS
> elected(UntypedEventAdapter.java:88)
> at org.eclipse.swt.events.SelectionEvent.dispatchToObserver(Sel
> ectionEvent.java:196)
> at org.eclipse.rwt.internal.events.Event.processEvent(Event.jav
> a:44)
> at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja
> va:163)
> at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.jav
> a:203)
> at org.eclipse.swt.widgets.Display.runPendingMessages(Display.j
> ava:1130)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
> :1120)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav
> a:2733)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
> at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:25 30)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:702)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault
> (Realm.java:332)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work
> bench.java:685)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j
> ava:157)
> at com.tcs.adex.ui.Application.createUI(Application.java:17)
> at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createU
> I(EntryPointManager.java:92)
> at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWT
> LifeCycle.java:242)
> at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadCont
> roller.run(RWTLifeCycle.java:111)
> at java.lang.Thread.run(Thread.java:595)
> at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.jav
> a:102)
>
>
> why this occur can anybody help me please
>
> thanks in advance
Previous Topic:Tree control over IPad
Next Topic:DelegatingStyledCellLabelProvider.IStyledLabelProvider
Goto Forum:
  


Current Time: Tue Apr 16 10:35:02 GMT 2024

Powered by FUDForum. Page generated in 0.54652 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top