diff --git a/diylc/diylc-core/src/org/diylc/common/PropertyWrapper.java b/diylc/diylc-core/src/org/diylc/common/PropertyWrapper.java
index 07b2ad39..4c32552f 100644
--- a/diylc/diylc-core/src/org/diylc/common/PropertyWrapper.java
+++ b/diylc/diylc-core/src/org/diylc/common/PropertyWrapper.java
@@ -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;
}
diff --git a/diylc/diylc-core/src/org/diylc/core/annotations/BomPolicy.java b/diylc/diylc-core/src/org/diylc/core/annotations/BomPolicy.java
index f2e5387f..e47de747 100644
--- a/diylc/diylc-core/src/org/diylc/core/annotations/BomPolicy.java
+++ b/diylc/diylc-core/src/org/diylc/core/annotations/BomPolicy.java
@@ -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,
}
diff --git a/diylc/diylc-core/src/org/diylc/core/annotations/ComponentDescriptor.java b/diylc/diylc-core/src/org/diylc/core/annotations/ComponentDescriptor.java
index f26b1c9e..e7fae204 100644
--- a/diylc/diylc-core/src/org/diylc/core/annotations/ComponentDescriptor.java
+++ b/diylc/diylc-core/src/org/diylc/core/annotations/ComponentDescriptor.java
@@ -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
*/
diff --git a/diylc/diylc-core/src/org/diylc/core/annotations/EditableProperty.java b/diylc/diylc-core/src/org/diylc/core/annotations/EditableProperty.java
index 9bc60eeb..a73f33f3 100644
--- a/diylc/diylc-core/src/org/diylc/core/annotations/EditableProperty.java
+++ b/diylc/diylc-core/src/org/diylc/core/annotations/EditableProperty.java
@@ -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 getXYZ and setXYZ respectively and this annotation must be
- * placed on the getter method.
+ * placed on the getter method.
+ *
+ * In the example below, {@code category} is the property we want to edit and
+ * {@code getCategories()} provides a list of available values for category.
+ *
+ *
+ *
+ * @EditableProperty(additionalOptions = EditableProperty.DYNAMIC_LIST
+ * + "getCategories")
+ * public String getCategory() {
+ * return category;
+ * }
+ *
+ * public String[] getCategories() {
+ * return categories;
+ * }
+ *
+ *
*
* @author Branislav Stojkovic
*/
diff --git a/diylc/diylc-core/src/org/diylc/core/annotations/IAutoCreator.java b/diylc/diylc-core/src/org/diylc/core/annotations/IAutoCreator.java
index 2785a053..93dece1a 100644
--- a/diylc/diylc-core/src/org/diylc/core/annotations/IAutoCreator.java
+++ b/diylc/diylc-core/src/org/diylc/core/annotations/IAutoCreator.java
@@ -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> createIfNeeded(IDIYComponent> lastAdded);
}
diff --git a/diylc/diylc-core/src/org/diylc/core/annotations/KeywordPolicy.java b/diylc/diylc-core/src/org/diylc/core/annotations/KeywordPolicy.java
index 5191334a..7157b71b 100644
--- a/diylc/diylc-core/src/org/diylc/core/annotations/KeywordPolicy.java
+++ b/diylc/diylc-core/src/org/diylc/core/annotations/KeywordPolicy.java
@@ -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.
diff --git a/diylc/diylc-core/src/org/diylc/core/annotations/PositiveMeasureValidator.java b/diylc/diylc-core/src/org/diylc/core/annotations/PositiveMeasureValidator.java
index 08e0fb1d..3d05a47c 100644
--- a/diylc/diylc-core/src/org/diylc/core/annotations/PositiveMeasureValidator.java
+++ b/diylc/diylc-core/src/org/diylc/core/annotations/PositiveMeasureValidator.java
@@ -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
diff --git a/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/CloudPresenter.java b/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/CloudPresenter.java
index 0aaf4ecc..9cfc58d6 100644
--- a/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/CloudPresenter.java
+++ b/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/CloudPresenter.java
@@ -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() {
diff --git a/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/PagingProvider.java b/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/SearchSession.java
similarity index 55%
rename from diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/PagingProvider.java
rename to diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/SearchSession.java
index ef9ebeeb..89ade8b1 100644
--- a/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/PagingProvider.java
+++ b/diylc/diylc-core/src/org/diylc/plugins/cloud/presenter/SearchSession.java
@@ -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 currentResults;
- public PagingProvider(CloudPresenter cloudPresenter) {
- this.cloudPresenter = cloudPresenter;
+ public SearchSession() {
}
public List 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 requestMoreData() throws CloudException {
currentPage++;
- return currentResults = cloudPresenter.search(searchFor, category, sort, currentPage, itemsPerPage);
+ return currentResults = CloudPresenter.Instance.search(searchFor, category, sort, currentPage, itemsPerPage);
}
}
diff --git a/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java b/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java
index f008a557..74fc0d11 100644
--- a/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java
+++ b/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java
@@ -36,7 +36,7 @@ public class TraceCut extends AbstractComponent {
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);
diff --git a/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java b/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java
index 02dcd00b..803b742e 100644
--- a/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java
+++ b/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java
@@ -49,6 +49,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent 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();
diff --git a/diylc/diylc-library/src/org/diylc/parsing/V2FileParser.java b/diylc/diylc-library/src/org/diylc/parsing/V2FileParser.java
index 17175273..21a052be 100644
--- a/diylc/diylc-library/src/org/diylc/parsing/V2FileParser.java
+++ b/diylc/diylc-library/src/org/diylc/parsing/V2FileParser.java
@@ -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 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;
}
diff --git a/diylc/diylc-swing/.classpath b/diylc/diylc-swing/.classpath
index 9aad9d34..f556021b 100644
--- a/diylc/diylc-swing/.classpath
+++ b/diylc/diylc-swing/.classpath
@@ -9,7 +9,7 @@
-
+
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/FieldEditorFactory.java b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/FieldEditorFactory.java
index cdebbe1c..83a78d06 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/FieldEditorFactory.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/FieldEditorFactory.java
@@ -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);
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MultiLineStringEditor.java b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MultiLineStringEditor.java
index b879d004..1d3194d6 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MultiLineStringEditor.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MultiLineStringEditor.java
@@ -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() {
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/PropertyEditorDialog.java b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/PropertyEditorDialog.java
index 046c0049..4fa184cd 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/PropertyEditorDialog.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/PropertyEditorDialog.java
@@ -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 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) {
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java
index ba44a5af..f274eee3 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java
@@ -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() {
@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);
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/CommentDialog.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/CommentDialog.java
index 58df4b20..9cab229c 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/CommentDialog.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/CommentDialog.java
@@ -42,7 +42,6 @@ public class CommentDialog extends JDialog {
private ProjectEntity project;
private List 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 comments,
- CloudPresenter presenter) {
+ public CommentDialog(ISimpleView cloudUI, ProjectEntity project, List 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();
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/UserEditDialog.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/UserEditDialog.java
index 675b4577..6d0e3274 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/UserEditDialog.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/UserEditDialog.java
@@ -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
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/CloudBrowserFrame.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/CloudBrowserFrame.java
index 47d208cc..ceee0919 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/CloudBrowserFrame.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/CloudBrowserFrame.java
@@ -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 doInBackground() throws Exception {
- return new Pair(cloudPresenter.getCategories(), cloudPresenter.getSortings());
+ return new Pair(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 doInBackground() throws Exception {
- return pagingProvider.startSession(getSearchHeaderPanel().getSearchText(),
+ return searchSession.startSession(getSearchHeaderPanel().getSearchText(),
getSearchHeaderPanel().getCategory(), getSearchHeaderPanel().getSorting());
}
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java
index 274ecdf0..dc9bc6f5 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java
@@ -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 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 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 projectProperties = cloudPresenter.getProjectProperties(project);
+ List 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, Void> worker = new SwingWorker, Void>() {
@Override
protected List doInBackground() throws Exception {
- return provider.requestMoreData();
+ return searchSession.requestMoreData();
}
@Override
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/UploadManagerFrame.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/UploadManagerFrame.java
index 7058d5b9..2aea67ab 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/UploadManagerFrame.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/UploadManagerFrame.java
@@ -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 doInBackground() throws Exception {
- return cloudPresenter.fetchUserUploads(null);
+ return CloudPresenter.Instance.fetchUserUploads(null);
}
@Override
diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml
index 79ade78e..bf53f951 100644
--- a/diylc/diylc-swing/update.xml
+++ b/diylc/diylc-swing/update.xml
@@ -1362,6 +1362,14 @@
IMPROVEMENT
Make order of items in the 'Edit Project' dialog more logical
+
+ IMPROVEMENT
+ Better support for V1 file import
+
+
+ IMPROVEMENT
+ Toggle switch spacing can be changed
+
IMPROVEMENT
Allow multi-line project description