-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ImplementedWarningDialogWhenMultipleProjectOpen ;fixes #73
- Loading branch information
Smiechowski Nathanael
authored
Jul 11, 2022
1 parent
e4255e3
commit f07a7a2
Showing
15 changed files
with
565 additions
and
12 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
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
37 changes: 37 additions & 0 deletions
37
DEHCapellaAdapter/src/Services/CapellaUserPreference/CapellaUserPreference.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,37 @@ | ||
/* | ||
* CapellaUserPreference.java | ||
* | ||
* Copyright (c) 2020-2022 RHEA System S.A. | ||
* | ||
* Author: Sam Gerené, Alex Vorobiev, Nathanael Smiechowski | ||
* | ||
* This file is part of DEH-Capella | ||
* | ||
* The DEH-Capella is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* The DEH-Capella 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package Services.CapellaUserPreference; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* The {@linkplain CapellaUserPreference} holds different preferences for the user saved as Json and handled by the {@linkplain CapellaUserPreferenceService} | ||
*/ | ||
public class CapellaUserPreference | ||
{ | ||
/** | ||
* Gets or sets the dictionary of preferences | ||
*/ | ||
public HashMap<UserPreferenceKey, Object> preferences = new HashMap<>(); | ||
} |
88 changes: 88 additions & 0 deletions
88
DEHCapellaAdapter/src/Services/CapellaUserPreference/CapellaUserPreferenceService.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,88 @@ | ||
/* | ||
* CapellaUserPreferenceService.java | ||
* | ||
* Copyright (c) 2020-2022 RHEA System S.A. | ||
* | ||
* Author: Sam Gerené, Alex Vorobiev, Nathanael Smiechowski | ||
* | ||
* This file is part of DEH-Capella | ||
* | ||
* The DEH-Capella is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* The DEH-Capella 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package Services.CapellaUserPreference; | ||
|
||
import Services.UserPreferenceService.UserPreferenceBaseService; | ||
import Services.UserPreferenceService.UserPreferenceService; | ||
|
||
/** | ||
* The {@linkplain CapellaUserPreferenceService} is dst adapter specific {@linkplain UserPreferenceService} | ||
*/ | ||
public class CapellaUserPreferenceService extends UserPreferenceBaseService<CapellaUserPreference> implements ICapellaUserPreferenceService | ||
{ | ||
/** | ||
* Gets the {@linkplain Class} of {@linkplain #TUserPreference} | ||
*/ | ||
@Override | ||
protected Class<CapellaUserPreference> GetUserPreferenceType() | ||
{ | ||
return CapellaUserPreference.class; | ||
} | ||
|
||
/** | ||
* Gets the user preference file name | ||
*/ | ||
@Override | ||
protected String GetFileName() | ||
{ | ||
return "Capella"; | ||
} | ||
|
||
/** | ||
* Saves one key to the {@linkplain CapellaUserPreference} file | ||
* | ||
* @param userPreferenceKey the {@linkplain UserPreferenceKey} | ||
* @param value the {@linkplain Object} value | ||
*/ | ||
@Override | ||
public void Save(UserPreferenceKey userPreferenceKey, Object value) | ||
{ | ||
this.GetUserPreference().preferences.put(userPreferenceKey, value); | ||
this.Save(); | ||
} | ||
|
||
/** | ||
* Reads one value associated to the specified {@linkplain UserPreferenceKey} from the {@linkplain CapellaUserPreference} file | ||
* | ||
* @param <TValue> the type of value to return | ||
* @param userPreferenceKey the {@linkplain UserPreferenceKey} | ||
* @param valueType the {@linkplain Class} of TValue | ||
* @param defaultValue a default value in case the value is not found | ||
* @return a TValue | ||
*/ | ||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <TValue> TValue Get(UserPreferenceKey userPreferenceKey, Class<TValue> valueType, TValue defaultValue) | ||
{ | ||
this.Read(); | ||
var value = this.GetUserPreference().preferences.get(userPreferenceKey); | ||
|
||
if(valueType.isInstance(value)) | ||
{ | ||
return (TValue)value; | ||
} | ||
|
||
return defaultValue; | ||
} | ||
} |
Oops, something went wrong.