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.siteview.mde.internal.ui.editor.EditorUtilities.java

License:Open Source License

public static void openImage(String value, String definingPluginId) {
    IResource resource = getImageResource(value, definingPluginId);
    try {//  w w  w. j  av  a2s  .c  o m
        if (resource != null && resource instanceof IFile)
            IDE.openEditor(MDEPlugin.getActivePage(), (IFile) resource, true);
        else
            MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.AboutSection_open,
                    MDEUIMessages.AboutSection_warning); // 
    } catch (PartInitException e) {
    }
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExtensionDetails.java

License:Open Source License

private void showNoExtensionPointMessage() {
    String title = MDEUIMessages.ExtensionDetails_noPoint_title;
    String message = NLS.bind(MDEUIMessages.ShowDescriptionAction_noPoint_desc, input.getPoint());

    MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(), title, message);
}

From source file:com.siteview.mde.internal.ui.editor.product.ConfigurationSection.java

License:Open Source License

private void handleOpen() {
    IWorkspaceRoot root = MDEPlugin.getWorkspace().getRoot();
    Path path = new Path(fCustomEntry.getValue());
    if (path.isEmpty()) {
        MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.WindowImagesSection_open,
                MDEUIMessages.WindowImagesSection_emptyPath); // 
        return;/*from  w ww  .  j a v  a 2s .  com*/
    }
    IResource resource = root.findMember(path);
    try {
        if (resource != null && resource instanceof IFile)
            IDE.openEditor(MDEPlugin.getActivePage(), (IFile) resource, true);
        else
            MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(),
                    MDEUIMessages.WindowImagesSection_open, MDEUIMessages.WindowImagesSection_warning); // 
    } catch (PartInitException e) {
    }
}

From source file:com.siteview.mde.internal.ui.editor.product.LauncherSection.java

License:Open Source License

private void openImage(String value) {
    IWorkspaceRoot root = MDEPlugin.getWorkspace().getRoot();
    Path path = new Path(value);
    if (path.isEmpty()) {
        MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.WindowImagesSection_open,
                MDEUIMessages.WindowImagesSection_emptyPath); // 
        return;/*w w w  .ja v a  2 s .  c  o  m*/
    }
    IResource resource = root.findMember(new Path(value));
    try {
        if (resource != null && resource instanceof IFile)
            IDE.openEditor(MDEPlugin.getActivePage(), (IFile) resource, true);
        else
            MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(),
                    MDEUIMessages.WindowImagesSection_open, MDEUIMessages.WindowImagesSection_warning); // 
    } catch (PartInitException e) {
    }
}

From source file:com.siteview.mde.internal.ui.editor.schema.ElementSection.java

License:Open Source License

protected void handleDoubleClick(IStructuredSelection selection) {
    super.handleDoubleClick(selection);
    Object object = selection.getFirstElement();
    if (object instanceof SchemaElementReference) {
        ISchemaElement element = ((SchemaElementReference) object).getReferencedElement();
        if (element == null) {
            String name = ((SchemaElementReference) object).getName();
            MessageDialog.openWarning(getPage().getSite().getShell(),
                    MDEUIMessages.ElementSection_missingRefElement,
                    NLS.bind(MDEUIMessages.SchemaIncludesSection_missingWarningMessage, name));
            return;
        }//  w w w .j a v a2 s .  co m
        ISchema schema = element.getSchema();
        if (schema.equals(fSchema))
            fireSelection(new StructuredSelection(element));
        else {
            ISchemaInclude[] includes = fSchema.getIncludes();
            for (int i = 0; i < includes.length; i++) {
                if (includes[i].getIncludedSchema().equals(schema)) {
                    String location = includes[i].getLocation();
                    SchemaEditor.openToElement(new Path(location), element);
                    break;
                }
            }
        }
    }
}

From source file:com.siteview.mde.internal.ui.editor.schema.SchemaIncludesSection.java

License:Open Source License

protected void handleDoubleClick(IStructuredSelection selection) {
    Object object = selection.getFirstElement();
    if (object instanceof ISchemaInclude) {
        IEditorInput edinput = getPage().getEditorInput();
        if (!(edinput instanceof IFileEditorInput))
            return;
        String path = ((ISchemaInclude) object).getLocation();
        IPath includePath = new Path(((ISchemaInclude) object).getLocation());
        boolean result = false;
        if (path.startsWith("schema:")) { //$NON-NLS-1$
            result = SchemaEditor.openSchema(includePath);
        } else {/*from  w w w .j  a  v  a 2s .c  om*/
            IFile currSchemaFile = ((IFileEditorInput) edinput).getFile();
            IProject project = currSchemaFile.getProject();
            IPath currSchemaPath = currSchemaFile.getProjectRelativePath();
            IFile file = project.getFile(currSchemaPath.removeLastSegments(1).append(includePath));
            result = SchemaEditor.openSchema(file);
        }
        if (!result)
            MessageDialog.openWarning(getPage().getSite().getShell(),
                    MDEUIMessages.SchemaIncludesSection_missingWarningTitle, NLS.bind(
                            MDEUIMessages.SchemaIncludesSection_missingWarningMessage, includePath.toString()));
    }
}

From source file:com.siteview.mde.internal.ui.launcher.BaseBlock.java

License:Open Source License

protected void createText(Composite parent, String text, int indent) {
    fLocationLink = new Link(parent, SWT.NONE);
    fLocationLink.setText("<a>" + text + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
    if (indent > 0) {
        GridData gd = new GridData();
        gd.horizontalIndent = indent;//from   w w w  .j a v a2  s .  c om
        fLocationLink.setLayoutData(gd);
    }

    fLocationText = new Text(parent, SWT.SINGLE | SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 400;
    fLocationText.setLayoutData(gd);
    fLocationText.addModifyListener(fListener);

    fLocationLink.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                String path = VariablesPlugin.getDefault().getStringVariableManager()
                        .performStringSubstitution(getLocation(), false);
                File f = new File(path);
                if (f.exists())
                    Program.launch(f.getCanonicalPath());
                else
                    MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(),
                            isFile() ? MDEUIMessages.BaseBlock_fileTitle
                                    : MDEUIMessages.BaseBlock_directoryTitle,
                            isFile() ? MDEUIMessages.BaseBlock_fileNotFoundMessage
                                    : MDEUIMessages.BaseBlock_directoryNotFoundMessage);
            } catch (Exception ex) {
                MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(),
                        isFile() ? MDEUIMessages.BaseBlock_fileTitle : MDEUIMessages.BaseBlock_directoryTitle,
                        isFile() ? MDEUIMessages.BaseBlock_fileErrorMessage
                                : MDEUIMessages.BaseBlock_directoryErrorMessage);
            }
        }
    });

}

From source file:com.siteview.mde.internal.ui.preferences.TargetPlatformPreferencePage.java

License:Open Source License

public boolean performOk() {
    ITargetPlatformService service = getTargetService();
    if (service == null) {
        return false;
    }//from   www  .  j a  v  a 2  s .c  o m

    // determine if default target has changed
    ITargetDefinition toLoad = null;
    boolean load = false;
    try {
        ITargetHandle activeHandle = null;
        if (fActiveTarget != null) {
            activeHandle = fActiveTarget.getHandle();
        }
        if (fPrevious == null) {
            if (activeHandle != null) {
                toLoad = fActiveTarget;
                load = true;
            }
        } else {
            if (activeHandle == null) {
                // load empty
                load = true;
            } else if (!fPrevious.equals(activeHandle) || isOutOfSynch) {
                toLoad = fActiveTarget;
                load = true;
            } else {
                ITargetDefinition original = fPrevious.getTargetDefinition();
                // TODO: should just check for structural changes
                if (((TargetDefinition) original).isContentEquivalent(fActiveTarget)) {
                    load = false;
                } else {
                    load = true;
                    toLoad = fActiveTarget;
                }
            }
        }
    } catch (CoreException e) {
        ErrorDialog.openError(getShell(), MDEUIMessages.TargetPlatformPreferencePage2_8,
                MDEUIMessages.TargetPlatformPreferencePage2_9, e.getStatus());
        return false;
    }

    // Move the marked definitions to workspace
    if (fMoved.size() > 0) {
        Iterator iterator = fMoved.keySet().iterator();
        while (iterator.hasNext()) {
            try {
                ITargetDefinition target = (ITargetDefinition) iterator.next();
                //IPath path = Path.fromPortableString((String) fMoved.get(target));
                IFile targetFile = MDECore.getWorkspace().getRoot().getFile((IPath) fMoved.get(target));

                WorkspaceFileTargetHandle wrkspcTargetHandle = new WorkspaceFileTargetHandle(targetFile);
                ITargetDefinition newTarget = service.newTarget();
                service.copyTargetDefinition(target, newTarget);
                wrkspcTargetHandle.save(newTarget);
                fRemoved.add(target);
                fTargets.remove(target);
                ITargetDefinition workspaceTarget = wrkspcTargetHandle.getTargetDefinition();
                fTargets.add(workspaceTarget);
                fTableViewer.refresh(false);
                if (target == fActiveTarget) {
                    load = true;
                    toLoad = workspaceTarget;
                }
            } catch (CoreException e) {
                MDEPlugin.log(e);
            }
        }
    }

    // Remove any definitions that have been removed
    Iterator iterator = fRemoved.iterator();
    while (iterator.hasNext()) {
        ITargetDefinition target = (ITargetDefinition) iterator.next();
        try {
            service.deleteTarget(target.getHandle());
        } catch (CoreException e) {
            ErrorDialog.openError(getShell(), MDEUIMessages.TargetPlatformPreferencePage2_8,
                    MDEUIMessages.TargetPlatformPreferencePage2_11, e.getStatus());
            return false;
        }
    }
    // save others that are dirty
    iterator = fTargets.iterator();
    while (iterator.hasNext()) {
        ITargetDefinition def = (ITargetDefinition) iterator.next();
        boolean save = true;
        if (def.getHandle().exists()) {
            try {
                ITargetDefinition original = def.getHandle().getTargetDefinition();
                if (((TargetDefinition) original).isContentEqual(def)) {
                    save = false;
                }
            } catch (CoreException e) {
                // failed to generate original
                setErrorMessage(e.getMessage());
                return false;
            }
        }
        if (save) {
            try {
                service.saveTargetDefinition(def);
            } catch (CoreException e) {
                setErrorMessage(e.getMessage());
                return false;
            }
        }
    }

    // set workspace target if required
    if (load) {

        // Warn about forward compatibility, synchronize java search
        IJobChangeListener listener = new JobChangeAdapter() {
            public void done(IJobChangeEvent event) {
                if (event.getResult().getSeverity() == IStatus.OK) {
                    if (fActiveTarget != null) {
                        MDEPreferencesManager pref = new MDEPreferencesManager(MDEPlugin.getPluginId());
                        if (pref.getBoolean(IPreferenceConstants.ADD_TO_JAVA_SEARCH)) {
                            AddToJavaSearchJob.synchWithTarget(fActiveTarget);
                        }
                        // Ignore the qualifier when comparing (otherwise N builds always newer than I builds)
                        Version platformOsgiVersion = Platform.getBundle(ORG_ECLIPSE_OSGI).getVersion();
                        platformOsgiVersion = new Version(platformOsgiVersion.getMajor(),
                                platformOsgiVersion.getMinor(), platformOsgiVersion.getMicro());
                        IResolvedBundle[] bundles;
                        bundles = fActiveTarget.getAllBundles();
                        if (bundles != null) {
                            for (int index = 0; index < bundles.length; index++) {
                                BundleInfo bundleInfo = bundles[index].getBundleInfo();
                                if (ORG_ECLIPSE_OSGI.equalsIgnoreCase(bundleInfo.getSymbolicName())) {
                                    // Ignore the qualifier when comparing (otherwise N builds always newer than I builds)
                                    Version bundleVersion = Version.parseVersion(bundleInfo.getVersion());
                                    bundleVersion = new Version(bundleVersion.getMajor(),
                                            bundleVersion.getMinor(), bundleVersion.getMicro());
                                    if (platformOsgiVersion.compareTo(bundleVersion) < 0) {
                                        Display.getDefault().syncExec(new Runnable() {
                                            public void run() {
                                                MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(),
                                                        MDEUIMessages.TargetPlatformPreferencePage2_28,
                                                        MDEUIMessages.TargetPlatformPreferencePage2_10);
                                            }
                                        });
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        };

        LoadTargetDefinitionJob.load(toLoad, listener);
        fPrevious = toLoad == null ? null : toLoad.getHandle();
    }

    fMoved.clear();
    boolean gc = !fRemoved.isEmpty();
    fRemoved.clear();
    if (toLoad != null) {
        fActiveTarget = toLoad;
    }
    fTableViewer.refresh(true);
    updateButtons();
    // start job to do GC
    if (gc) {
        runGC();
    }
    return super.performOk();
}

From source file:com.siteview.mde.internal.ui.search.ShowDescriptionAction.java

License:Open Source License

private void showNoSchemaMessage() {
    String title = MDEUIMessages.ShowDescriptionAction_title;
    String message;// ww  w .j  a  va  2s.co  m
    if (fPointID == null || fPointID.startsWith("null")) //$NON-NLS-1$
        message = MDEUIMessages.ShowDescriptionAction_schemaNotAvail;
    else
        message = NLS.bind(MDEUIMessages.ShowDescriptionAction_noPoint_desc, fPointID);
    MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(), title, message);
}

From source file:com.tencent.wstt.apt.action.StartTestAction.java

License:Open Source License

@Override
public void run() {
    if (bStatus) {
        if (DeviceInfo.getInstance().state != PhoneState.STATE_OK) {
            APTConsoleFactory.getInstance().APTPrint("?");
            MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??",
                    "?");
            return;
        }/*from   w w  w  .  ja v a 2s. com*/

        /**
         * ??
         */
        DeviceInfo.getInstance().print();
        /**
         * ????
         */
        if (!TestSenceUtil.update()) {
            APTConsoleFactory.getInstance().APTPrint(
                    "???????");
            return;
        }
        if (!TestSenceUtil.verifyTestSence()) {
            return;
        }

        APTConsoleFactory.getInstance().APTPrint("?\r\n");

        APTState.getInstance().DealWithEventBefore(APTEventEnum.START_OPER);
        if (!TestTaskManager.getInstance().initTest()) {
            APTConsoleFactory.getInstance().APTPrint("?\r\n");
            return;
        }
        TestTaskManager.getInstance().start();

        APTState.getInstance().DealWithEventAfter(APTEventEnum.START_OPER);
        /**
         * UI
         */
        this.setText("Stop");
        this.setToolTipText("?");
        this.setImageDescriptor(
                AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/stop.png"));
        bStatus = !bStatus;

        /**
         * ??
         */
        TestSence.getInstance().print();

    } else {
        // ?
        APTState.getInstance().DealWithEventBefore(APTEventEnum.STOP_OPER);
        TestTaskManager.getInstance().stop();
        APTConsoleFactory.getInstance().APTPrint("?");

        /**
         * ??UI
         */
        this.setText("Start");
        this.setToolTipText("");
        this.setImageDescriptor(
                AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/start.png"));
        bStatus = !bStatus;

        APTState.getInstance().DealWithEventAfter(APTEventEnum.STOP_OPER);
    }

}