Skip to content

Commit 329d54e

Browse files
Fix error by change tabletype and close session (#1953)
* Fix error by change tabletype and close session * Remove doens't exist recent path
1 parent 1ebfd31 commit 329d54e

File tree

8 files changed

+42
-28
lines changed

8 files changed

+42
-28
lines changed

java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/cacheservice/CacheServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ private void invalidate(final ToolboxFileRole role) {
7171
.flatMap(ele -> ele.values().stream())
7272
.forEach(Cache::invalidate);
7373
} else {
74-
caches.get(role).values().forEach(Cache::invalidate);
74+
caches.computeIfPresent(role, (k, v) -> {
75+
v.values().forEach(Cache::invalidate);
76+
return v;
77+
});
7578
}
7679

7780
}

java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/controlarea/ControlAreaSelectionControl.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public ControlAreaSelectionControl(final Composite parent,
110110
createCombo(parent);
111111
// Reset combo value, when close session
112112
broker.subscribe(Events.CLOSE_SESSION, this::closeSession);
113-
broker.subscribe(Events.MODEL_CHANGED, this::sessionChanged);
114113
}
115114

116115
private void createCombo(final Composite parent) {
@@ -131,6 +130,9 @@ public void accept(final NewTableTypeEvent t) {
131130
}
132131
};
133132

133+
ToolboxEvents.subscribe(broker, NewTableTypeEvent.class,
134+
newTableTypeHandler);
135+
134136
// register for session changes
135137
application.getContext().runAndTrack(new RunAndTrack() {
136138
@Override
@@ -389,18 +391,6 @@ private void closeSession(final Event event) {
389391
final Object property = event.getProperty(IEventBroker.DATA);
390392
if (property instanceof final ToolboxFileRole role
391393
&& role.equals(ToolboxFileRole.SESSION)) {
392-
ToolboxEvents.unsubscribe(broker, newTableTypeHandler);
393-
// Reset combo to default
394-
initCombo();
395-
}
396-
}
397-
398-
private void sessionChanged(final Event event) {
399-
final Object property = event.getProperty(IEventBroker.DATA);
400-
if (property instanceof final ToolboxFileRole role
401-
&& role.equals(ToolboxFileRole.SESSION)) {
402-
ToolboxEvents.subscribe(broker, NewTableTypeEvent.class,
403-
newTableTypeHandler);
404394
// Reset combo to default
405395
initCombo();
406396
}

java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/handler/OpenPlanProHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ protected String getTaskMessage() {
119119
@Override
120120
protected IModelSession validation(final IModelSession modelSession,
121121
final Shell shell, final Path path) {
122-
if (modelSession == null) {
122+
if (modelSession == null || modelSession.getToolboxFile()
123+
.getRole() != ToolboxFileRole.SESSION
124+
&& modelSession.getPlanProSchnittstelle() == null) {
123125
return null;
124126
}
125127
switch (modelSession.getFileValidateState()) {

java/bundles/org.eclipse.set.application/src/org/eclipse/set/application/tabletype/TableTypeSelectionControl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ private void createTableCombo(final Composite parent) {
119119
@Override
120120
public boolean changed(final IEclipseContext context) {
121121
setCombo(context.get(IModelSession.class));
122-
ToolboxEvents.send(broker,
123-
new NewTableTypeEvent(oldSelectedValue));
124122
return true;
125123
}
126124
});

java/bundles/org.eclipse.set.core/src/org/eclipse/set/core/configurationservice/UserConfigurationServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ protected void loadConfiguration() {
113113
/* */});
114114
configuration = (UserConfiguration) objectReader
115115
.readValue(configurationFile);
116+
configuration.lastOpenFiles.removeIf(p -> !p.toFile().exists());
117+
configuration.lastOpenCompareFiles
118+
.removeIf(p -> !p.toFile().exists());
119+
saveConfiguration();
116120
} catch (final IOException e) {
117121
// If the configuration isn't valid, create a new one
118122
configuration = new UserConfiguration();
@@ -198,6 +202,10 @@ public void setLastExportPath(final Path path) {
198202

199203
@Override
200204
public Optional<Path> getLastFileOpenPath(final ToolboxFileRole role) {
205+
if (configuration.lastFileOpenPath != null
206+
&& !configuration.lastFileOpenPath.toFile().exists()) {
207+
return Optional.empty();
208+
}
201209
return Optional.ofNullable(configuration.lastFileOpenPath);
202210
}
203211

@@ -237,6 +245,5 @@ private List<Path> getPathList(final ToolboxFileRole role) {
237245
return getPathList(role);
238246
}
239247
return list;
240-
241248
}
242249
}

java/bundles/org.eclipse.set.feature.validation/src/org/eclipse/set/feature/validation/session/ModelSession.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Set;
2222
import java.util.function.Function;
2323
import java.util.function.Predicate;
24+
import java.util.stream.Collectors;
2425
import java.util.stream.Stream;
2526

2627
import org.apache.commons.io.FileUtils;
@@ -231,12 +232,15 @@ public ModelSession(final ToolboxFile toolboxFile,
231232
final IModelSession session = this;
232233
final EditingDomain editingDomain = toolboxFile.getEditingDomain();
233234
editingDomain.getCommandStack().addCommandStackListener(event -> {
234-
setTitleFilename(IModelSessionExtensions.getTitleFilename(session,
235-
ModelSession.this.serviceProvider.messages.ModelSession_ChangeIndicator));
236-
ModelSession.this.serviceProvider.broker.post(
237-
UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC,
238-
UIEvents.ALL_ELEMENT_ID);
239235
checkForDirtyEvent();
236+
if (isDirty()) {
237+
setTitleFilename(IModelSessionExtensions.getTitleFilename(
238+
session,
239+
ModelSession.this.serviceProvider.messages.ModelSession_ChangeIndicator));
240+
ModelSession.this.serviceProvider.broker.post(
241+
UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC,
242+
UIEvents.ALL_ELEMENT_ID);
243+
}
240244
});
241245
guid = Guid.create();
242246
this.tempDir = tempDir;
@@ -598,6 +602,7 @@ public void init() {
598602
}
599603
} catch (final IOException e) {
600604
serviceProvider.dialogService.error(mainWindow, e);
605+
cleanUp();
601606
} finally {
602607
if (getPlanProSchnittstelle() != null) {
603608
setNature();
@@ -984,6 +989,15 @@ protected void readModel() throws IOException {
984989
} else {
985990
final ModelContents modelContents = serviceProvider.modelLoader
986991
.loadModel(toolboxFile, this::setValidationResult);
992+
if (toolboxFile.getRole() != ToolboxFileRole.SESSION
993+
&& modelContents.schnittStelle() == null) {
994+
final String errorMsg = schnittstelleValidationResult
995+
.getIoErrors()
996+
.stream()
997+
.map(Exception::getMessage)
998+
.collect(Collectors.joining());
999+
throw new IOException(errorMsg);
1000+
}
9871001
setPlanProSchnittstelle(modelContents.schnittStelle());
9881002
setPlanProLayoutinfo(modelContents.layoutInfo());
9891003
}
@@ -1042,7 +1056,8 @@ void setTitleFilename(final String filename) {
10421056
final String[] split = title.split(String.format("%s|%s", //$NON-NLS-1$
10431057
TITLE_SEPARATOR, TITLE_FILE_NAME_SEPARATOR));
10441058
final String titleProgrammPart = split[0];
1045-
if (toolboxFile.getRole() == ToolboxFileRole.COMPARE_PLANNING) {
1059+
if (toolboxFile.getRole() == ToolboxFileRole.COMPARE_PLANNING
1060+
&& split.length > 1) {
10461061
final String titleFileName = titleProgrammPart + TITLE_SEPARATOR
10471062
+ split[1];
10481063
if (filename == null) {

java/bundles/org.eclipse.set.feature.validation/src/org/eclipse/set/feature/validation/session/SetSessionService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ public boolean close(final IModelSession modelSession,
140140
}
141141

142142
// show the no session part
143-
if (getToolboxPartService()
144-
.showPart(ToolboxConstants.NO_SESSION_PART_ID)
145-
|| role == ToolboxFileRole.SESSION) {
143+
if (role == ToolboxFileRole.SESSION && getToolboxPartService()
144+
.showPart(ToolboxConstants.NO_SESSION_PART_ID)) {
146145
loadedModels.keySet().forEach(this::closeLoadedSession);
147146

148147
actionItems.clear();

web/siteplan/src/components/FeatureService.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default class FeatureService extends Vue {
137137
// Download the current model
138138
const modelType = store.state.planproModelType
139139
axios
140-
.get<SiteplanModel>(`/${modelType}.json`)
140+
.get<SiteplanModel>('/siteplanKR.json')
141141
.then(response => {
142142
this.modelLoaded(response.data)
143143
store.commit('setLoading', false)

0 commit comments

Comments
 (0)