-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shuffling menu items inside the Plugins submenu #6
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
57c6e02
Shuffling menu items inside the Plugins submenu
xulman ba8d0ac
Shuffling menu items continued
xulman 0140676
identifing constants/strings adopted to the menu layout,
xulman 90769f6
menu items descriptions made a bit clearer
xulman 12cf1dd
labels of menu items follow This Naming Scheme Just Like Main Mastodo…
xulman 33cf326
the "Merge projects" dialog (and plugin) is now registered in the same
xulman 4e04d6d
cosmetics in the dialogs for File->Merge and File->FixPath
xulman dd6b632
introduced subpackages and moved relevant files into them
xulman dde59b7
concluded to tag commands with the repo/group they belong to,
xulman 7d2b553
introduced F2 key-binding for LABEL_SELECTED_SPOTS action
xulman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,13 @@ | |
import org.mastodon.mamut.plugin.MamutPluginAppModel; | ||
import org.mastodon.mamut.project.MamutProject; | ||
import org.mastodon.mamut.tomancak.compact_lineage.CompactLineageFrame; | ||
import org.mastodon.mamut.tomancak.export.MakePhyloXml; | ||
import org.mastodon.mamut.tomancak.merging.Dataset; | ||
import org.mastodon.mamut.tomancak.merging.MergeDatasets; | ||
import org.mastodon.mamut.tomancak.merging.MergingDialog; | ||
import org.mastodon.mamut.tomancak.sort_tree.FlipDescendants; | ||
import org.mastodon.mamut.tomancak.sort_tree.SortTreeDialog; | ||
import org.mastodon.mamut.tomancak.spots.InterpolateMissingSpots; | ||
import org.mastodon.model.SelectionModel; | ||
import org.mastodon.ui.keymap.CommandDescriptionProvider; | ||
import org.mastodon.ui.keymap.CommandDescriptions; | ||
|
@@ -63,36 +69,39 @@ | |
@Plugin( type = MamutPlugin.class ) | ||
public class TomancakPlugins extends AbstractContextual implements MamutPlugin | ||
{ | ||
private static final String EXPORT_PHYLOXML = "[tomancak] export phyloxml for selection"; | ||
private static final String FLIP_DESCENDANTS = "[tomancak] flip descendants"; | ||
private static final String COPY_TAG = "[tomancak] copy tag"; | ||
private static final String INTERPOLATE_SPOTS = "[tomancak] interpolate spots"; | ||
private static final String TWEAK_DATASET_PATH = "[tomancak] tweak dataset path"; | ||
private static final String LABEL_SELECTED_SPOTS = "[tomancak] label spots"; | ||
private static final String COMPACT_LINEAGE_VIEW = "[tomancak] lineage tree view"; | ||
private static final String SORT_TREE = "[tomancak] sort tree"; | ||
private static final String EXPORT_PHYLOXML = "[exports] export phyloxml for selection"; | ||
private static final String FLIP_DESCENDANTS = "[trees] flip descendants"; | ||
private static final String COPY_TAG = "copy tag"; | ||
private static final String INTERPOLATE_SPOTS = "[trees] interpolate missing spots"; | ||
private static final String LABEL_SELECTED_SPOTS = "[trees] label selected spots"; | ||
private static final String COMPACT_LINEAGE_VIEW = "[displays] show compact lineage"; | ||
private static final String SORT_TREE = "[trees] sort lineage tree"; | ||
private static final String MERGE_PROJECTS = "merge projects"; | ||
private static final String TWEAK_DATASET_PATH = "fix project image path"; | ||
|
||
private static final String[] EXPORT_PHYLOXML_KEYS = { "not mapped" }; | ||
private static final String[] FLIP_DESCENDANTS_KEYS = { "not mapped" }; | ||
private static final String[] COPY_TAG_KEYS = { "not mapped" }; | ||
private static final String[] INTERPOLATE_SPOTS_KEYS = { "not mapped" }; | ||
private static final String[] TWEAK_DATASET_PATH_KEYS = { "not mapped" }; | ||
private static final String[] LABEL_SELECTED_SPOTS_KEYS = { "not mapped" }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very cool idea... -> commit 7d2b553 |
||
private static final String[] COMPACT_LINEAGE_VIEW_KEYS = { "not mapped" }; | ||
private static final String[] SORT_TREE_KEYS = { "not mapped" }; | ||
private static final String[] MERGE_PROJECTS_KEYS = { "not mapped" }; | ||
private static final String[] TWEAK_DATASET_PATH_KEYS = { "not mapped" }; | ||
|
||
private static Map< String, String > menuTexts = new HashMap<>(); | ||
|
||
static | ||
{ | ||
menuTexts.put( EXPORT_PHYLOXML, "Export phyloXML for selection" ); | ||
menuTexts.put( FLIP_DESCENDANTS, "Flip descendants" ); | ||
menuTexts.put( COPY_TAG, "Copy Tag..." ); | ||
menuTexts.put( INTERPOLATE_SPOTS, "Interpolate missing spots" ); | ||
menuTexts.put( TWEAK_DATASET_PATH, "Edit BDV XML path..." ); | ||
menuTexts.put( LABEL_SELECTED_SPOTS, "Label selected spots..." ); | ||
menuTexts.put( COMPACT_LINEAGE_VIEW, "Show compact lineage" ); | ||
menuTexts.put( SORT_TREE, "Sort lineage tree..." ); | ||
menuTexts.put( EXPORT_PHYLOXML, "Export phyloXML for Selection" ); | ||
menuTexts.put( FLIP_DESCENDANTS, "Flip Descendants" ); | ||
menuTexts.put( COPY_TAG, "Copy Tag" ); | ||
menuTexts.put( INTERPOLATE_SPOTS, "Interpolate Missing Spots" ); | ||
menuTexts.put( LABEL_SELECTED_SPOTS, "Label Selected Spots" ); | ||
menuTexts.put( COMPACT_LINEAGE_VIEW, "Show Compact Lineage" ); | ||
menuTexts.put( SORT_TREE, "Sort Lineage Tree" ); | ||
menuTexts.put( MERGE_PROJECTS, "Merge Two Projects" ); | ||
menuTexts.put( TWEAK_DATASET_PATH, "Fix Image Path" ); | ||
} | ||
|
||
/* | ||
|
@@ -110,13 +119,14 @@ public Descriptions() | |
public void getCommandDescriptions( final CommandDescriptions descriptions ) | ||
{ | ||
descriptions.add( EXPORT_PHYLOXML, EXPORT_PHYLOXML_KEYS, "Export subtree to PhyloXML format." ); | ||
descriptions.add( FLIP_DESCENDANTS, FLIP_DESCENDANTS_KEYS, "Flip children in trackscheme graph." ); | ||
descriptions.add( FLIP_DESCENDANTS, FLIP_DESCENDANTS_KEYS, "Flip children of the currently selected spot in trackscheme graph." ); | ||
descriptions.add( COPY_TAG, COPY_TAG_KEYS, "Copy tags: everything that has tag A assigned gets B assigned." ); | ||
descriptions.add( INTERPOLATE_SPOTS, INTERPOLATE_SPOTS_KEYS, "Interpolate missing spots." ); | ||
descriptions.add( TWEAK_DATASET_PATH, TWEAK_DATASET_PATH_KEYS, "Set the path to the BDV data and whether it is relative or absolute." ); | ||
descriptions.add( INTERPOLATE_SPOTS, INTERPOLATE_SPOTS_KEYS, "Along each track, new spot is inserted to every time points with no spots." ); | ||
descriptions.add( LABEL_SELECTED_SPOTS, LABEL_SELECTED_SPOTS_KEYS, "Set label for all selected spots." ); | ||
descriptions.add( COMPACT_LINEAGE_VIEW, COMPACT_LINEAGE_VIEW_KEYS, "Show compact representation of the lineage tree."); | ||
descriptions.add( SORT_TREE, SORT_TREE_KEYS, "Sort selected node according to tagged anchors."); | ||
descriptions.add( MERGE_PROJECTS, MERGE_PROJECTS_KEYS, "Merge two Mastodon projects into one." ); | ||
descriptions.add( TWEAK_DATASET_PATH, TWEAK_DATASET_PATH_KEYS, "Allows to insert new path to the BDV data and whether it is relative or absolute." ); | ||
} | ||
} | ||
|
||
|
@@ -128,14 +138,16 @@ public void getCommandDescriptions( final CommandDescriptions descriptions ) | |
|
||
private final AbstractNamedAction interpolateSpotsAction; | ||
|
||
private final AbstractNamedAction tweakDatasetPathAction; | ||
|
||
private final AbstractNamedAction labelSelectedSpotsAction; | ||
|
||
private final AbstractNamedAction lineageTreeViewAction; | ||
|
||
private final AbstractNamedAction sortTreeAction; | ||
|
||
private final AbstractNamedAction mergeProjectsAction; | ||
|
||
private final AbstractNamedAction tweakDatasetPathAction; | ||
|
||
private MamutPluginAppModel pluginAppModel; | ||
|
||
public TomancakPlugins() | ||
|
@@ -144,10 +156,11 @@ public TomancakPlugins() | |
flipDescendantsAction = new RunnableAction( FLIP_DESCENDANTS, this::flipDescendants ); | ||
copyTagAction = new RunnableAction( COPY_TAG, this::copyTag ); | ||
interpolateSpotsAction = new RunnableAction( INTERPOLATE_SPOTS, this::interpolateSpots ); | ||
tweakDatasetPathAction = new RunnableAction( TWEAK_DATASET_PATH, this::tweakDatasetPath ); | ||
labelSelectedSpotsAction = new RunnableAction( LABEL_SELECTED_SPOTS, this::labelSelectedSpots ); | ||
lineageTreeViewAction = new RunnableAction( COMPACT_LINEAGE_VIEW, this::showLineageView ); | ||
sortTreeAction = new RunnableAction( SORT_TREE, this::sortTree ); | ||
mergeProjectsAction = new RunnableAction( MERGE_PROJECTS, this::mergeProjects ); | ||
tweakDatasetPathAction = new RunnableAction( TWEAK_DATASET_PATH, this::tweakDatasetPath ); | ||
updateEnabledActions(); | ||
} | ||
|
||
|
@@ -163,15 +176,19 @@ public List< ViewMenuBuilder.MenuItem > getMenuItems() | |
{ | ||
return Arrays.asList( | ||
menu( "Plugins", | ||
menu( "Tomancak lab", | ||
item( EXPORT_PHYLOXML ), | ||
item( FLIP_DESCENDANTS ), | ||
item( INTERPOLATE_SPOTS ), | ||
item( COPY_TAG ), | ||
menu( "Auxiliary Displays", | ||
item( COMPACT_LINEAGE_VIEW )), | ||
menu( "Trees Management", | ||
item( LABEL_SELECTED_SPOTS ), | ||
item( COPY_TAG ), | ||
item( TWEAK_DATASET_PATH ), | ||
item( COMPACT_LINEAGE_VIEW ), | ||
item( SORT_TREE )) ) ); | ||
item( INTERPOLATE_SPOTS ), | ||
item( FLIP_DESCENDANTS ), | ||
item( SORT_TREE )), | ||
menu( "Exports", | ||
item( EXPORT_PHYLOXML )) ), | ||
menu( "File", | ||
item( TWEAK_DATASET_PATH ), | ||
item( MERGE_PROJECTS )) ); | ||
} | ||
|
||
@Override | ||
|
@@ -187,10 +204,11 @@ public void installGlobalActions( final Actions actions ) | |
actions.namedAction( flipDescendantsAction, FLIP_DESCENDANTS_KEYS ); | ||
actions.namedAction( copyTagAction, COPY_TAG_KEYS ); | ||
actions.namedAction( interpolateSpotsAction, INTERPOLATE_SPOTS_KEYS ); | ||
actions.namedAction( tweakDatasetPathAction, TWEAK_DATASET_PATH_KEYS ); | ||
actions.namedAction( labelSelectedSpotsAction, LABEL_SELECTED_SPOTS_KEYS ); | ||
actions.namedAction( lineageTreeViewAction, COMPACT_LINEAGE_VIEW_KEYS ); | ||
actions.namedAction( sortTreeAction, SORT_TREE_KEYS ); | ||
actions.namedAction( mergeProjectsAction, MERGE_PROJECTS_KEYS ); | ||
actions.namedAction( tweakDatasetPathAction, TWEAK_DATASET_PATH_KEYS ); | ||
} | ||
|
||
private void updateEnabledActions() | ||
|
@@ -200,10 +218,11 @@ private void updateEnabledActions() | |
flipDescendantsAction.setEnabled( appModel != null ); | ||
copyTagAction.setEnabled( appModel != null ); | ||
interpolateSpotsAction.setEnabled( appModel != null ); | ||
tweakDatasetPathAction.setEnabled( appModel != null ); | ||
labelSelectedSpotsAction.setEnabled( appModel != null ); | ||
lineageTreeViewAction.setEnabled( appModel != null ); | ||
sortTreeAction.setEnabled( appModel != null ); | ||
mergeProjectsAction.setEnabled( appModel != null ); | ||
tweakDatasetPathAction.setEnabled( appModel != null ); | ||
} | ||
|
||
private void exportPhyloXml() | ||
|
@@ -236,15 +255,6 @@ private void interpolateSpots() | |
} | ||
} | ||
|
||
private void tweakDatasetPath() | ||
{ | ||
if ( pluginAppModel != null ) | ||
{ | ||
final MamutProject project = pluginAppModel.getWindowManager().getProjectManager().getProject(); | ||
new DatasetPathDialog( null, project ).setVisible( true ); | ||
} | ||
} | ||
|
||
private void labelSelectedSpots() | ||
{ | ||
if ( pluginAppModel != null ) | ||
|
@@ -292,4 +302,42 @@ private void showLineageView() { | |
frame.setVisible(true); | ||
} | ||
|
||
private MergingDialog mergingDialog; | ||
|
||
private void mergeProjects() | ||
{ | ||
if ( mergingDialog == null ) | ||
mergingDialog = new MergingDialog( null ); | ||
mergingDialog.onMerge( () -> | ||
{ | ||
try | ||
{ | ||
final String pathA = mergingDialog.getPathA(); | ||
final String pathB = mergingDialog.getPathB(); | ||
final double distCutoff = mergingDialog.getDistCutoff(); | ||
final double mahalanobisDistCutoff = mergingDialog.getMahalanobisDistCutoff(); | ||
final double ratioThreshold = mergingDialog.getRatioThreshold(); | ||
|
||
final Dataset dsA = new Dataset( pathA ); | ||
final Dataset dsB = new Dataset( pathB ); | ||
pluginAppModel.getWindowManager().getProjectManager().open( new MamutProject( null, dsA.project().getDatasetXmlFile() ) ); | ||
final MergeDatasets.OutputDataSet output = new MergeDatasets.OutputDataSet( pluginAppModel.getAppModel().getModel() ); | ||
MergeDatasets.merge( dsA, dsB, output, distCutoff, mahalanobisDistCutoff, ratioThreshold ); | ||
} | ||
catch( final Exception e ) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} ); | ||
mergingDialog.setVisible( true ); | ||
} | ||
|
||
private void tweakDatasetPath() | ||
{ | ||
if ( pluginAppModel != null ) | ||
{ | ||
final MamutProject project = pluginAppModel.getWindowManager().getProjectManager().getProject(); | ||
new DatasetPathDialog( null, project ).setVisible( true ); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion here, but maybe let's keep the
"[tomancak] ..."
prefix here. It's more consistent, and gives an indication in the settings dialog that this plugin belongs to mastodon-tomancak.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, changed that back to [tomancak]... I also don't have a strong opinion on that
the original idea was to be able to group/filter related activities with a single keyword.. and so was essentially mirroring the menu layout in the brackets (besides, now that this repo is among the default installed, user is probably not realizing/not cares (maybe?)/does not see the source of this functionality)
but words like lineage, spot, sort... tend to group reasonably well and a user can see everything relevant and adjust/overview shortcuts in the key bindings dialog... so my primary goal is preserved and thus I'm happy :-)
I've took care of it in the commit dde59b7