diff --git a/net.java.amateras.db/src/net/java/amateras/db/util/DatabaseInfo.java b/net.java.amateras.db/src/net/java/amateras/db/util/DatabaseInfo.java index 7d3e5dc..0d6fdb4 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/util/DatabaseInfo.java +++ b/net.java.amateras.db/src/net/java/amateras/db/util/DatabaseInfo.java @@ -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; @@ -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) { diff --git a/net.java.amateras.db/src/net/java/amateras/db/util/JarClassLoader.java b/net.java.amateras.db/src/net/java/amateras/db/util/JarClassLoader.java index be2e45f..ac0e2f4 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/util/JarClassLoader.java +++ b/net.java.amateras.db/src/net/java/amateras/db/util/JarClassLoader.java @@ -38,21 +38,29 @@ public java.util.List> getJDBCDriverClass(String jarName) throws IOExce if(jarName.equals("")){ return Collections.emptyList(); } - JarFile jarFile = new JarFile(jarName); - Enumeration e = jarFile.entries(); + ArrayList> list = new ArrayList>(); - 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 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; } diff --git a/net.java.amateras.db/src/net/java/amateras/db/validator/DiagramErrors.java b/net.java.amateras.db/src/net/java/amateras/db/validator/DiagramErrors.java index 109b689..f6b69e9 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/validator/DiagramErrors.java +++ b/net.java.amateras.db/src/net/java/amateras/db/validator/DiagramErrors.java @@ -181,7 +181,7 @@ private static void addMarker(IResource resource, int type, String message){ try { IMarker marker = resource.createMarker(IMarker.PROBLEM); Map map = new HashMap(); - 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); diff --git a/net.java.amateras.db/src/net/java/amateras/db/visual/action/AutoLayoutAction.java b/net.java.amateras.db/src/net/java/amateras/db/visual/action/AutoLayoutAction.java index e8b9ccd..3f4533f 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/visual/action/AutoLayoutAction.java +++ b/net.java.amateras.db/src/net/java/amateras/db/visual/action/AutoLayoutAction.java @@ -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)); } diff --git a/net.java.amateras.db/src/net/java/amateras/db/visual/editor/VisualDBEditor.java b/net.java.amateras.db/src/net/java/amateras/db/visual/editor/VisualDBEditor.java index 3cdea4c..060d24e 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/visual/editor/VisualDBEditor.java +++ b/net.java.amateras.db/src/net/java/amateras/db/visual/editor/VisualDBEditor.java @@ -146,7 +146,6 @@ protected void setInput(IEditorInput input) { setPartName(input.getName()); } - @SuppressWarnings("unchecked") protected void initializeGraphicalViewer() { GraphicalViewer viewer = getGraphicalViewer(); @@ -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 getAdapter(Class type){ if(type == IContentOutlinePage.class){ - return this.outlinePage; + return (T) this.outlinePage; } return super.getAdapter(type); } @@ -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); diff --git a/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/AbstractDBEntityEditPart.java b/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/AbstractDBEntityEditPart.java index 2fe39d1..2fe7512 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/AbstractDBEntityEditPart.java +++ b/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/AbstractDBEntityEditPart.java @@ -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 @@ -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) getSourceConnections()); - invokePropertyChangeListener(evt, (List) getTargetConnections()); + invokePropertyChangeListener(evt, getSourceConnections()); + invokePropertyChangeListener(evt, getTargetConnections()); } - private void invokePropertyChangeListener(PropertyChangeEvent evt, List listeners){ - for(PropertyChangeListener listener: listeners){ - listener.propertyChange(evt); + private void invokePropertyChangeListener(PropertyChangeEvent evt, List listeners){ + for(ConnectionEditPart listener: listeners){ + ((AbstractDBConnectionEditPart) listener).propertyChange(evt); } } diff --git a/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/ManhattanConnectionRouter.java b/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/ManhattanConnectionRouter.java index 416c7ce..a82ea27 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/ManhattanConnectionRouter.java +++ b/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/ManhattanConnectionRouter.java @@ -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); @@ -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); @@ -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) { @@ -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) @@ -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 { @@ -356,13 +356,13 @@ 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; } @@ -370,20 +370,20 @@ public void route(Connection conn) { 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); } diff --git a/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/RootEditPart.java b/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/RootEditPart.java index 057532f..9449afb 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/RootEditPart.java +++ b/net.java.amateras.db/src/net/java/amateras/db/visual/editpart/RootEditPart.java @@ -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; @@ -58,9 +60,8 @@ public void propertyChange(PropertyChangeEvent evt) { refreshChildren(); } if (evt.getPropertyName().equals(RootModel.P_FONT)) { - @SuppressWarnings("unchecked") - List children = (List) getChildren(); - for(AbstractDBEntityEditPart part: children){ + List children = getChildren(); + for(GraphicalEditPart part: children){ part.refresh(); for(Object conn: part.getSourceConnections()){ ((AbstractDBConnectionEditPart) conn).refresh(); @@ -68,13 +69,11 @@ public void propertyChange(PropertyChangeEvent evt) { } } if (evt.getPropertyName().equals(RootModel.P_MODE)) { - @SuppressWarnings("unchecked") - List children = (List) getChildren(); - for(AbstractDBEntityEditPart part: children){ + List children = getChildren(); + for(GraphicalEditPart part: children){ part.refresh(); - @SuppressWarnings("unchecked") - List conns = (List) part.getSourceConnections(); - for(AbstractDBConnectionEditPart conn: conns){ + List conns = part.getSourceConnections(); + for(ConnectionEditPart conn: conns){ conn.refresh(); } } @@ -175,8 +174,8 @@ public void undo() { } } - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) { + @SuppressWarnings("unchecked") + public T getAdapter(Class adapter) { if (adapter == SnapToHelper.class) { List snapStrategies = new ArrayList(); Boolean val = (Boolean)getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY); @@ -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); } diff --git a/net.java.amateras.db/src/net/java/amateras/db/visual/model/AbstractDBModel.java b/net.java.amateras.db/src/net/java/amateras/db/visual/model/AbstractDBModel.java index 99a7106..6b6ab86 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/visual/model/AbstractDBModel.java +++ b/net.java.amateras.db/src/net/java/amateras/db/visual/model/AbstractDBModel.java @@ -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); } diff --git a/net.java.amateras.db/src/net/java/amateras/db/visual/model/RootModel.java b/net.java.amateras.db/src/net/java/amateras/db/visual/model/RootModel.java index b141ea1..0003147 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/visual/model/RootModel.java +++ b/net.java.amateras.db/src/net/java/amateras/db/visual/model/RootModel.java @@ -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(){ diff --git a/net.java.amateras.db/src/net/java/amateras/db/wizard/NewDiagramWizardPage2.java b/net.java.amateras.db/src/net/java/amateras/db/wizard/NewDiagramWizardPage2.java index fd327f9..3bf8c76 100644 --- a/net.java.amateras.db/src/net/java/amateras/db/wizard/NewDiagramWizardPage2.java +++ b/net.java.amateras.db/src/net/java/amateras/db/wizard/NewDiagramWizardPage2.java @@ -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; @@ -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;