Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added some new edit/tools

  • Loading branch information...
commit b1f1f585e7750a1032f82d5b732ee1cf87f84c68 1 parent b967618
@johnmay authored
View
46 action/src/main/java/uk/ac/ebi/mnb/dialog/edit/ReassignIdentifiers.java
@@ -0,0 +1,46 @@
+package uk.ac.ebi.mnb.dialog.edit;
+
+import org.apache.log4j.Logger;
+import uk.ac.ebi.mdk.domain.entity.*;
+import uk.ac.ebi.mdk.domain.entity.reaction.MetabolicReaction;
+import uk.ac.ebi.mdk.domain.identifier.basic.*;
+import uk.ac.ebi.mnb.core.ControllerAction;
+import uk.ac.ebi.mnb.interfaces.MainController;
+
+import java.awt.event.ActionEvent;
+
+/**
+ * @author John May
+ */
+public class ReassignIdentifiers extends ControllerAction {
+
+ private static final Logger LOGGER = Logger.getLogger(ReassignIdentifiers.class);
+
+ public ReassignIdentifiers(MainController controller) {
+ super(ReassignIdentifiers.class.getSimpleName(), controller);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ for (Entity entity : getSelection().get(Metabolite.class)) {
+ entity.setIdentifier(BasicChemicalIdentifier.nextIdentifier());
+ }
+ for (Entity entity : getSelection().get(MetabolicReaction.class)) {
+ entity.setIdentifier(BasicReactionIdentifier.nextIdentifier());
+ }
+ for (Entity entity : getSelection().get(Gene.class)) {
+ entity.setIdentifier(BasicGeneIdentifier.nextIdentifier());
+ }
+ for (Entity entity : getSelection().get(ProteinProduct.class)) {
+ entity.setIdentifier(BasicProteinIdentifier.nextIdentifier());
+ }
+ for (Entity entity : getSelection().get(RNAProduct.class)) {
+ entity.setIdentifier(BasicRNAIdentifier.nextIdentifier());
+ }
+
+ update(getSelection());
+
+ }
+
+}
View
27 action/src/main/java/uk/ac/ebi/mnb/dialog/edit/Resync.java
@@ -0,0 +1,27 @@
+package uk.ac.ebi.mnb.dialog.edit;
+
+import org.apache.log4j.Logger;
+import uk.ac.ebi.mdk.domain.entity.collection.DefaultReconstructionManager;
+import uk.ac.ebi.mnb.core.ControllerAction;
+import uk.ac.ebi.mnb.interfaces.MainController;
+
+import java.awt.event.ActionEvent;
+
+/**
+ * Simple util that will force an update to all views
+ * @author John May
+ */
+public class Resync extends ControllerAction {
+
+ private static final Logger LOGGER = Logger.getLogger(Resync.class);
+
+ public Resync(MainController controller) {
+ super(Resync.class.getSimpleName(), controller);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ DefaultReconstructionManager.getInstance().getActive().getReactome().rebuildParticipantMap();
+ getController().update();
+ }
+}
View
36 action/src/main/java/uk/ac/ebi/mnb/dialog/tools/AddFlags.java
@@ -0,0 +1,36 @@
+package uk.ac.ebi.mnb.dialog.tools;
+
+import org.apache.log4j.Logger;
+import uk.ac.ebi.mdk.domain.annotation.AnnotationFactory;
+import uk.ac.ebi.mdk.domain.annotation.DefaultAnnotationFactory;
+import uk.ac.ebi.mdk.domain.entity.AnnotatedEntity;
+import uk.ac.ebi.mnb.core.ControllerAction;
+import uk.ac.ebi.mnb.interfaces.MainController;
+
+import java.awt.event.ActionEvent;
+
+/**
+ * @author John May
+ */
+public class AddFlags extends ControllerAction {
+
+ private static final Logger LOGGER = Logger.getLogger(AddFlags.class);
+
+ public AddFlags(MainController controller) {
+ super(AddFlags.class.getSimpleName(), controller);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ AnnotationFactory factory = DefaultAnnotationFactory.getInstance();
+
+ for (AnnotatedEntity entity : getSelection().getEntities()) {
+ entity.addAnnotations(factory.getMatchingFlags(entity));
+ }
+
+ update(getSelection());
+
+ }
+
+}
View
8 action/src/main/resources/uk/ac/ebi/mnb/dialog/edit/action.properties
@@ -11,6 +11,12 @@ AddAuthorAnnotation.Action.ShortDescription=Adds an author annotation to the cur
CreateSubset.Action.Name=Create subset
CreateSubset.Action.ShortDescription=Create a subset using the current selection
-
AddAnnotation.Action.Name=Add annotation
AddAnnotation.Action.ShortDescription=Adds an annotation to the selected entity
+
+ReassignIdentifiers.Action.Name=Reassign Primary Identifiers
+ReassignIdentifiers.Action.ShortDescription=Reassigns the primary identifier for the selected entities
+
+Resync.Action.Name=Resync
+Resync.Action.ShortDescription=Resynchronises the view in case the view is missing updates from the object model
+
View
3  action/src/main/resources/uk/ac/ebi/mnb/dialog/tools/action.properties
@@ -1,5 +1,8 @@
## Tools Menu ##
+AddFlags.Action.Name=Add Flags
+AddFlags.Action.ShortDescription=Predicts flags/tags that should be added to the selected entities
+
ChokePoint.Action.Name=Choke Points
ChokePoint.Action.ShortDescription=Finds metabolic choke points (uniquely produced or consumed metabolites)
View
33 mnb-application/src/main/java/uk/ac/ebi/mnb/menu/EditMenu.java
@@ -4,17 +4,17 @@
* 2011.09.26
*
* This file is part of the CheMet library
- *
+ *
* The CheMet library 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.
- *
+ *
* CheMet 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 General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public License
* along with CheMet. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -36,11 +36,12 @@
/**
- * EditMenu – 2011.09.26 <br>
- * Class description
+ * EditMenu – 2011.09.26 <br>
+ * Class description
+ *
+ * @author johnmay
+ * @author $Author$ (this version)
* @version $Rev$ : Last Changed $Date$
- * @author johnmay
- * @author $Author$ (this version)
*/
public class EditMenu extends ContextMenu {
@@ -90,12 +91,18 @@ public boolean getContext(ReconstructionManager reconstructions, Reconstruction
add(new JSeparator());
add(create(AddAuthorAnnotation.class));
add(create(AddAnnotation.class));
-// add(new AssignFlags("Add", view), new ContextResponder() {
-//
-// public boolean getContext(ReconstructionManager reconstructions, ReconstructionImpl active, EntityCollection selection) {
-// return selection.hasSelection();
-// }
-// });
+ add(new ReassignIdentifiers(MainView.getInstance()), new ContextResponder() {
+ @Override
+ public boolean getContext(ReconstructionManager reconstructions, Reconstruction active, EntityCollection selection) {
+ return selection.hasSelection();
+ }
+ });
+ add(new Resync(MainView.getInstance()), new ContextResponder() {
+ @Override
+ public boolean getContext(ReconstructionManager reconstructions, Reconstruction active, EntityCollection selection) {
+ return active != null;
+ }
+ });
add(new JSeparator());
add(new AbstractAction("Preferences") {
View
6 mnb-application/src/main/java/uk/ac/ebi/mnb/menu/ToolsMenu.java
@@ -67,6 +67,12 @@ public boolean getContext(ReconstructionManager reconstructions, Reconstruction
return selection.hasSelection(MetabolicReactionImpl.class);
}
});
+ add(new AddFlags(view), new ContextResponder() {
+
+ public boolean getContext(ReconstructionManager reconstructions, Reconstruction active, EntityCollection selection) {
+ return !selection.isEmpty();
+ }
+ });
//add(new AssignReactions(view));
Please sign in to comment.
Something went wrong with that request. Please try again.