Skip to content

Commit

Permalink
added scripts and menue entries
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiantheblind committed Aug 9, 2011
1 parent b36dc74 commit 165bac9
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 37 deletions.
44 changes: 43 additions & 1 deletion MPOLnch.fr
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,22 @@ resource MenuDef (kSDKDefMenuResourceID)
kMPOLnchTargetMenuPath,
kMPOLnchFCQueriesMenuItemPosition,
kSDKDefIsNotDynamicMenuFlag,

kMPOLnchHelpActionID, // this is the FC Stuff
kMPOLnchTargetMenuPath,
kMPOLnchHelpMenuItemPosition,
kSDKDefIsNotDynamicMenuFlag,

kMPOLnchShowScriptsActionID, // this is show scripts Stuff
kMPOLnchTargetMenuPath,
kMPOLnchShowScriptsMenuItemPosition,
kSDKDefIsNotDynamicMenuFlag,

kMPOLnchShowFCActionID, // this is show FC Stuff
kMPOLnchTargetMenuPath,
kMPOLnchShowFCMenuItemPosition,
kSDKDefIsNotDynamicMenuFlag,

kMPOLnchRemoveItemActionID,
kMPOLnchTargetMenuPath,
kMPOLnchRemoveItemMenuItemPosition,
Expand Down Expand Up @@ -271,7 +286,34 @@ resource ActionDef (kSDKDefActionResourceID)
kDisableIfLowMem,
kInvalidInterfaceID,
kSDKDefInvisibleInKBSCEditorFlag,


kMPOLnchActionComponentBoss, // Help stuff
kMPOLnchHelpActionID,
kMPOLnchHelpMenuItemKey,
kOtherActionArea,
kNormalAction,
kDisableIfLowMem,
kInvalidInterfaceID,
kSDKDefInvisibleInKBSCEditorFlag,

kMPOLnchActionComponentBoss, // ShowScripts stuff
kMPOLnchShowScriptsActionID,
kMPOLnchShowScriptsMenuItemKey,
kOtherActionArea,
kNormalAction,
kDisableIfLowMem,
kInvalidInterfaceID,
kSDKDefInvisibleInKBSCEditorFlag,

kMPOLnchActionComponentBoss, // ShowScripts stuff
kMPOLnchShowFCActionID,
kMPOLnchShowFCMenuItemKey,
kOtherActionArea,
kNormalAction,
kDisableIfLowMem,
kInvalidInterfaceID,
kSDKDefInvisibleInKBSCEditorFlag,

kMPOLnchActionComponentBoss,
kMPOLnchRemoveItemActionID,
kMPOLnchRemoveItemMenuItemKey,
Expand Down
52 changes: 52 additions & 0 deletions MPOLnchActionComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,18 @@ class MPOLnchActionComponent : public CActionComponent
/** Encapsulates functionality for the restore fc queries menu item. */

void DoStoreFCQueries();

/** Encapsulates functionality for the restore fc queries menu item. */

void DoHelp();

/** Encapsulates functionality for the restore fc queries menu item. */

void ShowScripts();

/** Encapsulates functionality for the restore fc queries menu item. */

void ShowFC();
/** Encapsulates functionality for the AddItem menu item.
@param invokedWidget Widget that initiated the event (the panel menu), useful for getting the panel & other widgets.
Expand Down Expand Up @@ -145,6 +155,21 @@ void MPOLnchActionComponent::DoAction(IActiveContext *myContext, ActionID action
this->DoStoreFCQueries();
break;
}
case kMPOLnchHelpActionID:
{
this->DoHelp();
break;
}
case kMPOLnchShowScriptsActionID:
{
this->ShowScripts();
break;
}
case kMPOLnchShowFCActionID:
{
this->ShowFC();
break;
}
case kMPOLnchRemoveItemActionID:
{
//this->DoRemoveItem(widget);
Expand Down Expand Up @@ -238,6 +263,33 @@ void MPOLnchActionComponent::DoStoreFCQueries()
} // end of DoStoreFCQueries


/* DoHelp
*/
void MPOLnchActionComponent::DoHelp()
{
MPOLnchHelper helper;
helper.ShowHelp();

} // end of DoHelp

/* ShowScripts
*/
void MPOLnchActionComponent::ShowScripts()
{
MPOLnchHelper helper;
helper.ShowScripts();

} // end of ShowScripts

/* ShowFC
*/
void MPOLnchActionComponent::ShowFC()
{
MPOLnchHelper helper;
helper.ShowFC();

} // end of ShowFC

/* DoAddItem
*/
void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)
Expand Down
139 changes: 118 additions & 21 deletions MPOLnchHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// constructor
MPOLnchHelper::MPOLnchHelper(){
}
int MPOLnchHelper::MAXITEMS = 12;
int MPOLnchHelper::MAXITEMS = 13;
int MPOLnchHelper::METAMAXITEMS = 3;
int MPOLnchHelper::FCGREPMAXITEMS = 19;
int MPOLnchHelper::FCOBJECTMAXITEMS = 1;
Expand All @@ -38,47 +38,50 @@ PMString MPOLnchHelper::MissingHelpFileStr(PMString fn){

PMString MPOLnchHelper::GetScriptFile(int i){

PMString theFileName[12] = {
"importXML.jsx",
PMString theFileName[13] = {
"MPO_Importer.jsx",
"theNumbers.jsx",
"clearAllStyles.jsx",
"theFindChange.jsx",
"theItemFinder.jsx",
"theLinkButton.jsx",
"theImagePlacer.jsx",
"clearStructure.jsx",
"color_KEY.jsx",
"color_PAPER.jsx",
"color_XXX.jsx",
"color_MIXEDBLACK.jsx",
"newscriptfile11.jsx",

"QUICKY.jsx"};


if (i > 12) {
i = 12;
if (i > 13) {
i = 13;
}
return theFileName[i];
}

PMString MPOLnchHelper::GetHelpFile(int i){

PMString theFileName[12] = {
"importXML.txt",
PMString theFileName[13] = {
"MPO_Importer.txt",
"theNumbers.txt",
"clearAllStyles.txt",
"theFindChange.txt",
"theItemFinder.txt",
"theLinkButton.txt",
"theImagePlacer",
"theImagePlacer.txt",
"clearStructure.txt",
"color_KEY.txt",
"color_PAPER.txt",
"color_XXX.txt",
"color_MIXEDBLACK.jsx",
"newscriptfile11.txt",
"QUICKY.txt"};



if (i > 12) {
i = 12;
if (i > 13) {
i = 13;
}
return theFileName[i];
}
Expand Down Expand Up @@ -147,7 +150,7 @@ PMString MPOLnchHelper::GetMetaFile(int i){

PMString theFileName[3] = {
"glue code.jsx",
"processXML.jsx",
"processXML_v02.jsx",
"setupStyles.jsx"};


Expand Down Expand Up @@ -222,15 +225,32 @@ IDFile MPOLnchHelper::GetScriptFilesFolder(){

}

IDFile MPOLnchHelper::GetHelpFilesFolder(){

IDFile theTarget;
FileUtils::GetAppInstallationFolder(&theTarget);
FileUtils::AppendPath(&theTarget, PMString("Scripts"));
FileUtils::AppendPath(&theTarget, PMString("Scripts Panel"));
FileUtils::AppendPath(&theTarget, PMString("MPO Launcher"));
FileUtils::AppendPath(&theTarget, PMString("help"));


FileUtils::CreateFolderIfNeeded(theTarget,kTrue);

return theTarget;

}
void MPOLnchHelper::CopyQueryFilesToPrefsFolder(PMString fcfilename, PMString fctype){

//MPOLnchHelper helper;
PMString logStr("");

IDFile theGRPSource = this->GetInternalResourceFolder();

FileUtils::AppendPath(&theGRPSource, fcfilename);
PMString grpFileStringUrl = FileUtils::SysFileToFileURL(theGRPSource);
if(!FileUtils::DoesFileExist(theGRPSource)){

CAlert::InformationAlert(" could not find the Source File. I am Here-> " + grpFileStringUrl
+"\n"+
" Please report this bug to: [email protected]");
Expand All @@ -246,7 +266,9 @@ void MPOLnchHelper::CopyQueryFilesToPrefsFolder(PMString fcfilename, PMString fc
FileUtils::AppendPath(&theGRPTarget, fngrp);

if(!FileUtils::DoesFileExist(theGRPTarget)){
CAlert::InformationAlert("I will try to copy "+fngrp+ " to your Preferences");

//CAlert::InformationAlert("I will try to copy "+fngrp+ " to your Preferences");

if(!FileUtils::CopyFile(theGRPSource, theGRPTarget)){
CAlert::InformationAlert("Could not copy "+fngrp+". Sorry");
}
Expand Down Expand Up @@ -283,12 +305,12 @@ void MPOLnchHelper::CopyFilesToLauncherFolder(PMString filename , PMString folde

if(!FileUtils::DoesFileExist(target)){
if (subfolder) {
CAlert::InformationAlert("I will try to copy "+fn
+ " to the folder: Scripts Panel/MPO Launcher/"
+foldername);
//CAlert::InformationAlert("I will try to copy "+fn
// + " to the folder: Scripts Panel/MPO Launcher/"
// +foldername);
}else{
CAlert::InformationAlert("I will try to copy "+fn
+ " to the folder: Scripts Panel/MPO Launcher");
//CAlert::InformationAlert("I will try to copy "+fn
// + " to the folder: Scripts Panel/MPO Launcher");
}
if(!FileUtils::CopyFile(source, target)){
CAlert::InformationAlert("Could not copy "+fn
Expand All @@ -298,6 +320,75 @@ void MPOLnchHelper::CopyFilesToLauncherFolder(PMString filename , PMString folde

}

void MPOLnchHelper::ShowScripts(){
// look for the internal resource files
IDFile helpFile = this->GetScriptFilesFolder();


if (FileUtils::DoesFileExist(helpFile)) {


FileUtils::ShowFile(helpFile);


}else {
CAlert::InformationAlert(this->MissingHelpFileStr(helpFile.GetFileName()));
}

}

void MPOLnchHelper::ShowFC(){
// look for the internal resource files

// this gets the GREP folder within the Library/Preferences/Adobe InDesign/ ...
IDFile target;
FileUtils::GetAppRoamingDataFolder(&target, "Find-Change Queries");

if (FileUtils::DoesFileExist(target)) {


FileUtils::ShowFile(target);


}else {
CAlert::InformationAlert(this->MissingHelpFileStr(target.GetFileName()));
}

}
void MPOLnchHelper::ShowHelp(){
// look for the internal resource files
IDFile helpFile = this->GetHelpFilesFolder();


//PMString pre("help_");
PMString fn("help");
PMString exth(".txt");

FileUtils::AppendPath(&helpFile, fn + exth);



if (FileUtils::DoesFileExist(helpFile)) {
InterfacePtr<IPMStream> s(StreamUtil::CreateFileStreamRead(helpFile));


//CAlert::InformationAlert(helper.ReadAllAsText(s));
CAlert::ModalAlert(this->ReadAllAsText(s),
kOKString,
kNullString,
kNullString,
1, // pass in 1, 2, or 3 to make that button the default button or 0 for no default
CAlert::eWarningIcon);

FileUtils::OpenFileInEditor(helpFile,kNullAppInfo,nil);


}else {
CAlert::InformationAlert(this->MissingHelpFileStr(fn + exth));
}

}

void MPOLnchHelper::RestoreFCQueries(){

for (int i = 0; i < this->FCGREPMAXITEMS ; i++) {
Expand All @@ -317,19 +408,23 @@ void MPOLnchHelper::RestoreFCQueries(){

this->CopyQueryFilesToPrefsFolder(this->GetObjectFCFile(k), PMString("Object"));


} // end of for FCGREPMAXITEMS
CAlert::InformationAlert("Copied the missing files");

}

void MPOLnchHelper::RestoreMPOLnchScrpts(){

this->CopyFilesToLauncherFolder(PMString("help.txt") , "help",kTrue);

for (int i = 0; i < this->MAXITEMS ; i++) {

// The Scriptfiles
this->CopyFilesToLauncherFolder(this->GetScriptFile(i) , "NOFOLDER",kFalse);
// the helper files
this->CopyFilesToLauncherFolder(this->GetHelpFile(i) , "help",kTrue);


}// end for MAXITEMS


Expand All @@ -345,9 +440,11 @@ void MPOLnchHelper::RestoreMPOLnchScrpts(){
//THE MISC FILES
//

for(int k = 0; k < this->METAMAXITEMS; k++){
for(int k = 0; k < this->MISCMAXITEMS; k++){

this->CopyFilesToLauncherFolder(this->GetMiscFile(k) , "misc",kTrue);

}
CAlert::InformationAlert("Copied the missing files");

}
Loading

0 comments on commit 165bac9

Please sign in to comment.