Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
*/
package org.eclipse.set.application.cacheservice;

import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.set.basis.IModelSession;
Expand Down Expand Up @@ -58,10 +60,8 @@ public Cache getCache(final PlanPro_Schnittstelle schnittstelle,

@Override
public Cache getCache(final PlanPro_Schnittstelle schnittstelle,
final String cacheId, final String containerCacheId)
throws IllegalArgumentException {
return getCache(getSessionRole(schnittstelle), cacheId,
containerCacheId);
final String... cacheId) throws IllegalArgumentException {
return getCache(getSessionRole(schnittstelle), cacheId);
}

private void invalidate(final ToolboxFileRole role) {
Expand Down Expand Up @@ -126,9 +126,10 @@ public Cache getCache(final ToolboxFileRole role, final String cacheId)
}

@Override
public Cache getCache(final ToolboxFileRole role, final String cacheId,
final String containerCacheId) throws IllegalArgumentException {
final String cacheKey = cacheId + "/" + containerCacheId; //$NON-NLS-1$
public Cache getCache(final ToolboxFileRole role, final String... cacheId)
throws IllegalArgumentException {
final String cacheKey = Arrays.stream(cacheId)
.collect(Collectors.joining("/")); //$NON-NLS-1$
return getCache(role, cacheKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ public Cache getCache(PlanPro_Schnittstelle schnittstelle, String cacheId)
* the {@link PlanPro_Schnittstelle}
* @param cacheId
* the id for the cache
* @param containerCacheId
* the id for the container to consider
* @return the container cache
*
* @throws IllegalArgumentException
* if no cache for the given id is found
*/
public Cache getCache(PlanPro_Schnittstelle schnittstelle, String cacheId,
String containerCacheId) throws IllegalArgumentException;
public Cache getCache(PlanPro_Schnittstelle schnittstelle,
String... cacheId) throws IllegalArgumentException;

/**
* check if already storage cache
Expand Down Expand Up @@ -80,15 +78,13 @@ public Cache getCache(ToolboxFileRole role, String cacheId)
* {@link ToolboxFileRole}
* @param cacheId
* the id for the cache
* @param containerCacheId
* the id for the container to consider
* @return the container cache
*
* @throws IllegalArgumentException
* if no cache for the given id is found
*/
public Cache getCache(ToolboxFileRole role, String cacheId,
String containerCacheId) throws IllegalArgumentException;
public Cache getCache(ToolboxFileRole role, String... cacheId)
throws IllegalArgumentException;

/**
* check if already storage cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public Cache getCache(final PlanPro_Schnittstelle schnittStellle,

@Override
public Cache getCache(final PlanPro_Schnittstelle schnittStellle,
final String cacheId, final String containerCacheId)
throws IllegalArgumentException {
final String... cacheId) throws IllegalArgumentException {
return new NoCache();
}

Expand All @@ -54,8 +53,8 @@ public Cache getCache(final ToolboxFileRole role, final String cacheId)
}

@Override
public Cache getCache(final ToolboxFileRole role, final String cacheId,
final String containerCacheId) throws IllegalArgumentException {
public Cache getCache(final ToolboxFileRole role, final String... cacheId)
throws IllegalArgumentException {
return new NoCache();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ import javax.imageio.ImageIO
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.parsers.ParserConfigurationException
import org.eclipse.set.basis.FreeFieldInfo
import org.eclipse.set.basis.constants.ToolboxConstants
import org.eclipse.set.model.tablemodel.CellContent
import org.eclipse.set.model.tablemodel.CompareCellContent
import org.eclipse.set.model.tablemodel.CompareFootnoteContainer
import org.eclipse.set.model.tablemodel.CompareStateCellContent
import org.eclipse.set.model.tablemodel.CompareTableCellContent
import org.eclipse.set.model.tablemodel.CompareTableFootnoteContainer
import org.eclipse.set.model.tablemodel.FootnoteContainer
import org.eclipse.set.model.tablemodel.MultiColorCellContent
import org.eclipse.set.model.tablemodel.MultiColorContent
import org.eclipse.set.model.tablemodel.PlanCompareRow
import org.eclipse.set.model.tablemodel.SimpleFootnoteContainer
import org.eclipse.set.model.tablemodel.Table
import org.eclipse.set.model.tablemodel.TableContent
Expand All @@ -41,15 +44,12 @@ import org.w3c.dom.Document
import org.w3c.dom.Element

import static extension org.eclipse.set.model.tablemodel.extensions.CellContentExtensions.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableCellExtensions.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableContentExtensions.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableExtensions.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableCellExtensions.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableRowExtensions.*
import static extension org.eclipse.set.utils.StringExtensions.*
import static extension org.eclipse.set.utils.export.xsl.siteplan.SiteplanXSL.pxToMilimeter
import org.eclipse.set.basis.constants.ToolboxConstants
import org.eclipse.set.model.tablemodel.PlanCompareRow
import org.eclipse.set.model.tablemodel.CompareTableFootnoteContainer

/**
* Transformation from {@link Table} to TableDocument {@link Document}.
Expand Down Expand Up @@ -343,12 +343,12 @@ class TableToTableDocument {
}
}

private def dispatch Element createContent(CompareCellContent content,
private def dispatch Element createContent(CompareStateCellContent content,
FootnoteContainer fc, int columnNumber, boolean isRemarkColumn) {
val element = doc.createElement("DiffContent")
formatCompareContent(
content.oldValue,
content.newValue,
content.oldValue.stringValueIterable,
content.newValue.stringValueIterable,
[doc.createElement("OldValue")],
[doc.createElement("UnchangedValue")],
[doc.createElement("NewValue")],
Expand Down Expand Up @@ -487,8 +487,9 @@ class TableToTableDocument {
private def Element addContentToElement(String content, Element element,
int columnNumber, boolean isRemarkColumn) {
val checkOutput = content.checkForTestOutput(columnNumber)
element.textContent = isRemarkColumn ? checkOutput : checkOutput.
intersperseWithZeroSpacesSC
element.textContent = isRemarkColumn
? checkOutput
: checkOutput.intersperseWithZeroSpacesSC
return element
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@
import org.eclipse.set.model.planpro.Basisobjekte.Punkt_Objekt;
import org.eclipse.set.model.planpro.PZB.PZB_Element;
import org.eclipse.set.model.tablemodel.ColumnDescriptor;
import org.eclipse.set.model.tablemodel.CompareCellContent;
import org.eclipse.set.model.tablemodel.CompareStateCellContent;
import org.eclipse.set.model.tablemodel.MultiColorCellContent;
import org.eclipse.set.model.tablemodel.MultiColorContent;
import org.eclipse.set.model.tablemodel.RowGroup;
import org.eclipse.set.model.tablemodel.RowMergeMode;
import org.eclipse.set.model.tablemodel.StringCellContent;
import org.eclipse.set.model.tablemodel.TableCell;
import org.eclipse.set.model.tablemodel.extensions.CellContentExtensions;
import org.eclipse.set.ppmodel.extensions.PZBElementExtensions;
import org.eclipse.set.ppmodel.extensions.utils.TableNameInfo;
import org.eclipse.set.utils.table.ColumnDescriptorModelBuilder;
import org.eclipse.set.utils.table.sorting.ComparatorBuilder.CellComparatorType;
import org.eclipse.set.utils.table.sorting.TableRowGroupComparator;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.event.EventAdmin;
Expand Down Expand Up @@ -91,15 +93,19 @@ private static String getCellContent(final TableCell cell) {
if (cell.getContent() instanceof final StringCellContent cellContent) {
return getFirstOrNull(cellContent.getValue());
}
if (cell.getContent() instanceof final CompareCellContent cellContent) {
if (cellContent.getNewValue().isEmpty()
|| cellContent.getOldValue().isEmpty()) {
return Optional
.ofNullable(getFirstOrNull(cellContent.getNewValue()))
.orElse(getFirstOrNull(cellContent.getOldValue()));
if (cell.getContent() instanceof final CompareStateCellContent cellContent) {
final List<String> oldValues = IterableExtensions
.toList(CellContentExtensions
.getStringValueIterable(cellContent.getOldValue()));
final List<String> newValues = IterableExtensions
.toList(CellContentExtensions
.getStringValueIterable(cellContent.getNewValue()));
if (oldValues.isEmpty() || newValues.isEmpty()) {
return Optional.ofNullable(getFirstOrNull(newValues))
.orElse(getFirstOrNull(oldValues));
}
return cellContent.getNewValue().get(0) + cellContent.getSeparator()
+ cellContent.getOldValue().get(0);
return newValues.get(0) + cellContent.getSeparator()
+ oldValues.get(0);
}
if (cell.getContent() instanceof final MultiColorCellContent cellContent) {
final MultiColorContent firstOrNull = getFirstOrNull(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.eclipse.set.utils.table.sorting.MixedStringCellComparator
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

import static org.eclipse.set.model.tablemodel.extensions.CellContentExtensions.createStringCellContent
import static org.hamcrest.MatcherAssert.assertThat
import static org.hamcrest.core.Is.*
import static org.junit.jupiter.api.Assertions.*
Expand All @@ -35,8 +36,8 @@ class MixedStringCellComparatorTest {
@Test
def void testMixedCells() {
val cell1 = TablemodelFactory.eINSTANCE.createTableCell
val content1 = TablemodelFactory.eINSTANCE.createCompareCellContent
content1.newValue.add("86W9")
val content1 = TablemodelFactory.eINSTANCE.createCompareStateCellContent
content1.newValue = createStringCellContent("86W9")
cell1.content = content1

val cell2 = TablemodelFactory.eINSTANCE.createTableCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
package org.eclipse.set.feature.table.diff;

import static org.eclipse.set.model.tablemodel.extensions.CellContentExtensions.getStringValueList;
import static org.eclipse.set.ppmodel.extensions.EObjectExtensions.getNullableObject;

import java.util.ArrayList;
Expand All @@ -23,7 +24,7 @@
import org.eclipse.set.core.services.session.SessionService;
import org.eclipse.set.model.tablemodel.CellContent;
import org.eclipse.set.model.tablemodel.ColumnDescriptor;
import org.eclipse.set.model.tablemodel.CompareCellContent;
import org.eclipse.set.model.tablemodel.CompareStateCellContent;
import org.eclipse.set.model.tablemodel.CompareTableCellContent;
import org.eclipse.set.model.tablemodel.CompareTableFootnoteContainer;
import org.eclipse.set.model.tablemodel.FootnoteContainer;
Expand Down Expand Up @@ -270,7 +271,7 @@ protected boolean isSameValue(final CellContent first,
return switch (first) {
case final StringCellContent stringContent -> isSameValue(
stringContent, second);
case final CompareCellContent compareContent -> isSameValue(
case final CompareStateCellContent compareContent -> isSameValue(
compareContent, second);
case final MultiColorCellContent multiColorContent -> isSameValue(
multiColorContent, second);
Expand Down Expand Up @@ -311,7 +312,8 @@ private static CompareTableFootnoteContainer createCompareTableFootnoteContainer
* the {@link CellContent}
* @return true, if the table cell haven same value
*/
protected boolean isSameValue(final CompareCellContent firstCellContent,
protected boolean isSameValue(
final CompareStateCellContent firstCellContent,
final CellContent secondCellContent) {
// Compare between CompareCellContent with another cell content is only
// in compare table between two Project available.
Expand All @@ -323,10 +325,10 @@ protected boolean isSameValue(final CompareCellContent firstCellContent,
.createStringCellContent();
if (tableType == TableType.INITIAL) {
compareCellStringContent.getValue()
.addAll(firstCellContent.getOldValue());
.addAll(getStringValueList(firstCellContent.getOldValue()));
} else {
compareCellStringContent.getValue()
.addAll(firstCellContent.getNewValue());
.addAll(getStringValueList(firstCellContent.getNewValue()));
}
return isSameValue(compareCellStringContent, secondCellContent);
}
Expand Down Expand Up @@ -384,17 +386,18 @@ protected boolean isSameValue(final StringCellContent firstCellContent,
.collect(Collectors.toSet());
yield firstValues.equals(secondValues);
}
case final CompareCellContent compareContent -> {
case final CompareStateCellContent compareContent -> {
final TableType tableType = getSessionService()
.getLoadedSession(ToolboxFileRole.SESSION)
.getTableType();
final Set<String> values = switch (tableType) {
case TableType.INITIAL -> compareContent.getOldValue()
.stream()
.filter(value -> value != null
&& !value.trim().isEmpty())
.collect(Collectors.toSet());
default -> compareContent.getNewValue()
case TableType.INITIAL -> getStringValueList(
compareContent.getOldValue())
.stream()
.filter(value -> value != null
&& !value.trim().isEmpty())
.collect(Collectors.toSet());
default -> getStringValueList(compareContent.getNewValue())
.stream()
.filter(value -> value != null
&& !value.trim().isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
*/
package org.eclipse.set.feature.table.diff;

import static org.eclipse.set.model.tablemodel.extensions.CellContentExtensions.createStringCellContent;
import static org.eclipse.set.model.tablemodel.extensions.TableCellExtensions.getIterableStringValue;

import java.util.Collections;
import java.util.Set;

import org.eclipse.set.core.services.session.SessionService;
import org.eclipse.set.model.tablemodel.CellContent;
import org.eclipse.set.model.tablemodel.CompareCellContent;
import org.eclipse.set.model.tablemodel.CompareStateCellContent;
import org.eclipse.set.model.tablemodel.MultiColorCellContent;
import org.eclipse.set.model.tablemodel.StringCellContent;
import org.eclipse.set.model.tablemodel.TableCell;
import org.eclipse.set.model.tablemodel.TablemodelFactory;
import org.eclipse.set.model.tablemodel.extensions.CellContentExtensions;
import org.eclipse.set.model.tablemodel.extensions.TableCellExtensions;
import org.eclipse.set.ppmodel.extensions.EObjectExtensions;
import org.eclipse.set.services.table.TableDiffService;
import org.osgi.service.component.annotations.Component;
Expand Down Expand Up @@ -52,16 +53,24 @@ CellContent createDiffContent(final TableCell oldCell,
return oldCell.getContent();
}

if (!StringCellContent.class.isInstance(oldCell.getContent())
|| newCell != null && newCell.getContent() != null
&& !StringCellContent.class
.isInstance(newCell.getContent())) {
throw new IllegalArgumentException(
"Can create CompareStateCellContent only from StringCellContent"); //$NON-NLS-1$
}

final Set<String> oldValues = getIterableStringValue(oldCell);
final Set<String> newValues = newCell == null ? Collections.emptySet()
: getIterableStringValue(newCell);
if (oldValues.equals(newValues)) {
return null;
}
final CompareCellContent compareContent = TablemodelFactory.eINSTANCE
.createCompareCellContent();
compareContent.getOldValue().addAll(oldValues);
compareContent.getNewValue().addAll(newValues);
final CompareStateCellContent compareContent = TablemodelFactory.eINSTANCE
.createCompareStateCellContent();
compareContent.setOldValue(createStringCellContent(oldValues));
compareContent.setNewValue(createStringCellContent(newValues));
compareContent.setSeparator(EObjectExtensions
.getNullableObject(oldCell, c -> c.getContent().getSeparator())
.orElse(null));
Expand All @@ -85,17 +94,19 @@ private static void createMultiColorDiffCotent(final TableCell oldCell,
// Convert to CompareCellContent, when give different between
// initial
// and final state
final CompareCellContent compareCellContent = TablemodelFactory.eINSTANCE
.createCompareCellContent();
final CompareStateCellContent compareCellContent = TablemodelFactory.eINSTANCE
.createCompareStateCellContent();
oldCellContent.getValue()
.forEach(colorContent -> compareCellContent.getOldValue()
.add(String.format(colorContent.getStringFormat(),
colorContent.getMultiColorValue())));
.forEach(colorContent -> compareCellContent
.setOldValue(createStringCellContent(String.format(
colorContent.getStringFormat(),
colorContent.getMultiColorValue()))));

newCellContent.getValue()
.forEach(colorContent -> compareCellContent.getNewValue()
.add(String.format(colorContent.getStringFormat(),
colorContent.getMultiColorValue())));
.forEach(colorContent -> compareCellContent
.setNewValue(createStringCellContent(String.format(
colorContent.getStringFormat(),
colorContent.getMultiColorValue()))));
oldCell.setContent(compareCellContent);
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ _UI_PlanCompareRow_rowType_feature = Row Type
_UI_PlanCompareRowType_NEW_ROW_literal = NEW_ROW
_UI_PlanCompareRowType_REMOVED_ROW_literal = REMOVED_ROW
_UI_PlanCompareRowType_CHANGED_GUID_ROW_literal = CHANGED_GUID_ROW
_UI_CompareStateCellContent_type = Compare State Cell Content
_UI_CompareStateCellContent_oldValue_feature = Old Value
_UI_CompareStateCellContent_newValue_feature = New Value
Loading
Loading