Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe committed Jun 29, 2024
1 parent 58b6965 commit 0b90339
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.java.amateras.db.util;

import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Driver;
Expand Down Expand Up @@ -28,8 +29,8 @@ public class DatabaseInfo {
final public String DERBY = "Apache Derby";
final public String SYBASE = "Adaptive Server Enterprise";

public DatabaseInfo(Class<?> driverClass) throws InstantiationException, IllegalAccessException {
driver = (Driver) driverClass.newInstance();
public DatabaseInfo(Class<?> driverClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
driver = (Driver) driverClass.getDeclaredConstructor().newInstance();
}

public void setURI(String uri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,29 @@ public java.util.List<Class<?>> getJDBCDriverClass(String jarName) throws IOExce
if(jarName.equals("")){
return Collections.emptyList();
}
JarFile jarFile = new JarFile(jarName);
Enumeration<JarEntry> e = jarFile.entries();

ArrayList<Class<?>> list = new ArrayList<Class<?>>();
while(e.hasMoreElements()){
JarEntry entry = (JarEntry)e.nextElement();
String name = entry.getName();
if(name.lastIndexOf(".class")!=-1){
String ccls = name.replaceFirst(".class","").replaceAll("/",".");
try {
Class<?> cls = loadClass(ccls,true);
getJDBCDriverClass(list, cls ,cls);
} catch (NoClassDefFoundError ex) {
} catch (ClassNotFoundException ex) {
JarFile jarFile = new JarFile(jarName);
try {
Enumeration<JarEntry> e = jarFile.entries();
while(e.hasMoreElements()){
JarEntry entry = (JarEntry)e.nextElement();
String name = entry.getName();
if(name.lastIndexOf(".class")!=-1){
String ccls = name.replaceFirst(".class","").replaceAll("/",".");
try {
Class<?> cls = loadClass(ccls,true);
getJDBCDriverClass(list, cls ,cls);
} catch (NoClassDefFoundError ex) {
} catch (ClassNotFoundException ex) {
}
}
}
} finally {
try {
jarFile.close();
} catch (Exception ex) {
}
}
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static void addMarker(IResource resource, int type, String message){
try {
IMarker marker = resource.createMarker(IMarker.PROBLEM);
Map<String, Object> map = new HashMap<String, Object>();
map.put(IMarker.SEVERITY, new Integer(type));
map.put(IMarker.SEVERITY, type);
map.put(IMarker.MESSAGE, message);
// map.put(IMarker.LINE_NUMBER,new Integer(line));
marker.setAttributes(map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void run() {
graph.edges = graphEdges;
new DirectedGraphLayout().visit(graph);
for (int i = 0; i < graph.nodes.size(); i++) {
EntityNode node = (EntityNode) graph.nodes.getNode(i);
EntityNode node = (EntityNode) graph.nodes.get(i);
commands.add(new LayoutCommand(node.model, node.x, node.y));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ protected void setInput(IEditorInput input) {
setPartName(input.getName());
}

@SuppressWarnings("unchecked")
protected void initializeGraphicalViewer() {
GraphicalViewer viewer = getGraphicalViewer();

Expand Down Expand Up @@ -412,10 +411,10 @@ private PaletteEntry createEntityEntry(String itemName,Class<?> clazz,String ico
return entry;
}

@SuppressWarnings("rawtypes")
public Object getAdapter(Class type){
@SuppressWarnings("unchecked")
public <T> T getAdapter(Class<T> type){
if(type == IContentOutlinePage.class){
return this.outlinePage;
return (T) this.outlinePage;
}
return super.getAdapter(type);
}
Expand Down Expand Up @@ -483,16 +482,16 @@ protected void applyPreferences(){
IPreferenceStore store = DBPlugin.getDefault().getPreferenceStore();

getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED,
new Boolean(store.getBoolean(DBPlugin.PREF_SHOW_GRID)));
store.getBoolean(DBPlugin.PREF_SHOW_GRID));
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE,
new Boolean(store.getBoolean(DBPlugin.PREF_SHOW_GRID)));
store.getBoolean(DBPlugin.PREF_SHOW_GRID));

int gridSize = store.getInt(DBPlugin.PREF_GRID_SIZE);
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING,
new Dimension(gridSize, gridSize));

getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED,
new Boolean(store.getBoolean(DBPlugin.PREF_SNAP_GEOMETRY)));
store.getBoolean(DBPlugin.PREF_SNAP_GEOMETRY));

boolean isZoomableWithCtrlAndScroll = store.getBoolean(DBPlugin.PREF_ZOOMABLE_WITH_CTRL_AND_SCROLL);
String mouseWheelHandlerKey = MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public abstract class AbstractDBEntityEditPart extends AbstractDBEditPart implements NodeEditPart {

/**
* Creats a {@link CreateConnectionCommand} instance.
* Creates a {@link CreateConnectionCommand} instance.
* Override to return an instance of extended class to customize connection creation.
*
* @return the connection creation command
Expand Down Expand Up @@ -79,19 +79,18 @@ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
return new ChopboxAnchor(getFigure());
}

@SuppressWarnings("unchecked")
public void propertyChange(PropertyChangeEvent evt) {
refreshVisuals();
refreshSourceConnections();
refreshTargetConnections();

invokePropertyChangeListener(evt, (List<PropertyChangeListener>) getSourceConnections());
invokePropertyChangeListener(evt, (List<PropertyChangeListener>) getTargetConnections());
invokePropertyChangeListener(evt, getSourceConnections());
invokePropertyChangeListener(evt, getTargetConnections());
}

private void invokePropertyChangeListener(PropertyChangeEvent evt, List<PropertyChangeListener> listeners){
for(PropertyChangeListener listener: listeners){
listener.propertyChange(evt);
private void invokePropertyChangeListener(PropertyChangeEvent evt, List<? extends ConnectionEditPart> listeners){
for(ConnectionEditPart listener: listeners){
((AbstractDBConnectionEditPart) listener).propertyChange(evt);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private int getColumnNear(Connection connection, int r, int n, int x) {
r--;
Integer i;
while (proximity < r) {
i = new Integer(r + proximity * direction);
i = r + proximity * direction;
if (!colsUsed.containsKey(i)) {
colsUsed.put(i, i);
reserveColumn(connection, i);
Expand Down Expand Up @@ -159,7 +159,7 @@ protected int getRowNear(Connection connection, int r, int n, int x) {
r--;
Integer i;
while (proximity < r) {
i = new Integer(r + proximity * direction);
i = r + proximity * direction;
if (!rowsUsed.containsKey(i)) {
rowsUsed.put(i, i);
reserveRow(connection, i);
Expand Down Expand Up @@ -316,9 +316,9 @@ public void route(Connection conn) {

List positions = new ArrayList(5);
if (horizontal)
positions.add(new Integer(start.y));
positions.add(start.y);
else
positions.add(new Integer(start.x));
positions.add(start.x);
horizontal = !horizontal;

if (startNormal.dotProduct(endNormal) == 0) {
Expand All @@ -335,7 +335,7 @@ public void route(Connection conn) {
else
i = average.x;
}
positions.add(new Integer(i));
positions.add(i);
horizontal = !horizontal;

if (endNormal.dotProduct(direction) > 0)
Expand All @@ -346,7 +346,7 @@ public void route(Connection conn) {
else
i = average.x;
}
positions.add(new Integer(i + (duplicationCount * interval)));
positions.add(i + (duplicationCount * interval));
horizontal = !horizontal;
}
} else {
Expand All @@ -356,34 +356,34 @@ public void route(Connection conn) {
i = startNormal.similarity(start.getAdded(startNormal.getScaled(10)));
else
i = endNormal.similarity(end.getAdded(endNormal.getScaled(10)));
positions.add(new Integer(i + (duplicationCount * interval)));
positions.add(i + (duplicationCount * interval));
horizontal = !horizontal;
} else {
//3 or 1
if (startNormal.dotProduct(direction) < 0) {
i = startNormal.similarity(start.getAdded(startNormal.getScaled(10)));
positions.add(new Integer(i + (duplicationCount * interval)));
positions.add(i + (duplicationCount * interval));
horizontal = !horizontal;
}

if (horizontal)
i = average.y;
else
i = average.x;
positions.add(new Integer(i + (duplicationCount * interval)));
positions.add(i + (duplicationCount * interval));
horizontal = !horizontal;

if (startNormal.dotProduct(direction) < 0) {
i = endNormal.similarity(end.getAdded(endNormal.getScaled(10)));
positions.add(new Integer(i + (duplicationCount * interval)));
positions.add(i + (duplicationCount * interval));
horizontal = !horizontal;
}
}
}
if (horizontal)
positions.add(new Integer(end.y));
positions.add(end.y);
else
positions.add(new Integer(end.x));
positions.add(end.x);

processPositions(start, end, positions, startNormal.isHorizontal(), conn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.CompoundSnapToHelper;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.SnapToGeometry;
import org.eclipse.gef.SnapToGrid;
Expand Down Expand Up @@ -58,23 +60,20 @@ public void propertyChange(PropertyChangeEvent evt) {
refreshChildren();
}
if (evt.getPropertyName().equals(RootModel.P_FONT)) {
@SuppressWarnings("unchecked")
List<AbstractDBEntityEditPart> children = (List<AbstractDBEntityEditPart>) getChildren();
for(AbstractDBEntityEditPart part: children){
List<? extends GraphicalEditPart> children = getChildren();
for(GraphicalEditPart part: children){
part.refresh();
for(Object conn: part.getSourceConnections()){
((AbstractDBConnectionEditPart) conn).refresh();
}
}
}
if (evt.getPropertyName().equals(RootModel.P_MODE)) {
@SuppressWarnings("unchecked")
List<AbstractDBEntityEditPart> children = (List<AbstractDBEntityEditPart>) getChildren();
for(AbstractDBEntityEditPart part: children){
List<? extends GraphicalEditPart> children = getChildren();
for(GraphicalEditPart part: children){
part.refresh();
@SuppressWarnings("unchecked")
List<AbstractDBConnectionEditPart> conns = (List<AbstractDBConnectionEditPart>) part.getSourceConnections();
for(AbstractDBConnectionEditPart conn: conns){
List<? extends ConnectionEditPart> conns = part.getSourceConnections();
for(ConnectionEditPart conn: conns){
conn.refresh();
}
}
Expand Down Expand Up @@ -175,8 +174,8 @@ public void undo() {
}
}

@SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) {
@SuppressWarnings("unchecked")
public <T> T getAdapter(Class<T> adapter) {
if (adapter == SnapToHelper.class) {
List<SnapToHelper> snapStrategies = new ArrayList<SnapToHelper>();
Boolean val = (Boolean)getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
Expand All @@ -192,12 +191,12 @@ public Object getAdapter(Class adapter) {
if (snapStrategies.size() == 0)
return null;
if (snapStrategies.size() == 1)
return (SnapToHelper)snapStrategies.get(0);
return (T) snapStrategies.get(0);

SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()];
for (int i = 0; i < snapStrategies.size(); i++)
ss[i] = (SnapToHelper)snapStrategies.get(i);
return new CompoundSnapToHelper(ss);
ss[i] = (SnapToHelper) snapStrategies.get(i);
return (T) new CompoundSnapToHelper(ss);
}
return super.getAdapter(adapter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void addPropertyChangeListener(PropertyChangeListener listener) {
listeners.addPropertyChangeListener(listener);
}

public void firePropertyChange(String propName, Object oldValue,Object newValue) {
public void firePropertyChange(String propName, Object oldValue, Object newValue) {
listeners.firePropertyChange(propName, oldValue, newValue);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ public boolean isIncludeView() {

public void setIncludeView(boolean includeView) {
this.includeView = includeView;
firePropertyChange(P_JDBC_INFO, null, new Boolean(jdbcCatalog));
firePropertyChange(P_JDBC_INFO, null, includeView);
}

public void setLogicalMode(boolean logicalMode){
this.logicalMode = logicalMode;
firePropertyChange(P_MODE, null, new Boolean(logicalMode));
firePropertyChange(P_MODE, null, logicalMode);
}

public boolean getLogicalMode(){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.java.amateras.db.wizard;

import java.net.URI;
import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
Expand Down Expand Up @@ -251,12 +252,9 @@ private void loadJdbcDriver(){

IFile file = wsroot.getFile(new Path(jarFilePath));
jarFilePath = file.getLocation().makeAbsolute().toString();

jarURL = new URL("file:///" + jarFilePath);

} else {
jarURL = new URL("file:///" + jarFilePath);
}

jarURL = new URI("file:///" + jarFilePath).toURL();

URL[] clspath = new URL[classpathes.length + 1];
clspath[0] = jarURL;
Expand Down

0 comments on commit 0b90339

Please sign in to comment.