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.github.sdbg.debug.ui.internal.util.AbstractLaunchShortcut.java

License:Open Source License

@Override
public final void launch(IEditorPart editor, String mode) {
    IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);

    if (resource != null) {
        resource = getLaunchableResource(resource);

        if (resource != null) {
            launch(resource, mode);/*w w w.j  a  v  a  2 s  .  co  m*/

            return;
        }
    }

    MessageDialog.openWarning(null, "Error Launching " + launchTypeLabel,
            "Unable to locate launchable resource.");
}

From source file:com.google.code.t4eclipse.tools.action.OpenJavaTypeAction.java

License:Open Source License

public static void openJavaType(final String className) {
    Listener listener = null;//from ww w .  j  a  v  a2 s . c  om
    try {
        listener = new Listener() {
            public void handleEvent(Event event) {
                if (event.widget != null && event.widget instanceof Shell) {
                    Shell shell = (Shell) event.widget;
                    if (!shell.isDisposed()) {
                        // why use start with? because eclispe 3.2 is
                        // OpenTypeSelectionDialog2, eclipse 3.3 is
                        // OpenTypeSelectionDialog
                        if (shell.getData() != null && shell.getData().getClass().getSimpleName()
                                .startsWith("OpenTypeSelectionDialog")) {
                            Text text = (Text) Finder.getDefault().findOneByClass(shell, Text.class);
                            text.setText(className);
                        }
                    }
                }

            }
        };
        Display.getDefault().addFilter(SWT.Activate, listener);

        Class<?> action = Class.forName("org.eclipse.jdt.internal.ui.actions.OpenTypeAction");

        ReflectionUtil.invokeMethod("run", action.newInstance(), IAction.class);
        // new OpenTypeAction().run();

    } catch (Exception e) {
        // JDT is not installed
        MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning!", "Can not open type:"
                + className + "\nJDT is not installed!\n Can not directly open java class!\n");

    } finally {
        if (listener != null) {
            Display.getDefault().removeFilter(SWT.Activate, listener);
        }

    }
}

From source file:com.google.code.t4eclipse.tools.view.MainSWT.java

License:Open Source License

@SuppressWarnings({ "unused", "hiding" })
private void createControlAnalysis(Composite composite) {

    GridLayout gridLayout = new GridLayout(3, false);
    composite.setLayout(gridLayout);/*from  www .  jav a 2 s  .  com*/

    // controls group
    Group controls = new Group(composite, SWT.None);
    controls.setText("Controls");
    GridData controlGroupgridData = new GridData(GridData.FILL_VERTICAL);
    controlGroupgridData.widthHint = 300;

    controls.setLayoutData(controlGroupgridData);

    GridLayout conrolGroupgridLayout = new GridLayout();
    controls.setLayout(conrolGroupgridLayout);

    analysisControlTable = new SimpleKTable(controls);
    GridData d2 = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);

    analysisControlTable.setLayoutData(d2);
    SimpleKTableModel<ControlAnalysisModel> model = new SimpleKTableModel<ControlAnalysisModel>(
            ControlAnalysisModel.class);
    analysisControlTable.setModel(model);
    analysisControlTable.addMenuListener();

    final Button analysisB = new Button(composite, SWT.PUSH);
    analysisB.setText("=>");
    analysisB.setToolTipText("Analysis the selected control");
    analysisB.setLayoutData(new GridData());
    analysisB.setEnabled(false);

    analysisControlTable.setLayoutData(d2);

    Group analysis = new Group(composite, SWT.None);
    analysis.setText("Analysis");
    GridData analysisGroupgridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    analysis.setLayoutData(analysisGroupgridData);

    analysis.setLayout(new GridLayout(6, false));

    final Button runMethodButton = new Button(analysis, SWT.PUSH);
    runMethodButton.setText("RunMethod");
    GridData rumMethodData = new GridData();
    rumMethodData.horizontalAlignment = GridData.FILL;
    runMethodButton.setLayoutData(rumMethodData);

    final Label labelUseless = new Label(analysis, SWT.NULL);
    labelUseless.setText("  ");

    GridData isUIData = new GridData();
    isUIData.horizontalAlignment = GridData.FILL;
    labelUseless.setLayoutData(isUIData);

    final Combo methodCombo = new Combo(analysis, SWT.NULL);
    GridData methodComboData = new GridData(GridData.FILL_HORIZONTAL);
    methodComboData.horizontalSpan = 4;
    methodCombo.setLayoutData(methodComboData);

    final Button getFieldButton = new Button(analysis, SWT.PUSH);
    getFieldButton.setText("GetField");
    GridData getFieldData = new GridData();

    getFieldData.horizontalAlignment = GridData.FILL;
    getFieldButton.setLayoutData(getFieldData);
    // just for layout.
    Label label = new Label(analysis, SWT.NULL);
    label.setLayoutData(new GridData());

    final Combo fieldCombo = new Combo(analysis, SWT.NULL);
    GridData fieldComboData = new GridData(GridData.FILL_HORIZONTAL);
    fieldComboData.horizontalSpan = 4;
    fieldCombo.setLayoutData(fieldComboData);

    final Text resultText = new Text(analysis, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData textData = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL);
    textData.horizontalSpan = 6;
    resultText.setLayoutData(textData);

    // the selection listener.

    // bor button =>
    analysisB.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            // TODO Auto-generated method stub

        }

        @SuppressWarnings("unchecked")
        public void widgetSelected(SelectionEvent e) {

            // add all the method and field to the method combo and field
            Point[] selects = analysisControlTable.getCellSelection();
            if (selects != null && selects.length > 0) {
                methodCombo.removeAll();
                fieldCombo.removeAll();
                int row = selects[0].y;
                SimpleKTableModel<ControlAnalysisModel> model = (SimpleKTableModel<ControlAnalysisModel>) analysisControlTable
                        .getModel();
                ControlAnalysisModel obj = (ControlAnalysisModel) model.getContentAt(-1, row);
                // System.err.println(obj.getObject());
                // set the object to be analysised to the data.
                analysisB.setData(obj.getObject());

                String[] methods = ReflctionProvider.getMethods(obj.getObject());

                for (String m : methods) {
                    methodCombo.add(m);
                }
                String[] fields = ReflctionProvider.getFields(obj.getObject());
                for (String f : fields) {
                    fieldCombo.add(f);
                }

            } else {
                methodCombo.removeAll();
                fieldCombo.removeAll();
                MessageDialog.openWarning(analysisB.getShell(), "Warning", "Select object to analysis first!");
            }
            analysisB.setEnabled(false);

        }
    });

    analysisControlTable.addCellSelectionListener(new KTableCellSelectionListener() {

        public void cellSelected(int col, int row, int statemask) {
            analysisControlTable.redraw();
            analysisB.setEnabled(true);
        }

        public void fixedCellSelected(int col, int row, int statemask) {
            //do nothing
        }
    });

    // for run method
    runMethodButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            //do nothing
        }

        public void widgetSelected(SelectionEvent e) {
            // run the selected method according to method name and ui
            // thread setup.
            String methodComboText = methodCombo.getText();
            if (methodComboText != null && methodComboText.length() > 0) {
                String result = ReflctionProvider.getMethodResultASStr(analysisB.getData(), methodComboText);
                resultText.setText(result);
            }

        }
    });

    // for get field
    getFieldButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            //do nothing
        }

        public void widgetSelected(SelectionEvent e) {
            String fieldComboText = fieldCombo.getText();
            if (fieldComboText != null && fieldComboText.length() > 0) {
                String result = ReflctionProvider.getFieldContentAsStr(analysisB.getData(), fieldComboText);
                resultText.setText(result);
            }
        }
    });

}

From source file:com.google.dart.eclipse.ui.internal.jobs.ValidateSDKJob.java

License:Open Source License

private void handeMissingSDK() {

    //TODO(pquitslund): replace with an action to kick off download/install of the SDK

    Display.getDefault().asyncExec(new Runnable() {

        @Override/*from  ww w . j a  v  a  2  s.c  o m*/
        public void run() {
            //TODO(pquitslund): add correct SDK download link
            //TODO(pquitslund): migrate to a control that supports hyperlinks/selectable text
            MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    UIJobMessages.ValidateSDKJob_missing_sdk_popup_title,
                    NLS.bind(UIJobMessages.ValidateSDKJob_missing_sdk_desc, getEclipseHome()));
        }

    });
}

From source file:com.google.dart.tools.debug.ui.internal.util.AbstractLaunchShortcut.java

License:Open Source License

@Override
public final void launch(IEditorPart editor, String mode) {
    IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);

    if (resource != null) {
        try {/*  www . j  a  v  a2  s.c  om*/
            resource = getLaunchableResource(resource);

            if (resource != null) {
                launch(resource, mode);

                return;
            }
        } catch (DartModelException e) {
            DebugErrorHandler.errorDialog(null, "Error Launching " + launchTypeLabel,
                    "Unable to locate launchable resource.", e);
            return;
        }
    }

    MessageDialog.openWarning(null, "Error Launching " + launchTypeLabel,
            "Unable to locate launchable resource.");
}

From source file:com.google.dart.tools.ui.internal.HeapTracker.java

License:Open Source License

private static void doTrack() {
    while (true) {
        Uninterruptibles.sleepUninterruptibly(ONE_SECOND_MILLIS, TimeUnit.MILLISECONDS);
        if (isLowMemory()) {
            // if index was cleared recently, ignore OOM
            if (System.currentTimeMillis() - indexDisabledMillis < WAIT_AFTER_INDEX_MILLIS) {
                continue;
            }//  w  w  w . j  ava 2 s. co  m
            // first solution - disable index
            if (indexDisabledMillis == -1) {
                DartCore.getProjectManager().disableIndex();
                Display.getDefault().syncExec(new Runnable() {
                    @Override
                    public void run() {
                        MessageDialog.openWarning(DartToolsPlugin.getActiveWorkbenchShell(),
                                "Almost out of memory",
                                "Editor is almost out of memory.\n"
                                        + "To keep it responsive search and refactoring features are disabled now.\n\n"
                                        + "It is recommended to close some projects or give Editor more memory and restart it.");
                    }
                });
                indexDisabledMillis = System.currentTimeMillis();
                continue;
            }
            // final solution - inform user that Editor is again about to run out of memory
            Display.getDefault().syncExec(new Runnable() {
                @Override
                public void run() {
                    MessageDialog.openWarning(DartToolsPlugin.getActiveWorkbenchShell(), "Almost out of memory",
                            "Search and refactoring features are disabled, but Editor is again almost out of memory.\n\n"
                                    + "It is strongly recommended to give Editor more memory and restart it.");
                }
            });
            // stop tracking heap, we cannot do anything
            return;
        }
    }
}

From source file:com.google.gdt.eclipse.appsmarketplace.ui.AppsMarketplaceProjectPropertyPage.java

License:Open Source License

private void saveApplicationListingDetails() throws BackingStoreException {
    String appName = appNameText.getText().trim();
    String appUrl = appUrlText.getText().trim();
    AppsMarketplaceProjectProperties.setAppListingUrl(getProject(), appUrl);
    AppsMarketplaceProjectProperties.setAppListingName(getProject(), appName);

    if (appCategoryCombo.getSelectionIndex() != -1) {
        AppsMarketplaceProjectProperties.setAppListingCategory(getProject(),
                appCategoryCombo.getSelectionIndex());
    }/*  w w w . j  av a 2 s .  c  o m*/
    if (manageWarDirectory) {
        AppsMarketplaceProjectProperties.setAppListingWarDirectory(getProject(),
                warLocationText.getText().trim());
    }
    AppsMarketplaceProject appsMktProject = AppsMarketplaceProject.create(getProject());
    try {
        // set appUrl and appName values in the application-manifest.xml
        appsMktProject.setAppUrl(appUrl);
        appsMktProject.setAppName(appName);
    } catch (CoreException e) {
        MessageDialog.openWarning(AppsMarketplacePlugin.getActiveWorkbenchShell(), "Google Plugin for Eclipse",
                "Could not set application url in application-manifest.xml." + " Please set it manually.");
    }
}

From source file:com.google.gdt.eclipse.appsmarketplace.ui.ListOnMarketplaceDialog.java

License:Open Source License

private boolean deployAppsMarketplaceListing() {
    // Store appUrl and appName
    String appUrl = appUrlText.getText().trim();
    String appName = appNameText.getText().trim();
    Integer categoryId = appCategoryCombo.getSelectionIndex();
    try {/*from  w w  w  .j  a  v  a2 s  .  co  m*/
        AppsMarketplaceProjectProperties.setAppListingUrl(project, appUrl);
        AppsMarketplaceProjectProperties.setAppListingName(project, appName);
        AppsMarketplaceProjectProperties.setAppListingCategory(project, categoryId);
        if (listingId != null) {
            AppsMarketplaceProjectProperties.setAppListingId(project, listingId);
        }
    } catch (BackingStoreException e) {
        // Do nothing
        AppsMarketplacePluginLog.logError(e);
    }

    try {
        // set appUrl and appName values in the application-manifest.xml
        this.appsMarketplaceProject.setAppUrl(appUrl);
        this.appsMarketplaceProject.setAppName(appName);
    } catch (CoreException e) {
        MessageDialog.openWarning(AppsMarketplacePlugin.getActiveWorkbenchShell(), "Google Plugin for Eclipse",
                "Could not set application url in application-manifest.xml." + " Please set it manually.");
        return false;
    }
    BackendJob job;
    ProgressMonitorDialog pdlg = null;
    if (createListingButton.getSelection()) {
        job = new BackendJob("Creating Appication Listing on Google Apps Marketplace",
                BackendJob.Type.CreateAppListing, requestFactory, appsMarketplaceProject);
    } else {
        job = new BackendJob("Upgrading Appication Listing on Google Apps Marketplace",
                BackendJob.Type.UpdateAppListing, requestFactory, appsMarketplaceProject);
    }
    pdlg = BackendJob.launchBackendJob(job, getShell());
    return (pdlg.open() == Window.OK && job.getOperationStatus() == true);
}

From source file:com.google.gdt.eclipse.designer.model.property.css.StylesEditComposite.java

License:Open Source License

private void searchRule() {
    String searchText = m_searchField.getText();
    if (!StringUtils.isEmpty(searchText)) {
        if (!locateRuleInFiles(searchText)) {
            MessageDialog.openWarning(getShell(), "Search", "Rule selector \"" + searchText + "\" not found.");
        }// ww  w  .  j  a va2 s .  co  m
    }
}

From source file:com.google.gdt.eclipse.suite.launch.SpeedTracerLaunchDelegate.java

License:Open Source License

@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
        throws CoreException {

    final String finalUrl = SpeedTracerLaunchConfiguration.getAbsoluteUrl(configuration);

    /*//ww w.jav  a2 s . co m
     * LaunchConfigurations (in the OOPHM model) are added in one of two places:
     * (1) here and (2) as a callback from the GWT SDK's DevMode. For Speed
     * Tracer launches, the SpeedTracerLaunchConfiguration subclass must be used
     * (instead of just LaunchConfiguration.) Therefore, we call this method
     * _BEFORE_ we call through to super.launch() so there is no chance the GWT
     * SDK DevMode can add the launch configuration model object before us (if
     * it were to, it would add a regular LaunchConfiguration instance instead
     * of SpeedTracerLaunchConfiguration.)
     * 
     * TODO: This needs to be cleaned up. Speed Tracer launch support has been
     * added uncleanly to the existing DevMode view/model framework.
     */
    WebAppDebugModel.getInstance().addOrReturnExistingLaunchConfiguration(launch, null,
            new ILaunchConfigurationFactory() {
                public LaunchConfiguration newLaunchConfiguration(ILaunch launch, String name,
                        WebAppDebugModel model) {
                    return new com.google.gwt.eclipse.oophm.model.SpeedTracerLaunchConfiguration(launch,
                            finalUrl, name, model);
                }
            });

    /*
     * Our super class, JavaLaunchDelegate, does not understand the profile
     * mode. Since we only use profile mode for UI purposes, pretend we are
     * launching as run mode.
     */
    super.launch(configuration, ILaunchManager.RUN_MODE, launch, monitor);

    try {

        SpeedTracerBrowserUtilities.createTrampolineFileAndAddToLaunch(finalUrl, launch);

    } catch (Throwable e) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                MessageDialog.openWarning(SWTUtilities.getShell(), "Speed Tracer error",
                        "Speed Tracer will not be opened automatically, please click on the Speed Tracer icon in the Chrome toolbar");
            }
        });
        GWTPluginLog.logWarning(e, "Could not create trampoline HTML file for Speed Tracer");
    }

    // Open Chrome
    SpeedTracerBrowserUtilities.openBrowser(finalUrl, launch);
}