mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
refactored component framework
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ class CanvasTargetListener implements DropTargetListener {
|
||||
// (t.isDataFlavorSupported(SelectionTransferable.selectionFlavor))
|
||||
// {
|
||||
// if (currentPoint != null) {
|
||||
// List<IComponentInstance> selection = (List<IComponentInstance>) t
|
||||
// List<IDIYComponent> selection = (List<IDIYComponent>) t
|
||||
// .getTransferData(SelectionTransferable.selectionFlavor);
|
||||
// Point startPoint = (Point) t
|
||||
// .getTransferData(PointTransferable.pointFlavor);
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.core.IComponentInstance;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
|
||||
public class SelectionTransferable implements Transferable {
|
||||
@@ -16,9 +16,9 @@ public class SelectionTransferable implements Transferable {
|
||||
"Component Selection");
|
||||
|
||||
private Point startPoint;
|
||||
private List<IComponentInstance> selection;
|
||||
private List<IDIYComponent> selection;
|
||||
|
||||
public SelectionTransferable(List<IComponentInstance> selection, Point startPoint) {
|
||||
public SelectionTransferable(List<IDIYComponent> selection, Point startPoint) {
|
||||
super();
|
||||
this.selection = selection;
|
||||
this.startPoint = startPoint;
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import org.diylc.common.ComponentSelection;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IComponentInstance;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.images.IconLoader;
|
||||
|
||||
@@ -163,7 +163,7 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Paste triggered");
|
||||
try {
|
||||
List<IComponentInstance> components = (List<IComponentInstance>) clipboard
|
||||
List<IDIYComponent> components = (List<IDIYComponent>) clipboard
|
||||
.getData(ComponentSelection.listFlavor);
|
||||
plugInPort.addComponents(cloner.deepClone(components), null);
|
||||
} catch (Exception ex) {
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.diylc.core.IComponentInstance;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ public class BomMaker {
|
||||
private BomMaker() {
|
||||
}
|
||||
|
||||
public List<BomEntry> createBom(List<IComponentInstance> components) {
|
||||
public List<BomEntry> createBom(List<IDIYComponent> components) {
|
||||
Map<String, BomEntry> entryMap = new HashMap<String, BomEntry>();
|
||||
for (IComponentInstance component : components) {
|
||||
for (IDIYComponent component : components) {
|
||||
String name = ComponentProcessor.getInstance().extractBomName(component);
|
||||
String value = ComponentProcessor.getInstance().extractBomValue(component);
|
||||
if ((name != null) && (value != null)) {
|
||||
|
||||
+8
-8
@@ -21,9 +21,9 @@ import org.diylc.common.ControlPointWrapper;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IComponentInstance;
|
||||
import org.diylc.core.IComponentType;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
import org.diylc.presenter.ComponentType;
|
||||
|
||||
import com.diyfever.gui.MemoryBar;
|
||||
import com.diyfever.gui.miscutils.PercentageListCellRenderer;
|
||||
@@ -41,8 +41,8 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
// State variables
|
||||
private IComponentType componentSlot;
|
||||
private List<IComponentInstance> componentsUnderCursor;
|
||||
private ComponentType componentSlot;
|
||||
private List<IDIYComponent> componentsUnderCursor;
|
||||
|
||||
public StatusBar() {
|
||||
super();
|
||||
@@ -159,12 +159,12 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
}
|
||||
break;
|
||||
case SLOT_CHANGED:
|
||||
componentSlot = (IComponentType) params[0];
|
||||
componentSlot = (ComponentType) params[0];
|
||||
refreshStatusText();
|
||||
break;
|
||||
case AVAILABLE_CTRL_POINTS_CHANGED:
|
||||
componentsUnderCursor = new ArrayList<IComponentInstance>(
|
||||
((Map<IComponentInstance, ControlPointWrapper>) params[0]).keySet());
|
||||
componentsUnderCursor = new ArrayList<IDIYComponent>(
|
||||
((Map<IDIYComponent, ControlPointWrapper>) params[0]).keySet());
|
||||
refreshStatusText();
|
||||
break;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
} else {
|
||||
// String formattedNames = "";
|
||||
// int n = 1;
|
||||
// for (IComponentInstance component : componentsUnderCursor) {
|
||||
// for (IDIYComponent component : componentsUnderCursor) {
|
||||
// if (n > 1) {
|
||||
// formattedNames += ", ";
|
||||
// }
|
||||
|
||||
+5
-8
@@ -8,8 +8,7 @@ import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IComponentType;
|
||||
|
||||
import org.diylc.presenter.ComponentType;
|
||||
|
||||
/**
|
||||
* {@link JButton} that displays component type icon and instantiates the
|
||||
@@ -22,9 +21,9 @@ class ComponentButton extends JButton {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private IComponentType componentType;
|
||||
private ComponentType componentType;
|
||||
|
||||
public ComponentButton(final IPlugInPort plugInPort, final IComponentType componentType) {
|
||||
public ComponentButton(final IPlugInPort plugInPort, final ComponentType componentType) {
|
||||
super(componentType.getIcon());
|
||||
this.plugInPort = plugInPort;
|
||||
this.componentType = componentType;
|
||||
@@ -59,10 +58,8 @@ class ComponentButton extends JButton {
|
||||
|
||||
private void initializeDnD() {
|
||||
// Initialize drag source recognizer.
|
||||
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
|
||||
this,
|
||||
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this,
|
||||
DnDConstants.ACTION_MOVE,
|
||||
new ToolboxGestureListener(plugInPort, componentType.getComponentInstanceClass()
|
||||
.getName()));
|
||||
new ToolboxGestureListener(plugInPort, componentType.getInstanceClass().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -9,7 +9,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IComponentType;
|
||||
import org.diylc.presenter.ComponentType;
|
||||
|
||||
|
||||
class ComponentTabbedPane extends JTabbedPane {
|
||||
@@ -20,16 +20,16 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
public ComponentTabbedPane(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
Map<String, List<IComponentType>> componentTypes = plugInPort.getComponentTypes();
|
||||
for (Map.Entry<String, List<IComponentType>> entry : componentTypes.entrySet()) {
|
||||
Map<String, List<ComponentType>> componentTypes = plugInPort.getComponentTypes();
|
||||
for (Map.Entry<String, List<ComponentType>> entry : componentTypes.entrySet()) {
|
||||
addTab(entry.getKey(), createComponentPanel(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private Container createComponentPanel(List<IComponentType> componentTypes) {
|
||||
private Container createComponentPanel(List<ComponentType> componentTypes) {
|
||||
Container componentPanel = new Container();
|
||||
componentPanel.setLayout(new BoxLayout(componentPanel, BoxLayout.X_AXIS));
|
||||
for (IComponentType componentType : componentTypes) {
|
||||
for (ComponentType componentType : componentTypes) {
|
||||
JButton button = new ComponentButton(plugInPort, componentType);
|
||||
componentPanel.add(button);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user