Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/multidom/MultiDOM.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public SingleDOM loadDocument(String name) throws Exception {
SingleDOM doc = newDocument();
doc.setName(name);
doc.loadDocument(); // can throw Exception!
setActiveDocument(doc);
return doc;
}

Expand Down
66 changes: 59 additions & 7 deletions src/pooledit/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import attributetable.AttributeTable;
import attributetable.AttributeTableModel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -71,6 +72,8 @@
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.TreeSelectionEvent;
Expand Down Expand Up @@ -288,6 +291,7 @@ public void valueChanged(TreeSelectionEvent e) {
@Override
public void stateChanged(ChangeEvent e) {
objecttree.setActivePath(multidom.getActivePath());
model.setActivePath(multidom.getActivePath());
}
});

Expand Down Expand Up @@ -517,6 +521,23 @@ public void windowClosing(DockingWindow window) throws OperationAbortedException
// Add a mouse button listener that closes a window when it's
// clicked with the middle mouse button.
rootWindow.addTabMouseButtonListener(DockingWindowActionMouseButtonListener.MIDDLE_BUTTON_CLOSE_LISTENER);

rootWindow.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control Z"), "undo");
rootWindow.getActionMap().put("undo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
multidom.getActiveDocument().getTreeModel().undoAction();
}
});

rootWindow.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control Y"), "redo");
rootWindow.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control shift Z"), "redo");
rootWindow.getActionMap().put("redo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
multidom.getActiveDocument().getTreeModel().redoAction();
}
});
}

/**
Expand Down Expand Up @@ -614,8 +635,11 @@ private void showFrame() {
* Creates the frame tool bar.
* @return the frame tool bar
*/
private JToolBar createToolBar() {
JToolBar toolBar = new JToolBar();
private JPanel createToolBar() {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT));

JToolBar toolBarObjects = new JToolBar();

TransferHandler hnd = new TransferHandler("XML");
MouseListener listener = new MouseAdapter() {
Expand All @@ -630,10 +654,10 @@ public void mousePressed(MouseEvent evt) {
JLabel lbl = new DragLabel(Definitions.OBJECTS[i], libdoc);
lbl.setTransferHandler(hnd);
lbl.addMouseListener(listener);
Border bdr = BorderFactory.createRaisedBevelBorder();
Border bdr = BorderFactory.createRaisedBevelBorder();
lbl.setBorder(bdr);
toolBar.add(lbl);
toolBar.addSeparator(new Dimension(2, 1));
toolBarObjects.add(lbl);
toolBarObjects.addSeparator(new Dimension(2, 1));
}

/*
Expand All @@ -651,7 +675,35 @@ public DockingWindowDragger getDragger(MouseEvent mouseEvent) {
}
});
*/
return toolBar;

JToolBar toolBarTools = new JToolBar();

JButton btnUndo = new JButton("Undo");
btnUndo.setToolTipText("Undo");
btnUndo.setBorder(BorderFactory.createRaisedBevelBorder());
btnUndo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
multidom.getActiveDocument().getTreeModel().undoAction();
}
});
toolBarTools.add(btnUndo);

JButton btnRedo = new JButton("Redo");
btnRedo.setToolTipText("Redo");
btnRedo.setBorder(BorderFactory.createRaisedBevelBorder());
btnRedo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
multidom.getActiveDocument().getTreeModel().redoAction();
}
});
toolBarTools.add(btnRedo);

panel.add(toolBarObjects);
panel.add(toolBarTools);

return panel;
}

/**
Expand Down Expand Up @@ -1435,7 +1487,7 @@ public void actionPerformed(ActionEvent e) {
"3 of the License, or (at your option) any later version.",
" ",
"Authors:",
"Matti �hman (matti.ohman@aalto.fi)",
"Matti Ohman (matti.ohman@aalto.fi)",
"Jouko Kalmari"},
"About PoolEdit", JOptionPane.INFORMATION_MESSAGE, Icons.POOLEDIT_LOGO);
}
Expand Down
55 changes: 55 additions & 0 deletions src/treemodel/XMLTreeAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2020 Automation technology laboratory,
* Helsinki University of Technology
*
* Visit automation.tkk.fi for information about the automation
* technology laboratory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
package treemodel;

import javax.swing.tree.TreePath;
import org.w3c.dom.Element;

/**
*
* @author Alan Valmorbida
*/
public class XMLTreeAction {
public int type;
public Element elem;
public TreePath parentPath;
public Element nextSibling;
public String name;
public String newValue;
public String oldValue;

public static final int actionRemove = 0;
public static final int actionInsert = 1;
public static final int actionChange = 2;


public XMLTreeAction(int type, Element elem, TreePath parentPath, Element nextSibling, String name, String newValue, String oldValue) {
this.type = type;
this.elem = elem;
this.parentPath = parentPath;
this.nextSibling = nextSibling;
this.name = name;
this.newValue = newValue;
this.oldValue = oldValue;
}
}
Loading