Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
SimpleCommands.java
1 package ij.plugin;
2 import ij.*;
3 import ij.process.*;
4 import ij.gui.*;
5 
8 public class SimpleCommands implements PlugIn {
9 
10  public void run(String arg) {
11  ImagePlus imp = IJ.getInstance().getImagePlus();
12  if (imp==null)
13  {IJ.noImage(); return;}
14  if (arg.equals("unlock"))
15  unlock(imp);
16  else if (arg.equals("rename"))
17  rename(imp);
18  }
19 
20  void unlock(ImagePlus imp) {
21  boolean wasUnlocked = imp.lockSilently();
22  if (wasUnlocked)
23  IJ.showStatus("\""+imp.getTitle()+"\" is not locked");
24  else {
25  IJ.showStatus("\""+imp.getTitle()+"\" is now unlocked");
26  IJ.beep();
27  }
28  imp.unlock();
29  }
30 
31  void rename(ImagePlus imp) {
32  GenericDialog gd = new GenericDialog("Rename");
33  gd.addStringField("Title:", imp.getTitle(), 30);
34  gd.showDialog();
35  if (gd.wasCanceled())
36  return;
37  else
38  imp.setTitle(gd.getNextString());
39  }
40 
41 }