mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
Ability to drag components directly from the tree to the canvas for
faster process
This commit is contained in:
@@ -279,8 +279,9 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
|||||||
*
|
*
|
||||||
* @param componentType
|
* @param componentType
|
||||||
* @param template
|
* @param template
|
||||||
|
* @param forceInstatiate
|
||||||
*/
|
*/
|
||||||
void setNewComponentTypeSlot(ComponentType componentType, Template template);
|
void setNewComponentTypeSlot(ComponentType componentType, Template template, boolean forceInstatiate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes default size notation, true for metric, false for imperial.
|
* Changes default size notation, true for metric, false for imperial.
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class InstantiationManager {
|
|||||||
this.potentialControlPoint = potentialControlPoint;
|
this.potentialControlPoint = potentialControlPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setComponentTypeSlot(ComponentType componentTypeSlot, Template template, Project currentProject)
|
public void setComponentTypeSlot(ComponentType componentTypeSlot, Template template, Project currentProject, boolean forceInstatiate)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
this.componentTypeSlot = componentTypeSlot;
|
this.componentTypeSlot = componentTypeSlot;
|
||||||
this.template = template;
|
this.template = template;
|
||||||
@@ -103,7 +103,7 @@ public class InstantiationManager {
|
|||||||
} else {
|
} else {
|
||||||
switch (componentTypeSlot.getCreationMethod()) {
|
switch (componentTypeSlot.getCreationMethod()) {
|
||||||
case POINT_BY_POINT:
|
case POINT_BY_POINT:
|
||||||
this.componentSlot = null;
|
this.componentSlot = forceInstatiate ? instantiateComponent(componentTypeSlot, template, new Point(0, 0), currentProject) : null;
|
||||||
break;
|
break;
|
||||||
case SINGLE_CLICK:
|
case SINGLE_CLICK:
|
||||||
this.componentSlot = instantiateComponent(componentTypeSlot, template, new Point(0, 0), currentProject);
|
this.componentSlot = instantiateComponent(componentTypeSlot, template, new Point(0, 0), currentProject);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
List<Version> allVersions = (List<Version>) xStream.fromXML(in);
|
List<Version> allVersions = (List<Version>) xStream.fromXML(in);
|
||||||
CURRENT_VERSION = allVersions.get(allVersions.size() - 1).getVersionNumber();
|
CURRENT_VERSION = allVersions.get(allVersions.size() - 1).getVersionNumber();
|
||||||
LOG.info("Current DIYLC version: " + CURRENT_VERSION);
|
LOG.info("Current DIYLC version: " + CURRENT_VERSION);
|
||||||
RECENT_VERSIONS = allVersions.subList(allVersions.size() - 3, allVersions.size());
|
RECENT_VERSIONS = allVersions.subList(allVersions.size() - 10, allVersions.size());
|
||||||
Collections.sort(RECENT_VERSIONS, new Comparator<Version>() {
|
Collections.sort(RECENT_VERSIONS, new Comparator<Version>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -571,9 +571,9 @@ public class Presenter implements IPlugInPort {
|
|||||||
editSelection();
|
editSelection();
|
||||||
}
|
}
|
||||||
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.CONTINUOUS_CREATION_KEY, false)) {
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.CONTINUOUS_CREATION_KEY, false)) {
|
||||||
setNewComponentTypeSlot(componentTypeSlot, template);
|
setNewComponentTypeSlot(componentTypeSlot, template, false);
|
||||||
} else {
|
} else {
|
||||||
setNewComponentTypeSlot(null, null);
|
setNewComponentTypeSlot(null, null, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case POINT_BY_POINT:
|
case POINT_BY_POINT:
|
||||||
@@ -595,33 +595,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
} else {
|
} else {
|
||||||
// On the second click, add the component to the
|
// On the second click, add the component to the
|
||||||
// project.
|
// project.
|
||||||
List<IDIYComponent<?>> componentSlot = instantiationManager.getComponentSlot();
|
addPendingComponentsToProject(scaledPoint, componentTypeSlot, template);
|
||||||
Point firstPoint = componentSlot.get(0).getControlPoint(0);
|
|
||||||
// don't allow to create component with the same points
|
|
||||||
if (scaledPoint.equals(firstPoint))
|
|
||||||
return;
|
|
||||||
componentSlot.get(0).setControlPoint(scaledPoint, 1);
|
|
||||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>();
|
|
||||||
for (IDIYComponent<?> component : componentSlot) {
|
|
||||||
addComponent(component, true);
|
|
||||||
// Select the new component if it's not locked and invisible.
|
|
||||||
if (!isComponentLocked(component) && isComponentVisible(component)) {
|
|
||||||
newSelection.add(component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSelection(newSelection);
|
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
|
||||||
|
|
||||||
if (componentTypeSlot.isAutoEdit()
|
|
||||||
&& ConfigurationManager.getInstance().readBoolean(IPlugInPort.AUTO_EDIT_KEY, false)) {
|
|
||||||
editSelection();
|
|
||||||
}
|
|
||||||
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.CONTINUOUS_CREATION_KEY, false)) {
|
|
||||||
setNewComponentTypeSlot(componentTypeSlot, template);
|
|
||||||
} else {
|
|
||||||
setNewComponentTypeSlot(null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -675,6 +649,36 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addPendingComponentsToProject(Point scaledPoint, ComponentType componentTypeSlot, Template template) {
|
||||||
|
List<IDIYComponent<?>> componentSlot = instantiationManager.getComponentSlot();
|
||||||
|
Point firstPoint = componentSlot.get(0).getControlPoint(0);
|
||||||
|
// don't allow to create component with the same points
|
||||||
|
if (scaledPoint == null || scaledPoint.equals(firstPoint))
|
||||||
|
return;
|
||||||
|
// componentSlot.get(0).setControlPoint(scaledPoint, 1);
|
||||||
|
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>();
|
||||||
|
for (IDIYComponent<?> component : componentSlot) {
|
||||||
|
addComponent(component, true);
|
||||||
|
// Select the new component if it's not locked and invisible.
|
||||||
|
if (!isComponentLocked(component) && isComponentVisible(component)) {
|
||||||
|
newSelection.add(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSelection(newSelection);
|
||||||
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
|
|
||||||
|
if (componentTypeSlot.isAutoEdit()
|
||||||
|
&& ConfigurationManager.getInstance().readBoolean(IPlugInPort.AUTO_EDIT_KEY, false)) {
|
||||||
|
editSelection();
|
||||||
|
}
|
||||||
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.CONTINUOUS_CREATION_KEY, false)) {
|
||||||
|
setNewComponentTypeSlot(componentTypeSlot, template, false);
|
||||||
|
} else {
|
||||||
|
setNewComponentTypeSlot(null, null, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int key, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
public boolean keyPressed(int key, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
||||||
if (key != VK_DOWN && key != VK_LEFT && key != VK_UP && key != VK_RIGHT && key != IKeyProcessor.VK_H
|
if (key != VK_DOWN && key != VK_LEFT && key != VK_UP && key != VK_RIGHT && key != IKeyProcessor.VK_H
|
||||||
@@ -1162,6 +1166,10 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED,
|
// messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED,
|
||||||
// selectionRect);
|
// selectionRect);
|
||||||
|
} else if (instantiationManager.getComponentSlot() != null) {
|
||||||
|
this.previousScaledPoint = scalePoint(point);
|
||||||
|
instantiationManager.updateSingleClick(previousScaledPoint, isSnapToGrid(),
|
||||||
|
currentProject.getGridSpacing());
|
||||||
}
|
}
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
return true;
|
return true;
|
||||||
@@ -1448,10 +1456,15 @@ public class Presenter implements IPlugInPort {
|
|||||||
@Override
|
@Override
|
||||||
public void dragEnded(Point point) {
|
public void dragEnded(Point point) {
|
||||||
LOG.debug(String.format("dragEnded(%s)", point));
|
LOG.debug(String.format("dragEnded(%s)", point));
|
||||||
|
|
||||||
|
Point scaledPoint = scalePoint(point);
|
||||||
|
|
||||||
if (!dragInProgress) {
|
if (!dragInProgress) {
|
||||||
|
if (instantiationManager.getComponentSlot() != null)
|
||||||
|
addPendingComponentsToProject(scaledPoint, instantiationManager.getComponentTypeSlot(), null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Point scaledPoint = scalePoint(point);
|
|
||||||
if (selectedComponents.isEmpty()) {
|
if (selectedComponents.isEmpty()) {
|
||||||
// If there's no selection finalize selectionRect and see which
|
// If there's no selection finalize selectionRect and see which
|
||||||
// components intersect with it.
|
// components intersect with it.
|
||||||
@@ -2113,11 +2126,11 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNewComponentTypeSlot(ComponentType componentType, Template template) {
|
public void setNewComponentTypeSlot(ComponentType componentType, Template template, boolean forceInstatiate) {
|
||||||
LOG.info(String.format("setNewComponentSlot(%s)", componentType == null ? null : componentType.getName()));
|
LOG.info(String.format("setNewComponentSlot(%s)", componentType == null ? null : componentType.getName()));
|
||||||
if (componentType != null && componentType.getInstanceClass() == null) {
|
if (componentType != null && componentType.getInstanceClass() == null) {
|
||||||
LOG.info("Cannot set new component type slot for type " + componentType.getName());
|
LOG.info("Cannot set new component type slot for type " + componentType.getName());
|
||||||
setNewComponentTypeSlot(null, null);
|
setNewComponentTypeSlot(null, null, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2135,10 +2148,13 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
instantiationManager.setComponentTypeSlot(componentType, template, currentProject);
|
instantiationManager.setComponentTypeSlot(componentType, template, currentProject, forceInstatiate);
|
||||||
if (componentType != null) {
|
|
||||||
|
if (forceInstatiate)
|
||||||
|
updateSelection(instantiationManager.getComponentSlot());
|
||||||
|
else if (componentType != null)
|
||||||
updateSelection(EMPTY_SELECTION);
|
updateSelection(EMPTY_SELECTION);
|
||||||
}
|
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||||
// selectedComponents);
|
// selectedComponents);
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
CanvasPanel.this.plugInPort.setNewComponentTypeSlot(null, null);
|
CanvasPanel.this.plugInPort.setNewComponentTypeSlot(null, null, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
for (Map.Entry<String, List<ComponentType>> entry : componentTypes.entrySet()) {
|
for (Map.Entry<String, List<ComponentType>> entry : componentTypes.entrySet()) {
|
||||||
for (ComponentType type : entry.getValue()) {
|
for (ComponentType type : entry.getValue()) {
|
||||||
if (type.getInstanceClass().getCanonicalName().equals(clazz)) {
|
if (type.getInstanceClass().getCanonicalName().equals(clazz)) {
|
||||||
CanvasPanel.this.plugInPort.setNewComponentTypeSlot(type, null);
|
CanvasPanel.this.plugInPort.setNewComponentTypeSlot(type, null, false);
|
||||||
// hack: fake mouse movement to repaint
|
// hack: fake mouse movement to repaint
|
||||||
CanvasPanel.this.plugInPort.mouseMoved(getMousePosition(), false, false, false);
|
CanvasPanel.this.plugInPort.mouseMoved(getMousePosition(), false, false, false);
|
||||||
return;
|
return;
|
||||||
@@ -201,7 +201,7 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
LOG.error("Could not find type: " + typeName);
|
LOG.error("Could not find type: " + typeName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.plugInPort.setNewComponentTypeSlot(type, null);
|
this.plugInPort.setNewComponentTypeSlot(type, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack: fake mouse movement to repaint
|
// hack: fake mouse movement to repaint
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class ComponentButtonFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
plugInPort.setNewComponentTypeSlot(componentType, null);
|
plugInPort.setNewComponentTypeSlot(componentType, null, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public class ComponentButtonFactory {
|
|||||||
newSelection.addAll(plugInPort.getSelectedComponents());
|
newSelection.addAll(plugInPort.getSelectedComponents());
|
||||||
}
|
}
|
||||||
plugInPort.updateSelection(newSelection);
|
plugInPort.updateSelection(newSelection);
|
||||||
plugInPort.setNewComponentTypeSlot(null, null);
|
plugInPort.setNewComponentTypeSlot(null, null, false);
|
||||||
plugInPort.refresh();
|
plugInPort.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ public class ComponentButtonFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
plugInPort.setNewComponentTypeSlot(componentType, variant);
|
plugInPort.setNewComponentTypeSlot(componentType, variant, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class ComponentTabbedPane extends JTabbedPane {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot(null, null);
|
ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot(null, null, false);
|
||||||
// Refresh recent components if needed
|
// Refresh recent components if needed
|
||||||
if (pendingRecentComponents != null) {
|
if (pendingRecentComponents != null) {
|
||||||
refreshRecentComponentsToolbar(getRecentToolbar(), pendingRecentComponents);
|
refreshRecentComponentsToolbar(getRecentToolbar(), pendingRecentComponents);
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||||
|
*
|
||||||
|
* This file is part of DIYLC.
|
||||||
|
*
|
||||||
|
* DIYLC 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.
|
||||||
|
*
|
||||||
|
* DIYLC 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 DIYLC. If not, see
|
||||||
|
* <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.diylc.swing.plugins.tree;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.dnd.DragGestureEvent;
|
||||||
|
import java.awt.dnd.DragGestureListener;
|
||||||
|
|
||||||
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.swing.plugins.canvas.EmptyTransferable;
|
||||||
|
import org.diylc.swing.plugins.tree.TreePanel.Payload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DragGestureListener} for {@link TreePanel}.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
|
class TreeGestureListener implements DragGestureListener {
|
||||||
|
|
||||||
|
private IPlugInPort presenter;
|
||||||
|
|
||||||
|
public TreeGestureListener(IPlugInPort presenter) {
|
||||||
|
super();
|
||||||
|
this.presenter = presenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dragGestureRecognized(DragGestureEvent dge) {
|
||||||
|
JTree tree = (JTree) dge.getComponent();
|
||||||
|
Point p = dge.getDragOrigin();
|
||||||
|
TreePath path = tree.getClosestPathForLocation(p.x, p.y);
|
||||||
|
if (path != null && path.getLastPathComponent() instanceof DefaultMutableTreeNode) {
|
||||||
|
DefaultMutableTreeNode leaf = (DefaultMutableTreeNode)path.getLastPathComponent();
|
||||||
|
Payload payload = (Payload) leaf.getUserObject();
|
||||||
|
if (payload != null) {
|
||||||
|
if (payload.getComponentType() != null)
|
||||||
|
presenter.setNewComponentTypeSlot(payload.getComponentType(), null, true);
|
||||||
|
else
|
||||||
|
payload.getClickListener().mouseClicked(null);
|
||||||
|
dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(), new TreeSourceListener(
|
||||||
|
presenter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,8 @@ import java.awt.Graphics;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.dnd.DnDConstants;
|
||||||
|
import java.awt.dnd.DragSource;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.FocusAdapter;
|
import java.awt.event.FocusAdapter;
|
||||||
@@ -167,6 +169,14 @@ public class TreePanel extends JPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
getTree().expandRow(0);
|
getTree().expandRow(0);
|
||||||
|
|
||||||
|
initializeDnD();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeDnD() {
|
||||||
|
// Initialize drag source recognizer.
|
||||||
|
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(getTree(),
|
||||||
|
DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK, new TreeGestureListener(plugInPort));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JScrollPane getTreeScroll() {
|
public JScrollPane getTreeScroll() {
|
||||||
@@ -226,7 +236,7 @@ public class TreePanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (plugInPort.getNewComponentTypeSlot() != componentType)
|
if (plugInPort.getNewComponentTypeSlot() != componentType)
|
||||||
plugInPort.setNewComponentTypeSlot(componentType, null);
|
plugInPort.setNewComponentTypeSlot(componentType, null, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final DefaultMutableTreeNode componentNode = new DefaultMutableTreeNode(payload, false);
|
final DefaultMutableTreeNode componentNode = new DefaultMutableTreeNode(payload, false);
|
||||||
@@ -289,7 +299,7 @@ public class TreePanel extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
plugInPort.setNewComponentTypeSlot(type, null);
|
plugInPort.setNewComponentTypeSlot(type, null, false);
|
||||||
}
|
}
|
||||||
}), false);
|
}), false);
|
||||||
categoryNode.add(componentNode);
|
categoryNode.add(componentNode);
|
||||||
@@ -710,7 +720,7 @@ public class TreePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugInPort.updateSelection(newSelection);
|
plugInPort.updateSelection(newSelection);
|
||||||
plugInPort.setNewComponentTypeSlot(null, null);
|
plugInPort.setNewComponentTypeSlot(null, null, false);
|
||||||
plugInPort.refresh();
|
plugInPort.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
DIY Layout Creator (DIYLC).
|
||||||
|
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||||
|
|
||||||
|
This file is part of DIYLC.
|
||||||
|
|
||||||
|
DIYLC 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.
|
||||||
|
|
||||||
|
DIYLC 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 DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.diylc.swing.plugins.tree;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.dnd.DragSourceDragEvent;
|
||||||
|
import java.awt.dnd.DragSourceDropEvent;
|
||||||
|
import java.awt.dnd.DragSourceEvent;
|
||||||
|
import java.awt.dnd.DragSourceListener;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DragSourceListener} for {@link TreePanel}.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
|
class TreeSourceListener implements DragSourceListener {
|
||||||
|
|
||||||
|
private IPlugInPort presenter;
|
||||||
|
|
||||||
|
public TreeSourceListener(IPlugInPort presenter) {
|
||||||
|
super();
|
||||||
|
this.presenter = presenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dragDropEnd(DragSourceDropEvent dsde) {
|
||||||
|
presenter.dragEnded(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dragEnter(DragSourceDragEvent dsde) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dragExit(DragSourceEvent dse) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dragOver(DragSourceDragEvent dsde) {
|
||||||
|
Point p = dsde.getDragSourceContext().getComponent().getMousePosition();
|
||||||
|
if (p != null) {
|
||||||
|
dsde.getDragSourceContext().getComponent().firePropertyChange("dragPoint", p.x, p.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dropActionChanged(DragSourceDragEvent dsde) {}
|
||||||
|
}
|
||||||
@@ -2358,6 +2358,10 @@
|
|||||||
<releaseDate>2019-01-28 00:00:00.000 CET</releaseDate>
|
<releaseDate>2019-01-28 00:00:00.000 CET</releaseDate>
|
||||||
<name></name>
|
<name></name>
|
||||||
<changes>
|
<changes>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Ability to drag components directly from the tree to the canvas for faster process</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>"Fuse Symbol" added</description>
|
<description>"Fuse Symbol" added</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user