From 165bac93ba846c0199784bf628b3c3d87b3a5079 Mon Sep 17 00:00:00 2001 From: fabiantheblind Date: Tue, 9 Aug 2011 20:18:45 +0200 Subject: [PATCH] added scripts and menue entries --- MPOLnch.fr | 44 +++++++++++- MPOLnchActionComponent.cpp | 52 ++++++++++++++ MPOLnchHelper.cpp | 139 +++++++++++++++++++++++++++++++------ MPOLnchHelper.h | 6 ++ MPOLnchID.h | 20 +++++- MPOLnch_deDE.fr | 20 +++--- MPOLnch_enUS.fr | 7 +- MPOLnch_jaJP.fr | 3 +- README.markdown | 8 ++- 9 files changed, 262 insertions(+), 37 deletions(-) diff --git a/MPOLnch.fr b/MPOLnch.fr index 07acd8c..1e403b9 100644 --- a/MPOLnch.fr +++ b/MPOLnch.fr @@ -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, @@ -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, diff --git a/MPOLnchActionComponent.cpp b/MPOLnchActionComponent.cpp index b49939d..e1c9049 100644 --- a/MPOLnchActionComponent.cpp +++ b/MPOLnchActionComponent.cpp @@ -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. @@ -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); @@ -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) diff --git a/MPOLnchHelper.cpp b/MPOLnchHelper.cpp index e615f90..a13dfc8 100644 --- a/MPOLnchHelper.cpp +++ b/MPOLnchHelper.cpp @@ -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; @@ -38,10 +38,12 @@ 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", @@ -49,36 +51,37 @@ PMString MPOLnchHelper::GetScriptFile(int i){ "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]; } @@ -147,7 +150,7 @@ PMString MPOLnchHelper::GetMetaFile(int i){ PMString theFileName[3] = { "glue code.jsx", - "processXML.jsx", + "processXML_v02.jsx", "setupStyles.jsx"}; @@ -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: info@the-moron.net"); @@ -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"); } @@ -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 @@ -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 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++) { @@ -317,11 +408,16 @@ 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 @@ -329,7 +425,6 @@ void MPOLnchHelper::RestoreMPOLnchScrpts(){ // the helper files this->CopyFilesToLauncherFolder(this->GetHelpFile(i) , "help",kTrue); - }// end for MAXITEMS @@ -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"); + } diff --git a/MPOLnchHelper.h b/MPOLnchHelper.h index b0087af..7061c0c 100644 --- a/MPOLnchHelper.h +++ b/MPOLnchHelper.h @@ -13,6 +13,8 @@ #include "IPMStream.h" #include "FileUtils.h" #include "CAlert.h" +#include "StreamUtil.h" + class MPOLnchHelper @@ -31,6 +33,9 @@ class MPOLnchHelper void RestoreFCQueries(); // copy the FCQueries to the Preferences + void ShowHelp(); // copy the FCQueries to the Preferences + void ShowScripts(); // Show the scripts folder + void ShowFC(); // show the FC folder void RestoreMPOLnchScrpts(); // copy the scripts to the Scripts Panel PMString GetScriptFile(int i); // holds also the nodenames @@ -43,6 +48,7 @@ class MPOLnchHelper IDFile GetInternalResourceFolder(); // this is within the plugin IDFile GetScriptFilesFolder(); // this is in the ScriptsPanel the "MPO Launcher" folder + IDFile GetHelpFilesFolder(); PMString MissingScrptFileStr(PMString fn); // Error warning PMString MissingHelpFileStr(PMString fn); // Error warning diff --git a/MPOLnchID.h b/MPOLnchID.h index 8dbe4ef..509aaca 100644 --- a/MPOLnchID.h +++ b/MPOLnchID.h @@ -75,6 +75,10 @@ DECLARE_PMID(kActionIDSpace, kMPOLnchPopupAboutThisActionID, kMPOLnchPrefix + 3 DECLARE_PMID(kActionIDSpace, kMPOLnchAddItemActionID, kMPOLnchPrefix + 11) DECLARE_PMID(kActionIDSpace, kMPOLnchRemoveItemActionID, kMPOLnchPrefix + 12) DECLARE_PMID(kActionIDSpace, kMPOLnchFCQueriesActionID, kMPOLnchPrefix + 13) +DECLARE_PMID(kActionIDSpace, kMPOLnchHelpActionID, kMPOLnchPrefix + 14) +DECLARE_PMID(kActionIDSpace, kMPOLnchShowScriptsActionID, kMPOLnchPrefix + 15) +DECLARE_PMID(kActionIDSpace, kMPOLnchShowFCActionID, kMPOLnchPrefix + 16) + // WidgetIDs: DECLARE_PMID(kWidgetIDSpace, kMPOLnchPanelWidgetID, kMPOLnchPrefix + 0) @@ -95,12 +99,19 @@ DECLARE_PMID(kWidgetIDSpace, kMPOLnchListElementPenWidgetID, kMPOLnchPrefix + 5) #define kMPOLnchAddItemMenuItemKey kMPOLnchStringPrefix "kMPOLnchAddItemMenuItemKey" #define kMPOLnchRemoveItemMenuItemKey kMPOLnchStringPrefix "kMPOLnchRemoveItemMenuItemKey" #define kMPOLnchFCQueriesMenuItemKey kMPOLnchStringPrefix "kMPOLnchFCQueriesMenuItemKey" +#define kMPOLnchHelpMenuItemKey kMPOLnchStringPrefix "kMPOLnchHelpMenuItemKey" +#define kMPOLnchShowScriptsMenuItemKey kMPOLnchStringPrefix "kMPOLnchShowScriptsMenuItemKey" +#define kMPOLnchShowFCMenuItemKey kMPOLnchStringPrefix "kMPOLnchShowFCMenuItemKey" // Other StringKeys: #define kMPOLnchAboutBoxStringKey kMPOLnchStringPrefix "kMPOLnchAboutBoxStringKey" #define kMPOLnchAddItemStringKey kMPOLnchStringPrefix "kMPOLnchAddItemStringKey" #define kMPOLnchRemoveItemStringKey kMPOLnchStringPrefix "kMPOLnchRemoveItemStringKey" #define kMPOLnchFCQueriesItemStringKey kMPOLnchStringPrefix "kMPOLnchFCQueriesItemStringKey" +#define kMPOLnchHelpItemStringKey kMPOLnchStringPrefix "kMPOLnchHelpItemStringKey" +#define kMPOLnchShowScriptsItemStringKey kMPOLnchStringPrefix "kMPOLnchShowScriptsItemStringKey" +#define kMPOLnchShowFCItemStringKey kMPOLnchStringPrefix "kMPOLnchShowFCItemStringKey" + #define kMPOLnchMissingScriptItemStringKey kMPOLnchStringPrefix "kMPOLnchMissingScriptItemStringKey" @@ -115,9 +126,14 @@ DECLARE_PMID(kWidgetIDSpace, kMPOLnchListElementPenWidgetID, kMPOLnchPrefix + 5) // Menu item positions: #define kMPOLnchAddItemMenuItemPosition 1.0 -#define kMPOLnchFCQueriesMenuItemPosition 2.0 +#define kMPOLnchShowScriptsMenuItemPosition 2.0 + +#define kMPOLnchFCQueriesMenuItemPosition 3.0 +#define kMPOLnchShowFCMenuItemPosition 4.0 + +#define kMPOLnchHelpMenuItemPosition 5.0 -#define kMPOLnchRemoveItemMenuItemPosition 3.0 +#define kMPOLnchRemoveItemMenuItemPosition 6.0 #define kMPOLnchSeparator1MenuItemPosition 10.0 #define kMPOLnchAboutThisMenuItemPosition 11.0 diff --git a/MPOLnch_deDE.fr b/MPOLnch_deDE.fr index 5a0bf2c..463d5cb 100644 --- a/MPOLnch_deDE.fr +++ b/MPOLnch_deDE.fr @@ -38,12 +38,16 @@ resource StringTable (kSDKDefStringsResourceID + index_deDE) // ----- Menu strings kMPOLnchCompanyKey, kMPOLnchCompanyValue, - kMPOLnchAboutMenuKey, kMPOLnchPluginName "[DE]...", - kMPOLnchPluginsMenuKey, kMPOLnchPluginName "[DE]", - kMPOLnchAddItemMenuItemKey, "Skriptdateien wiederherstellen [DE]", - kMPOLnchFCQueriesMenuItemKey, "Find Change-Queries wiederherstellen [DE]", + kMPOLnchAboutMenuKey, kMPOLnchPluginName "...", + kMPOLnchPluginsMenuKey, kMPOLnchPluginName , + kMPOLnchAddItemMenuItemKey, "Skriptdateien wiederherstellen...", + kMPOLnchFCQueriesMenuItemKey, "Find Change-Queries wiederherstellen...", + kMPOLnchHelpMenuItemKey, "help.txt anzeigen...", + kMPOLnchShowScriptsMenuItemKey, "MPO Launcher Skript Ordner anzeigen...", + kMPOLnchShowFCMenuItemKey, "Find Change-Queries Ordner anzeigen...", - kMPOLnchRemoveItemMenuItemKey, "Object löschen [DE]", + + kMPOLnchRemoveItemMenuItemKey, "Objekt loeschen", kSDKDefAboutThisPlugInMenuKey, kSDKDefAboutThisPlugInMenuValue_deDE, // ----- Command strings @@ -53,12 +57,12 @@ resource StringTable (kSDKDefStringsResourceID + index_deDE) // ----- Panel/dialog strings - kMPOLnchPanelTitleKey, "Launcher" " [DE]",// irp was kMPOLnchPluginName "[DE]", + kMPOLnchPanelTitleKey, "Launcher",// irp was kMPOLnchPluginName "", // ----- Error strings - // ----- Misc strings - kMPOLnchAboutBoxStringKey, kMPOLnchPluginName "[DE], version " kMPOLnchVersion " by " kMPOLnchAuthor " © 2011 unter GPLv03 Lizenz\n\n Dieses Plugin benutzt einen Satz an Javascripten die im Plugin selber liegen.\nWenn du diese bearbeiten möchtest benutze die \"" kMPOLnchAddItemMenuItemKey "\" Option.", + // ----- Misc string + kMPOLnchAboutBoxStringKey, kMPOLnchPluginName ", version " kMPOLnchVersion " by " kMPOLnchAuthor " © 2011 unter GPLv03 Lizenz\n\n Dieses Plugin benutzt einen Satz an Javascripten die im Plugin selber liegen.\nWenn du diese bearbeiten möchtest benutze die \"Skriptdateien wiederherstellen...\" Option.", kMPOLnchItemBaseKey "1", "THIS IS NOT RIGHT", kMPOLnchItemBaseKey "2", "THIS IS NOT RIGHT", diff --git a/MPOLnch_enUS.fr b/MPOLnch_enUS.fr index 2c6d283..2bbcb73 100644 --- a/MPOLnch_enUS.fr +++ b/MPOLnch_enUS.fr @@ -41,8 +41,11 @@ resource StringTable (kSDKDefStringsResourceID + index_enUS) kMPOLnchAboutMenuKey, kMPOLnchPluginName "[US]...", kMPOLnchPluginsMenuKey, kMPOLnchPluginName "[US]", kMPOLnchAddItemMenuItemKey, "Build Scripts [US]", - kMPOLnchFCQueriesMenuItemKey, "Build Find Change-Queries [DE]", - + kMPOLnchFCQueriesMenuItemKey, "Build Find Change-Queries [US]", + kMPOLnchHelpMenuItemKey, "Show help.txt... [US]", + kMPOLnchShowScriptsMenuItemKey, "Show MPO Launcher Scripts ... [US]", + kMPOLnchShowFCMenuItemKey, "Show Find Change-Queries Folder ... [US]", + kMPOLnchRemoveItemMenuItemKey, "Remove item[US]", kSDKDefAboutThisPlugInMenuKey, kSDKDefAboutThisPlugInMenuValue_enUS, diff --git a/MPOLnch_jaJP.fr b/MPOLnch_jaJP.fr index 8e6bb2f..d30a360 100644 --- a/MPOLnch_jaJP.fr +++ b/MPOLnch_jaJP.fr @@ -42,7 +42,8 @@ resource StringTable (kSDKDefStringsResourceID + index_jaJP) kMPOLnchPluginsMenuKey, kMPOLnchPluginName "[JP]", kMPOLnchAddItemMenuItemKey, "ڂlj[JP]", kMPOLnchFCQueriesMenuItemKey, "ڂlj[JP]", - + kMPOLnchFCQueriesMenuItemKey, "ڂlj[JP]", + kMPOLnchRemoveItemMenuItemKey, "ڂ폜[JP]", kSDKDefAboutThisPlugInMenuKey, kSDKDefAboutThisPlugInMenuValue_jaJP, diff --git a/README.markdown b/README.markdown index 1db5daf..4d11b96 100644 --- a/README.markdown +++ b/README.markdown @@ -1,8 +1,11 @@ #some documentation is comming soon also the xcode project #please use your own prefixID -license ---- +##This InDesgin Plugin +###works best with the MPO ( [mediaplanungonline.de](http://mediaplanungonline.de/) ) +####It serves as a launcher for different Javascripts + +#####license // Copyright (C) 2011 Fabian "fabiantheblind" Morón Zirfas // [the-moron.net](http://www.the-moron.net) @@ -20,3 +23,4 @@ license // You should have received a copy of the GNU General Public License // along with this program. If not, see --> [gnu.org](http://www.gnu.org/licenses/). +