List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:edu.tsinghua.lumaqq.ui.dialogs.SelectGroupDialog.java
License:Open Source License
/** * ??//from w w w . j a v a2 s . c om * @param shell */ private void initLayout(final Shell shell) { // ?layout GridLayout layout = new GridLayout(); layout.marginHeight = layout.marginWidth = layout.horizontalSpacing = layout.verticalSpacing = 0; shell.setLayout(layout); // ?? Label lblHint = new Label(shell, SWT.CENTER); lblHint.setText(select_group_label_hint); lblHint.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // ??table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER); table.setLayoutData(new GridData(GridData.FILL_BOTH)); table.addControlListener(new ControlListener() { public void controlResized(ControlEvent e) { table.getColumn(0).setWidth(table.getClientArea().width); } public void controlMoved(ControlEvent e) { // ?? } }); table.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selection = table.getSelectionIndex(); if (selection != -1) selection = (Integer) table.getItem(selection).getData(); } }); // new TableColumn(table, SWT.CENTER); table.setHeaderVisible(false); // Slat btnOK = new Slat(shell, SWT.NONE); btnOK.setText(button_ok); btnOK.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnOK.addMouseListener(new MouseAdapter() { public void mouseUp(MouseEvent e) { if (selection == -1) MessageDialog.openWarning(shell, message_box_common_warning_title, message_box_please_select_group); else shell.close(); } }); }
From source file:edu.tsinghua.lumaqq.ui.helper.MenuHelper.java
License:Open Source License
/** * ???//from w ww .jav a 2s. c o m */ private void initDiskMenu() { diskMenu = new CMenu(); // final CMenuItem miRefresh = new CMenuItem(diskMenu, SWT.PUSH); miRefresh.setImage(res.getImage(Resources.icoRefresh)); miRefresh.setText(disk_tooltip_refresh); miRefresh.addSelectionListener(new ISelectionListener() { public void widgetSelected(SelectionEvent e) { Object obj = diskMenu.getData(); main.getDiskManager().refresh(obj); main.getDiskViewer().refresh(); } }); // final CMenuItem miShare = new CMenuItem(diskMenu, SWT.PUSH); miShare.setText(disk_tooltip_set_share); miShare.addSelectionListener(new ISelectionListener() { public void widgetSelected(SelectionEvent e) { Directory dir = (Directory) diskMenu.getData(); DiskShareDialog dialog = new DiskShareDialog(main, dir); dialog.open(); } }); // separator new CMenuItem(diskMenu, SWT.SEPARATOR); // final CMenuItem miUpload = new CMenuItem(diskMenu, SWT.PUSH); miUpload.setImage(res.getImage(Resources.icoDiskUpload)); miUpload.setText(disk_tooltip_upload); miUpload.addSelectionListener(new ISelectionListener() { public void widgetSelected(SelectionEvent e) { } }); // final CMenuItem miDownload = new CMenuItem(diskMenu, SWT.PUSH); miDownload.setImage(res.getImage(Resources.icoDiskDownload)); miDownload.setText(disk_tooltip_download); miDownload.addSelectionListener(new ISelectionListener() { public void widgetSelected(SelectionEvent e) { main.onDiskDownload(new StructuredSelection(diskMenu.getData())); } }); // separator new CMenuItem(diskMenu, SWT.SEPARATOR); // final CMenuItem miDelete = new CMenuItem(diskMenu, SWT.PUSH); miDelete.setText(disk_tooltip_delete); miDelete.addSelectionListener(new ISelectionListener() { public void widgetSelected(SelectionEvent e) { Object obj = diskMenu.getData(); if (obj instanceof Directory) { Directory dir = (Directory) obj; if (dir.isSystemDir()) { MessageDialog.openWarning(main.getShell(), message_box_common_warning_title, disk_hint_cannot_delete_system_dir); return; } } String msg = null; if (obj instanceof Integer) msg = NLS.bind(disk_hint_confirm_delete, String.valueOf(obj)); else if (obj instanceof File) msg = NLS.bind(disk_hint_confirm_delete, ((File) obj).name); else if (obj instanceof Directory) msg = NLS.bind(disk_hint_confirm_delete, ((Directory) obj).name); else return; if (MessageDialog.openQuestion(main.getShell(), message_box_common_question_title, msg)) { if (obj instanceof Integer) main.getDiskJobQueue().addJob(new DeleteJob((Integer) obj)); else if (obj instanceof File) main.getDiskJobQueue().addJob(new DeleteJob((File) obj)); else main.getDiskJobQueue().addJob(new DeleteJob((Directory) obj)); } } }); // separator new CMenuItem(diskMenu, SWT.SEPARATOR); // ??? final CMenuItem miRename = new CMenuItem(diskMenu, SWT.PUSH); miRename.setText(disk_tooltip_rename); miRename.addSelectionListener(new ISelectionListener() { public void widgetSelected(SelectionEvent e) { Object obj = diskMenu.getData(); boolean renameFile = obj instanceof File; InputDialog dialog = new InputDialog(main.getShell(), "Rename", disk_hint_input_new_name, renameFile ? ((File) obj).name : ((Directory) obj).name, new IInputValidator() { public String isValid(String newText) { if (!newText.equals("")) return null; else return disk_hint_name_cannot_null; } }); if (dialog.open() == IDialogConstants.OK_ID) { if (renameFile) main.getDiskJobQueue().addJob(new RenameJob((File) obj, dialog.getValue())); else main.getDiskJobQueue().addJob(new RenameJob((Directory) obj, dialog.getValue())); } } }); // final CMenuItem miNewFolder = new CMenuItem(diskMenu, SWT.PUSH); miNewFolder.setText(disk_tooltip_new_directory); miNewFolder.addSelectionListener(new ISelectionListener() { public void widgetSelected(SelectionEvent e) { Object obj = diskMenu.getData(); int parentId = (obj instanceof Integer) ? 0 : ((Directory) obj).id; InputDialog dialog = new InputDialog(main.getShell(), "New", disk_hint_input_new_name, null, new IInputValidator() { public String isValid(String newText) { if (!newText.equals("")) return null; else return disk_hint_name_cannot_null; } }); if (dialog.open() == IDialogConstants.OK_ID) { main.getDiskJobQueue().addJob(new CreateDirectoryJob(dialog.getValue(), parentId)); } } }); // ?? diskMenu.addMenuListener(new IMenuListener() { public void menuShown(MenuEvent e) { Object obj = diskMenu.getData(); if (obj == null) { miRefresh.setEnabled(false); miDownload.setEnabled(false); miUpload.setEnabled(false); miRename.setEnabled(false); miDelete.setEnabled(false); miShare.setEnabled(false); } else { if (obj instanceof Integer) miRefresh.setEnabled(true); else if (obj instanceof Directory) { Directory dir = (Directory) obj; switch (dir.id) { case QQ.QQ_DISK_DIR_MY_FAVORITE: case QQ.QQ_DISK_DIR_MY_ALBUM: miRefresh.setEnabled(true); break; default: miRefresh.setEnabled(false); break; } } else miRefresh.setEnabled(false); miDownload.setEnabled(obj instanceof File); miShare.setEnabled(obj instanceof Directory && ((Directory) obj).owner == main.getMyModel().qq); miUpload.setEnabled( obj instanceof Directory && main.getDiskManager().isChildCreatable((Directory) obj) || obj instanceof Integer && (Integer) obj == DiskContentProvider.MY_DISK); miRename.setEnabled(obj instanceof File && ((File) obj).owner == main.getMyModel().qq || obj instanceof Directory && ((Directory) obj).owner == main.getMyModel().qq && !((Directory) obj).isSystemDir()); miDelete.setEnabled(obj instanceof File && ((File) obj).owner == main.getMyModel().qq || obj instanceof Directory && ((Directory) obj).owner == main.getMyModel().qq || obj instanceof Integer && (Integer) obj > 10000); if (obj instanceof Directory) { miNewFolder.setEnabled(main.getDiskManager().isChildCreatable((Directory) obj)); } else if (obj instanceof Integer) { miNewFolder.setEnabled((Integer) obj == DiskContentProvider.MY_DISK); } else miNewFolder.setEnabled(false); } } }); }
From source file:edu.tsinghua.lumaqq.ui.helper.ShellLauncher.java
License:Open Source License
/** * ??//w w w. ja v a2 s. c o m * * @param url * URL * @param title * ? * @param errorString * ? */ public void openBrowserShell(String url, String title, String errorString) { // ????? String browser = main.getOptionHelper().getBrowser(); try { if (browser.equals("")) { MessageDialog dialog = new MessageDialog(main.getShell(), message_box_common_question_title, null, message_box_browser_not_set, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); switch (dialog.open()) { case 0: main.getShellLauncher().openSystemOptionWindow().setCurrentPage(SystemOptionWindow.OTHER); break; case 1: BrowserShell bs = ShellFactory.createBrowserShell(main); bs.setUrl(url); bs.setTitle(title); bs.open(); break; } } else Runtime.getRuntime().exec(browser.replaceAll("\\[URL\\]", url)); } catch (Throwable t) { MessageDialog.openWarning(main.getShell(), message_box_common_warning_title, errorString); } }
From source file:edu.tsinghua.lumaqq.ui.jobs.DialogJobExecutor.java
License:Open Source License
public void execute() { if (!BusyFlag.get()) { MessageDialog.openWarning(main.getShell(), message_box_common_warning_title, message_box_job_running); return;//from w ww . j a v a2 s . c o m } main.getDisplay().syncExec(new Runnable() { public void run() { JobProgressMonitorDialog dialog = new JobProgressMonitorDialog(main.getShell(), modeless); try { dialog.run(true, cancelable, new JobSequencer()); } catch (Exception e) { } } }); BusyFlag.release(); for (IExecutorListener lis : listeners) lis.allCompleted(); }
From source file:edu.tsinghua.lumaqq.ui.NormalIMContainer.java
License:Open Source License
public void send() { // ??//from ww w. ja v a 2 s .c om String s = inputBox.getText(); if (s.length() == 0) { MessageDialog.openWarning(getShell(), message_box_common_warning_title, message_box_cannot_send_empty_message); return; } // ? if (main.getClient().getUser().isLoggedIn()) { message = s; // ?? RecordEntry key = new RecordEntry(); key.owner = user.qq; key.sender = main.getMyModel().qq; key.senderParent = 0; key.receiver = user.qq; key.time = System.currentTimeMillis(); key.type = IKeyConstants.NORMAL; key.message = message; main.getRecordManager().addRecord(key); // ??? appendMessage(key); // ?? inputBox.clear(); // TODO ??????QQ???? // ???? main.getIMJobQueue().addJob(new SendNormalIMJob(message, (User) getModel())); } else { MessageDialog.openWarning(getShell(), message_box_common_warning_title, message_box_please_login_first); } }
From source file:edu.tsinghua.lumaqq.ui.QQEventProcessor.java
License:Open Source License
/** * ?//from w w w .java2 s .c o m */ private void processKickedOutBySystem() { main.getDisplay().asyncExec(new Runnable() { public void run() { main.getClient().getUser().setStatus(QQ.QQ_STATUS_OFFLINE); main.logout(); MessageDialog.openWarning(main.getShell(), message_box_common_warning_title, message_box_login_twice); } }); }
From source file:edu.tsinghua.lumaqq.ui.QQEventProcessor.java
License:Open Source License
/** * ???/*w w w.j av a2s . c o m*/ */ private void processChangeStatusFail() { main.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openWarning(main.getShell(), message_box_common_fail_title, error_change_status_fail); } }); }
From source file:edu.tsinghua.lumaqq.ui.SendClusterIMWindow.java
License:Open Source License
/** * ???// w w w .j a v a 2 s. c o m * @param string */ protected void sendMessage(String s) { // ?? if (s.length() == 0) { MessageDialog.openWarning(getShell(), message_box_common_warning_title, message_box_cannot_send_empty_message); return; } // ? if (main.getClient().getUser().isLoggedIn()) { workflow.setOriginalMessage(s); workflow.start(); } else { MessageDialog.openWarning(getShell(), message_box_common_warning_title, message_box_please_login_first); } }
From source file:edu.tsinghua.lumaqq.ui.SendIMWindow.java
License:Open Source License
/** * ???/*from w ww .j a v a2 s. c o m*/ * * @param string */ protected void sendMessage(String s) { // ?? if (s.length() == 0) { MessageDialog.openWarning(getShell(), message_box_common_warning_title, message_box_cannot_send_empty_message); return; } // ? if (main.getClient().getUser().isLoggedIn()) { message = s; // ?? RecordEntry key = new RecordEntry(); key.owner = model.qq; key.sender = main.getMyModel().qq; key.senderParent = 0; key.receiver = model.qq; key.time = System.currentTimeMillis(); key.type = IKeyConstants.NORMAL; key.message = message; main.getRecordManager().addRecord(key); // ??? if (model.talkMode) appendMessage(key); if (model.talkMode) inputBox.clear(); else { /* * ?? */ // ?? inputBox.setReadonly(true); inputBox.setBackground(Colors.READONLY_BACKGROUND); // ?? getShell().setMinimized(true); } // TODO ??????QQ???? // ???? main.getIMJobQueue().addJob(new SendNormalIMJob(message, model)); } else { MessageDialog.openWarning(getShell(), message_box_common_warning_title, message_box_please_login_first); } }