JaTeOn 플러그인을 만들면서 알리미가 있었으면 좋겠다고 생각해서 플러그인 카페에글을 올렸더니 눈꽃 님께서 힌트를 주셔서 어찌저찌 가져다가 붙였습니다.디자인만 제가 원하는대로 살짝 다듬으면 이쁘게 나올 것 같습니다.~슬라이딩 하는 것은 좀 더 검색을 해보면 나올 것 같네요~
MessageNotificationPopup.javaimport org.eclipse.jface.dialogs.PopupDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.ImageHyperlink; import org.eclipse.ui.forms.widgets.Section; public class MessageNotificationPopup extends PopupDialog { private FormToolkit toolkit; private Form form; private Composite sectionClient; private IWorkbenchWindow window; private String userName; private String message; public MessageNotificationPopup(IWorkbenchWindow window, Shell parent) { super(parent, PopupDialog.INFOPOPUP_SHELLSTYLE | SWT.ON_TOP, false, false, false, false, false, null, null); this.window = window; } public boolean close() { toolkit.dispose(); return super.close(); } public void setContent(String userName, String message) { this.userName = userName; this.message = message; } protected Control createContents(Composite parent) { getShell().setBackground( getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createForm(parent); form.getBody().setLayout(new FillLayout()); Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR); section.setText(userName); section.setLayout(new FillLayout()); sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); Hyperlink link = toolkit.createHyperlink(sectionClient, message, SWT.NONE); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { // try { // // FIXME 링크 선택했을 경우에 대한 처리 // } catch (CoreException ce) { // ce.printStackTrace(); // } } }); section.setClient(sectionClient); ImageHyperlink hyperlink = toolkit.createImageHyperlink(section, SWT.NONE); hyperlink.setBackground(null); hyperlink.setImage(PlatformUI.getWorkbench().getSharedImages() .getImage(ISharedImages.IMG_TOOL_DELETE)); hyperlink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { close(); } }); section.setTextClient(hyperlink); form.pack(); return parent; } /** * Initialize the shell's bounds. */ public void initializeBounds() { getShell().setBounds(restoreBounds()); } private Rectangle restoreBounds() { Rectangle bounds = form.getBounds(); Rectangle maxBounds = window.getShell().getMonitor().getClientArea(); if (bounds.width > -1 && bounds.height > -1) { if (maxBounds != null) { bounds.width = Math.min(bounds.width, maxBounds.width); bounds.height = Math.min(bounds.height, maxBounds.height); } // Enforce an absolute minimal size bounds.width = Math.max(bounds.width, 30); bounds.height = Math.max(bounds.height, 30); } if (bounds.x > -1 && bounds.y > -1 && maxBounds != null) { if (bounds.width > -1 && bounds.height > -1) { bounds.x = maxBounds.x + maxBounds.width - bounds.width; bounds.y = maxBounds.y + maxBounds.height - bounds.height; } } return bounds; } }사용예제 IWorkbenchWindow window = getSite().getWorkbenchWindow(); final MessageNotificationPopup popup = new MessageNotificationPopup( window, window.getShell()); popup.setContent("vicki", "Vicki 님이 접속하셨습니다."); popup.open(); new UIJob(window.getShell().getDisplay(), "Close Popup Job") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { Shell shell = popup.getShell(); if (shell != null && !shell.isDisposed()) { popup.close(); } return Status.OK_STATUS; } }.schedule(5000);