mirror of https://github.com/rusefi/RomRaider.git
Copied and used old desktoppane
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@582 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
0bc4f2c224
commit
5b78e83afa
|
@ -31,6 +31,7 @@ import javax.swing.tree.TreeSelectionModel;
|
|||
|
||||
import enginuity.NewGUI.data.ApplicationStateManager;
|
||||
import enginuity.NewGUI.data.TableNodeMetaData;
|
||||
import enginuity.NewGUI.desktop.EDesktopPane;
|
||||
import enginuity.NewGUI.etable.EInternalFrame;
|
||||
import enginuity.NewGUI.etable.ETable;
|
||||
import enginuity.NewGUI.etable.EToolBar;
|
||||
|
@ -49,7 +50,7 @@ public class NewGUI extends JFrame implements ActionListener, TreeSelectionListe
|
|||
private JMenu tuningEntitiesJMenu = new JMenu("Tuning Entities");
|
||||
|
||||
private JSplitPane splitPane = new JSplitPane();
|
||||
private JDesktopPane rightDesktopPane = new JDesktopPane();
|
||||
private EDesktopPane rightDesktopPane = new EDesktopPane();
|
||||
|
||||
private ETreeNode rootNode = new ETreeNode("Enginuity", new TableNodeMetaData(TableNodeMetaData.RESERVED_ROOT,0.0,0.0,new Object[0],false,""));
|
||||
private ETree leftJTree = new ETree(rootNode);
|
||||
|
@ -160,7 +161,11 @@ public class NewGUI extends JFrame implements ActionListener, TreeSelectionListe
|
|||
}
|
||||
|
||||
public void displayInternalFrameTable(double[][] data, TableNodeMetaData tableMetaData){
|
||||
|
||||
JInternalFrame[] internalFrames = this.rightDesktopPane.getAllFrames();
|
||||
for(int i = 0; i < internalFrames.length; i ++){
|
||||
JInternalFrame theFrame = internalFrames[i];
|
||||
theFrame.toBack();
|
||||
}
|
||||
|
||||
this.rightDesktopPane.add(new EInternalFrame(tableMetaData, data, new Dimension(470, 450)));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,226 @@
|
|||
package enginuity.NewGUI.desktop;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.beans.PropertyVetoException;
|
||||
|
||||
import javax.swing.DefaultDesktopManager;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JViewport;
|
||||
|
||||
|
||||
public class EDesktopPane extends JDesktopPane{
|
||||
private static int FRAME_OFFSET = 20;
|
||||
private MDIDesktopManager manager;
|
||||
|
||||
public EDesktopPane() {
|
||||
manager = new MDIDesktopManager(this);
|
||||
setDesktopManager(manager);
|
||||
setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y, int w, int h) {
|
||||
super.setBounds(x, y, w, h);
|
||||
checkDesktopSize();
|
||||
}
|
||||
|
||||
public Component add(JInternalFrame frame) {
|
||||
JInternalFrame[] array = getAllFrames();
|
||||
Point p;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
Component retval = super.add(frame);
|
||||
checkDesktopSize();
|
||||
if (array.length > 0) {
|
||||
p = array[0].getLocation();
|
||||
p.x = p.x + FRAME_OFFSET;
|
||||
p.y = p.y + FRAME_OFFSET;
|
||||
} else {
|
||||
p = new Point(0, 0);
|
||||
}
|
||||
frame.setLocation(p.x, p.y);
|
||||
if (frame.isResizable()) {
|
||||
w = getWidth() - (getWidth() / 3);
|
||||
h = getHeight() - (getHeight() / 3);
|
||||
if (w < frame.getMinimumSize().getWidth()) {
|
||||
w = (int) frame.getMinimumSize().getWidth();
|
||||
}
|
||||
if (h < frame.getMinimumSize().getHeight()) {
|
||||
h = (int) frame.getMinimumSize().getHeight();
|
||||
}
|
||||
frame.setSize(w, h);
|
||||
}
|
||||
moveToFront(frame);
|
||||
frame.setVisible(true);
|
||||
try {
|
||||
frame.setSelected(true);
|
||||
} catch (PropertyVetoException e) {
|
||||
frame.toBack();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void remove(Component c) {
|
||||
super.remove(c);
|
||||
checkDesktopSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cascade all internal frames
|
||||
*/
|
||||
public void cascadeFrames() {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
JInternalFrame allFrames[] = getAllFrames();
|
||||
|
||||
manager.setNormalSize();
|
||||
int frameHeight = (getBounds().height - 5) - allFrames.length * FRAME_OFFSET;
|
||||
int frameWidth = (getBounds().width - 5) - allFrames.length * FRAME_OFFSET;
|
||||
for (int i = allFrames.length - 1; i >= 0; i--) {
|
||||
allFrames[i].setSize(frameWidth, frameHeight);
|
||||
allFrames[i].setLocation(x, y);
|
||||
x = x + FRAME_OFFSET;
|
||||
y = y + FRAME_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile all internal frames
|
||||
*/
|
||||
public void tileFrames() {
|
||||
java.awt.Component allFrames[] = getAllFrames();
|
||||
manager.setNormalSize();
|
||||
int frameHeight = getBounds().height / allFrames.length;
|
||||
int y = 0;
|
||||
for (int i = 0; i < allFrames.length; i++) {
|
||||
allFrames[i].setSize(getBounds().width, frameHeight);
|
||||
allFrames[i].setLocation(0, y);
|
||||
y = y + frameHeight;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all component size properties ( maximum, minimum, preferred)
|
||||
* to the given dimension.
|
||||
*/
|
||||
public void setAllSize(Dimension d) {
|
||||
setMinimumSize(d);
|
||||
setMaximumSize(d);
|
||||
setPreferredSize(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all component size properties ( maximum, minimum, preferred)
|
||||
* to the given width and height.
|
||||
*/
|
||||
public void setAllSize(int width, int height) {
|
||||
setAllSize(new Dimension(width, height));
|
||||
}
|
||||
|
||||
private void checkDesktopSize() {
|
||||
if (getParent() != null && isVisible()) {
|
||||
manager.resizeDesktop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Private class used to replace the standard DesktopManager for JDesktopPane.
|
||||
* Used to provide scrollbar functionality.
|
||||
*/
|
||||
class MDIDesktopManager extends DefaultDesktopManager {
|
||||
private EDesktopPane desktop;
|
||||
|
||||
public MDIDesktopManager(EDesktopPane desktop) {
|
||||
this.desktop = desktop;
|
||||
}
|
||||
|
||||
public void endResizingFrame(JComponent f) {
|
||||
super.endResizingFrame(f);
|
||||
resizeDesktop();
|
||||
}
|
||||
|
||||
public void endDraggingFrame(JComponent f) {
|
||||
super.endDraggingFrame(f);
|
||||
resizeDesktop();
|
||||
}
|
||||
|
||||
public void setNormalSize() {
|
||||
JScrollPane scrollPane = getScrollPane();
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Insets scrollInsets = getScrollPaneInsets();
|
||||
|
||||
if (scrollPane != null) {
|
||||
Dimension d = scrollPane.getVisibleRect().getSize();
|
||||
if (scrollPane.getBorder() != null) {
|
||||
d.setSize(d.getWidth() - scrollInsets.left - scrollInsets.right,
|
||||
d.getHeight() - scrollInsets.top - scrollInsets.bottom);
|
||||
}
|
||||
|
||||
d.setSize(d.getWidth() - 20, d.getHeight() - 20);
|
||||
desktop.setAllSize(x, y);
|
||||
scrollPane.invalidate();
|
||||
scrollPane.validate();
|
||||
}
|
||||
}
|
||||
|
||||
private Insets getScrollPaneInsets() {
|
||||
JScrollPane scrollPane = getScrollPane();
|
||||
if (scrollPane == null) {
|
||||
return new Insets(0, 0, 0, 0);
|
||||
} else {
|
||||
return getScrollPane().getBorder().getBorderInsets(scrollPane);
|
||||
}
|
||||
}
|
||||
|
||||
private JScrollPane getScrollPane() {
|
||||
if (desktop.getParent() instanceof JViewport) {
|
||||
JViewport viewPort = (JViewport) desktop.getParent();
|
||||
if (viewPort.getParent() instanceof JScrollPane) {
|
||||
return (JScrollPane) viewPort.getParent();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void resizeDesktop() {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
JScrollPane scrollPane = getScrollPane();
|
||||
Insets scrollInsets = getScrollPaneInsets();
|
||||
|
||||
if (scrollPane != null) {
|
||||
JInternalFrame allFrames[] = desktop.getAllFrames();
|
||||
for (int i = 0; i < allFrames.length; i++) {
|
||||
if (allFrames[i].getX() + allFrames[i].getWidth() > x) {
|
||||
x = allFrames[i].getX() + allFrames[i].getWidth();
|
||||
}
|
||||
if (allFrames[i].getY() + allFrames[i].getHeight() > y) {
|
||||
y = allFrames[i].getY() + allFrames[i].getHeight();
|
||||
}
|
||||
}
|
||||
Dimension d = scrollPane.getVisibleRect().getSize();
|
||||
if (scrollPane.getBorder() != null) {
|
||||
d.setSize(d.getWidth() - scrollInsets.left - scrollInsets.right,
|
||||
d.getHeight() - scrollInsets.top - scrollInsets.bottom);
|
||||
}
|
||||
|
||||
if (x <= d.getWidth()) {
|
||||
x = ((int) d.getWidth()) - 20;
|
||||
}
|
||||
if (y <= d.getHeight()) {
|
||||
y = ((int) d.getHeight()) - 20;
|
||||
}
|
||||
desktop.setAllSize(x, y);
|
||||
scrollPane.invalidate();
|
||||
scrollPane.validate();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package enginuity.NewGUI.etable;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
public class ESelectionListener implements ListSelectionListener{
|
||||
private JTable parentTable = null;
|
||||
|
||||
public ESelectionListener(JTable parentTable){
|
||||
}
|
||||
public void valueChanged(ListSelectionEvent event) {
|
||||
//System.out.println("1: "+ event.getFirstIndex()+" 2: "+event.getLastIndex());
|
||||
|
||||
int selRow[] = parentTable.getSelectedRows();
|
||||
int selCol[] = parentTable.getSelectedColumns();
|
||||
|
||||
|
||||
for(int i = 0; i < selRow.length; i++){
|
||||
//System.out.println("Row Value: "+selRow[i]);
|
||||
}
|
||||
|
||||
for(int i = 0; i < selCol.length; i++){
|
||||
//System.out.println("Col Value: "+selCol[i]);
|
||||
}
|
||||
|
||||
//System.out.println("---------------------------");
|
||||
Object[] selectedCells = new Object[selRow.length * selCol.length];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -187,12 +187,10 @@ public class EToolBar extends JToolBar implements MouseListener, ItemListener,Ac
|
|||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getSource() == incrementCoarse) {
|
||||
System.out.println("> inc");
|
||||
eTable.changeSelectedCells(Double.parseDouble(String.valueOf(incrementByCoarse.getValue())), ETable.INCREMENT);
|
||||
}
|
||||
|
||||
else if (e.getSource() == decrementCoarse) {
|
||||
System.out.println("> dec");
|
||||
eTable.changeSelectedCells(Double.parseDouble(String.valueOf(incrementByCoarse.getValue())), ETable.DECREMENT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue