-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add merge function to tip containers
This may be useful if your plugin also loads tips using the TipLoader
- Loading branch information
Showing
4 changed files
with
42 additions
and
40 deletions.
There are no files selected for viewing
33 changes: 0 additions & 33 deletions
33
core/src/main/java/dk/gtz/graphedit/internal/TipLoader.java
This file was deleted.
Oops, something went wrong.
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 @@ | ||
package dk.gtz.graphedit.util; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; | ||
|
||
import dk.gtz.graphedit.viewmodel.Tip; | ||
import dk.gtz.graphedit.viewmodel.TipContainer; | ||
|
||
public class TipLoader { | ||
private static final Logger logger = LoggerFactory.getLogger(TipLoader.class); | ||
|
||
public static record Tips(ArrayList<Tip> tips) { | ||
} | ||
|
||
public static TipContainer loadTips(String tipsFile) { | ||
try { | ||
var mapper = new ObjectMapper(new YAMLFactory()); | ||
mapper.registerModule(new Jdk8Module()); | ||
var tips = mapper.readValue(TipLoader.class.getClassLoader().getResourceAsStream(tipsFile), Tips.class); | ||
return new TipContainer(tips.tips()); | ||
} catch (Exception e) { | ||
logger.error("Failed to load tips", e); | ||
return new TipContainer(List.of(new Tip("Error", "Failed to load tips"))); | ||
} | ||
} | ||
|
||
public static TipContainer loadTips() { | ||
return loadTips("tips/tips.yaml"); | ||
} | ||
} |
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