Skip to content

Commit

Permalink
Merge pull request #183 from Bananeweizen/class_cast_exception
Browse files Browse the repository at this point in the history
ClassCastException in property page
  • Loading branch information
RoiSoleil authored Dec 7, 2023
2 parents b3cf346 + 8c6d3c3 commit e696fd4
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.IOException;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.preference.IPreferenceStore;
Expand Down Expand Up @@ -126,11 +128,15 @@ private Composite fixesSecondTabStyle(Composite tab)

private IJavaProject getJavaProject()
{
if(getElement() instanceof IJavaProject)
IAdaptable selection = getElement();
if(selection instanceof IJavaProject)
{
return (IJavaProject) getElement();
return (IJavaProject) selection;
}
return JavaCore.create((IProject) getElement());
// when files are selected, they need to be adapted to their project
// first (see enabledWhen clause of plugin.xml)
IProject project = Adapters.adapt(selection, IProject.class);
return JavaCore.create(project);
}

private void handleCheckboxSelectionChanged()
Expand Down

0 comments on commit e696fd4

Please sign in to comment.