-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* flatpak file updated * add sha generator * fix mail * remove mail * Mini Toggle Switch - lugs do not get rotated when changing orientation; rotate from the context menu doesn't work * Added 'SVG Image' component * Fixed the issue with Perf Board, Vero Board and TriPad Board sometimes rendering an extra row with pads when there's no space for them * release 4.18 * Keep grouped components together when pasting * Added 'Dial Scale' component for designing device face-plates * dial scale updates * dial scale tweaks * release * release * release * release
- Loading branch information
Showing
15 changed files
with
461 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
diylc/diylc-core/src/org/diylc/clipboard/ComponentTransferableFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* | ||
* 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.clipboard; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.diylc.core.IDIYComponent; | ||
|
||
public class ComponentTransferableFactory { | ||
|
||
private static final Logger LOG = Logger.getLogger(ComponentTransferableFactory.class); | ||
|
||
private static ComponentTransferableFactory instance; | ||
|
||
public static ComponentTransferableFactory getInstance() { | ||
if (instance == null) | ||
instance = new ComponentTransferableFactory(); | ||
return instance; | ||
} | ||
|
||
public ComponentTransferable build(Collection<IDIYComponent<?>> selectedComponents, Set<Set<IDIYComponent<?>>> groups) { | ||
Set<IDIYComponent<?>> originalComponentSet = new HashSet<IDIYComponent<?>>(selectedComponents); | ||
List<IDIYComponent<?>> originalComponents = new ArrayList<IDIYComponent<?>>(selectedComponents); | ||
List<IDIYComponent<?>> clonedComponents = originalComponents.stream( | ||
).map(x -> { | ||
try { | ||
return x.clone(); | ||
} catch (CloneNotSupportedException e) { | ||
LOG.error(e); | ||
return null; | ||
} | ||
}) | ||
.filter(Objects::nonNull) | ||
.collect(Collectors.toList()); | ||
Set<Set<IDIYComponent<?>>> clonedGroups = new HashSet<Set<IDIYComponent<?>>>(); | ||
|
||
for (Set<IDIYComponent<?>> group : groups) { | ||
if (group.isEmpty()) | ||
continue; | ||
|
||
if (originalComponentSet.contains(group.iterator().next())) { | ||
Set<IDIYComponent<?>> clonedGroup = new HashSet<IDIYComponent<?>>(); | ||
clonedGroups.add(clonedGroup); | ||
for (int i = 0; i < originalComponents.size(); i++) { | ||
if (group.contains(originalComponents.get(i))) { | ||
clonedGroup.add(clonedComponents.get(i)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return new ComponentTransferable(clonedComponents, clonedGroups); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.