Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [SOLVED] How to Use Eclipse Error Dialog with Preference Pages Extension
icon14.gif  [SOLVED] How to Use Eclipse Error Dialog with Preference Pages Extension [message #658022] Sat, 05 March 2011 06:31
Kivanc Muslu is currently offline Kivanc MusluFriend
Messages: 153
Registered: November 2010
Senior Member
Note: This question is resolved. Please visit: amp; amp;unread=1&S=0a833943dd5407c74fe6f0fda2005701 for solution.

Hi all,

I am trying to extend org.eclipse.ui.preferencePages to add a new Preference Page to the GUI where I can let users do some configuration related to my plug-in.

All in all this works quite good. For one configuration, I let them enter a 'project name'. I need to make sure that a project with that name must exist in the workspace, and show an error to the user if it does not exist (also cancel the performOK(...) method). I tried doing this with the following code:

private boolean validate()
        String projectName = projectName_.getStringValue();
        if (projectName.trim().equals(""))
            return false;
        IProject project = Util.getProject(projectName);
        if (project.exists() && project.isOpen())
            return true;
            ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Speculation Error!", "Project " + projectName + " does not exists in the workspace.", Status.CANCEL_STATUS);
            return false;

// where projectName_ is the text field in the preference page that the user writes on and
// where Util.getProject(...) is defined as:
    public static IProject getProject(String name)
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IWorkspaceRoot root = workspace.getRoot();
        IProject project = root.getProject(name);
        return project;

I can detect if the entered project is valid or not, however for some reason when it is not valid, my code does not show an error dialog to the user, it just does not let her to close the window (since validate returns false). By looking at the ErrorDialog part of the code, could you tell me if there is something I am missing?

Thanks in advance, best regards,

[Updated on: Sat, 05 March 2011 06:32]

Report message to a moderator

Previous Topic:Writing to zip file with Eclipse EFS
Next Topic:LTK Rename Resource Dialog
Goto Forum:

Current Time: Mon Jan 25 09:03:02 GMT 2021

Powered by FUDForum. Page generated in 0.01829 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top