GridData gridData1 = new org.eclipse.swt.layout.GridData();
gridData1.grabExcessHorizontalSpace = false;
gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.END;
CoolBar buttonCoolBar = new CoolBar(bottomComposite, SWT.FLAT);
buttonCoolBar.setLayoutData(gridData1);
final ToolBar toolBar = new ToolBar(buttonCoolBar, SWT.FLAT);
toolItemHistory = new ToolItem(toolBar,SWT.PUSH);
toolItemHistory.setImage(GOIMIcons.getImage(GOIMIcons.CONTACT_HISTORY));
toolItemHistory.setToolTipText("Open Chat History");
toolItemHistory.addListener(SWT.Selection,new Listener() {
public void handleEvent(Event event) {
HistoryViewer.showHistoryOf(account,StringUtils.parseBareAddress(chat.getJID()));
}
});
toolItemVCard = new ToolItem(toolBar,SWT.PUSH);
toolItemVCard.setImage(GOIMIcons.getImage(GOIMIcons.CONTACT_VCARD));
toolItemVCard.setToolTipText("Show VCard");
toolItemVCard.addListener(SWT.Selection,new Listener() {
public void handleEvent(Event event) {
new vCardGUI(account, StringUtils.parseBareAddress(chat.getJID()));
}
});
if(emoticons != null && emoticons.getIcons().size() > 0) {
ToolItem toolItemSmileys = new ToolItem(toolBar, SWT.DROP_DOWN);
toolItemSmileys.setImage(emoticons.getIcons().get(0).getImage());
toolItemSmileys.setToolTipText("Add Emoticon");
//toolItemSmileys.setText("abc");
toolItemSmileys.addListener(SWT.Selection,new Listener() {
public void handleEvent(Event event) {
Rectangle bounds = ((ToolItem)event.widget).getBounds();
Point loc = toolBar.toDisplay(bounds.x,bounds.y);
final Shell shell = new Shell(toolBar.getShell(),SWT.RESIZE | SWT.BORDER);
shell.setBounds(loc.x,loc.y,150,200);
shell.setLayout(new FillLayout());
final Tree tree = new Tree(shell,SWT.BORDER);
for(IconDef iconDef : emoticons.getIcons()) {
TreeItem item = new TreeItem(tree,SWT.NULL);
item.setImage(iconDef.getImage());
item.setText(iconDef.text.get(0));
// item.setData("iconDef",iconDef);
item.setData("text",iconDef.text.get(0));
}
shell.open();
tree.forceFocus();
tree.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if(tree.getSelectionCount() < 1) return;
TreeItem item = tree.getSelection()[0];
// IconDef iconDef = (IconDef)item.getData("iconDef");
// chatInput.insert(iconDef.text.get(0));
String text = (String)item.getData("text");
chatInput.insert(text);
chatInput.setSelection(chatInput.getSelection().x+text.length());
shell.close();
} });
tree.addListener(SWT.FocusOut, new Listener() {
public void handleEvent(Event event) {
shell.close();
}
});
// Menu menu = new Menu(((ToolItem)event.widget).getParent());
// for(IconDef iconDef : emoticons.getIcons()) {
// MenuItem menuItem = new MenuItem(menu,SWT.PUSH);
// menuItem.setText(iconDef.text.get(0));
// menuItem.setImage(iconDef.getImage());
// }
// menu.setVisible(true);
} });
}
ToolItem toolItemBold = new ToolItem(toolBar, SWT.PUSH);
toolItemBold.setToolTipText("Make Selected Text Bold");
toolItemBold.setImage(GOIMIcons.getImage(GOIMIcons.CHATWINDOW_BOLD));
ToolItem toolItemUnderline = new ToolItem(toolBar, SWT.PUSH);
toolItemBold.setToolTipText("Make Selected Text Underlined");
toolItemUnderline.setImage(GOIMIcons.getImage(GOIMIcons.CHATWINDOW_UNDERLINE));
int totalx = 0;
CoolItem coolItem = new CoolItem(buttonCoolBar, SWT.NULL);
coolItem.setControl(toolBar);
toolBar.pack();
Point size = toolBar.getSize();
size = coolItem.computeSize(size.x,size.y);
totalx+=size.x;
coolItem.setMinimumSize(size);
coolItem.setPreferredSize(size);
ToolBar sendToolBar = new ToolBar(buttonCoolBar, SWT.FLAT);
ToolItem toolItemSend = new ToolItem(sendToolBar, SWT.PUSH);
toolItemSend.setToolTipText("Send Input");
toolItemSend.setText("Send");
CoolItem sendCoolItem = new CoolItem(buttonCoolBar, SWT.NULL);
sendCoolItem.setControl(sendToolBar);
sendToolBar.pack();
size = sendToolBar.getSize();
size = sendCoolItem.computeSize(size.x, size.y);
totalx+=size.x;
sendCoolItem.setMinimumSize(size);
sendCoolItem.setPreferredSize(size);
//gridData1.minimumWidth = totalx + 30;
gridData1.widthHint = totalx + 30;
buttonCoolBar.pack();
/*
buttonComposite = new Composite(bottomComposite, SWT.NONE);
buttonComposite.setLayoutData(gridData1);
buttonComposite.setLayout(rowLayout);