mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
code cleanup
V1 file import - added support for more component types minor improvements
This commit is contained in:
@@ -25,7 +25,7 @@ public class PropertyWrapper implements Cloneable {
|
||||
private boolean changed = false;
|
||||
private String additionalOptions;
|
||||
private int sortOrder;
|
||||
private String[] listItems;
|
||||
private Object[] listItems;
|
||||
|
||||
public PropertyWrapper(String name, Class<?> type, String getter, String setter, boolean defaultable,
|
||||
IPropertyValidator validator, String additionalOptions, int sortOrder) {
|
||||
@@ -46,7 +46,7 @@ public class PropertyWrapper implements Cloneable {
|
||||
if (additionalOptions.startsWith(EditableProperty.DYNAMIC_LIST)) {
|
||||
String functionName = additionalOptions.substring(EditableProperty.DYNAMIC_LIST.length());
|
||||
Method listMethod = object.getClass().getMethod(functionName);
|
||||
listItems = (String[]) listMethod.invoke(object);
|
||||
listItems = (Object[]) listMethod.invoke(object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ public class PropertyWrapper implements Cloneable {
|
||||
return sortOrder;
|
||||
}
|
||||
|
||||
public String[] getListItems() {
|
||||
public Object[] getListItems() {
|
||||
return listItems;
|
||||
}
|
||||
|
||||
public void setOptions(String[] listItems) {
|
||||
public void setOptions(Object[] listItems) {
|
||||
this.listItems = listItems;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package org.diylc.core.annotations;
|
||||
|
||||
/**
|
||||
* Tells the system how to represent components in the B.O.M.
|
||||
*
|
||||
* @see ComponentDescriptor
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public enum BomPolicy {
|
||||
SHOW_ALL_NAMES, SHOW_ONLY_TYPE_NAME, NEVER_SHOW,
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
* Annotation for {@link IDIYComponent} implementation. Describes component properties.
|
||||
* Annotation that needs to be used for each {@link IDIYComponent} implementation. Describes
|
||||
* component properties and how component should be represented and interact with the rest of the
|
||||
* system.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,24 @@ import org.diylc.core.IPropertyValidator;
|
||||
/**
|
||||
* Used to annotate editable component property. Editable property XYZ must have both getter and
|
||||
* setter named <code>getXYZ</code> and <code>setXYZ</code> respectively and this annotation must be
|
||||
* placed on the getter method.
|
||||
* placed on the getter method. <br>
|
||||
* <br>
|
||||
* In the example below, {@code category} is the property we want to edit and
|
||||
* {@code getCategories()} provides a list of available values for category.
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* @EditableProperty(additionalOptions = EditableProperty.DYNAMIC_LIST
|
||||
* + "getCategories")
|
||||
* public String getCategory() {
|
||||
* return category;
|
||||
* }
|
||||
*
|
||||
* public String[] getCategories() {
|
||||
* return categories;
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,18 @@ import java.util.List;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
* Interface for creating components automatically each time a component is created by the user.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public interface IAutoCreator {
|
||||
|
||||
/**
|
||||
* @param lastAdded the component created by the user
|
||||
* @return {@link List} of {@link IDIYComponent}s that will be automatically created as a result.
|
||||
* Empty {@link List} or {@code null} are valid responses for cases when no components
|
||||
* should be auto-created.
|
||||
*/
|
||||
public List<IDIYComponent<?>> createIfNeeded(IDIYComponent<?> lastAdded);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package org.diylc.core.annotations;
|
||||
|
||||
/**
|
||||
* Tells the system how keywords should be extracted from a component.
|
||||
*
|
||||
* @see ComponentDescriptor
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public enum KeywordPolicy {
|
||||
/**
|
||||
* The component is represented with its type.
|
||||
|
||||
@@ -4,6 +4,12 @@ import org.diylc.core.IPropertyValidator;
|
||||
import org.diylc.core.ValidationException;
|
||||
import org.diylc.core.measures.AbstractMeasure;
|
||||
|
||||
/**
|
||||
* Validates any generic {@link AbstractMeasure} descendants and makes sure that the value is
|
||||
* positive.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class PositiveMeasureValidator implements IPropertyValidator {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,8 @@ import com.diyfever.httpproxy.ProxyFactory;
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class CloudPresenter {
|
||||
|
||||
public static final CloudPresenter Instance = new CloudPresenter();
|
||||
|
||||
private static String USERNAME_KEY = "cloud.Username";
|
||||
private static String TOKEN_KEY = "cloud.token";
|
||||
@@ -44,15 +46,11 @@ public class CloudPresenter {
|
||||
private String machineId;
|
||||
private String[] categories;
|
||||
|
||||
private CloudListener listener;
|
||||
|
||||
private boolean loggedIn = false;
|
||||
|
||||
private CloudPresenter() {}
|
||||
|
||||
public CloudPresenter(CloudListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public IServiceAPI getService() {
|
||||
private IServiceAPI getService() {
|
||||
if (service == null) {
|
||||
serviceUrl =
|
||||
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1");
|
||||
@@ -79,7 +77,6 @@ public class CloudPresenter {
|
||||
LOG.info("Login success");
|
||||
ConfigurationManager.getInstance().writeValue(USERNAME_KEY, username);
|
||||
ConfigurationManager.getInstance().writeValue(TOKEN_KEY, res);
|
||||
listener.loggedIn();
|
||||
this.loggedIn = true;
|
||||
return true;
|
||||
}
|
||||
@@ -102,7 +99,6 @@ public class CloudPresenter {
|
||||
return false;
|
||||
} else {
|
||||
LOG.info("Login success");
|
||||
listener.loggedIn();
|
||||
this.loggedIn = true;
|
||||
return true;
|
||||
}
|
||||
@@ -114,7 +110,6 @@ public class CloudPresenter {
|
||||
LOG.info("Logged out");
|
||||
ConfigurationManager.getInstance().writeValue(TOKEN_KEY, null);
|
||||
this.loggedIn = false;
|
||||
listener.loggedOut();
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
|
||||
+8
-11
@@ -6,16 +6,14 @@ import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||
|
||||
/**
|
||||
* Used to create paging of the search results. Use
|
||||
* {@link PagingProvider#startSession(String, String, String)} to start the search session and then
|
||||
* {@link PagingProvider#hasMoreData()} returns true if there's more data available and
|
||||
* {@link PagingProvider#requestMoreData()} returns the next page.
|
||||
* {@link SearchSession#startSession(String, String, String)} to start the search session and then
|
||||
* {@link SearchSession#hasMoreData()} returns true if there's more data available and
|
||||
* {@link SearchSession#requestMoreData()} returns the next page.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class PagingProvider {
|
||||
|
||||
private CloudPresenter cloudPresenter;
|
||||
|
||||
public class SearchSession {
|
||||
|
||||
private String searchFor;
|
||||
private String category;
|
||||
private String sort;
|
||||
@@ -24,8 +22,7 @@ public class PagingProvider {
|
||||
private int currentPage;
|
||||
private List<ProjectEntity> currentResults;
|
||||
|
||||
public PagingProvider(CloudPresenter cloudPresenter) {
|
||||
this.cloudPresenter = cloudPresenter;
|
||||
public SearchSession() {
|
||||
}
|
||||
|
||||
public List<ProjectEntity> startSession(String searchFor, String category, String sort) throws CloudException {
|
||||
@@ -34,7 +31,7 @@ public class PagingProvider {
|
||||
this.sort = sort;
|
||||
this.currentPage = 1;
|
||||
|
||||
return currentResults = cloudPresenter.search(searchFor, category, sort, currentPage, itemsPerPage);
|
||||
return currentResults = CloudPresenter.Instance.search(searchFor, category, sort, currentPage, itemsPerPage);
|
||||
}
|
||||
|
||||
public boolean hasMoreData() {
|
||||
@@ -43,6 +40,6 @@ public class PagingProvider {
|
||||
|
||||
public List<ProjectEntity> requestMoreData() throws CloudException {
|
||||
currentPage++;
|
||||
return currentResults = cloudPresenter.search(searchFor, category, sort, currentPage, itemsPerPage);
|
||||
return currentResults = CloudPresenter.Instance.search(searchFor, category, sort, currentPage, itemsPerPage);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class TraceCut extends AbstractComponent<Void> {
|
||||
private Color fillColor = FILL_COLOR;
|
||||
private Color borderColor = BORDER_COLOR;
|
||||
private Color boardColor = AbstractBoard.BOARD_COLOR;
|
||||
private Boolean cutBetweenHoles = true;
|
||||
private Boolean cutBetweenHoles = false;
|
||||
private Size holeSpacing = VeroBoard.SPACING;
|
||||
|
||||
protected Point point = new Point(0, 0);
|
||||
|
||||
+16
-2
@@ -49,6 +49,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
protected String name;
|
||||
protected ToggleSwitchType switchType = ToggleSwitchType.DPDT;
|
||||
private OrientationHV orientation = OrientationHV.VERTICAL;
|
||||
private Size spacing = SPACING;
|
||||
|
||||
public MiniToggleSwitch() {
|
||||
super();
|
||||
@@ -57,7 +58,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
|
||||
private void updateControlPoints() {
|
||||
Point firstPoint = controlPoints[0];
|
||||
int spacing = (int) SPACING.convertToPixels();
|
||||
int spacing = (int) getSpacing().convertToPixels();
|
||||
switch (switchType) {
|
||||
case SPST:
|
||||
controlPoints = new Point[] {firstPoint, new Point(firstPoint.x, firstPoint.y + spacing)};
|
||||
@@ -188,6 +189,19 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
// Reset body shape.
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Size getSpacing() {
|
||||
if (spacing == null) {
|
||||
spacing = SPACING;
|
||||
}
|
||||
return spacing;
|
||||
}
|
||||
|
||||
public void setSpacing(Size spacing) {
|
||||
this.spacing = spacing;
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
@@ -244,7 +258,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
if (body == null) {
|
||||
Point firstPoint = controlPoints[0];
|
||||
int margin = (int) MARGIN.convertToPixels();
|
||||
int spacing = (int) SPACING.convertToPixels();
|
||||
int spacing = (int) getSpacing().convertToPixels();
|
||||
switch (switchType) {
|
||||
case SPST:
|
||||
body =
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.apache.log4j.Logger;
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
@@ -23,6 +24,9 @@ import org.diylc.components.connectivity.CopperTrace;
|
||||
import org.diylc.components.connectivity.HookupWire;
|
||||
import org.diylc.components.connectivity.Jumper;
|
||||
import org.diylc.components.connectivity.SolderPad;
|
||||
import org.diylc.components.connectivity.TraceCut;
|
||||
import org.diylc.components.electromechanical.MiniToggleSwitch;
|
||||
import org.diylc.components.electromechanical.ToggleSwitchType;
|
||||
import org.diylc.components.misc.Label;
|
||||
import org.diylc.components.passive.PotentiometerPanel;
|
||||
import org.diylc.components.passive.RadialElectrolytic;
|
||||
@@ -32,6 +36,7 @@ import org.diylc.components.passive.Taper;
|
||||
import org.diylc.components.semiconductors.DIL_IC;
|
||||
import org.diylc.components.semiconductors.DiodePlastic;
|
||||
import org.diylc.components.semiconductors.LED;
|
||||
import org.diylc.components.semiconductors.SIL_IC;
|
||||
import org.diylc.components.semiconductors.TransistorTO92;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
@@ -149,6 +154,13 @@ public class V1FileParser implements IOldFileParser {
|
||||
}
|
||||
pad.setControlPoint(convertV1CoordinatesToV3Point(referencePoint, x1Attr, y1Attr), 0);
|
||||
component = pad;
|
||||
} else if (nodeName.equalsIgnoreCase("cut")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
TraceCut cut = new TraceCut();
|
||||
cut.setCutBetweenHoles(false);
|
||||
cut.setName(nameAttr);
|
||||
cut.setControlPoint(convertV1CoordinatesToV3Point(referencePoint, x1Attr, y1Attr), 0);
|
||||
component = cut;
|
||||
} else if (nodeName.equalsIgnoreCase("trace")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
CopperTrace trace = new CopperTrace();
|
||||
@@ -312,6 +324,95 @@ public class V1FileParser implements IOldFileParser {
|
||||
}
|
||||
ic.setValue(valueAttr);
|
||||
component = ic;
|
||||
} else if (nodeName.equalsIgnoreCase("switch")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
MiniToggleSwitch sw = new MiniToggleSwitch();
|
||||
int sizeX = Math.abs(x1Attr - x2Attr);
|
||||
int sizeY = Math.abs(y1Attr - y2Attr);
|
||||
ToggleSwitchType switchType = null;
|
||||
OrientationHV orientation = null;
|
||||
if (Math.min(sizeX, sizeY) == 0 && Math.max(sizeX, sizeY) == 1) {
|
||||
switchType = ToggleSwitchType.SPST;
|
||||
orientation = sizeX < sizeY ? OrientationHV.VERTICAL : OrientationHV.HORIZONTAL;
|
||||
}
|
||||
if (Math.min(sizeX, sizeY) == 0 && Math.max(sizeX, sizeY) == 2) {
|
||||
switchType = ToggleSwitchType.SPDT;
|
||||
orientation = sizeX < sizeY ? OrientationHV.VERTICAL : OrientationHV.HORIZONTAL;
|
||||
}
|
||||
if (Math.min(sizeX, sizeY) == 1 && Math.max(sizeX, sizeY) == 2) {
|
||||
switchType = ToggleSwitchType.DPDT;
|
||||
orientation = sizeX < sizeY ? OrientationHV.VERTICAL : OrientationHV.HORIZONTAL;
|
||||
}
|
||||
if (Math.min(sizeX, sizeY) == 2 && Math.max(sizeX, sizeY) == 2) {
|
||||
switchType = ToggleSwitchType._3PDT;
|
||||
orientation = OrientationHV.VERTICAL;
|
||||
}
|
||||
if (Math.min(sizeX, sizeY) == 2 && Math.max(sizeX, sizeY) == 3) {
|
||||
switchType = ToggleSwitchType._4PDT;
|
||||
orientation = sizeX < sizeY ? OrientationHV.HORIZONTAL : OrientationHV.VERTICAL;
|
||||
}
|
||||
if (Math.min(sizeX, sizeY) == 2 && Math.max(sizeX, sizeY) == 4) {
|
||||
switchType = ToggleSwitchType._5PDT;
|
||||
orientation = sizeX < sizeY ? OrientationHV.HORIZONTAL : OrientationHV.HORIZONTAL;
|
||||
}
|
||||
|
||||
if (switchType == null || orientation == null) {
|
||||
String message = "Unsupported toggle switch dimensions";
|
||||
LOG.debug(message);
|
||||
if (!warnings.contains(message)) {
|
||||
warnings.add(message);
|
||||
}
|
||||
} else {
|
||||
sw.setName(nameAttr);
|
||||
sw.setOrientation(orientation);
|
||||
sw.setValue(switchType);
|
||||
sw.setSpacing(new Size(0.1, SizeUnit.in));
|
||||
// compensate for potential negative coordinates after the type and orientation have
|
||||
// been set. Make sure that the top left corner is at (0, 0)
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
for (int j = 0; j < sw.getControlPointCount(); j++) {
|
||||
Point p = new Point(sw.getControlPoint(j));
|
||||
if (p.x < 0 && p.x < dx)
|
||||
dx = p.x;
|
||||
if (p.y < 0 && p.y < dy)
|
||||
dy = p.y;
|
||||
}
|
||||
// Translate control points.
|
||||
for (int j = 0; j < sw.getControlPointCount(); j++) {
|
||||
Point p = new Point(sw.getControlPoint(j));
|
||||
p.translate(Math.min(point1.x, point2.x) - dx, Math.min(point1.y, point2.y) - dy);
|
||||
sw.setControlPoint(p, j);
|
||||
}
|
||||
component = sw;
|
||||
}
|
||||
} else if (nodeName.equalsIgnoreCase("lineic")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
SIL_IC ic = new SIL_IC();
|
||||
int pinCount = 8;
|
||||
if (x1Attr == x2Attr && y1Attr < y2Attr) {
|
||||
pinCount = (y2Attr - y1Attr + 1);
|
||||
ic.setOrientation(Orientation.DEFAULT);
|
||||
} else if (x1Attr > x2Attr && y1Attr == y2Attr) {
|
||||
pinCount = (x1Attr - x2Attr + 1);
|
||||
ic.setOrientation(Orientation._90);
|
||||
} else if (x1Attr == x2Attr && y1Attr > y2Attr) {
|
||||
pinCount = (y1Attr - y2Attr + 1);
|
||||
ic.setOrientation(Orientation._180);
|
||||
} else if (x1Attr < x2Attr && y1Attr == y2Attr) {
|
||||
pinCount = (x2Attr - x1Attr + 1);
|
||||
ic.setOrientation(Orientation._270);
|
||||
}
|
||||
ic.setPinCount(SIL_IC.PinCount.valueOf("_" + pinCount));
|
||||
ic.setName(nameAttr);
|
||||
// Translate control points.
|
||||
for (int j = 0; j < ic.getControlPointCount(); j++) {
|
||||
Point p = new Point(ic.getControlPoint(j));
|
||||
p.translate(point1.x, point1.y);
|
||||
ic.setControlPoint(p, j);
|
||||
}
|
||||
ic.setValue(valueAttr);
|
||||
component = ic;
|
||||
} else if (nodeName.equalsIgnoreCase("pot")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
PotentiometerPanel pot = new PotentiometerPanel();
|
||||
|
||||
@@ -2,15 +2,12 @@ package org.diylc.parsing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.core.Project;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class V2FileParser implements IOldFileParser {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(V2FileParser.class);
|
||||
|
||||
// private static final Logger LOG = Logger.getLogger(V2FileParser.class);
|
||||
|
||||
@Override
|
||||
public boolean canParse(String version) {
|
||||
@@ -20,21 +17,22 @@ public class V2FileParser implements IOldFileParser {
|
||||
@Override
|
||||
public Project parseFile(Element root, List<String> warnings) {
|
||||
Project project = new Project();
|
||||
String projectName = root.getAttribute("projectName");
|
||||
String credits = root.getAttribute("credits");
|
||||
String width = root.getAttribute("width");
|
||||
String height = root.getAttribute("height");
|
||||
NodeList childNodes = root.getChildNodes();
|
||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||
Node node = childNodes.item(i);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (node.getNodeName().equalsIgnoreCase("component")) {
|
||||
LOG.debug(node.getAttributes().getNamedItem("name").getNodeValue());
|
||||
} else {
|
||||
LOG.debug("Unrecognized node name found: " + node.getNodeName());
|
||||
}
|
||||
}
|
||||
}
|
||||
warnings.add("V2 file parser is not yet implemented due to lack of interest and short life of DIYLC V2.");
|
||||
// String projectName = root.getAttribute("projectName");
|
||||
// String credits = root.getAttribute("credits");
|
||||
// String width = root.getAttribute("width");
|
||||
// String height = root.getAttribute("height");
|
||||
// NodeList childNodes = root.getChildNodes();
|
||||
// for (int i = 0; i < childNodes.getLength(); i++) {
|
||||
// Node node = childNodes.item(i);
|
||||
// if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
// if (node.getNodeName().equalsIgnoreCase("component")) {
|
||||
// LOG.debug(node.getAttributes().getNamedItem("name").getNodeValue());
|
||||
// } else {
|
||||
// LOG.debug("Unrecognized node name found: " + node.getNodeName());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry kind="lib" path="lib/swing-framework.jar"/>
|
||||
<classpathentry kind="lib" path="library/main.jar"/>
|
||||
<classpathentry kind="lib" path="library/main.jar" sourcepath="/diylc-library"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_45"/>
|
||||
|
||||
@@ -12,6 +12,11 @@ import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.AbstractMeasure;
|
||||
|
||||
/**
|
||||
* Based on {@link PropertyWrapper#getType()}, creates an appropriate {@link Component} that can edit that type.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class FieldEditorFactory {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(FieldEditorFactory.class);
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
@@ -22,11 +24,14 @@ public class MultiLineStringEditor extends JScrollPane {
|
||||
|
||||
private final PropertyWrapper property;
|
||||
|
||||
private static final Border border = new JTextField().getBorder();
|
||||
|
||||
public MultiLineStringEditor(PropertyWrapper property) {
|
||||
super();
|
||||
this.property = property;
|
||||
setViewportView(getTextArea());
|
||||
setPreferredSize(new Dimension(192, 64));
|
||||
setBorder(border);
|
||||
}
|
||||
|
||||
public JTextArea getTextArea() {
|
||||
|
||||
@@ -52,21 +52,6 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
|
||||
layoutGui();
|
||||
setLocationRelativeTo(owner);
|
||||
//
|
||||
// setModal(true);
|
||||
//
|
||||
// JPanel holderPanel = new JPanel();
|
||||
// holderPanel.setLayout(new BorderLayout());
|
||||
// holderPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
||||
//
|
||||
// holderPanel.add(createEditorFields(), BorderLayout.CENTER);
|
||||
// holderPanel.add(createButtonPanel(), BorderLayout.SOUTH);
|
||||
//
|
||||
// setContentPane(holderPanel);
|
||||
//
|
||||
//
|
||||
// pack();
|
||||
// setLocationRelativeTo(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,15 +148,6 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
return defaultedProperties;
|
||||
}
|
||||
|
||||
public static boolean showFor(JFrame owner, List<PropertyWrapper> properties, String title) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title);
|
||||
editor.setVisible(true);
|
||||
if (OK.equals(editor.getSelectedButtonCaption())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
if (b && componentToFocus != null) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.diylc.common.ITask;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.plugins.cloud.presenter.CloudException;
|
||||
import org.diylc.plugins.cloud.presenter.CloudListener;
|
||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
@@ -30,7 +29,7 @@ import org.diylc.swing.plugins.cloud.view.browser.UploadManagerFrame;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
public class CloudPlugIn implements IPlugIn {
|
||||
|
||||
private static final String ONLINE_TITLE = "Project Cloud";
|
||||
|
||||
@@ -39,7 +38,6 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
private ISwingUI swingUI;
|
||||
private IPlugInPort plugInPort;
|
||||
private IPlugInPort thumbnailPresenter;
|
||||
private CloudPresenter cloudPresenter;
|
||||
|
||||
private LibraryAction libraryAction;
|
||||
|
||||
@@ -81,7 +79,6 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
this.cloudPresenter = new CloudPresenter(this);
|
||||
|
||||
initialize();
|
||||
}
|
||||
@@ -91,7 +88,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
@Override
|
||||
public Boolean doInBackground() throws Exception {
|
||||
return cloudPresenter.tryLogInWithToken();
|
||||
return CloudPresenter.Instance.tryLogInWithToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,13 +110,13 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
public CloudBrowserFrame getCloudBrowser() {
|
||||
if (cloudBrowser == null) {
|
||||
cloudBrowser = new CloudBrowserFrame(swingUI, plugInPort, cloudPresenter);
|
||||
cloudBrowser = new CloudBrowserFrame(swingUI, plugInPort);
|
||||
}
|
||||
return cloudBrowser;
|
||||
}
|
||||
|
||||
public UploadManagerFrame createUploadManagerFrame() {
|
||||
return new UploadManagerFrame(swingUI, plugInPort, cloudPresenter);
|
||||
return new UploadManagerFrame(swingUI, plugInPort);
|
||||
}
|
||||
|
||||
public LibraryAction getLibraryAction() {
|
||||
@@ -220,11 +217,12 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
dialog.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(dialog.getSelectedButtonCaption())) {
|
||||
try {
|
||||
if (cloudPresenter.logIn(dialog.getUserName(), dialog.getPassword())) {
|
||||
if (CloudPresenter.Instance.logIn(dialog.getUserName(), dialog.getPassword())) {
|
||||
swingUI
|
||||
.showMessage(
|
||||
"You have successfully logged into the system. You will remain logged in from this machine until logged out.",
|
||||
"Login Successful", IView.INFORMATION_MESSAGE);
|
||||
loggedIn();
|
||||
break;
|
||||
} else {
|
||||
swingUI.showMessage(
|
||||
@@ -252,7 +250,8 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
cloudPresenter.logOut();
|
||||
CloudPresenter.Instance.logOut();
|
||||
loggedOut();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +274,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
cloudPresenter.createUserAccount(dialog.getUserName(), dialog.getPassword(), dialog.getEmail(),
|
||||
CloudPresenter.Instance.createUserAccount(dialog.getUserName(), dialog.getPassword(), dialog.getEmail(),
|
||||
dialog.getWebsite(), dialog.getBio());
|
||||
return null;
|
||||
}
|
||||
@@ -308,14 +307,14 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
final UserEditDialog dialog = DialogFactory.getInstance().createUserEditDialog(cloudPresenter.getUserDetails());
|
||||
final UserEditDialog dialog = DialogFactory.getInstance().createUserEditDialog(CloudPresenter.Instance.getUserDetails());
|
||||
dialog.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(dialog.getSelectedButtonCaption())) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
cloudPresenter.updateUserDetails(dialog.getEmail(), dialog.getWebsite(), dialog.getBio());
|
||||
CloudPresenter.Instance.updateUserDetails(dialog.getEmail(), dialog.getWebsite(), dialog.getBio());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -357,7 +356,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
cloudPresenter.updatePassword(dialog.getOldPassword(), dialog.getNewPassword());
|
||||
CloudPresenter.Instance.updatePassword(dialog.getOldPassword(), dialog.getNewPassword());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -400,7 +399,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
public String[] doInBackground() throws Exception {
|
||||
LOG.debug("Uploading from " + file.getAbsolutePath());
|
||||
thumbnailPresenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
return cloudPresenter.getCategories();
|
||||
return CloudPresenter.Instance.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -417,7 +416,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
cloudPresenter.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
||||
CloudPresenter.Instance.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
||||
dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(), thumbnailFile, file,
|
||||
null);
|
||||
return null;
|
||||
@@ -471,7 +470,6 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loggedIn() {
|
||||
getLoginAction().setEnabled(false);
|
||||
getCreateAccountAction().setEnabled(false);
|
||||
@@ -482,7 +480,6 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
getManageProjectsAction().setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loggedOut() {
|
||||
getLoginAction().setEnabled(true);
|
||||
getCreateAccountAction().setEnabled(true);
|
||||
|
||||
@@ -42,7 +42,6 @@ public class CommentDialog extends JDialog {
|
||||
|
||||
private ProjectEntity project;
|
||||
private List<CommentEntity> comments;
|
||||
private CloudPresenter presenter;
|
||||
|
||||
private JPanel mainPanel;
|
||||
private JPanel listPanel;
|
||||
@@ -53,19 +52,17 @@ public class CommentDialog extends JDialog {
|
||||
|
||||
private ISimpleView cloudUI;
|
||||
|
||||
public CommentDialog(ISimpleView cloudUI, ProjectEntity project, List<CommentEntity> comments,
|
||||
CloudPresenter presenter) {
|
||||
public CommentDialog(ISimpleView cloudUI, ProjectEntity project, List<CommentEntity> comments) {
|
||||
super(cloudUI.getOwnerFrame(), "Comments on " + project.getName());
|
||||
this.project = project;
|
||||
this.comments = comments;
|
||||
this.presenter = presenter;
|
||||
this.cloudUI = cloudUI;
|
||||
setMinimumSize(new Dimension(400, 600));
|
||||
setContentPane(getMainPanel());
|
||||
pack();
|
||||
setLocationRelativeTo(cloudUI.getOwnerFrame());
|
||||
setModal(true);
|
||||
if (!presenter.isLoggedIn()) {
|
||||
if (!CloudPresenter.Instance.isLoggedIn()) {
|
||||
getReplyArea().setEnabled(false);
|
||||
getReplyArea().setText("Must be logged in to reply.");
|
||||
getSendButton().setEnabled(false);
|
||||
@@ -148,7 +145,7 @@ public class CommentDialog extends JDialog {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
presenter.postComment(project.getId(), comment);
|
||||
CloudPresenter.Instance.postComment(project.getId(), comment);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -162,7 +159,7 @@ public class CommentDialog extends JDialog {
|
||||
getReplyArea().setText("");
|
||||
CommentEntity newComment = new CommentEntity();
|
||||
newComment.setPostedAt(JUST_NOW);
|
||||
newComment.setUsername(presenter.getCurrentUsername());
|
||||
newComment.setUsername(CloudPresenter.Instance.getCurrentUsername());
|
||||
newComment.setComment(comment);
|
||||
addComment(newComment).requestFocusInWindow();
|
||||
getListPanel().revalidate();
|
||||
|
||||
@@ -34,6 +34,7 @@ public class UserEditDialog extends ButtonDialog {
|
||||
private JTextField emailField;
|
||||
private JTextField websiteField;
|
||||
private JTextArea bioArea;
|
||||
private JScrollPane bioPane;
|
||||
|
||||
private String userName;
|
||||
private String password;
|
||||
@@ -130,7 +131,7 @@ public class UserEditDialog extends ButtonDialog {
|
||||
|
||||
gbc.gridy = 5;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
mainPanel.add(new JScrollPane(getBioArea()), gbc);
|
||||
mainPanel.add(getBioPane(), gbc);
|
||||
}
|
||||
return mainPanel;
|
||||
}
|
||||
@@ -254,7 +255,7 @@ public class UserEditDialog extends ButtonDialog {
|
||||
return emailField;
|
||||
}
|
||||
|
||||
public JTextField getWebsiteField() {
|
||||
private JTextField getWebsiteField() {
|
||||
if (websiteField == null) {
|
||||
websiteField = new JTextField();
|
||||
if (existingEntity != null)
|
||||
@@ -280,14 +281,23 @@ public class UserEditDialog extends ButtonDialog {
|
||||
return websiteField;
|
||||
}
|
||||
|
||||
public JTextArea getBioArea() {
|
||||
private JScrollPane getBioPane() {
|
||||
if (bioPane == null) {
|
||||
bioPane = new JScrollPane(getBioArea());
|
||||
bioPane.setPreferredSize(new Dimension(192, 64));
|
||||
bioPane.setBorder(getBioArea().getBorder());
|
||||
getBioArea().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
}
|
||||
return bioPane;
|
||||
}
|
||||
|
||||
private JTextArea getBioArea() {
|
||||
if (bioArea == null) {
|
||||
bioArea = new HTMLTextArea();
|
||||
if (existingEntity != null)
|
||||
bioArea.setText(existingEntity.getBio());
|
||||
bioArea.setFont(getUserNameField().getFont());
|
||||
bioArea.setBorder(getUserNameField().getBorder());
|
||||
bioArea.setPreferredSize(new Dimension(192, 69));
|
||||
bioArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
|
||||
+7
-9
@@ -27,7 +27,7 @@ import org.diylc.core.IView;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||
import org.diylc.plugins.cloud.presenter.PagingProvider;
|
||||
import org.diylc.plugins.cloud.presenter.SearchSession;
|
||||
import org.diylc.swing.ISimpleView;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.utils.Pair;
|
||||
@@ -54,19 +54,17 @@ public class CloudBrowserFrame extends JFrame implements ISimpleView {
|
||||
private ResultsScrollPanel resultsScrollPane;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private CloudPresenter cloudPresenter;
|
||||
private PagingProvider pagingProvider;
|
||||
private SearchSession searchSession;
|
||||
|
||||
private ISwingUI swingUI;
|
||||
|
||||
public CloudBrowserFrame(ISwingUI swingUI, IPlugInPort plugInPort, CloudPresenter cloudPresenter) {
|
||||
public CloudBrowserFrame(ISwingUI swingUI, IPlugInPort plugInPort) {
|
||||
super(TITLE);
|
||||
this.swingUI = swingUI;
|
||||
this.setIconImage(IconLoader.Cloud.getImage());
|
||||
this.setPreferredSize(new Dimension(700, 640));
|
||||
this.plugInPort = plugInPort;
|
||||
this.cloudPresenter = cloudPresenter;
|
||||
this.pagingProvider = new PagingProvider(cloudPresenter);
|
||||
this.searchSession = new SearchSession();
|
||||
|
||||
setContentPane(getSearchPanel());
|
||||
this.pack();
|
||||
@@ -85,7 +83,7 @@ public class CloudBrowserFrame extends JFrame implements ISimpleView {
|
||||
|
||||
@Override
|
||||
public Pair<String[], String[]> doInBackground() throws Exception {
|
||||
return new Pair<String[], String[]>(cloudPresenter.getCategories(), cloudPresenter.getSortings());
|
||||
return new Pair<String[], String[]>(CloudPresenter.Instance.getCategories(), CloudPresenter.Instance.getSortings());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,7 +179,7 @@ public class CloudBrowserFrame extends JFrame implements ISimpleView {
|
||||
|
||||
private ResultsScrollPanel getResultsScrollPane() {
|
||||
if (resultsScrollPane == null) {
|
||||
resultsScrollPane = new ResultsScrollPanel(swingUI, this, plugInPort, pagingProvider, cloudPresenter, false);
|
||||
resultsScrollPane = new ResultsScrollPanel(swingUI, this, plugInPort, searchSession, false);
|
||||
}
|
||||
return resultsScrollPane;
|
||||
}
|
||||
@@ -192,7 +190,7 @@ public class CloudBrowserFrame extends JFrame implements ISimpleView {
|
||||
|
||||
@Override
|
||||
public List<ProjectEntity> doInBackground() throws Exception {
|
||||
return pagingProvider.startSession(getSearchHeaderPanel().getSearchText(),
|
||||
return searchSession.startSession(getSearchHeaderPanel().getSearchText(),
|
||||
getSearchHeaderPanel().getCategory(), getSearchHeaderPanel().getSorting());
|
||||
}
|
||||
|
||||
|
||||
+19
-22
@@ -42,7 +42,7 @@ import org.diylc.images.IconLoader;
|
||||
import org.diylc.plugins.cloud.model.CommentEntity;
|
||||
import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||
import org.diylc.plugins.cloud.presenter.PagingProvider;
|
||||
import org.diylc.plugins.cloud.presenter.SearchSession;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ISimpleView;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
@@ -59,7 +59,7 @@ import org.diylc.swingframework.ButtonDialog;
|
||||
* Component that is capable of showing a list of {@link ProjectEntity} objects. Can work in paging
|
||||
* mode and pull one page of data at a time.
|
||||
*
|
||||
* @see {@link PagingProvider}
|
||||
* @see {@link SearchSession}
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
@@ -88,22 +88,19 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
* This flag tells us whether the loadMoreLabel should invoke a new data pull or not.
|
||||
*/
|
||||
private boolean armed;
|
||||
private PagingProvider provider;
|
||||
|
||||
private CloudPresenter cloudPresenter;
|
||||
|
||||
private SearchSession searchSession;
|
||||
|
||||
private Icon spinnerIcon = IconLoader.Spinning.getIcon();
|
||||
|
||||
private boolean showEditControls;
|
||||
|
||||
public ResultsScrollPanel(ISwingUI mainUI, ISimpleView cloudUI, IPlugInPort plugInPort, PagingProvider provider,
|
||||
CloudPresenter cloudPresenter, boolean showEditControls) {
|
||||
public ResultsScrollPanel(ISwingUI mainUI, ISimpleView cloudUI, IPlugInPort plugInPort, SearchSession searchSession,
|
||||
boolean showEditControls) {
|
||||
super();
|
||||
this.mainUI = mainUI;
|
||||
this.cloudUI = cloudUI;
|
||||
this.plugInPort = plugInPort;
|
||||
this.provider = provider;
|
||||
this.cloudPresenter = cloudPresenter;
|
||||
this.searchSession = searchSession;
|
||||
this.showEditControls = showEditControls;
|
||||
|
||||
this.getVerticalScrollBar().setUnitIncrement(16);
|
||||
@@ -174,7 +171,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
getViewport().setViewPosition(old);
|
||||
}
|
||||
});
|
||||
if (provider != null && provider.hasMoreData()) {
|
||||
if (searchSession != null && searchSession.hasMoreData()) {
|
||||
getLoadMoreLabel().setText("Querying the cloud for more results...");
|
||||
getLoadMoreLabel().setIcon(spinnerIcon);
|
||||
} else {
|
||||
@@ -211,7 +208,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
|
||||
@Override
|
||||
public List<CommentEntity> doInBackground() throws Exception {
|
||||
return cloudPresenter.getComments(project.getId());
|
||||
return CloudPresenter.Instance.getComments(project.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,7 +219,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
|
||||
@Override
|
||||
public void complete(List<CommentEntity> result) {
|
||||
CommentDialog dialog = new CommentDialog(cloudUI, project, result, cloudPresenter);
|
||||
CommentDialog dialog = new CommentDialog(cloudUI, project, result);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -320,7 +317,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
editButton.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
List<PropertyWrapper> projectProperties = cloudPresenter.getProjectProperties(project);
|
||||
List<PropertyWrapper> projectProperties = CloudPresenter.Instance.getProjectProperties(project);
|
||||
PropertyEditorDialog editor =
|
||||
DialogFactory.getInstance().createPropertyEditorDialog(cloudUI.getOwnerFrame(), projectProperties,
|
||||
"Edit Published Project");
|
||||
@@ -341,8 +338,8 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
|
||||
@Override
|
||||
public ProjectEntity doInBackground() throws Exception {
|
||||
cloudPresenter.updateProjectDetails(project, plugInPort.getCurrentVersionNumber().toString());
|
||||
return cloudPresenter.fetchUserUploads(project.getId()).get(0);
|
||||
CloudPresenter.Instance.updateProjectDetails(project, plugInPort.getCurrentVersionNumber().toString());
|
||||
return CloudPresenter.Instance.fetchUserUploads(project.getId()).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -389,7 +386,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
public String[] doInBackground() throws Exception {
|
||||
LOG.debug("Uploading from " + file.getAbsolutePath());
|
||||
thumbnailPresenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
return cloudPresenter.getCategories();
|
||||
return CloudPresenter.Instance.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -406,10 +403,10 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
|
||||
@Override
|
||||
public ProjectEntity doInBackground() throws Exception {
|
||||
cloudPresenter.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
||||
CloudPresenter.Instance.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
||||
dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(), thumbnailFile,
|
||||
file, project.getId());
|
||||
return cloudPresenter.fetchUserUploads(project.getId()).get(0);
|
||||
return CloudPresenter.Instance.fetchUserUploads(project.getId()).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -463,7 +460,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
cloudPresenter.deleteProject(project.getId());
|
||||
CloudPresenter.Instance.deleteProject(project.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -601,14 +598,14 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
if (armed && provider != null && provider.hasMoreData()) {
|
||||
if (armed && searchSession != null && searchSession.hasMoreData()) {
|
||||
// disarm immediately so we don't trigger successive requests to the provider
|
||||
armed = false;
|
||||
SwingWorker<List<ProjectEntity>, Void> worker = new SwingWorker<List<ProjectEntity>, Void>() {
|
||||
|
||||
@Override
|
||||
protected List<ProjectEntity> doInBackground() throws Exception {
|
||||
return provider.requestMoreData();
|
||||
return searchSession.requestMoreData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-5
@@ -29,17 +29,15 @@ public class UploadManagerFrame extends JFrame implements ISimpleView {
|
||||
private ResultsScrollPanel resultsScrollPane;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private CloudPresenter cloudPresenter;
|
||||
|
||||
private ISwingUI swingUI;
|
||||
|
||||
public UploadManagerFrame(ISwingUI swingUI, IPlugInPort plugInPort, CloudPresenter cloudPresenter) {
|
||||
public UploadManagerFrame(ISwingUI swingUI, IPlugInPort plugInPort) {
|
||||
super(TITLE);
|
||||
this.swingUI = swingUI;
|
||||
this.setIconImage(IconLoader.CloudGear.getImage());
|
||||
this.setPreferredSize(new Dimension(700, 640));
|
||||
this.plugInPort = plugInPort;
|
||||
this.cloudPresenter = cloudPresenter;
|
||||
|
||||
setContentPane(getResultsScrollPane());
|
||||
this.pack();
|
||||
@@ -51,7 +49,7 @@ public class UploadManagerFrame extends JFrame implements ISimpleView {
|
||||
|
||||
private ResultsScrollPanel getResultsScrollPane() {
|
||||
if (resultsScrollPane == null) {
|
||||
resultsScrollPane = new ResultsScrollPanel(swingUI, this, plugInPort, null, cloudPresenter, true);
|
||||
resultsScrollPane = new ResultsScrollPanel(swingUI, this, plugInPort, null, true);
|
||||
}
|
||||
return resultsScrollPane;
|
||||
}
|
||||
@@ -62,7 +60,7 @@ public class UploadManagerFrame extends JFrame implements ISimpleView {
|
||||
|
||||
@Override
|
||||
public List<ProjectEntity> doInBackground() throws Exception {
|
||||
return cloudPresenter.fetchUserUploads(null);
|
||||
return CloudPresenter.Instance.fetchUserUploads(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1362,6 +1362,14 @@
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Make order of items in the 'Edit Project' dialog more logical</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Better support for V1 file import</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Toggle switch spacing can be changed</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Allow multi-line project description</description>
|
||||
|
||||
Reference in New Issue
Block a user