[SOLVED] How to Use Eclipse Error Dialog with Preference Pages Extension [message #658022] |
Sat, 05 March 2011 06:31 |
Kivanc Muslu Messages: 153 Registered: November 2010 |
Senior Member |
|
|
Note: This question is resolved. Please visit: http://www.eclipse.org/forums/index.php?t=msg&th=205550& 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;
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:32] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03611 seconds