java Class.forName("org.eclipse.swt.SWT"); if (!InstantMessagingClient.getInstance().getRunning()) { throw new ClassNotFoundException("SWT app not running"); } java super(); addContactBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { notifyAddClicked(); } }); removeContactBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { notifyRemoveClicked(); } }); list.addSelectionListener(new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { notifyContactAction(); } }); final Shell shell = InstantMessagingClient.getInstance().getShell(); shell.setText("Instant Messenger"); shell.setLayout(new FormLayout()); FormData pfd = new FormData(); pfd.top = new FormAttachment(0, 5); pfd.left = new FormAttachment(0, 5); pfd.right = new FormAttachment(100, -5); pfd.bottom = new FormAttachment(100, -5); panel.setLayoutData(pfd); panel.setLayout(new FormLayout()); FormData bpfd = new FormData(); bpfd.left = new FormAttachment(0, 5); bpfd.right = new FormAttachment(100, -5); bpfd.bottom = new FormAttachment(100, -5); btnPanel.setLayoutData(bpfd); btnPanel.setLayout(new FillLayout()); FormData lfd = new FormData(); lfd.top = new FormAttachment(0, 5); lfd.left = new FormAttachment(0, 5); lfd.right = new FormAttachment(100, -5); lfd.bottom = new FormAttachment(btnPanel, -5); list.setLayoutData(lfd); addContactBtn.setText("Add"); removeContactBtn.setText("Remove"); java list.getDisplay().syncExec(new Runnable() { public void run() { TableItem item; try { item = new TableItem(list, SWT.NONE, index); } catch (IllegalArgumentException e) { item = new TableItem(list, SWT.NONE); } item.setText(c.toString()); item.setImage(getStatusIcon(c.getStatus())); } }); java getPanel().getDisplay().syncExec(new Runnable() { public void run() { getPanel().setEnabled(enabled); } }); java return list.getSelectionIndex(); java list.getDisplay().syncExec(new Runnable() { public void run() { list.remove(index); } }); java for (java.util.Enumeration ls = getListeners(); ls.hasMoreElements();) { ((ContactListViewListener) ls.nextElement()).onContactListAction(); } java for (java.util.Enumeration ls = getListeners(); ls.hasMoreElements();) { ((ContactListViewListener) ls.nextElement()).onContactListRemove(); } java for (java.util.Enumeration ls = getListeners(); ls.hasMoreElements();) { ((ContactListViewListener) ls.nextElement()).onContactListAdd(); } java final java.net.URL iconURL; if (status != null) { if (status.equals("away")) { iconURL = SWTContactListView.class.getResource("away.png"); } else if (status.equals("dnd")) { iconURL = SWTContactListView.class.getResource("busy.png"); } else if (status.equals("xa")) { iconURL = SWTContactListView.class .getResource("extended-away.png"); } else if (status.equals("offline")) { iconURL = SWTContactListView.class.getResource("offline.png"); } else { iconURL = SWTContactListView.class.getResource("available.png"); } } else { iconURL = SWTContactListView.class.getResource("offline.png"); } final im.InstantMessagingClient imc = im.InstantMessagingClient .getInstance(); try { return new Image(imc.getShell().getDisplay(), iconURL.openStream()); } catch (Exception e) { imc.report(e); } return null;
java return uidField.getText(); java return nameField.getText(); java return networkField.getSelectionIndex(); java return passwordField.getText(); java super(); InstantMessagingClient.getInstance().getShell().getDisplay().syncExec( new Runnable() { public void run() { initialize(); } }); java networkField.add(n); networkField.select(0); java notifyListeners(true); java notifyListeners(false); java for (java.util.Enumeration ls = getListeners(); ls.hasMoreElements();) { ((NewContactDialogListener) ls.nextElement()) .onNewContactDialogClose(okClicked, this); } java shell = new Shell(InstantMessagingClient.getInstance().getShell(), SWT.RESIZE); dlgPanel = new Composite(getShell(), SWT.NONE); btnPanel = new Composite(getShell(), SWT.NONE); okBtn = new Button(btnPanel, SWT.PUSH); cancelBtn = new Button(btnPanel, SWT.PUSH); network = new Label(dlgPanel, SWT.HORIZONTAL | SWT.RIGHT); networkField = new Combo(dlgPanel, SWT.DROP_DOWN | SWT.READ_ONLY); uid = new Label(dlgPanel, SWT.HORIZONTAL | SWT.RIGHT); uidField = new Text(dlgPanel, SWT.SINGLE | SWT.BORDER); name = new Label(dlgPanel, SWT.HORIZONTAL | SWT.RIGHT); nameField = new Text(dlgPanel, SWT.SINGLE | SWT.BORDER); password = new Label(dlgPanel, SWT.HORIZONTAL | SWT.RIGHT); passwordField = new Text(dlgPanel, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER); shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { onCancel(); } }); cancelBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { onCancel(); getShell().close(); } }); okBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { onOk(); getShell().close(); } }); shell.setText("Add new contact"); shell.setLayout(new FormLayout()); shell.setDefaultButton(okBtn); FormData dpfd = new FormData(); dpfd.top = new FormAttachment(0, 5); dpfd.left = new FormAttachment(0, 5); dpfd.right = new FormAttachment(100, -5); dpfd.bottom = new FormAttachment(btnPanel, -5); dlgPanel.setLayoutData(dpfd); dlgPanel.setLayout(new GridLayout(2, false)); FormData bpfd = new FormData(); bpfd.left = new FormAttachment(0, 5); bpfd.right = new FormAttachment(100, -5); bpfd.bottom = new FormAttachment(100, -5); btnPanel.setLayoutData(bpfd); btnPanel.setLayout(new FillLayout()); okBtn.setText("OK"); cancelBtn.setText("Cancel"); uid.setText("User ID"); name.setText("Name"); network.setText("Network"); password.setText("Password"); GridData fgd = new GridData(); fgd.horizontalAlignment = SWT.FILL; fgd.grabExcessHorizontalSpace = true; fgd.heightHint = Math.round(uidField.getLineHeight() * (float) 1.1); uidField.setLayoutData(fgd); nameField.setLayoutData(fgd); networkField.setLayoutData(fgd); passwordField.setLayoutData(fgd); shell.pack(); shell.open(); shell.traverse(SWT.TRAVERSE_TAB_NEXT);
java return messageField.getText(); java if (c instanceof String) { textConvField.getDisplay().syncExec(new Runnable() { public void run() { textConvField.append(c.toString() + "\n"); } }); } java getShell().getDisplay().syncExec(new Runnable() { public void run() { getShell().setText(t); } }); java getShell().getDisplay().syncExec(new Runnable() { public void run() { if (!getShell().isVisible()) { getShell().setVisible(true); pop(); } getShell().setActive(); getShell().traverse(SWT.TRAVERSE_TAB_NEXT); } }); java super(); InstantMessagingClient.getInstance().getShell().getDisplay().syncExec( new Runnable() { public void run() { initialize(); } }); java InstantMessagingClient.getInstance().getShell().getDisplay().beep(); java for (java.util.Enumeration ls = getListeners(); ls.hasMoreElements();) { ((ConversationViewListener) ls.nextElement()).onConversationClose(); } java for (java.util.Enumeration ls = getListeners(); ls.hasMoreElements();) { ((ConversationViewListener) ls.nextElement()).onConversationSend(); } messageField.setText(""); java shell = new Shell(InstantMessagingClient.getInstance().getShell() .getDisplay()); convPanel = new Composite(getShell(), SWT.NONE); btnPanel = new Composite(getShell(), SWT.NONE); textConvField = new Text(convPanel, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.SCROLL_LINE | SWT.READ_ONLY); messageField = new Text(btnPanel, SWT.SINGLE | SWT.BORDER); sendBtn = new Button(btnPanel, SWT.PUSH); shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { notifyClose(); } }); sendBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { notifySendClicked(); } }); setTitle("Message"); shell.setLayout(new FormLayout()); shell.setDefaultButton(sendBtn); shell.setTabList(new Control[]{btnPanel}); FormData cpfd = new FormData(); cpfd.top = new FormAttachment(0, 5); cpfd.left = new FormAttachment(0, 5); cpfd.right = new FormAttachment(100, -5); cpfd.bottom = new FormAttachment(btnPanel, -5); convPanel.setLayoutData(cpfd); convPanel.setLayout(new FillLayout()); FormData bpfd = new FormData(); bpfd.left = new FormAttachment(0, 5); bpfd.right = new FormAttachment(100, -5); bpfd.bottom = new FormAttachment(100, -5); btnPanel.setLayoutData(bpfd); btnPanel.setLayout(new FormLayout()); btnPanel.setTabList(new Control[]{messageField}); FormData mffd = new FormData(); mffd.top = new FormAttachment(0, 5); mffd.left = new FormAttachment(0, 0); mffd.right = new FormAttachment(sendBtn, -5); messageField.setLayoutData(mffd); FormData sbfd = new FormData(); sbfd.top = new FormAttachment(0, 0); sbfd.right = new FormAttachment(100, 0); sendBtn.setLayoutData(sbfd); sendBtn.setText("Send"); shell.pack(); shell.setSize(300, 300); toFront();