-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 660245b
Showing
12 changed files
with
4,363 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<actions> | ||
<action> | ||
<actionName>run</actionName> | ||
<packagings> | ||
<packaging>jar</packaging> | ||
</packagings> | ||
<goals> | ||
<goal>process-classes</goal> | ||
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal> | ||
</goals> | ||
<properties> | ||
<exec.args>-classpath %classpath com.bangmaple.jdbcgenerator.MainController</exec.args> | ||
<exec.executable>java</exec.executable> | ||
</properties> | ||
</action> | ||
<action> | ||
<actionName>debug</actionName> | ||
<packagings> | ||
<packaging>jar</packaging> | ||
</packagings> | ||
<goals> | ||
<goal>process-classes</goal> | ||
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal> | ||
</goals> | ||
<properties> | ||
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.bangmaple.jdbcgenerator.MainController</exec.args> | ||
<exec.executable>java</exec.executable> | ||
<jpda.listen>true</jpda.listen> | ||
</properties> | ||
</action> | ||
<action> | ||
<actionName>profile</actionName> | ||
<packagings> | ||
<packaging>jar</packaging> | ||
</packagings> | ||
<goals> | ||
<goal>process-classes</goal> | ||
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal> | ||
</goals> | ||
<properties> | ||
<exec.args>-classpath %classpath com.bangmaple.jdbcgenerator.MainController</exec.args> | ||
<exec.executable>java</exec.executable> | ||
</properties> | ||
</action> | ||
</actions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.bangmaple</groupId> | ||
<artifactId>BangMapleJDBCGenerator</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.github.vincenzopalazzo</groupId> | ||
<artifactId>material-ui-swing</artifactId> | ||
<version>1.1.1_pre-release_6.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.microsoft.sqlserver</groupId> | ||
<artifactId>sqljdbc4</artifactId> | ||
<version>4.0</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<configuration> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<archive> | ||
<manifest> | ||
<mainClass>com.bangmaple.jdbcgenerator.MainController</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<name>BangMapleJDBCGenerator</name> | ||
</project> |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/bangmaple/jdbcgenerator/CutCopyPasteActionSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package com.bangmaple.jdbcgenerator; | ||
|
||
import java.awt.event.InputEvent; | ||
import java.awt.event.KeyEvent; | ||
import javax.swing.AbstractAction; | ||
import javax.swing.JMenu; | ||
import javax.swing.JMenuItem; | ||
import javax.swing.JPopupMenu; | ||
import javax.swing.KeyStroke; | ||
import javax.swing.text.DefaultEditorKit; | ||
import javax.swing.text.JTextComponent; | ||
import javax.swing.text.TextAction; | ||
|
||
/** | ||
* | ||
* @author bangmaple | ||
*/ | ||
public class CutCopyPasteActionSupport { | ||
private JMenu jMenu; | ||
JPopupMenu popupMenu = new JPopupMenu(); | ||
|
||
public CutCopyPasteActionSupport() { | ||
init(); | ||
} | ||
|
||
private void init() { | ||
jMenu = new JMenu("Edit"); | ||
addAction(new DefaultEditorKit.CutAction(), KeyEvent.VK_X, "Cut" ); | ||
addAction(new DefaultEditorKit.CopyAction(), KeyEvent.VK_C, "Copy" ); | ||
addAction(new DefaultEditorKit.PasteAction(), KeyEvent.VK_V, "Paste" ); | ||
} | ||
|
||
private void addAction(TextAction action, int key, String text) { | ||
action.putValue(AbstractAction.ACCELERATOR_KEY, | ||
KeyStroke.getKeyStroke(key, InputEvent.CTRL_DOWN_MASK)); | ||
action.putValue(AbstractAction.NAME, text); | ||
jMenu.add(new JMenuItem(action)); | ||
popupMenu.add(new JMenuItem(action)); | ||
} | ||
|
||
public void setPopup(JTextComponent... components){ | ||
if(components == null){ | ||
return; | ||
} | ||
for (JTextComponent tc : components) { | ||
tc.setComponentPopupMenu(popupMenu); | ||
} | ||
} | ||
|
||
public JMenu getMenu() { | ||
return jMenu; | ||
} | ||
} |
135 changes: 135 additions & 0 deletions
135
src/main/java/com/bangmaple/jdbcgenerator/DraggableTabbedPane.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package com.bangmaple.jdbcgenerator; | ||
|
||
/** | ||
* | ||
* @author bangmaple | ||
*/ | ||
import java.awt.Component; | ||
import java.awt.Graphics; | ||
import java.awt.Image; | ||
import java.awt.Point; | ||
import java.awt.Rectangle; | ||
import java.awt.event.MouseAdapter; | ||
import java.awt.event.MouseEvent; | ||
import java.awt.event.MouseMotionAdapter; | ||
import java.awt.image.BufferedImage; | ||
|
||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
import javax.swing.JTabbedPane; | ||
|
||
public class DraggableTabbedPane extends JTabbedPane { | ||
|
||
private boolean dragging = false; | ||
private Image tabImage = null; | ||
private Point currentMouseLocation = null; | ||
private int draggedTabIndex = 0; | ||
|
||
public DraggableTabbedPane(final JFrame parent) { | ||
super(); | ||
addMouseMotionListener(new MouseMotionAdapter() { | ||
@Override | ||
public void mouseDragged(MouseEvent e) { | ||
|
||
if (!dragging) { | ||
// Gets the tab index based on the mouse position | ||
int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), e.getY()); | ||
|
||
if (tabNumber >= 0) { | ||
draggedTabIndex = tabNumber; | ||
Rectangle bounds = getUI().getTabBounds(DraggableTabbedPane.this, tabNumber); | ||
|
||
// Paint the tabbed pane to a buffer | ||
Image totalImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); | ||
Graphics totalGraphics = totalImage.getGraphics(); | ||
totalGraphics.setClip(bounds); | ||
// Don't be double buffered when painting to a static image. | ||
setDoubleBuffered(false); | ||
paintComponent(totalGraphics); | ||
|
||
// Paint just the dragged tab to the buffer | ||
tabImage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB); | ||
Graphics graphics = tabImage.getGraphics(); | ||
graphics.drawImage(totalImage, 0, 0, bounds.width, bounds.height, bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, DraggableTabbedPane.this); | ||
|
||
dragging = true; | ||
repaint(); | ||
} | ||
int thisX = parent.getLocation().x; | ||
int thisY = parent.getLocation().y; | ||
|
||
int xMoved = e.getX() - currentMouseLocation.x; | ||
int yMoved = e.getY() - currentMouseLocation.y; | ||
|
||
int X = thisX + xMoved; | ||
int Y = thisY + yMoved; | ||
parent.setLocation(X, Y); | ||
} else { | ||
currentMouseLocation = e.getPoint(); | ||
|
||
// Need to repaint | ||
repaint(); | ||
} | ||
|
||
super.mouseDragged(e); | ||
} | ||
}); | ||
|
||
addMouseListener(new MouseAdapter() { | ||
@Override | ||
public void mousePressed(MouseEvent e) { | ||
currentMouseLocation = e.getPoint(); | ||
getComponentAt(currentMouseLocation); | ||
} | ||
|
||
@Override | ||
public void mouseReleased(MouseEvent e) { | ||
|
||
if (dragging) { | ||
int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), 10); | ||
|
||
if (tabNumber >= 0) { | ||
Component comp = getComponentAt(draggedTabIndex); | ||
String title = getTitleAt(draggedTabIndex); | ||
removeTabAt(draggedTabIndex); | ||
insertTab(title, null, comp, null, tabNumber); | ||
} | ||
} | ||
|
||
dragging = false; | ||
tabImage = null; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
protected void paintComponent(Graphics g) { | ||
super.paintComponent(g); | ||
|
||
// Are we dragging? | ||
if (dragging && currentMouseLocation != null && tabImage != null) { | ||
// Draw the dragged tab | ||
g.drawImage(tabImage, currentMouseLocation.x, currentMouseLocation.y, this); | ||
} | ||
} | ||
|
||
// public static void main(String[] args) { | ||
// JFrame test = new JFrame("Tab test"); | ||
// test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
// test.setSize(400, 400); | ||
// | ||
// DraggableTabbedPane tabs = new DraggableTabbedPane(); | ||
// tabs.addTab("One", new JButton("One")); | ||
// tabs.addTab("Two", new JButton("Two")); | ||
// tabs.addTab("Three", new JButton("Three")); | ||
// tabs.addTab("Four", new JButton("Four")); | ||
// | ||
// test.add(tabs); | ||
// test.setVisible(true); | ||
// } | ||
} |
Oops, something went wrong.