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:com.predic8.plugin.membrane.preferences.ProxyPreferencePage.java

License:Apache License

private void setAndSaveConfig() {
    if (btUseProxy.getSelection()) {
        if (isValidProxyParams()) {
            saveWidgetValues(true);//from w w  w . ja v  a 2 s .  c  o m
        } else {
            MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Warning",
                    "Invaled configuration: please check proxy host and proxy port values");
            return;
        }
    } else {
        saveWidgetValues(false);
    }

    try {
        Router.getInstance().getConfigurationManager().saveConfiguration(
                Router.getInstance().getConfigurationManager().getDefaultConfigurationFile());
    } catch (Exception e) {
        e.printStackTrace();
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error",
                "Unable to save configuration: " + e.getMessage());
    }
}

From source file:com.predic8.plugin.membrane.wizards.AddProxyWizard.java

License:Apache License

void openWarningDialog(String msg) {
    MessageDialog.openWarning(this.getShell(), "Warning", msg);
}

From source file:com.predic8.plugin.membrane_client.views.RequestView.java

License:Apache License

private boolean canPerformClientCall() {
    if ("".equals(textAddress.getText().trim()) && request == null) {
        MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Client Call Error",
                "Request and destination address is missing.");
        return false;
    }/*  w ww.  j a v  a2  s.  c  o m*/

    if ("".equals(textAddress.getText().trim())) {
        MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Client Call Error",
                "Destination address is missing.");
        return false;
    }

    try {
        new URL(textAddress.getText().trim());
    } catch (Exception ex) {
        MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Client Call Error",
                "Destination address is not valid URL.");
        return false;
    }

    if (request == null) {
        MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Client Call Error",
                "Request is missing.");
        return false;
    }
    return true;
}

From source file:com.predic8.plugin.membrane_client.views.ServiceTreeView.java

License:Apache License

private void onDoubleClick(DoubleClickEvent event) {
    ITreeSelection selection = (ITreeSelection) event.getSelection();
    Object firstElement = selection.getFirstElement();

    if (firstElement instanceof BindingOperation) {
        BindingOperation bOp = (BindingOperation) firstElement;
        if (!(bOp.getBinding().getBinding() instanceof AbstractSOAPBinding)) {
            MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning",
                    "This operation is not supported yet.");
            return;
        }//from  w  w w.  j  ava  2 s.c o  m

        PluginUtil.closeView(ResponseView.VIEW_ID);
        ((RequestView) PluginUtil.showView(RequestView.VIEW_ID)).updateView((BindingOperation) firstElement,
                null);
        return;
    }

    if (firstElement instanceof ParamsMap) {
        PluginUtil.closeView(ResponseView.VIEW_ID);
        ((RequestView) PluginUtil.showView(RequestView.VIEW_ID)).updateView(getAncestorBinding(selection),
                (ParamsMap) firstElement);
        return;
    }

    if (firstElement instanceof Response) {
        PluginUtil.closeView(ResponseView.VIEW_ID);
        Response resp = (Response) firstElement;
        BindingOperation ancestorBinding = getAncestorBinding(selection);

        ParamsMap reqMap = getSiblingParamsMap(selection, resp);
        if (reqMap != null) {
            ((RequestView) PluginUtil.showView(RequestView.VIEW_ID)).updateView(ancestorBinding, reqMap);
        }

        ((ResponseView) PluginUtil.showView(ResponseView.VIEW_ID)).setMessage(resp, ancestorBinding, null);
        return;
    }

}

From source file:com.safi.workshop.sqlexplorer.preview.LargeTextPreviewer.java

License:Open Source License

public void createControls(final Composite parent, Object obj) {
    if (obj == null)
        return;/*from   www  . j av  a2  s . c  o  m*/
    String content = null;

    if (obj instanceof LargeTextDataType) {
        LargeTextDataType data = (LargeTextDataType) obj;
        try {
            Reader reader = data.getTextData();
            char[] buffer = new char[4096];
            StringBuffer result = new StringBuffer();
            int pos;
            int length = 0;
            while ((pos = reader.read(buffer)) > -1) {
                result.append(buffer);
                length += pos;
                if (length > MAX_TEXT_SIZE) {
                    parent.getDisplay().asyncExec(new Runnable() {
                        public void run() {
                            MessageDialog.openWarning(parent.getShell(),
                                    Messages.getString("LargeTextPreviewer.TooMuchData.Title"),
                                    Messages.getString("LargeTextPreviewer.TooMuchData.Message"));
                        }
                    });
                    break;
                }
            }
            content = result.toString();
        } catch (Exception e) {
            SQLExplorerPlugin.error("Cannot read CLOB", e);
            return;
        }
    } else
        content = obj.toString();

    if (content == null)
        return;

    Text text = new Text(parent, SWT.NONE);
    text.setEditable(false);
    text.setText(content);
}

From source file:com.safi.workshop.util.SafletPersistenceManager.java

public void saveEmptyProject(IProject project) throws PublishResourceException {
    Session session = null;// w  w  w .ja  va 2 s  .c  om
    try {
        session = DBManager.getInstance().createSession();
    } catch (DBManagerException e1) {
        throw new PublishResourceException(e1);
    }
    try {
        session.beginTransaction();
        // int pid = handler.getId();
        int pid = getResourceId(project);

        SafletProject sameId = null;
        if (pid != -1) {
            List results = session.createCriteria(SafletProject.class).add(Restrictions.eq("id", pid)).list();
            if (!results.isEmpty()) {
                sameId = (SafletProject) results.get(0);
            }
        }

        SafletProject sameName = null;
        List results = session.createCriteria(SafletProject.class)
                .add(Restrictions.eq("name", project.getName())).list();
        if (!results.isEmpty()) {
            sameName = (SafletProject) results.get(0);
        }

        if (sameName != null) {
            if (sameId != null && sameId != sameName) {
                MessageDialog.openWarning(SafiWorkshopEditorUtil.getActiveShell(), "Project Renamed",
                        "A Project named " + project.getName()
                                + " already exists on the server. Publishing cannot continue.");
                return;
            }
            Date now = new Date();
            project.setPersistentProperty(RES_ID_KEY, String.valueOf(sameName.getId()));
            project.setPersistentProperty(MODIFIED_KEY, String.valueOf(now.getTime()));
            project.setPersistentProperty(UPDATED_KEY, String.valueOf(now.getTime()));
            return;
        }

        if (sameId != null) {
            Date now = new Date();
            sameId.setName(project.getName());
            sameId.setLastUpdated(now);
            session.update(sameId);
            project.setPersistentProperty(RES_ID_KEY, String.valueOf(sameId.getId()));
            project.setPersistentProperty(MODIFIED_KEY, String.valueOf(now.getTime()));
            project.setPersistentProperty(UPDATED_KEY, String.valueOf(now.getTime()));
        } else {
            Date now = new Date();
            SafletProject newp = ConfigFactory.eINSTANCE.createSafletProject();
            newp.setName(project.getName());

            newp.setLastModified(now);
            newp.setLastUpdated(now);
            session.save(newp);
            int id = newp.getId();
            project.setPersistentProperty(RES_ID_KEY, String.valueOf(id));

            project.setPersistentProperty(MODIFIED_KEY, String.valueOf(now.getTime()));
            project.setPersistentProperty(UPDATED_KEY, String.valueOf(now.getTime()));
        }

        session.getTransaction().commit();
    } catch (Exception e) {
        // if (session != null && session.getTransaction() != null)
        // session.getTransaction().rollback();
        throw new PublishResourceException(e);
    } finally {
        session.close();
    }

}

From source file:com.safi.workshop.util.SafletPersistenceManager.java

public void prepareProjects(Shell shell, List<ServerResource> serverResourceList,
        Map<SafletProject, IProject> projectToResourceMap, List<IProject> existingProjects) {
    for (ServerResource sr : serverResourceList) {
        IProject sameId = null;/*from  w ww  .  ja v  a 2  s.  co  m*/
        IProject sameName = null;

        if (sr instanceof SafletProject) {
            for (IProject p : existingProjects) {
                if (p.getName().equals(sr.getName()))
                    sameName = p;
                int pid = SafletPersistenceManager.getInstance().getResourceId(p);
                if (sr.getId() == pid && pid != -1)
                    sameId = p;
            }
            if (sameId != null && sameName != null && sameName != sameId) {
                MessageDialog.openWarning(shell, "Project Name Conflict",
                        "A project with the name " + sameName.getName()
                                + " already exists and has been persisted under a different name. Project "
                                + sameName.getName() + " cannot be retrieved");
                continue;
            } else if (sameId != null && sameName == null) { // its been renamed
                boolean ok = MessageDialog.openQuestion(shell, "Project Renamed", "The local project "
                        + sameId.getName()
                        + " has been renamed on the SafiServer.  Press OK to rename the local project instance or press "
                        + "'Cancel' to skip this project.");
                if (!ok)
                    continue;
                try {
                    IProjectDescription desc = sameId.getDescription();
                    desc.setName(sr.getName());

                    sameId.move(desc, true, null);
                    projectToResourceMap.put((SafletProject) sr, sameId);
                } catch (CoreException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    MessageDialog.openError(shell, "Move Project Error",
                            "Couldn't move project " + sameId.getName() + ": " + e.getLocalizedMessage());
                    AsteriskDiagramEditorPlugin.getInstance().logError("Move Project Error", e);
                    continue;
                }
            } else if (sameId != null && sameId == sameName) { // name is unchanged
                projectToResourceMap.put((SafletProject) sr, sameId);
            } else if (sameName != null) {
                projectToResourceMap.put((SafletProject) sr, sameName);
            } else {
                try {
                    IProject newProj = createNewProject((SafletProject) sr);
                    projectToResourceMap.put((SafletProject) sr, newProj);
                } catch (CoreException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    MessageDialog.openError(shell, "Create Project Error",
                            "Couldn't create project " + sr.getName() + ": " + e.getLocalizedMessage());
                    AsteriskDiagramEditorPlugin.getInstance().logError("Create Project Error", e);
                    continue;
                }
            }
        }

    }
}

From source file:com.salesforce.ide.core.internal.utils.DialogUtils.java

License:Open Source License

public void invalidLoginDialog(String exceptionMessage, String projectName, boolean showProjectProperties) {
    List<String> params = new ArrayList<String>();

    params.add(projectName == null ? ""
            : Messages.getString("General.InvalidLogin.UpdateCredentials.Parms.project",
                    new String[] { projectName }));
    params.add(exceptionMessage);/* www  . jav a  2 s.  c om*/
    params.add(
            !showProjectProperties ? "" : Messages.getString("General.InvalidLogin.UpdateCredentials.message"));

    MessageDialog.openWarning(getShell(), "Invalid Login",
            Messages.getString("General.InvalidLogin.UpdateCredentials.Parms.message", params.toArray()));
}

From source file:com.salesforce.ide.core.internal.utils.Utils.java

License:Open Source License

public static void openWarn(String pTitle, String pMessage) {
    MessageDialog.openWarning(getShell(), pTitle, pMessage);
}

From source file:com.salesforce.ide.core.internal.utils.Utils.java

License:Open Source License

public static void openWarn(Shell shell, String pTitle, String pMessage) {
    MessageDialog.openWarning(shell, pTitle, pMessage);
}