Skip to content

Commit

Permalink
Merge pull request #632 from bancika/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
bancika authored Feb 14, 2021
2 parents 2c81782 + bf31204 commit ad8d719
Show file tree
Hide file tree
Showing 19 changed files with 1,317 additions and 149 deletions.
89 changes: 89 additions & 0 deletions diylc/diylc-core/diylc-core.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="jar://$MODULE_DIR$/lib/log4j-1.2.15.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/junit-4.7.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/app-framework.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/jettison-1.0.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/xstream-1.3.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/java-http-proxy.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/AppleJavaExtensions.jar!/" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/test" expected_position="1" />
</src_description>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="log4j-1.2.15.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/log4j-1.2.15.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="junit-4.7.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/junit-4.7.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="app-framework.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/app-framework.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="jettison-1.0.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jettison-1.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="xstream-1.3.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/xstream-1.3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="java-http-proxy.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/java-http-proxy.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="AppleJavaExtensions.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/AppleJavaExtensions.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="inheritedJdk" />
</component>
</module>
85 changes: 42 additions & 43 deletions diylc/diylc-core/src/org/diylc/plugins/cloud/model/IServiceAPI.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.plugins.cloud.model;

import java.io.File;
Expand Down Expand Up @@ -79,7 +79,7 @@ String login(@ParamName("username") String username, @ParamName("password") Stri
* Retrieves current user's details.
*
* @param username
* @param password
* @param token
* @param machineId
* @return string with an error message if it fails, or an instance of {@link UserEntity} if it
* succeeds.
Expand All @@ -91,7 +91,7 @@ Object getUserDetails(@ParamName("username") String username, @ParamName("token"
* Tries to authenticate with the token that was previously created by calling login() function.
*
* @param username
* @param password
* @param token
* @param machineId
* @return "Success" if the login is successful or error message if it failed.
*/
Expand All @@ -102,9 +102,8 @@ String loginWithToken(@ParamName("username") String username, @ParamName("token"
* Updates password of the current user using token to authenticate.
*
* @param username
* @param token
* @param machineId
* @param password
* @param oldPassword
* @param newPassword
* @return "Success" if the login is successful or error message if it failed.
*/
String updatePassword(@ParamName("username") String username, @ParamName("oldPassword") String oldPassword,
Expand Down Expand Up @@ -149,23 +148,23 @@ String uploadProject(@ParamName("username") String username, @ParamName("token")
@ParamName("category") String category, @ParamName("description") String description,
@ParamName("diylcVersion") String diylcVersion, @ParamName("keywords") String keywords,
@ParamName("thumbnail") File thumbnail, @ParamName("project") File project,
@ParamName("projectId") Integer projectId);

/**
* Replaces project files using token to authenticate. The project must belong to the user.
*
* @param username
* @param token
* @param machineId
* @param diylcVersion
* @param thumbnail
* @param project
* @param projectId
* @return "Success" if the upload was successful or error message if it failed.
*/
String replaceProjectFiles(@ParamName("username") String username, @ParamName("token") String token,
@ParamName("machineId") String machineId, @ParamName("diylcVersion") String diylcVersion,
@ParamName("thumbnail") File thumbnail, @ParamName("project") File project,
@ParamName("projectId") Integer projectId);

/**
* Replaces project files using token to authenticate. The project must belong to the user.
*
* @param username
* @param token
* @param machineId
* @param diylcVersion
* @param thumbnail
* @param project
* @param projectId
* @return "Success" if the upload was successful or error message if it failed.
*/
String replaceProjectFiles(@ParamName("username") String username, @ParamName("token") String token,
@ParamName("machineId") String machineId, @ParamName("diylcVersion") String diylcVersion,
@ParamName("thumbnail") File thumbnail, @ParamName("project") File project,
@ParamName("projectId") Integer projectId);

/**
Expand Down
5 changes: 2 additions & 3 deletions diylc/diylc-core/src/org/diylc/presenter/Presenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ public void loadProject(Project project, boolean freshStart, String filename) {
this.currentProject = project;
drawingManager.clearComponentAreaMap();
drawingManager.clearContinuityArea();
DrawingCache.Instance.clear();
updateSelection(EMPTY_SELECTION);
messageDispatcher.dispatchMessage(EventType.PROJECT_LOADED, project, freshStart, filename);
messageDispatcher.dispatchMessage(EventType.REPAINT);
Expand All @@ -326,8 +327,7 @@ public void createNewProject() {
Project project = new Project();
instantiationManager.fillWithDefaultProperties(project, null);
loadProject(project, true, null);
projectFileManager.startNewFile();
DrawingCache.Instance.clear();
projectFileManager.startNewFile();
} catch (Exception e) {
LOG.error("Could not create new file", e);
view.showMessage(ERROR_NEW, ERROR, IView.ERROR_MESSAGE);
Expand All @@ -353,7 +353,6 @@ public void loadProjectFromFile(String fileName) {
view.showMessage(builder.toString(), WARNING, IView.WARNING_MESSAGE);
}
addToRecentFiles(fileName);
DrawingCache.Instance.clear();
} catch (Exception ex) {
LOG.error("Could not load file", ex);
String errorMessage = "Could not open file " + fileName + ". Check the log for details.";
Expand Down
30 changes: 29 additions & 1 deletion diylc/diylc-core/src/org/diylc/presenter/update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3517,5 +3517,33 @@
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
<minor>17</minor>
<build>0</build>
</versionNumber>
<releaseDate>2021-02-14 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added 'Eurorack Stripboard' component, designed by David Haillant</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Allow multi-line text in label components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Slightly fancier splash screen :)</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Fixed a major memory leak when using Undo functionality</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
</a>
</java.util.Arrays_-ArrayList>
</java.util.Arrays_-ArrayList>
79 changes: 79 additions & 0 deletions diylc/diylc-library/diylc-library.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="jar://$MODULE_DIR$/lib/log4j-1.2.15.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/app-framework.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/jep-2.4.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/poi-3.5-FINAL-20090928.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/xstream-1.4.3.jar!/" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/test" expected_position="1" />
</src_description>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="log4j-1.2.15.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/log4j-1.2.15.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="app-framework.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/app-framework.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="jep-2.4.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jep-2.4.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="poi-3.5-FINAL-20090928.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/poi-3.5-FINAL-20090928.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module" module-name="diylc-core" />
<orderEntry type="module-library">
<library name="xstream-1.4.3.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/xstream-1.4.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="junit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.12.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="inheritedJdk" />
</component>
</module>
Binary file modified diylc/diylc-library/lib/diylc-core.jar
Binary file not shown.
9 changes: 6 additions & 3 deletions diylc/diylc-library/src/org/diylc/awt/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ DIY Layout Creator (DIYLC).
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import org.diylc.common.HorizontalAlignment;
import org.diylc.common.VerticalAlignment;
Expand Down Expand Up @@ -70,7 +72,8 @@ else if (horizontalAlignment == HorizontalAlignment.RIGHT)
* @return a non-empty list of strings
*/
public static List<String> wrap(String str, FontMetrics fm, int maxWidth) {
List<String> lines = splitIntoLines(str);
String[] split = str.split("\\<br\\>");
List<String> lines = Arrays.stream(split).flatMap(s -> splitIntoLines(s).stream()).collect(Collectors.toList());
if (lines.size() == 0)
return lines;

Expand Down Expand Up @@ -203,7 +206,7 @@ public static List<String> splitIntoLines(String str) {

public static void drawCenteredText(Graphics2D g2d, String text, double x, double y, HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) {
String[] parts = text.split("\n");
String[] parts = text.split("\\<br\\>");
if (parts.length > 1) {
FontMetrics fontMetrics = g2d.getFontMetrics();
Rectangle stringBounds = fontMetrics.getStringBounds(parts[0], g2d).getBounds();
Expand Down Expand Up @@ -244,7 +247,7 @@ public static void drawCenteredText(Graphics2D g2d, String text, double x, doubl
case BOTTOM:
textY = y - visualBounds.y;
break;
}
}

g2d.drawString(text, (int)Math.round(textX), (int)Math.round(textY));
}
Expand Down
Loading

0 comments on commit ad8d719

Please sign in to comment.