Skip to content

Commit a4535b2

Browse files
ptzieglerazoitl
authored andcommitted
Fix "raw types" warnings in ToolEntry
This requires that the class set for the ToolEntry implements the Tool interface.
1 parent 2253efc commit a4535b2

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

org.eclipse.gef/src/org/eclipse/gef/palette/ToolEntry.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2010 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -15,7 +15,6 @@
1515
import java.util.HashMap;
1616
import java.util.Map;
1717

18-
import org.eclipse.core.runtime.Assert;
1918
import org.eclipse.jface.resource.ImageDescriptor;
2019

2120
import org.eclipse.gef.Tool;
@@ -29,7 +28,7 @@ public abstract class ToolEntry extends PaletteEntry {
2928
public static final Object PALETTE_TYPE_TOOL = "$Palette Tool";//$NON-NLS-1$
3029

3130
private Map<Object, Object> map;
32-
private Class toolClass;
31+
private Class<? extends Tool> toolClass;
3332

3433
/**
3534
* Creates a new ToolEntry. Any parameter can be <code>null</code>.
@@ -55,7 +54,7 @@ public ToolEntry(String label, String shortDesc, ImageDescriptor iconSmall, Imag
5554
* @since 3.1
5655
*/
5756
public ToolEntry(String label, String description, ImageDescriptor iconSmall, ImageDescriptor iconLarge,
58-
Class tool) {
57+
Class<? extends Tool> tool) {
5958
super(label, description, iconSmall, iconLarge, PALETTE_TYPE_TOOL);
6059
setToolClass(tool);
6160
}
@@ -74,10 +73,8 @@ public Tool createTool() {
7473
}
7574
Tool tool;
7675
try {
77-
tool = (Tool) toolClass.newInstance();
78-
} catch (IllegalAccessException iae) {
79-
return null;
80-
} catch (InstantiationException ie) {
76+
tool = toolClass.getDeclaredConstructor().newInstance();
77+
} catch (ReflectiveOperationException e) {
8178
return null;
8279
}
8380
tool.setProperties(getToolProperties());
@@ -115,10 +112,7 @@ public Object getToolProperty(Object key) {
115112
* @param toolClass the type of tool to be created by this entry
116113
* @since 3.1
117114
*/
118-
public void setToolClass(Class toolClass) {
119-
if (toolClass != null) {
120-
Assert.isTrue(Tool.class.isAssignableFrom(toolClass));
121-
}
115+
public void setToolClass(Class<? extends Tool> toolClass) {
122116
this.toolClass = toolClass;
123117
}
124118

0 commit comments

Comments
 (0)