Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Remove create contingencies menu item #278

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -9,6 +9,8 @@
import com.google.auto.service.AutoService;
import com.powsybl.afs.ProjectFolder;
import com.powsybl.afs.contingency.ContingencyStore;
import com.powsybl.commons.config.ModuleConfig;
import com.powsybl.commons.config.PlatformConfig;
import com.powsybl.gse.spi.GseContext;
import com.powsybl.gse.spi.ProjectFileCreator;
import com.powsybl.gse.spi.ProjectFileCreatorExtension;
Expand Down Expand Up @@ -54,6 +56,17 @@ public KeyCodeCombination getMenuKeycode() {
return new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN);
}

@Override
public boolean isMenuVisible() {
ModuleConfig moduleConfig = PlatformConfig.defaultConfig().getOptionalModuleConfig("contingency-creator-extension-menu").orElse(null);
if (moduleConfig == null) {
return true;
} else if (moduleConfig.hasProperty("visible")) {
return moduleConfig.getBooleanProperty("visible");
}
return true;
}

@Override
public ProjectFileCreator newCreator(ProjectFolder folder, Scene scene, GseContext context) {
return new ContingencyStoreCreator(folder);
Expand Down
2 changes: 1 addition & 1 deletion gse-app/src/main/java/com/powsybl/gse/app/ProjectPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ private ContextMenu createFolderContextMenu(TreeItem<Object> selectedTreeItem) {
items.add(createCreateFolderItem(selectedTreeItem, folder).order(99));
for (Class<? extends ProjectFile> type : project.getFileSystem().getData().getProjectFileClasses()) {
for (ProjectFileCreatorExtension creatorExtension : findCreatorExtension(type)) {
if (creatorExtension != null) {
if (creatorExtension != null && creatorExtension.isMenuVisible()) {
GseMenuItem menuItem = new GseMenuItem(creatorExtension.getMenuText());
menuItem.setOrder(creatorExtension.getMenuOrder());
menuItem.setGraphic(creatorExtension.getMenuGraphic());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ default int getMenuOrder() {

KeyCodeCombination getMenuKeycode();

default boolean isMenuVisible() {
return true;
}

ProjectFileCreator newCreator(ProjectFolder folder, Scene scene, GseContext context);
}