/**
*
*/
package de.toaot.view;
import java.net.URI;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
import winterwell.jtwitter.Twitter.User;
import de.toaot.twitter.auth.TwitterFactory;
import org.eclipse.swt.widgets.Canvas;
/**
* @author hseifert
*
*/
public class Account extends ViewPart {
private Text text_1;
private Text text_2;
private Text text_3;
private Text text_4;
/**
*
*/
public Account() {
// TODO Auto-generated constructor stub
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
* .Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FormLayout());
User user = new User("ToaoT");
try {
user = TwitterFactory.getTwitter().getUser("ToaoT");
} catch (Exception e) {
e.printStackTrace();
System.out.println("Excpetion calling the Twitter API.");
}
// Screen name
text_1 = new Text(parent, SWT.BORDER | SWT.SINGLE);
FormData fd = new FormData();
fd.top = new FormAttachment(0, 49);
fd.right = new FormAttachment(100, -123);
text_1.setLayoutData(fd);
String temp = user.getScreenName();
text_1.setText((temp == null) ? "{screen name}" : temp);
// Location
text_2 = new Text(parent, SWT.BORDER | SWT.SINGLE);
fd.bottom = new FormAttachment(text_2, -6);
fd.left = new FormAttachment(text_2, 0, SWT.LEFT);
fd = new FormData();
fd.top = new FormAttachment(0, 74);
fd.left = new FormAttachment(0, 10);
fd.right = new FormAttachment(100, -123);
text_2.setLayoutData(fd);
temp = user.getLocation();
text_2.setText((temp == null) ? "{location}" : temp);
// Web site
text_3 = new Text(parent, SWT.BORDER | SWT.SINGLE);
fd.bottom = new FormAttachment(text_3, -6);
fd = new FormData();
fd.top = new FormAttachment(0, 99);
fd.left = new FormAttachment(0, 10);
fd.right = new FormAttachment(100, -123);
text_3.setLayoutData(fd);
URI temp2 = user.getWebsite();
text_3.setText((temp2 == null) ? "{web site}" : temp2.toASCIIString());
// Description
text_4 = new Text(parent, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
fd.bottom = new FormAttachment(text_4, -6);
fd = new FormData();
fd.height = 50;
fd.top = new FormAttachment(0, 124);
fd.left = new FormAttachment(0, 10);
fd.right = new FormAttachment(100, -10);
fd.bottom = new FormAttachment(100, -281);
text_4.setLayoutData(fd);
temp = user.getDescription();
text_4.setText((temp == null) ? "{description}" : temp);
Canvas canvas = new Canvas(parent, SWT.BORDER | SWT.NO_REDRAW_RESIZE);
FormData fd_canvas = new FormData();
fd_canvas.bottom = new FormAttachment(text_3, 0, SWT.BOTTOM);
fd_canvas.top = new FormAttachment(0, 10);
fd_canvas.right = new FormAttachment(text_4, 0, SWT.RIGHT);
fd_canvas.left = new FormAttachment(text_1, 6);
fd_canvas.width = 48;
fd_canvas.height = 48;
canvas.setLayoutData(fd_canvas);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}