Example usage for org.eclipse.jface.dialogs MessageDialog openWarning

List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openWarning.

Prototype

public static void openWarning(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard warning dialog.

Usage

From source file:edu.toronto.cs.se.modelepedia.tutorial.state.diagram.part.StateDiagramEditor.java

License:Open Source License

/**
 * @generated//from  w  ww  . j av  a2  s.co  m
 */
protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null;
    if (original != null) {
        dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
        // editor has been programmatically closed while the dialog was open
        return;
    }
    if (provider.isDeleted(input) && original != null) {
        String message = NLS.bind(Messages.StateDiagramEditor_SavingDeletedFile, original.getName());
        dialog.setErrorMessage(null);
        dialog.setMessage(message, IMessageProvider.WARNING);
    }
    if (dialog.open() == Window.CANCEL) {
        if (progressMonitor != null) {
            progressMonitor.setCanceled(true);
        }
        return;
    }
    IPath filePath = dialog.getResult();
    if (filePath == null) {
        if (progressMonitor != null) {
            progressMonitor.setCanceled(true);
        }
        return;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell, Messages.StateDiagramEditor_SaveAsErrorTitle,
                    Messages.StateDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell, Messages.StateDiagramEditor_SaveErrorTitle,
                    Messages.StateDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:edu.tsinghua.lumaqq.ui.ClusterIMContainer.java

License:Open Source License

public void send() {
    String s = inputBox.getText();
    // ??//from www.j  av  a 2s.com
    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.config.face.FaceManagePage.java

License:Open Source License

protected Control createContent(Composite parent) {
    content = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    content.setLayout(layout);//from www.  j a v  a 2s.  c  om
    content.setBackground(Colors.WHITE);
    FormData fd = new FormData();
    fd.top = fd.left = new FormAttachment(0, 1);
    fd.bottom = fd.right = new FormAttachment(100, -1);
    setLayoutData(fd);

    // viewer
    faceViewer = new TableViewer(content,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    faceViewer.setContentProvider(new FaceContentProvider());
    faceViewer.setLabelProvider(new FaceLabelProvider());
    Table t = faceViewer.getTable();
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.verticalSpan = 5;
    t.setLayoutData(gd);
    TableColumn tc = new TableColumn(t, SWT.LEFT);
    tc.setText(face_id);
    tc.setWidth(70);
    tc = new TableColumn(t, SWT.LEFT);
    tc.setText(face_image);
    tc.setWidth(100);
    t.setLinesVisible(true);
    t.setHeaderVisible(true);

    // 
    Slat btnAdd = new Slat(content, SWT.NONE);
    btnAdd.setText(button_add_dot);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = 100;
    btnAdd.setLayoutData(gd);
    btnAdd.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
            if (currentPage == -1) {
                MessageDialog.openWarning(parentShell, message_box_common_warning_title,
                        message_box_need_face_group);
                return;
            }

            FileDialog dialog = new FileDialog(parentShell, SWT.OPEN);
            dialog.setFilterExtensions(new String[] { "*.*", "*.gif", "*.jpg", "*.bmp" });
            dialog.setFilterNames(new String[] { "All Files(*.*)", "GIF Files(*.gif)", "JPEG Files(*.jpg)",
                    "Bitmap Files(*.bmp)" });
            dialog.open();

            String filename = dialog.getFileName();
            if (filename == null)
                return;

            String path = dialog.getFilterPath();
            if (!path.endsWith(File.separator))
                path += File.separatorChar;

            // ?
            FaceRegistry util = FaceRegistry.getInstance();
            FaceGroup g = util.getFaceGroup(getCurrentPage());
            SingleFaceImporter importer = new SingleFaceImporter(path + filename, LumaQQ.CUSTOM_FACE_DIR, g);
            FaceEntry entry = importer.getEntry();
            if (util.hasFace(entry.md5))
                return;
            // ?
            if (!importer.saveEntry())
                return;
            // table
            util.addFace(entry, g);
            refreshViewer(g);
        }
    });
    // 
    Slat btnDelete = new Slat(content, SWT.NONE);
    btnDelete.setText(button_delete);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = 100;
    btnDelete.setLayoutData(gd);
    btnDelete.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
            FaceRegistry util = FaceRegistry.getInstance();
            IStructuredSelection selection = (IStructuredSelection) faceViewer.getSelection();
            Iterator<?> i = selection.iterator();
            while (i.hasNext()) {
                Face face = (Face) i.next();
                FileTool.deleteFile(util.getFacePath(face));
                FileTool.deleteFile(util.getSmallFacePath(face));
                util.removeFace(face.getMd5());
            }

            faceViewer.refresh();
        }
    });
    // 
    Slat btnUp = new Slat(content, SWT.NONE);
    btnUp.setText(button_up);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = 100;
    btnUp.setLayoutData(gd);
    btnUp.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
            FaceRegistry util = FaceRegistry.getInstance();
            Table table = faceViewer.getTable();
            int[] indices = table.getSelectionIndices();
            for (int i = 0; i < indices.length; i++)
                util.upFace(currentPage, indices[i]);

            faceViewer.refresh();
        }
    });
    // 
    Slat btnDown = new Slat(content, SWT.NONE);
    btnDown.setText(button_down);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = 100;
    btnDown.setLayoutData(gd);
    btnDown.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
            FaceRegistry util = FaceRegistry.getInstance();
            Table table = faceViewer.getTable();
            int[] indices = table.getSelectionIndices();
            for (int i = 0; i < indices.length; i++)
                util.downFace(currentPage, indices[i]);

            faceViewer.refresh();
        }
    });
    // 
    btnMove = new Slat(content, SWT.NONE);
    btnMove.setText(button_move_dot);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = 100;
    btnMove.setLayoutData(gd);
    btnMove.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
            Rectangle bound = btnMove.getBounds();
            moveMenu.setLocation(btnMove.getParent().toDisplay(bound.x, bound.y + bound.height));
            moveMenu.setVisible(true);
        }
    });

    // ???
    initMoveMenu();

    return content;
}

From source file:edu.tsinghua.lumaqq.ui.config.face.FaceWindow.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
protected void createTopControl(Composite parent) {
    ToolBar tb = new ToolBar(parent, SWT.FLAT | SWT.RIGHT);
    tb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    final Resources res = Resources.getInstance();

    // //from  w  ww .ja  va2  s . com
    ToolItem ti = new ToolItem(tb, SWT.PUSH);
    ti.setText(button_import);
    ti.setImage(res.getImage(Resources.icoImport24));
    ti.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            importFace();
        }
    });

    // separator
    ti = new ToolItem(tb, SWT.SEPARATOR);

    // 
    ti = new ToolItem(tb, SWT.PUSH);
    ti.setText(face_add_group);
    ti.setImage(res.getImage(Resources.icoAddFaceGroup24));
    ti.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            InputDialog dialog = new InputDialog(getShell(), face_new_group_title, face_new_group_message, null,
                    null);
            if (dialog.open() == IDialogConstants.OK_ID) {
                String name = dialog.getValue();
                if (name != null && !name.equals("") && !FaceRegistry.getInstance().hasGroup(name)) {
                    addGroup(name);
                }
            }
        }
    });

    // 
    ti = new ToolItem(tb, SWT.PUSH);
    ti.setText(face_modify_group);
    ti.setImage(res.getImage(Resources.icoModifyFaceGroup24));
    ti.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FaceGroup g = util.getFaceGroup(getCurrentPageId());
            switch (g.getId()) {
            case FaceConstant.DEFAULT_GROUP_ID:
            case FaceConstant.RECEIVED_GROUP_ID:
            case FaceConstant.CUSTOM_HEAD_GROUP_ID:
                MessageDialog.openWarning(getShell(), message_box_common_warning_title,
                        message_box_cannot_change_default_group);
                break;
            default:
                InputDialog dialog = new InputDialog(getShell(), face_new_group_title, face_new_group_message,
                        null, null);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    String name = dialog.getValue();
                    if (name != null && !name.equals("")) {
                        FaceRegistry.getInstance().setGroupName(getCurrentPageId(), name);
                        getCurrentPageLabel().setText(name);
                    }
                }
                break;
            }
        }
    });

    // 
    ti = new ToolItem(tb, SWT.PUSH);
    ti.setText(face_delete_group);
    ti.setImage(res.getImage(Resources.icoDeleteFaceGroup24));
    ti.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FaceGroup g = util.getFaceGroup(getCurrentPageId());
            switch (g.getId()) {
            case FaceConstant.DEFAULT_GROUP_ID:
            case FaceConstant.RECEIVED_GROUP_ID:
            case FaceConstant.CUSTOM_HEAD_GROUP_ID:
                MessageDialog.openWarning(getShell(), message_box_common_warning_title,
                        message_box_cannot_delete_default_group);
                break;
            default:
                util.removeGroup(getCurrentPageId());
                removeCurrentPage();
                break;
            }
        }
    });
}

From source file:edu.tsinghua.lumaqq.ui.config.face.FaceWindow.java

License:Open Source License

/**
  * ???CFC//from   ww w .  ja v  a2  s .  c  o m
  */
private void importFace() {
    // ?
    if (getPageCount() == 0) {
        MessageDialog.openWarning(getShell(), message_box_common_warning_title, message_box_need_face_group);
        return;
    }

    FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
    dialog.setFilterExtensions(new String[] { "*.eip", "*.cfc" });
    dialog.setFilterNames(new String[] { face_eip, face_cfc });
    dialog.open();

    String filename = dialog.getFileName();
    if (filename == null)
        return;
    String path = dialog.getFilterPath();
    if (!path.endsWith(File.separator))
        path += File.separatorChar;

    FaceGroup g = util.getFaceGroup(getCurrentPageId());
    if (filename.endsWith(".cfc")) {
        IExecutor executor = new DialogJobExecutor(main);
        executor.addJob(new ImportCFCJob(path + filename, LumaQQ.CUSTOM_FACE_DIR, g));
        executor.execute();
    } else {
        IExecutor executor = new DialogJobExecutor(main);
        executor.addJob(new ImportEIPJob(this, path + filename, LumaQQ.CUSTOM_FACE_DIR, g));
        executor.execute();
    }
    g = util.getFaceGroup(getCurrentPageId());
    facePage.refreshViewer(g);
}

From source file:edu.tsinghua.lumaqq.ui.config.sys.LoginPage.java

License:Open Source License

/**
* ??????//from w  w w.  j  a v a2 s.c  o  m
* 
* @return 
*       truefalse??
*/
private boolean checkProxy() {
    if (textProxyAddress.getText().equals("")) {
        MessageDialog.openWarning(parentShell, message_box_common_warning_title,
                message_box_please_fill_proxy_address);
        return false;
    } else {
        int port = Util.getInt(textProxyPort.getText(), 0);
        if (port == 0) {
            MessageDialog.openWarning(parentShell, message_box_common_warning_title,
                    message_box_please_fill_proxy_port);
            return false;
        }
    }
    return true;
}

From source file:edu.tsinghua.lumaqq.ui.debug.Debugger.java

License:Open Source License

private void showWarning(String msg) {
    MessageDialog.openWarning(getShell(), "Warning", msg);
}

From source file:edu.tsinghua.lumaqq.ui.debug.InitialArgumentDialog.java

License:Open Source License

@Override
protected void okPressed() {
    arg = createDebugArgument();/*from  ww  w  .  ja va2  s.c o  m*/
    if (arg == null)
        MessageDialog.openWarning(getShell(), "Warning", "Some errors exist in your input, try again!");
    else
        super.okPressed();
}

From source file:edu.tsinghua.lumaqq.ui.dialogs.DiskPasswordDialog.java

License:Open Source License

@Override
protected void okPressed() {
    String savePassword = main.getDiskManager().getPassword();
    if (savePassword != null && !savePassword.equals(oldPassword)) {
        MessageDialog.openWarning(getShell(), message_box_common_warning_title,
                message_box_old_password_incorrect);
    } else if (setPassword) {
        if (newPassword == null || confirmNewPassword == null || newPassword.length() < 6
                || confirmNewPassword.length() < 6)
            MessageDialog.openWarning(getShell(), message_box_common_warning_title,
                    NLS.bind(message_box_password_length, "6", "16"));
        else if (!newPassword.equals(confirmNewPassword))
            MessageDialog.openWarning(getShell(), message_box_common_warning_title,
                    message_box_new_password_confirm);
        else/*from   w  ww.j ava  2s .c om*/
            super.okPressed();
    } else
        super.okPressed();
}

From source file:edu.tsinghua.lumaqq.ui.dialogs.DiskShareDialog.java

License:Open Source License

@Override
protected void okPressed() {
    // ?/*from  w w w.j  av  a 2s.  com*/
    if (share && newList.isEmpty()) {
        MessageDialog.openWarning(getShell(), message_box_common_warning_title, disk_hint_cannot_empty);
        return;
    }

    if (!share)
        newList.clear();

    getButton(IDialogConstants.OK_ID).setEnabled(false);
    viewer.getTable().setEnabled(false);
    fss.setVisible(false);

    for (Integer qq : newList)
        oldList.remove(qq);
    IJob job = null;
    if (share) {
        job = new SetShareListJob(dir, false, oldList, newList);
        job.addJobListener(this);
        main.getDiskJobQueue().addJob(job);
    } else {
        job = new SetShareListJob(dir, true, oldList, newList);
        job.addJobListener(this);
        main.getDiskJobQueue().addJob(job);
    }
}