Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » [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 #657790] Fri, 04 March 2011 04:46 Go to next message
Kivanc Muslu is currently offline Kivanc MusluFriend
Messages: 153
Registered: November 2010
Senior Member
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;
        else
        {
            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:30]

Report message to a moderator

Re: How to Use Eclipse Error Dialog [message #657866 is a reply to message #657790] Fri, 04 March 2011 11:28 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 04/03/11 10:16 AM, Kivanc Muslu wrote:

> 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

Don't show an error dialog when you are in the PreferenceDialog. Use
preferencePage.setErrorMessage() instead. Also you are on the wrong
forum. You need eclipse.platform not this.

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: How to Use Eclipse Error Dialog [message #658002 is a reply to message #657866] Fri, 04 March 2011 22:01 Go to previous messageGo to next message
Kivanc Muslu is currently offline Kivanc MusluFriend
Messages: 153
Registered: November 2010
Senior Member
Hi Prakash,

Thanks for the suggestion, worked like a charm. Also, my apologies that I didn't know there was another forum for Eclipse Platform. I looked for it, however couldn't figure out a way to create an account so I can post a similar question there and give a link to this post (if there are other people wondering the same thing). Do I need to go through somewhere else to create an account for Eclipse Platform Forums?

The link I found is: http://www.eclipsezone.com/eclipse/forums/f18122.html

Thanks, best regards,

[Updated on: Fri, 04 March 2011 22:02]

Report message to a moderator

Re: How to Use Eclipse Error Dialog [message #658019 is a reply to message #658002] Sat, 05 March 2011 04:18 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 3/5/2011 3:31 AM, Kivanc Muslu wrote:
> Hi Prakash,
>
> Thanks for the suggestion, worked like a charm. Also, my apoligies that
> I didn't know there was another forum for Eclipse Platform. I looked for
> it, however couldn't figure out a way to create an account so I can post
> a similar question there and give a link to this post (if there are
> other people wondering the same thing). Do I need to go through
> somewhere else to create an account for Eclipse Platform Forums?
> The link I found is: http://www.eclipsezone.com/eclipse/forums/f18122.html
>
> Thanks, best regards,
Eclipse Platform forum is on the same site as this forum -
http://www.eclipse.org/forums/index.php?t=thread&frm_id= 11&S=d62ae48f0440cbb85fecdaa25117312c
Re: How to Use Eclipse Error Dialog [message #658023 is a reply to message #658019] Sat, 05 March 2011 06:31 Go to previous message
Kivanc Muslu is currently offline Kivanc MusluFriend
Messages: 153
Registered: November 2010
Senior Member
Thanks Deepak, I also created a thread there and put a link to this thread.
Previous Topic:How to get buffer (IBuffer) of a normal text (.txt) file?
Next Topic:How to Differentiate The Type of Change (i.e., normal, or undo) using IUndoManagerListener
Goto Forum:
  


Current Time: Thu Apr 25 15:13:14 GMT 2024

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

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

Back to the top