-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from MesquiteProject/development
3.51 development into master
- Loading branch information
Showing
97 changed files
with
767 additions
and
273 deletions.
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
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
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
103 changes: 103 additions & 0 deletions
103
Source/mesquite/dmanager/RemoveTaxonPrefixSuffix/RemoveTaxonPrefixSuffix.java
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,103 @@ | ||
/* Mesquite source code. Copyright 1997 and onward, W. Maddison and D. Maddison. | ||
Disclaimer: The Mesquite source code is lengthy and we are few. There are no doubt inefficiencies and goofs in this code. | ||
The commenting leaves much to be desired. Please approach this source code with the spirit of helping out. | ||
Perhaps with your help we can be more than a few, and make Mesquite better. | ||
Mesquite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. | ||
Mesquite's web site is http://mesquiteproject.org | ||
This source code and its compiled class files are free and modifiable under the terms of | ||
GNU Lesser General Public License. (http://www.gnu.org/copyleft/lesser.html) | ||
*/ | ||
package mesquite.dmanager.RemoveTaxonPrefixSuffix; | ||
|
||
import java.util.*; | ||
import java.awt.*; | ||
|
||
import mesquite.lib.*; | ||
import mesquite.lib.duties.*; | ||
import mesquite.lib.table.*; | ||
|
||
|
||
public class RemoveTaxonPrefixSuffix extends TaxonNameAlterer { | ||
String searchText="."; | ||
MesquiteBoolean suffix = new MesquiteBoolean(true); | ||
|
||
/*.................................................................................................................*/ | ||
public boolean startJob(String arguments, Object condition, boolean hiredByName){ | ||
return true; | ||
} | ||
/*.................................................................................................................*/ | ||
public int getVersionOfFirstRelease(){ | ||
return 351; | ||
} | ||
/*.................................................................................................................*/ | ||
public boolean getOptions(Taxa taxa, int firstSelected){ | ||
if (MesquiteThread.isScripting()) | ||
return true; | ||
MesquiteInteger buttonPressed = new MesquiteInteger(1); | ||
ExtensibleDialog queryDialog = new ExtensibleDialog(containerOfModule(), "Remove Prefix or Suffix", buttonPressed); | ||
queryDialog.addLabel("Remove the prefix or suffix of taxon name", Label.CENTER); | ||
SingleLineTextField searchField = queryDialog.addTextField("Delimiter:", searchText, 12, true); | ||
Checkbox suffixBox = queryDialog.addCheckBox("Remove Suffix (otherwise Prefix)", suffix.getValue()); | ||
queryDialog.completeAndShowDialog(true); | ||
|
||
boolean ok = (queryDialog.query()==0); | ||
|
||
if (ok) { | ||
searchText = searchField.getText(); | ||
suffix.setValue(suffixBox.getState()); | ||
} | ||
|
||
queryDialog.dispose(); | ||
|
||
return ok; | ||
} | ||
/*.................................................................................................................*/ | ||
/** Called to alter the taxon name in a single cell. If you use the alterContentOfCells method of this class, | ||
then you must supply a real method for this, not just this stub. */ | ||
public boolean alterName(Taxa taxa, int it){ | ||
boolean nameChanged = false; | ||
String name = taxa.getTaxonName(it); | ||
if (name!=null){ | ||
String s = ""; | ||
if (suffix.getValue()){ //removing suffix | ||
int delim = name.lastIndexOf(searchText); | ||
if (delim>=0){ | ||
name = name.substring(0, delim); | ||
taxa.setTaxonName(it, name, false); | ||
nameChanged = true; | ||
} | ||
} | ||
else { | ||
int delim = name.indexOf(searchText); | ||
if (delim>=0){ | ||
name = name.substring(delim+1, name.length()); | ||
taxa.setTaxonName(it, name, false); | ||
nameChanged = true; | ||
} | ||
} | ||
} | ||
return nameChanged; | ||
} | ||
/*.................................................................................................................*/ | ||
public String getNameForMenuItem() { | ||
return "Remove Prefix/Suffix of Taxon Name..."; | ||
} | ||
/*.................................................................................................................*/ | ||
public String getName() { | ||
return "Remove Prefix/Suffix of Taxon Name"; | ||
} | ||
|
||
/*.................................................................................................................*/ | ||
public String getExplanation() { | ||
return "Remove Prefix or Suffix of Taxon Name."; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.