public static void generateTXT(String fileName, Collection smsCollection) { try { FileWriter fileWriter = new FileWriter(fileName); Iterator it = smsCollection.iterator(); while (it.hasNext()) { Message message = (Message) it.next(); fileWriter.write("Index: " + message.getIndex() + "\r\n"); switch (message.getStatus()) { case Message.UNREAD_STATUS: fileWriter.write("Status: Unread\r\n"); case Message.READ_STATUS: fileWriter.write("Status: Read\r\n"); case Message.SENT_STATUS: fileWriter.write("Status: Sent\r\n"); case Message.UNSENT_STATUS: fileWriter.write("Status: UnSent\r\n"); } fileWriter.write( "TeleNumber: " + message.getTeleNum() + "\r\n" + "Conetnet: " + message.getContent() + "\r\n" + "Time: " + message.getReceiveTime() + "\r\n\r\n"); } fileWriter.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void build() { shell = new Shell(parentShell, SWT.TOOL | SWT.CLOSE); final Rectangle bounds = this.display.getBounds(); shell.setLocation(bounds.width - 220, bounds.height - iY); shell.setSize(200, iheight); final Timer upDownWindowTimer = new Timer(true); upDownWindowTimer.schedule( new TimerTask() { public void run() { display.syncExec( new Runnable() { public void run() { if (step < 0 && delayTime > 0) { delayTime = delayTime - 30; return; } shell.setLocation(bounds.width - 220, bounds.height - iY); shell.setSize(200, iheight); iheight = iheight + step; iY = iY + step; if (iheight == 150 && step > 0) { step = -step; delayTime = POPUP_WINDOW_DELAY_TIME; } if (iheight == 0 && step < 0) { step = -step; delayTime = 0; upDownWindowTimer.cancel(); shell.close(); } } }); } }, 0, 30); shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { upDownWindowTimer.cancel(); } }); // For the jmobile invoke. shell.setText(Messages.getString(MessagesConstant.NEW_SMS_TITLE)); // For the main() invoke. // shell.setText("NEW SMS"); setBackGroundWhite(shell); FormLayout layout = new FormLayout(); layout.marginTop = 5; layout.marginLeft = 5; shell.setLayout(layout); // The first row: product name label FormData formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(0, 200); formData.top = new FormAttachment(0, 0); Label lbSender = new Label(shell, SWT.LEFT); lbSender.setLayoutData(formData); // For the jmobile invoke. lbSender.setText(Messages.getString(MessagesConstant.NEW_SMS_FROM, message.getTeleNum())); // For the main() invoke. // lbSender.setText(message.getTeleNum()); setBackGroundWhite(lbSender); // The first row: product name label formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(0, 200); formData.top = new FormAttachment(lbSender, 10); Link lkContent = new Link(shell, SWT.NONE); lkContent.setLayoutData(formData); lkContent.setText(MessageFormat.format(smsContentFormat, new Object[] {message.getContent()})); lkContent.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.close(); NewSMSDialog dialog = new NewSMSDialog(NewMessageArrivalPopupWindowShell.this.parentShell); dialog.create(); // set value to control in dialog dialog.getTxtReceiver().setText(message.getTeleNum()); dialog.getTxtContent().setText(message.getContent()); dialog.getTxtContent().setFocus(); dialog.open(); } }); setBackGroundWhite(lkContent); shell.setFocus(); shell.open(); shell.forceActive(); PlaySound.execute(WAV_FILE); }