AMADEUS html plain
import java.awt.*;
Color
import java.lang.*;
import java.io.File;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
class ProjectBoard
atribuutide nimed
static final String PATHS = "Paths";
static final String OPEN = "Open-script";
static final String SAVE = "Save-script";
SGolovko
static Vector search_parameters = new Vector();;
static final String NEW_PROJECT = "New project";
static final String PROJECT_FILES = "Project files";
static final String PATH = "path";
static final String EXT = "ext";
static final String params[] = {"path", "ext"};
static String er = (Am.isWindows)? "\\" : "/";
eraldaja kataloogitees
static final String INHERITANCE = ".";
atribuutide eraldajad
static char KOLUMN = ':';
static char PUNKT = '.';
static char EQUAL_SIGN = '=';
static char PLUS_SIGN = '+';
static char LESS_THAN = '{';
static char MORE_THAN = '}';
static char SPACE = ' ';
save/open codes
static final int SAVE_SCRIPT = 1;
static final int OPEN_SCRIPT = 0;
project branch codes
static final int ATRIBUTE_BRANCH = 0;
static final int FILE_BRANCH = 1;
static Cursor moveToProjectFileName(Sketch project, String pFName)
tagastatakse kursor (või null),
mis on viidud antud projektifailinime sisaldavale primitiivile
Cursor cur = new Cursor(project);
* ; cur.moveDirectDown();
? cur.text != null
? (cur.text.toPlainString().trim()).equals(pFName)
<==========cur
<======null
static Sketch getSelectionOwnProject(AmFrame pDFrame)
kasutab: AmProjectFileFrame konstruktor ja :setOwnProject
leitakse lähim valitud primitiivi hõlmav projektikirjeldus,
tagastatakse leitud projektikirjelduse skeem nimi
(või null, kui ei leitud)
AmCanvas c = (AmCanvas)(pDFrame.viewArea);
??c.selection.kind()
? Selection.PRIMITIVE:
? Selection.PRIMITIVETEXT:
Branch br = null;
Scheme s = c.selection.parent();
? s instanceof Branch
br = (Branch)s;
? br == null
<==========null
Sketch sk = getProjectSketch(br);
? sk == null
<======
<==========sk
<======null
static String getProjectFileName(AmFrame pDFrame)
kasutab Item01Listener (File + Open)
leitakse valitud projektifailinimi,
või null, kui projektifailinimi pole (õiges kohas) valitud
AmCanvas c = (AmCanvas)(pDFrame.viewArea);
??c.selection.kind()
? Selection.PRIMITIVE:
? Selection.PRIMITIVETEXT:
Branch br = null;
Scheme s = c.selection.parent();
? s instanceof Branch
br = (Branch)s;
? br == null
<==========null
Sketch sk = getProjectSketch(br);
? sk == null
<==========null
//sk polnud kaheharuline
Primitive pr = c.selection.start.primitive;
? ((Scheme)br).isSubScheme((Scheme)sk.branch(FILE_BRANCH))
<==============c.selection.start.primitive.text.toPlainString().trim()
<==============null
<==========null
static void colorProjectFileName(AmFrame pDFrame, Sketch projectSketch, String fileName, Color col)
Sisend: pDFrame - projektiKirjelduse aken;
projectSketch - sketch pDFrame - s, kus otsitakse fileName;
fileName - vaja värvida värviks col primitiivi teksti kust fileName on kirjas;
Kasut:
Cursor cur = moveToProjectFileName(projectSketch, fileName);
? cur == null
writeLog("ERROR (ProjectBoard.colorProjectFileName): file name '"+fileName+"' does not found in project.");
return;
Primitive p = cur.primitive;
p.text.setColor(col);
? !cur.scheme.isInIconifiedScheme()
AmCanvas c = (AmCanvas)(pDFrame.viewArea);
Graphics g = c.getGraphics();
? g == null
kui projektifaili raam on juba suletud
<==========
g.translate(c.start.x, c.start.y);
float sizeFactorKeep = AmView.sizeFactor;
AmView.sizeFactor = pDFrame.sizeFactor;
p.text.draw(g);
AmView.sizeFactor = sizeFactorKeep;
static boolean isProjectFileNameGrayed(AmFrame pDFrame)
kasutab AmMouse- ja Item01Listener, et mitte avatut avada
leitakse valitud projektifailinimi, tagastatakse
true, kui see on lightGray,
siis ka sellele nimele vastav raam tuuakse esile
false kui see pole lightGray või pole valikut
AmCanvas c = (AmCanvas)(pDFrame.viewArea);
? c.selection == null
return true;
valik oli vigane, kuid ei ole vaja otsida faili nimet
??c.selection.kind()
? Selection.PRIMITIVE:
? Selection.PRIMITIVETEXT:
Branch br = null;
Scheme s = c.selection.parent();
? s instanceof Branch
br = (Branch)s;
? br == null
<==========true
Sketch sk = getProjectSketch(br);;
? sk == null
<==========true
//sk polnud kaheharuline
Row r = c.selection.start.primitive.text.row(0);
r.getElement(0);
? r.sy != null
? r.sy.color == Color.lightGray
tuua vastav raam esile
String s =
c.selection.start.primitive.text.toPlainString().trim();
* int i = 0; i < Am.frames.size(); i++
AmFrame fr = (AmFrame)(Am.frames.elementAt(i));
? fr instanceof AmProjectFileFrame
? fr.getTitle().indexOf(s) >= 0
fr.setState(javax.swing.JFrame.NORMAL);
fr.toFront();
<======
<==========true
<==========false
<==========true
kuid edasi otsida faili nimet ja projektikirjeldust ei ole vaja
S.Golovko
SULGEMISE MEETODID
static void closeAmProjectFileFrame( AmProjectFileFrame frame )
String failiLihtnimi;
? frame.contents == null
<======
? frame.contents.file == null
<======
int i = frame.contents.file.name.lastIndexOf(ProjectBoard.er);
? i == -1
Fail on antud mitte täis nimega
failiLihtnimi = frame.contents.file.name.trim();
<======
failiLihtnimi = frame.contents.file.name.substring(i+1).trim();
<==========
? failiLihtnimi.equals("")
<==========
colorProjectFileName(frame.projectDescriptionFrame, frame.ownProject, failiLihtnimi, Default.foregroundColor);
static boolean isAnyFrameForSave(AmFrame frame)
boolean returnValue = false;
int k = Am.frames.size();
AmFrame fr = null;
* int i =0; i < k; i++
fr =(AmFrame)Am.frames.get(i);
? fr instanceof AmProjectFileFrame
? ((AmProjectFileFrame)fr).projectDescriptionFrame == frame
? fr.contents != null
? fr.contents.file != null
? fr.contents.file.changed
returnValue = true;
return returnValue;
return returnValue;
DEFAULT PROJECT
static Sketch defaultProject()
tagastab tühja projektskeemi
kasutatakse Item0100Listener.importProjectInto
Sketch project;
kompil.
project = new Sketch(Scheme.MODULE,
new Branch(Scheme.SIMPLE,
new BaseLanguage0()),
new BaseLanguage0());
Text headCaption= new Text();
headCaption.insert(new Row(NEW_PROJECT, Default.sketchHeadColor),0);
headCaption.joinRow(1);
project.add(new PrimitiveHead(PrimitiveHead.SIMPLE, headCaption));
PATH atribuudid
Sketch attributeSketch = new Sketch(Scheme.SIMPLE, new Branch(Scheme.SIMPLE, new BaseLanguage0()), new BaseLanguage0());
attributeSketch.icon = true;
headCaption= new Text();
headCaption.insert(new Row(PATHS, Default.sketchHeadColor), 0);
headCaption.joinRow(1);
attributeSketch.add(new PrimitiveHead(PrimitiveHead.SIMPLE, headCaption));
project.branch(0).add(attributeSketch);
OPEN atribuudid
attributeSketch = new Sketch(Scheme.SIMPLE, new Branch(Scheme.SIMPLE, new BaseLanguage0()), new BaseLanguage0());
attributeSketch.icon = true;
headCaption= new Text();
headCaption.insert(new Row(OPEN, Default.sketchHeadColor),0);
headCaption.joinRow(1);
attributeSketch.add(new PrimitiveHead(PrimitiveHead.SIMPLE, headCaption));
project.branch(0).add(attributeSketch);
SAVE atribuudid
attributeSketch = new Sketch(Scheme.SIMPLE, new Branch(Scheme.SIMPLE, new BaseLanguage0()), new BaseLanguage0());
attributeSketch.icon = true;
headCaption= new Text();
headCaption.insert(new Row(SAVE, Default.sketchHeadColor),0);
headCaption.joinRow(1);
attributeSketch.add(new PrimitiveHead(PrimitiveHead.SIMPLE, headCaption));
project.branch(0).add(attributeSketch);
project.branch(0).removeMember(0);
Teine haru
Branch secondBranch = new Branch(Scheme.SIMPLE, new BaseLanguage0());
secondBranch.comment = new Row(PROJECT_FILES, Default.commentColor);
project.add(secondBranch);
return project;
ATTRIBUTE INHERITANCE
static String getProjectName(Sketch project)
String project_name = null;
? !project.isHeadless()
project_name = (String)project.primitiveHead(0).text.toPlainString();
return project_name;
static boolean addSearchParameterss(String parameter)
boolean returnValue = false;
? (search_parameters.indexOf((Object)parameter)) == -1
search_parameters.addElement((Object)parameter.trim());
returnValue = true;
return returnValue;
static boolean addSearchParameters(String[] parameters)
boolean returnValue = false;
? search_parameters.indexOf((Object)parameters)>=0
<==========true
? search_parameters.size() == 0
search_parameters.addElement((Object)parameters);
returnValue = true;
<======
? !cycle(parameters)
search_parameters.addElement((Object)parameters);
returnValue = true;
return returnValue;
static boolean cycle(String[] kaar)
Vector tee_tipud = tee(kaar[1]);
? tee_tipud == null || tee_tipud.indexOf((Object)kaar[0])>-1
return true;
return false;
static Vector tee(String tipp)
Vector res = new Vector();
Vector sub;
String [] kaar;
* int i = 0; i < search_parameters.size(); i++
kaar = (String[])search_parameters.elementAt(i);
? kaar[0].trim().equals(tipp)
res.add(kaar[1]);
sub = tee(kaar[1]);
!!
? sub != null
res.addAll(sub);
! (NullPointerException e)
return res;
static void printV()
String [] kaar;
System.out.println("VECTOR"+search_parameters.size());
* int i = 0; i < search_parameters.size(); i++
kaar = (String[])search_parameters.elementAt(i);
System.out.println(kaar[0]+"->"+kaar[1]);
static void clearSearchParameters()
search_parameters.clear();
static Sketch getAttributeSketch(Sketch project, String groupName)
Sketch attributeSketch = null;
? project == null
writeLog("ERROR (Project.getAttributeSketch): Attemp to search in null project ");
<======null
Antud: projektikirjeldus
Tulemus: tagastatakse skeem projektikirjelduse esimeses harus,
mille kommentaar algab attName-ga (või null)
Branch br = project.branch(0);
* int i = 0; i < br.body.size(); i++
Object o = br.member(i);
? !(o instanceof Sketch)
<------
attributeSketch = (Sketch)o;
(SG)Atribute group name is in sketch head.
String str = attributeSketch.primitiveHead(0).text.toPlainString().trim();
<==============attributeSketch
Attempt to seach attribute group in parent Projects.
? attributeSketch == null
Tuleb leida script ylem projektides
Sketch parentProject;
parentProject = getProjectSketch((Branch)project.parent);
* ;attributeSketch == null && parentProject !=null;
attributeSketch = getAttributeSketch(parentProject, groupName);
? attributeSketch != null
<======
parentProject = getProjectSketch((Branch)parentProject.parent);
? attributeSketch == null
writeLog("WARNING (Project.getAttributeSketch): Attribute Group '"+ groupName+"' is missing in the project and in parents projects too");
<======attributeSketch
static String getAttrElementInherited(Sketch project,
String attrGroup, String attrName)
Otsib atribuudi nimega 'attrName' projekti 'prjoect' ülem projektides
Atribuutide grupp 'attrGroup' on otsimise lihtsustamiseks
String atribuut = "";
String atribuudi_sisu = null;
String atribuudi_nimi = "";
boolean isFound = false;
Sketch ylem;
? project == null
<======null
Sketch attrSk = getAttributeSketch(project, attrGroup);
Kui atribuutskeem puudub antud projektis
? attrSk == null
//ylem = project;
//ylem = getProjectSketch((Branch)ylem.parent);
// String vastus = getAttrElementInherited(ylem, attrGroup, attrName);
<==========null
Branch attrBr = attrSk.branch(0);
int BranchSize = attrBr.body.size();
* int i = 0; i < BranchSize; i++
PrimitiveMember attrPrimitive =(PrimitiveMember)(attrBr.member(i));
atribuut = attrPrimitive.text.toPlainString().trim();
ylem = project;
? !atribuut.equals("")
? atribuut.startsWith(attrName)
? atribuut.substring(attrName.length()).trim().indexOf(KOLUMN) != 0
String project_name = getProjectName(project);
writeLog("ERROR (ProjectBoard.getAttrElementInherited): Definition of attribute '"+attrName+"' in project '"+project_name+"' is not correct!");
return "";
int kolumn = atribuut.indexOf(KOLUMN);
kas attrName võrdne atribuut alamstringiga mis asub enne kolumit
? (kolumn >= 0)
atribuudi_nimi = atribuut.substring(0, kolumn).trim();
String attrNameInAtribuut = atribuut.substring(0, kolumn).trim();
? atribuudi_nimi.equals(attrName)
isFound = true;
atribuudi_sisu = atribuut.substring(kolumn+1).trim();
kasutada pärimise mehhanismi?
? atribuudi_sisu.startsWith(INHERITANCE)
atribuudi_sisu = atribuudi_sisu.substring(atribuudi_sisu.indexOf(INHERITANCE)+INHERITANCE.length()).trim();
? ylem.level() <= 1
? atribuudi_sisu.startsWith(er)
atribuudi_sisu = atribuudi_sisu.substring(er.length());
? ylem.level() > 1
mis juhtub kui on kirjas '.' kuid asume esimese skeemas? -> vea viskama vaja.
ylem = getProjectSketch((Branch)ylem.parent);
String vastus = getAttrElementInherited(ylem, attrGroup, attrName);
? vastus == null || vastus.trim().equals("")
? atribuudi_sisu.startsWith(er)
atribuudi_sisu = atribuudi_sisu.substring(er.length());
<======
? (vastus.endsWith(er)) && atribuudi_sisu.startsWith(er)
atribuudi_sisu = atribuudi_sisu.substring(er.length());
<======
? !(vastus.endsWith(er)) && !(atribuudi_sisu.startsWith(er))
atribuudi_sisu = er + atribuudi_sisu;
atribuudi_sisu = vastus+atribuudi_sisu;
return atribuudi_sisu;
V\~oib olla atribuut ei ole defineeritud selles projektis, vaid \"ulemprojektis
? !isFound
ylem = project;
? ylem.level() > 1
mis juhtub kui on kirjas '.' kuid asume esimese skeemas? -> vea viskama vaja.
ylem = getProjectSketch((Branch)ylem.parent);
return getAttrElementInherited(ylem, attrGroup, attrName);
// !(atribuudi_sisu == null)
// atribuudi_sisu.endsWith(er)
Eeldame, et kui vaja siis viimast kripsu lisatakse ise
// atribuudi_sisu = atribuudi_sisu.substring(0, atribuudi_sisu.length()-1);
<======replaceSubAttrs(attrName, atribuudi_sisu, project, attrGroup)
static String replaceSubAttrs(String name,String str, Sketch project,
String attrGroup)
Input: attrValue - str, kus võib olla kasutatud teise atribuudi märgend eri sümbolite vahel
Output: Teiste atribuutide märgendid koos eri sümbolitega asendatud atribuutide väärtustega.
? str == null || str.length() ==0
return null;
int more;
String subPath;
String subPathReal;
String subPathValue;
String returnValue = str;
int less = returnValue.indexOf(LESS_THAN, 0);
String project_name = getProjectName(project);
Vector found_parameters = new Vector();
? project_name == null || project_name.trim().equals("")
project_name = "None";
* ; (less >= 0) ;
more = returnValue.indexOf(MORE_THAN, less+1);
? more >= 0
subPathReal = returnValue.substring(less+1, more);
subPath = subPathReal.trim();
String arrow_start;
? name == null || name.trim().equals("")
arrow_start = "";
<======
arrow_start = project_name+"."+name;
? ! addSearchParameters(new String[]{arrow_start,project_name+"."+subPath})
writeLog("ERROR (ProjectBoard.replaceSubAttrs): cycle in defenition of atribute '"+subPath+"' that used in project '"+project_name+"' has been found.");
return null;
tagastame antud atribuudi teksti
subPathValue = getAttrElementInherited(project, attrGroup, subPath);
? subPathValue != null && subPathValue.length()>0
returnValue = returnValue.substring(0, less) + subPathValue + returnValue.substring(more+1);
less = returnValue.indexOf(LESS_THAN, less+1);
? found_parameters.indexOf((Object)subPath) == -1
found_parameters.addElement((Object)subPath);
found_parameters.addElement((Object)subPathValue);
<======
less = returnValue.indexOf(LESS_THAN, more);
<======
return returnValue;
static String pathInheritedValue(Sketch project, String pathDef)
Antud: Project sketch, atribuudi nimi
Tulemus: atribuudi väärtus projekti sketchi path atribuudi gruppis
Atribuudi väärtus otsitakse pärimise mehhaniismiga
String pathValue1=null;
clearSearchParameters();
pathValue1 = getAttrElementInherited(project, PATHS, pathDef);
return pathValue1;
VALIDATION
static Sketch getProjectSketch(Branch br)
kasutab (vähemalt): getProjectFileName()
Antud: br - projektifaili nime sisaldav haru
Tulemus: tagastatakse lähim hõlmav valiidne projektiskeem (või null)
// ((Sketch)(br.parent)).level() == 0
// null
Sketch canBeProject;
canBeProject = (Sketch)(br.parent);
* ; canBeProject !=null;
? isProjectSketch(canBeProject)
<==========canBeProject
? canBeProject.level() == 0
<==========null
? ((Sketch)(br.parent)).level() == 0
<==========null
canBeProject = (Sketch)(canBeProject.parent.parent);
<======null
static boolean isProjectSketch(Sketch sk)
[SS]
Tagastab true kui antud skeem sk on projektikirjeldav skeem
Skeem peab olema MODULE t\"u\"ubi ja peab koosnema kahest harust (m\~olemad harud t\"u\"ubi SIMPLE)
String sketchName = "";
String errorMessage = "";
selgitav veateade - miks projektiskeem ei ole validne; t\"uhi, kui projekti skeem on valiidne
? !sk.isHeadless()
sketchName =sk.primitiveHead(0).text.toPlainString().trim();
? (sketchName.length() == 0)
sketchName = sk.comment.toString().trim();
? sk.type != Scheme.MODULE
errorMessage = "isProjectSketch, Sketch -'" +sketchName+ "' is not MODUL sketch";
<======false
? sk.body.size() != 2
errorMessage = "isProjectSketch, Sketch - '" +sketchName+ "' has more than two branches";
? !(sketchName.equals(""))
writeLog("ERROR (ProjectBoard.isProjectSketch):"+errorMessage);
<======false
? ((Branch)sk.member(0)).type != Scheme.SIMPLE
errorMessage = "isProjectSketch, Sketch - '" +sketchName+ "' first branche is not SIMPLE branch";
//writeLog("ERROR (method ProjectBoard.isProjectSketch):"+errorMessage);
<======false
? ((Branch)sk.member(1)).type != Scheme.SIMPLE
errorMessage = "isProjectSketch, Sketch - '" +sketchName+ "' second branche is not SIMPLE branch";
//writeLog("ERROR (method ProjectBoard.isProjectSketch):"+errorMessage);
<======false
<======true
static boolean isValidProjectSketch(Sketch sk)
[SS]
Projektiskeemi validsuse kontroll
Kontrollib projektiskeemit sk ja k\~oik tema alamskeemid
Tagastab true kui sk ei sisalda MODULE alamskeemid v\~oi
kui k\~oik sk alamskeemid(ja tema ise) sisaldavad validsed MODUL skeemid (ehk projektikirjeldusi)
String sketchName = "";
String errorMessage = "";
selgitav veateade - miks projektiskeem ei ole validne; t\"uhi, kui projekti skeem on valiidne
boolean retrunValue = false;
sketch name
? !sk.isHeadless()
sketchName =sk.primitiveHead(0).text.toPlainString().trim();
? (sketchName.length() == 0)
sketchName = sk.comment.toString().trim();
Kas skeemi t\"u\"up on projekti skeemi t\"u\"up?
? sk.type == Scheme.MODULE
? sk.body.size() != 2
String sizeOfSketch = Integer.toString(sk.body.size());
errorMessage ="Sketch - '" +sketchName+ "' has " + sizeOfSketch+" branches. Project scketch needs 2 branches. ";
//writeLog(errorMessage);
<==============false
? ((Branch)sk.member(0)).type != Scheme.SIMPLE
errorMessage = "Sketch - " +sketchName+ " first branche is not SIMPLE branch.";
//writeLog(errorMessage);
<==============false
? ((Branch)sk.member(1)).type != Scheme.SIMPLE
errorMessage = "Sketch - " +sketchName+ " second branche is not SIMPLE branch.";
//writeLog(errorMessage);
<==============false
// N\"u\"ud vaja kontrollida k\~oik alam skeemid
Branch controllBranch;
controllBranch = ((Branch)sk.member(1));
* int i=0; i< controllBranch.body.size(); i++
? controllBranch.member(i) instanceof Sketch
? !isValidProjectSketch((Sketch)controllBranch.member(i))
<==================false
<==========true
oli moodul skeem ja korrektne moodul skeem
// If skeem ei ole MODUL skeem siis k\~oik tema MODULE alamskeemid
peavad olema korrektsed
Branch childBranch;
* int j=0; j
childBranch = ((Branch)(sk.member(j)));
* int l=0; l
? childBranch.member(l) instanceof Sketch
? !isValidProjectSketch((Sketch)childBranch.member(l))
<==================false
<==========true
static boolean isProjectDescriptionFrame(AmFrame frame)
kontroll, kas leidub mõni sellele viitav raam
<==========false
? frame.contents.main == null
<==========false
boolean returnValue = isValidProjectSketch(frame.contents.main);
? !returnValue
// writeLog("INFO (method ProjectBoard.isProjectDescriptionFrame): Trying to work with Project. Frame is not ProjectDescriptionFrame.");
return returnValue;
AUTOMAT SCRIPTS
static void executeAutomatScript(AmFrame frame, String fileName, int code )
frame == null?
? frame == null
writeLog("ERROR (ProjectBoard.executeAutomatScript): input frame is null.");
return;
//frame.contents == null || frame.contents.main == null
? frame.contents == null || frame.contents.main == null
writeLog("ERROR (ProjectBoard.executeAutomatScript): Action can't be performed. SketchyText is null in frame!");
//return;
frame.contents == null || frame.contents.main == null kas seda üldsegi vaja ???
? frame.contents == null || frame.contents.main == null
? code == SAVE_SCRIPT
JK 19.19.2006
writeLog("ERROR (ProjectBoard.executeAutomatScript): Action can't be performed. SketchyText is null in frame!");
//return;
AmFrame pDFrame = null;
String pFName;
kas tegemis avamis või salvestamis tegevusega
? code == SAVE_SCRIPT
? fileName == null || fileName.trim().equals("")
! (frame instanceof AmProjectFileFrame)
? ! (frame instanceof AmProjectFileFrame)
writeLog("ERROR (ProjectBoard.executeAutomatScript): Save action can't be performed. frame is not AmProjectFileFrame!");
return;
pFName = frame.contents.file.name;
<======
executeSaveAutomatScript((AmProjectFileFrame)frame, pFName);
<======
? code == OPEN_SCRIPT
executeOpenAutomatScript(frame);
static void executeSaveAutomatScript( AmProjectFileFrame pDFrame, String fileName )
meetod skriptide automatiseerimiseks
Sissend parameetrid: pDFframe - kus oli tehtud kl\~ops
frame - uus aken, kus toimub faili avamine
pFName -failinimi, millele vaja rakendada avamise skripti
Eeldame, et 'open' grupis on anul üks script primitivi tekstis
Sketch Project = pDFrame.ownProject;
boolean isSaved = true;
is Project is null?
? Project == null
writeLog("ERROR (ProjectBoard.executeSaveAutomatScript): project of frame can not be found.");
return;
Leiame projektikirjeldus millele kuulub pFName
Leiame kõik projektikirjelduse Project avamisescriptid
Sketch saveAttributeSketch = getAttributeSketch(Project, SAVE);
is group is null?
? (saveAttributeSketch == null)
writeLog("ERROR (ProjectBoard.executeSaveAutomatScript): Save attribute group can not be found in project desciption.");
return;
execute scripts
? !executeScriptsFromAttributeGroup(((AmFrame)pDFrame), Project, saveAttributeSketch, fileName, SAVE_SCRIPT)
isSaved = false;
is save succeeded?
? isSaved
pDFrame.contents.setChanged(false);
static void executeOpenAutomatScript( AmFrame frame)
meetod skriptide automatiseerimiseks
Sissend parameetrid: pDFframe - kus oli tehtud kl\~ops
frame - uus aken, kus toimub faili avamine
pFName -failinimi, millele vaja rakendada avamise skripti
AmFrame pDFrame = null;
boolean openInNewWindow = true;
Sketch Project = null;
Project frame
? frame instanceof AmProjectFileFrame
pDFrame = ((AmProjectFileFrame)frame).projectDescriptionFrame;
openInNewWindow = false;
<======
? isProjectDescriptionFrame(frame)
Siin saab olla validsuse kontroll
pDFrame = frame;
<======
writeLog("ERROR (ProjectBoard.executeOpenAutomatScript): frame is not Project Description frame or Project File Frame.");
return;
pDFrame == null?
? pDFrame == null
writeLog("ERROR (ProjectBoard.executeOpenAutomatScript): Project frame can not be found.");
return;
isProjectFileNameGrayed(pDFrame)
AmCanvas c = (AmCanvas)(pDFrame.viewArea);
//System.out.println("ProjectBoard:executeOpenAutomatScript 3 c.selection.kind(): " + c.selection.kind());
? c.selection.kind() == Selection.NONE
AmDialog d = new AmDialog(frame, AmLocale.Error(), AmDialog.B_OK,
AmLocale.No_file_name_selected_in_project() + "!");
<==============
? isProjectFileNameGrayed(pDFrame)
<==========
Project = getSelectionOwnProject(pDFrame);
AmProjectFileFrame newProjectFileFrame;
String fileName;
Project == null?
? Project == null
writeLog("ERROR (ProjectBoard.executeOpenAutomatScript): Project desciption is null or selection was not made in project description.");
return;
Leiame projektikirjeldus millele kuulub pFName
Leiame kõik projektikirjelduse Project avamisescriptid
Sketch openAttributeSketch = getAttributeSketch(Project, OPEN);
is group is null?
? (openAttributeSketch == null)
writeLog("ERROR (ProjectBoard.executeOpenAutomatScript): Open attribute group can not be found in project desciption.");
return;
fileName = getProjectFileName(pDFrame);
is fileName is null?
? ((fileName == null) || fileName.trim().equals(""))
writeLog("ERROR (ProjectBoard.executeOpenAutomatScript): No file name was selected in project desciption or file name can not be found in the selection.");
return;
Kontrollime kas grupis on tegevused kirjas. Muidu ei ole vaja uut akna avada
Branch attrBr = openAttributeSketch.branch(0);
????? Juht kui atribuudid asuvad mite esimesel harus ?????
int k = attrBr.body.size();
There is no branch in sketch
? (k == 0)
writeLog("ERROR (ProjectBoard.executeOpenAutomatScript): Open attribute group has no scripts");
return;
Uus aken avatava faili jaoks
? openInNewWindow
newProjectFileFrame = Am.addProjectFileFrame(pDFrame);
Open ja Save menüü itemite enablemine
newProjectFileFrame.menuBar.setEnabled(AmLocale.File(), AmLocale.Open(), true);
newProjectFileFrame.menuBar.setEnabled(AmLocale.File(), AmLocale.Save(), true);
newProjectFileFrame.setLocation(new Point(350, 50));
pDFrame.setLocation(new Point(50, 50));
pDFrame.setSize(300, 600);
<======
JK 03.05.02
? ! (frame.menuBar.menuItemIsEnabled(AmLocale.File(),
AmLocale.Save()))
kas Save polnud lubatud?
Save ei olnud lubatud, uue jaoks Save lubada:
frame.menuBar.setEnabled(AmLocale.File(),
AmLocale.Save(), true);
<==========
Save jääb ära.
Save lubatud. Kontrollime, kas fail oli muudetud.
? frame.contents != null && frame.contents.file.changed
Fail oli muudetud, küsime kas salvestada faili
AmDialog d;
d = new AmDialog(frame, AmLocale.Open(),
AmDialog.B_YES_NO_CANCEL,
AmLocale.Save_file()+ "?"
+"\n"+ frame.contents.file.name);
??d.getTulemus()
? AmDialog.NO:
<======
? AmDialog.YES:
Toimub all olnud faili salvestamine
frame.menuBar.i02L.actionPerformed(null);
<======
? AmDialog.CANCEL:
Cursor cur = ProjectBoard.moveToProjectFileName(
Project, fileName);
? cur == null
<======================
<==================
newProjectFileFrame = ((AmProjectFileFrame)frame);
closeAmProjectFileFrame((AmProjectFileFrame)frame);
newProjectFileFrame.contents = null;
newProjectFileFrame.setTitle(AmFrame.TITLE0);
newProjectFileFrame.setOwnProject( );
SketchyText sk = new SketchyText((AmFrame)newProjectFileFrame);
// sk.file = new AmFile(sk);
execute scripts
AmFrame frame1 = ((AmFrame)newProjectFileFrame);
? !executeScriptsFromAttributeGroup(frame1, Project, openAttributeSketch, fileName, OPEN_SCRIPT)
? openInNewWindow
newProjectFileFrame.dispose();
Am.remove(newProjectFileFrame);
<======
newProjectFileFrame.repaint();
? (frame1.contents != null && frame1.contents.file != null &&
(frame1.contents.file.name != null) && !(frame1.contents.file.name.trim().equals("")))
? frame1.contents.file.name.trim().indexOf(fileName) >= 0
colorProjectFileName(pDFrame, Project, fileName, Color.lightGray);
static boolean executeScriptsFromAttributeGroup(AmFrame frame, Sketch Project, Sketch attributeGroup, String fileName, int code)
boolean returnValue = true;
PrimitiveMember attrPrimitive;
String parameterRida;
int kolumn;
kolumi asukoht
String scripts;
tegevuse scripti nimetus
String parameters;
tegevuse scriptile vastav path
attributeGroup is null?
? (attributeGroup == null)
writeLog("ERROR (ProjectBoard.executeScriptsFromAttributeGroup): Input attributeGroup is null.");
returnValue = false;
return returnValue;
Leida kõik tegevused mis on kirjeldatud avamiseskriptis
Branch attrBr = attributeGroup.branch(0);
????? Juht kui atribuudid asuvad mite esimesel harus ?????
int k = attrBr.body.size();
Atribuudi skeemil on skriptid?
? (k == 0)
writeLog("ERROR (ProjectBoard.executeScriptsFromAttributeGroup): Attribute group has no scripts!");
returnValue = false;
return returnValue;
Vector scriptsVector, parametersVector;
Sketch pathAttributeSketch = getAttributeSketch(Project, PATHS);
!!
* int i = 0; i < k; i++
Saame atribuudi rida
attrPrimitive = (PrimitiveMember)(attrBr.member(i));
parameterRida = attrPrimitive.text.toPlainString().trim();
? parameterRida.equals("")
continue;
Nüüd vaja eraldada Tegevuse ja Pathi nimetused
kolumn = parameterRida.indexOf(KOLUMN);
? kolumn >= 0
scripts = parameterRida.substring(0, kolumn).trim();
parameters = parameterRida.substring(kolumn+1).trim();
? parameters.indexOf(PATH) >= 0
? pathAttributeSketch == null
writeLog("ERROR (ProjectBoard.executeScriptsFromAttributeGroup): Attribute group PATHS is missing.");
return false;
parametersVector = parseParameters(parameters, Project);
scriptsVector = parseScripts(scripts);
? scriptsVector != null
PROCESS
? (scriptsVector.indexOf((Object)ActionController.PROCESS) >-1)
? scriptsVector.size()>1
writeLog("ERROR (ProjectBoard.executeScriptsFromAttributeGroup): Process function must be alone defined in attribute!");
returnValue = false;
break;
parameters = parseProcessParameters(frame, parameters, parametersVector, fileName, Project);
? !executeScriptsFromPrimitive( frame, scriptsVector, parametersVector, parameters, fileName, code )
System.out.println("executeScriptsFromPrimitive was false");
returnValue = false;
break;
<======
writeLog("ERROR (ProjectBoard.executeScriptsFromAttributeGroup): Wrong script definition:" + parameterRida + ".");
returnValue = false;
return returnValue;
! (Exception e)
e.printStackTrace();
writeLog("ERROR (ProjectBoard.executeScriptsFromAttributeGroup): " + e.toString());
returnValue = false;
return returnValue;
static boolean executeScriptsFromPrimitive(AmFrame frame, Vector scripts, Vector parameters, String parametersText, String inputFileName, int code)
Input: code = 0 avamise puhul; code = 1 salvestamise puhul
scripts - tegevuste vector mis vaja üks teise järel rakendada ( oli kirjutatud plus märki kaudu atribuut primitiivi tekstis)
parameters - funktsiooni käivitamiseks parameetrid koos leitud väärtustega
parametersText - primitiivi osa kus kirjeldatud parameetrid
inputFileName - faili nimi millega kutsuti projekti kirjelduse tegevused
boolean returnValue = true;
Input frame is null?
? frame == null
writeLog("ERROR (ProjectBoard. executeScriptsFromPrimitive): input AmFrame is null.");
returnValue = false;
return returnValue;
SketchyText backup = null;
String title = null;
String frameFileName = null;
String workingFileName;
fail millega alustame töötama (avama, salvestama, muutma(Sketchify, Reduce, ))
String workingFileName2;
fail millega alustame töötama (avama, salvestama, muutma(Sketchify, Reduce, ))
String newFileExtention = "";
String path = "";
boolean recovered = false;
parameetrite laadimine
? parameters != null
newFileExtention = getPathAttrValue(EXT, parameters);
path = getPathAttrValue(PATH, parameters);
workingFileName = getOutputFileName(frame, inputFileName, path, newFileExtention);
workingFileName2 = workingFileName;
? (workingFileName == null || (workingFileName.trim().equals("")))
return false;
is File read only?
? code == SAVE_SCRIPT
File controllFile = new File(workingFileName);
? controllFile.exists()
? controllFile.isFile()
? !controllFile.canWrite()
AmDialog d;
d = new AmDialog(frame, "WARNING",
AmDialog.B_OK,
" File " + workingFileName + " is read only!!!");
return false;
Vaja panna frame nimesse
<======
String fileDirectory = getDirectory(workingFileName);
? (fileDirectory == null || fileDirectory.trim().equals("") )
writeLog("ERROR (ProjectBoard. executeScriptsFromPrimitive): Wrong file directory. Controll Path group attributes !!!");
returnValue = false;
return returnValue;
File dirForFile = new File(fileDirectory);
? ( !dirForFile.exists())
writeLog("ERROR (ProjectBoard. executeScriptsFromPrimitive): Wrong file directory. Controll Path group attributes !!!");
returnValue = false;
return returnValue;
!!
controllFile.createNewFile();
! (IOException e)
writeLog("ERROR(ProjectBoard.executeScriptsFromPrimitive): Unable to create file '"+workingFileName+"'");
make backup
? (frame.contents != null)
backup = new SketchyText(null);
backup.cloneSketchyText(frame.contents);
Salvestame frame faili nimi
Kui tegemist faili avamisega, siis frame faili nimi on tühi
ja sellel juhul salvestame avatava faili nimi frame faili nimi hilja taastamiseks
? (frame.contents != null && frame.contents.file != null &&
(frame.contents.file.name != null) && !(frame.contents.file.name.trim().equals("")))
frameFileName = frame.contents.file.name;
title = frame.getTitle();
<======
? workingFileName != null && !(workingFileName.trim().equals(""))
fileNameForOpen != null
frameFileName = workingFileName;
title = frame.TITLE0 + " - " + frameFileName;
int leng = scripts.size();
String taskName;
ActionListener amListener;
* int j = 0; j < leng; j++
taskName = ((String)scripts.elementAt(j));
? taskName.equals(ActionController.PROCESS)
callController(frame, taskName, parametersText);
<======
callController(frame, taskName, workingFileName2);
kopeerime frame sketchyText backupist
? (backup != null)
frame.contents.cloneSketchyText(backup);
enableUndoMenu(frame);
repaint igaks juhuks
AmCanvas c = (AmCanvas)(frame.viewArea);
c.caretToScreen();
c.own = true; // c.repaint();
putFileNameToFrame(frame, frameFileName, title);
frame file ei tohi jääda tühjaks või nimeta
return returnValue;
help automat script methods
static void enableUndoMenu(AmFrame frame)
UNDO
? !frame.contents.editor.stack.stack_is_empty()
frame.menuBar.setEnabled(AmLocale.Edit(),AmLocale.Undo(),true);
REDO
? !frame.contents.editor.redoStack.stack_is_empty()
frame.menuBar.setEnabled(AmLocale.Edit(),AmLocale.Redo(),true);
static void putFileNameToFrame(AmFrame frame, String frameFileName, String title)
frame.contents.file.name
? frame.contents != null
? ((frame.contents.file != null) &&
(frame.contents.file.name != null) && !(frame.contents.file.name.trim().equals("")))
frame.contents.file.name = frameFileName;
<======
frame.contents.file = new AmFile(frame.contents);
frame.contents.file.name = frameFileName;
frame.getTitle()
? frame.getTitle() != title
frame.setTitle(title);
static void callController(AmFrame frame, String taskName, String fileName)
ActionController.setAttributes(fileName);
ActionController.execute(taskName.toLowerCase(), frame);
ActionController.setAttributes("");
static String getOutputFileName(AmFrame frame, String inputFileName, String path, String newFileExtention)
String workingFileName = null;
? ((inputFileName != null) && !(inputFileName.trim().equals("")))
workingFileName = inputFileName;
<==========
? (frame.contents != null && frame.contents.file != null &&
(frame.contents.file.name != null) && !(frame.contents.file.name.trim().equals("")))
workingFileName = frame.contents.file.name;
<==========
writeLog("ERROR (ProjectBoard.getOutputFileName): no file name to deal.");
<==========workingFileName
workingFileName = changeFileExtention(workingFileName, newFileExtention);
? path != null && !(path.trim().equals(""))
File f = new File (path);
? f.isDirectory()
workingFileName = putPathAndFileName(path, workingFileName);
<==========
? f.isFile()
workingFileName = f.getPath();
<==========
String controllStr = f.getPath().trim();
? ((controllStr.indexOf(er) < 0) && (controllStr.indexOf(SPACE) < 0))
workingFileName = f.getPath();
<==========
// workingFileName = f.getPath();
workingFileName = putPathAndFileName(path, workingFileName);
//System.out.println("ProjectBoard.getOutputFileName - ERROR: path attribute '"+path+"' value is not correct.");
//writeLog("ProjectBoard.getOutputFileName - ERROR: path attribute '"+path+"' value is not correct.");
//workingFileName = null;
kontroll on lisatud uue baaskeele projekti jaoks(parseri lisamine)
? workingFileName.indexOf(".Parser.java") >=0
workingFileName=workingFileName.substring(0,workingFileName.indexOf(".Parser.java"))+"Parser.java";
<======workingFileName
static Vector parseParameters(String attributeRida, Sketch project)
? (attributeRida == null)
<======null
? (attributeRida.trim().equals(""))
<======null
Vector returnVector = new Vector();
int equalSign;
String attributeRidaHelp = attributeRida;
equalSign = attributeRidaHelp.indexOf(EQUAL_SIGN);
? (equalSign < 0)
<======null
String a, temp;
String parameter = null;
String parameter_value = null;
char last_letter;
String maybe_parameter;
* ; (equalSign >= 0) ;
temp = attributeRidaHelp.substring(0, equalSign).trim();
int r = temp.lastIndexOf(SPACE);
? r > -1
maybe_parameter = temp.substring(r).trim();
<======
* int h =0; h
parameter = params[h];
? maybe_parameter.endsWith(parameter)
int lastInd = maybe_parameter.lastIndexOf(parameter);
? lastInd == 0
parameter on leitud
attributeRidaHelp = attributeRidaHelp.substring(equalSign + 1).trim();
<======================
<==========
char c = maybe_parameter.charAt(lastInd-1);
? (Character.isLetterOrDigit(c) || (c == '_'))
attributeRidaHelp = attributeRidaHelp.substring(equalSign + 1).trim();
? (attributeRidaHelp == null)
equalSign = -1;
<======
equalSign = attributeRidaHelp.indexOf(EQUAL_SIGN);
<--------------------------
parameter on leitud
attributeRidaHelp = attributeRidaHelp.substring(equalSign + 1).trim();
<======================
parameter != null && !parameter.trim().equals("")
? parameter != null && !parameter.trim().equals("")
parameter on leitud, equal_sign ka, nüüd tuleb leida parameetri väärtus(märgend)
kolmik - parameeter = märgend peab vasakult ja paremalt eraldatud tühikuga( või vastavalt parameetri stringi alguse või lõppuga) teisest tekstist
kuid tühiku ja kolmiku vahel võivad esineda mitte tähelised/numbrilised sümbolid
Näiteks järgmised kolm näided ekvivalentsed:
Export plain-HTML: path = SOURCE ext = html
Export plain-HTML: 'path = SOURCE' #ext = html
Export plain-HTML: ext = html
? (attributeRidaHelp.indexOf(SPACE) >-1)
parameter_value = attributeRidaHelp.substring(0, attributeRidaHelp.indexOf(SPACE)).trim();
attributeRidaHelp = attributeRidaHelp.substring(attributeRidaHelp.indexOf(SPACE)).trim();
<======
parameter_value = attributeRidaHelp;
attributeRidaHelp = "";
* int j = parameter_value.length()-1; j>0; j--
last_letter = parameter_value.charAt(j);
? (Character.isLetterOrDigit(last_letter) || (last_letter == '_'))
parameter_value = parameter_value.substring(0, j+1);
<======
atribuudi väärtuse otsimine
a = pathInheritedValue(project, parameter_value);
? !(a == null)
parameter_value = a;
lisada elementid vektorisse
returnVector.addElement((Object)parameter.toLowerCase().trim());
returnVector.addElement((Object)parameter_value);
<======
attributeRidaHelp = attributeRidaHelp.substring(equalSign + 1).trim();
järgmise parameetri otsimine
? (attributeRidaHelp == null || attributeRidaHelp.trim().equals(""))
equalSign = -1;
<----------
equalSign = attributeRidaHelp.indexOf(EQUAL_SIGN);
return returnVector;
static Vector parseScripts(String scripts)
<======null
? (scripts.trim().equals(""))
<======null
Vector returnVector = new Vector();
String backScripts, oneScript;
backScripts = scripts.trim();
int plus_sign = backScripts.indexOf(PLUS_SIGN);
* ; plus_sign > 0;
oneScript = backScripts.substring(0, plus_sign).trim();
returnVector.addElement((Object)oneScript.toLowerCase());
backScripts = backScripts.substring(plus_sign+1).trim();
plus_sign = backScripts.indexOf(PLUS_SIGN);
? !(backScripts == null || backScripts.equals(""))
returnVector.addElement((Object)backScripts.toLowerCase());
return returnVector;
static String changeFileExtention(String fileName, String newFileExtention)
String newFileName = fileName;
? newFileExtention != null
? !newFileExtention.equals("")
newFileName = fileName.substring(0, fileName.lastIndexOf(PUNKT)+1)+newFileExtention;
return newFileName;
static String getPathAttrValue(String searchAttr, Vector vector)
String returnString = null;
<==========returnString
int index = vector.indexOf(searchAttr.trim().toLowerCase());
? index >= 0
returnString = ((String)vector.elementAt(index+1));
return returnString;
static void printVector(Vector vector)
int leng = vector.size();
writeLog("vector.size ="+Integer.toString(leng));
String b;
* int j = 0; j < leng; j++
b = ((String)vector.elementAt(j));
writeLog(j+"."+b+"+");
static String putPathAndFileName(String path, String fileName)
Antud: path - uus faili tee, fileName - faili nimi( täis teega või ilma)
Tulemus: file uue täisteega
String fullFileName;
? path == null
fullFileName = fileName;
<======
int e = fileName.lastIndexOf(er);
? e >= 0
fileName = fileName.substring(e+1);
? !path.endsWith(er)
Eeldame, et kui vaja siis viimast kripsu lisatakse ise
path = path + er;
fullFileName = path + fileName;
return fullFileName;
static void removeAsteriskFromTitle(AmFrame frame)
String oldTitle = frame.getTitle().trim();
? oldTitle.endsWith("*")
frame.setTitle(oldTitle.substring(0, oldTitle.length() - 1));
static void writeLog(String text)
System.out.println(text);
/*
!!
File dir = new File("log");
dir.mkdir();
File file = new File(dir, "amadeus.log");
PrintStream ps = new PrintStream(new FileOutputStream(file.getAbsolutePath(), true));
java.text.DateFormat df = java.text.DateFormat.getDateTimeInstance();
ps.println(df.format(new Date()));
ps.println(text);
ps.println();
ps.close();
! (Exception e)
*/
public static String getDirectory(String fileName)
Tagastab kausta tee.
? fileName == null || fileName.trim().equals("")
<==========null
int i = -1;
int j = -1;
String returnVal = null;
i = fileName.indexOf(PUNKT);
j = fileName.lastIndexOf(er);
? i > -1
? i > j
returnVal = fileName.substring(0, j);
<======
? j > -1
returnVal = fileName.substring(0, j);
<======returnVal
PROCESS
static String parseProcessParameters(AmFrame frame, String processString, Vector vector, String inputFileName, Sketch project)
Input: Process käsu parameetrite string - eeldatav käivitav käsurea tekst
vector - parameetrite ja parameetrite väärtused
Output: käsurea tekst kus asendatud kõik atribuutide viited
int i = 0;
String parameter;
String stringToReplace, replacemantString="";
String remainProcessString;
String path;
String newFileExtention;
clearSearchParameters();
String returnProcessString = replaceSubAttrs("",processString, project, PATHS);
<==========returnProcessString
int vector_size = vector.size();
* int index = 0; index < vector_size; index++
? index > 0 && index%2==1
continue;
replacemantString="";
parameter = ((String)vector.elementAt(index));
? !(vector_size < (index+1))
String l = ((String)vector.elementAt(index+1));
? (l.indexOf(LESS_THAN) > -1 || l.indexOf(MORE_THAN) > -1)
writeLog("WARNING (ProjectBoard.parseProcessParameters): Not all parameters for PROCESS atribute was found. ");
// Mitte kõik atribuutid olid leitud (võib olla olid tsüklid defineerimesel)
return "";
<======
writeLog("ERROR (ProjectBoard.parseProcessParameters): Parametes for PROCESS attribute was wrongly found.");
return "";
stringToReplace = getStringToReplace(returnProcessString, parameter);
? stringToReplace != null
int k = 0;
k = returnProcessString.indexOf(stringToReplace);
* ;k > 0;
char pch = returnProcessString.charAt(k-1);
? ((Character.isLetterOrDigit(pch)) || (pch == '_'))
k = returnProcessString.indexOf(stringToReplace, k+1);
<======
<==========
<==============
remainProcessString = returnProcessString.substring(k+stringToReplace.length()).trim();
? parameter.equals(PATH)
path = ((String)vector.elementAt(index+1));
? remainProcessString.indexOf(EXT) == 0
? remainProcessString.substring(EXT.length()).trim().indexOf(EQUAL_SIGN) == 0
stringToReplace = returnProcessString.substring(k, returnProcessString.indexOf(remainProcessString)+ getStringToReplace(returnProcessString, EXT).length()).trim();
? (vector_size < (index+3))
writeLog("ERROR (ProjectBoard.parseProcessParameters): Parametes for PROCESS attribute was wrongly found.");
return "";
? ((String)vector.elementAt(index+2)).equals(EXT)
newFileExtention = ((String)vector.elementAt(index+3));
replacemantString = getOutputFileName(frame, inputFileName, path, newFileExtention);
index = index + 2;
<======
writeLog("ERROR (ProjectBoard.parseProcessParameters): Parametes for PROCESS attribute was wrongly found.");
return "";
<======
replacemantString = getOutputFileName(frame, inputFileName, path, "");
<======
? parameter.equals(EXT)
newFileExtention = ((String)vector.elementAt(index+1));
? (remainProcessString.indexOf(PATH) == 0)
? remainProcessString.substring(PATH.length()).trim().indexOf(EQUAL_SIGN) == 0
stringToReplace = stringToReplace+ getStringToReplace(returnProcessString, PATH);
stringToReplace = returnProcessString.substring(k, returnProcessString.indexOf(remainProcessString)+ getStringToReplace(returnProcessString, PATH).length());
? (vector_size < (index+3))
writeLog("ERROR (ProjectBoard.parseProcessParameters): Parametes for PROCESS attribute was wrongly found.");
return "";
? ((String)vector.elementAt(index+2)).equals(PATH)
path = ((String)vector.elementAt(index+3));
replacemantString = getOutputFileName(frame, inputFileName, path, newFileExtention);
index = index + 2;
<======
writeLog("ERROR (ProjectBoard.parseProcessParameters): Parametes for PROCESS attribute was wrongly found.");
return "";
<======
replacemantString = getOutputFileName(frame, inputFileName, "", newFileExtention);
index = index + 1;
? (replacemantString != null && !replacemantString.trim().equals(""))
//returnProcessString = replaceString(returnProcessString, stringToReplace, replacemantString);
JK080306: Process sees paneb jutumärkidesse (jooksva) täisnime "path nimi ext"
returnProcessString = replaceString(returnProcessString, stringToReplace, "\"" + replacemantString + "\"" );
return returnProcessString;
static String getStringToReplace(String processString, String parameter)
String returnStr = null;
int j = processString.indexOf(parameter);
char pch;
* ;j > 0;
pch = processString.charAt(j-1);
? ((Character.isLetterOrDigit(pch)) || (pch == '_'))
j = processString.indexOf(parameter, j+1);
<======
<==========
? j >-1
int equal_sign = processString.indexOf(EQUAL_SIGN, j + parameter.length());
? equal_sign >-1
String remainProcessString = processString.substring(equal_sign+1).trim();
int space = remainProcessString.indexOf(SPACE);
? space > -1
int last_index = processString.indexOf(remainProcessString, equal_sign) + space;
returnStr = processString.substring(j, last_index).trim();
<======
returnStr = processString.substring(j).trim();
char last_letter;
* int k = returnStr.length()-1; k>0; k--
last_letter = returnStr.charAt(k);
? (Character.isLetterOrDigit(last_letter) || (last_letter == '_'))
returnStr = returnStr.substring(0, k+1).trim();
<======
return returnStr;
static String replaceString(String whereReplace, String whatReplace, String replaceTo)
int where = whereReplace.indexOf(whatReplace);
int lastIndex = where + whatReplace.length() ;
String replaced = whereReplace.substring(0, where) +replaceTo + whereReplace.substring(lastIndex);
<======replaced