Skip to content

Commit

Permalink
running version
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiantheblind committed Jul 26, 2011
1 parent ffcfc51 commit b2659f1
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 149 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions MPOLnch.fr
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ resource MPOLnchNodeWidget (kMPOLnchListElementRsrcID + index_enUS)
kTrue, kTrue, // Visible, Enabled
"", // Panel name
{
/*
MPOLnchEyeballWidget
(
kMPOLnchListElementEyeballWidgetID, kMPOLnchEyeBallIcon, kMPOLnchPluginID, // WidgetId, RsrcId
Expand All @@ -442,7 +441,8 @@ resource MPOLnchNodeWidget (kMPOLnchListElementRsrcID + index_enUS)
kTrue, kTrue, // Visible, Enabled
kADBEIconSuiteButtonType,
),

/*

MPOLnchPenWidget
(
kMPOLnchListElementPenWidgetID, kMPOLnchPenIcon, kMPOLnchPluginID, // WidgetId, RsrcId
Expand Down
154 changes: 152 additions & 2 deletions MPOLnchActionComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
#include "MPOLnchID.h"
// file creation
#include "FileUtils.h"
#include "MPOLnchSciptsbuilder.cpp"
#include "CoreFileUtils.h"
#include "StreamUtil.h"
#include <fstream>
#include <cstdlib>
#include <string>


/** MPOLnchActionComponent
Expand Down Expand Up @@ -88,6 +92,13 @@ class MPOLnchActionComponent : public CActionComponent
@param invokedWidget Widget that initiated the event (the panel menu), useful for getting the panel & other widgets.
*/
void DoAddItem(IPMUnknown *invokedWidget);


/* My personal copyFile
* until i get FileUtils::CopyFile() to work
*/
// bool copyFile (const char SRC[], const char DEST[]);


/** Encapsulates functionality for the RemoveItem menu item.
Expand Down Expand Up @@ -126,13 +137,15 @@ void MPOLnchActionComponent::DoAction(IActiveContext *myContext, ActionID action

case kMPOLnchAddItemActionID:
{
//this->DoAddItem(widget);
this->DoAddItem(widget);
break;
}

case kMPOLnchRemoveItemActionID:
{
//this->DoRemoveItem(widget);
CAlert::InformationAlert("This optin doesn't work right now. Sry");

break;
}

Expand Down Expand Up @@ -252,9 +265,146 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)

// building the scripts



using namespace std;

const int MAXITEMS = 12;

PMString scriptfiles[MAXITEMS] = {
"scriptfile01.jsx",
"scriptfile02.jsx",
"scriptfile03.jsx",
"scriptfile04.jsx",
"scriptfile05.jsx",
"scriptfile06.jsx",
"scriptfile07.jsx",
"scriptfile08.jsx",
"scriptfile09.jsx",
"scriptfile10.jsx",
"scriptfile11.jsx",
"scriptfile12.jsx"};

PMString newscriptfiles[MAXITEMS] = {
"newscriptfile01.jsx",
"newscriptfile02.jsx",
"newscriptfile03.jsx",
"newscriptfile04.jsx",
"newscriptfile05.jsx",
"newscriptfile06.jsx",
"newscriptfile07.jsx",
"newscriptfile08.jsx",
"newscriptfile09.jsx",
"newscriptfile10.jsx",
"newscriptfile11.jsx",
"newscriptfile12.jsx"};

//string source = "incoming.txt";
//string clone = "outgoing.txt";

// cout << "Enter the source file: ";
// cin >> source;
// cout << "Enter the name of the new file: ";
// cin >> clone;

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


IDFile theSource;//scriptfiles[i];

FileUtils::GetAppInstallationFolder(&theSource);
FileUtils::AppendPath(&theSource, PMString("Plug-Ins"));
FileUtils::AppendPath(&theSource, PMString("tmn"));
FileUtils::AppendPath(&theSource, PMString("MPOLauncher.InDesignPlugin"));
//
FileUtils::AppendPath(&theSource, PMString("Versions"));
FileUtils::AppendPath(&theSource, PMString("A"));
FileUtils::AppendPath(&theSource, PMString("Resources"));
FileUtils::AppendPath(&theSource, PMString(scriptfiles[i]));

PMString sourceFileStringUrl = FileUtils::SysFileToFileURL(theSource);

if(!FileUtils::DoesFileExist(theSource)){
CAlert::InformationAlert(" could not find the Source File. I am Here-> " + sourceFileStringUrl
+"\n"+
" Please report this bug to: [email protected]");
break;
}




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

FileUtils::CreateFolderIfNeeded(theTarget,kTrue);

PMString fn(newscriptfiles[i]);

FileUtils::AppendPath(&theTarget, fn);

//FileUtils::OpenFile(theTarget, "w");
if(!FileUtils::DoesFileExist(theTarget)){

CAlert::InformationAlert("I will try to copy "+fn+ " to the folder: Scripts Panel/MPO Launcher");

if(!FileUtils::CopyFile(theSource, theTarget)){

CAlert::InformationAlert("Could not copy "+fn+". Sorry");


}
}

// PMString sourceFileStringUrl = FileUtils::SysFileToFileURL(theSource);
// string sfurl = sourceFileStringUrl.GrabCString();
//
// PMString targetFileStringUrl = FileUtils::SysFileToFileURL(theTarget);
// string tfurl = targetFileStringUrl.GrabCString();
//
// std::ifstream src; // the source file
// std::ofstream dest; // the destination file
//
// src.open (sfurl.c_str(), std::ios::binary); // open in binary to prevent jargon at the end of the buffer
// dest.open (tfurl.c_str(), std::ios::binary); // same again, binary
// if (src.is_open() && dest.is_open())
// {
// dest << src.rdbuf (); // copy the content
// dest.close (); // close destination file
// src.close (); // close source file
}

// if(!copyFile(sfurl.c_str(),tfurl.c_str())){
//
// CAlert::InformationAlert("Could not copy the scriptfiles. Sorry");
//
// }

//FileUtils::CopyFile(theSource, theTarget);
//FileUtils::OpenFile(file, "wt");

//PMString sourcefile = FileUtils::SysFileToFileURL(theSource);
// PMString targetfile = FileUtils::SysFileToFileURL(theTarget);
// ifstream in(sourcefile.GetPlatformString().c_str()); // Open for reading
// ofstream out( targetfile.GetPlatformString().c_str()); // Open for writing
//
// //printf("wrote file newscriptfile with number %do to disc\n",i);
// string s;
// while(getline(in, s))
// out << s << "\n";
//in->Close();
//out->Close();

//}



}


/* DoRemoveItem
*/
void MPOLnchActionComponent::DoRemoveItem(IPMUnknown *invokedWidget)
Expand Down
1 change: 1 addition & 0 deletions MPOLnchID.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ DECLARE_PMID(kWidgetIDSpace, kMPOLnchListElementPenWidgetID, kMPOLnchPrefix + 5)




// Menu item positions:
#define kMPOLnchAddItemMenuItemPosition 1.0
#define kMPOLnchRemoveItemMenuItemPosition 2.0
Expand Down
35 changes: 15 additions & 20 deletions MPOLnchListBoxObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void MPOLnchListBoxObserver::Update
const int kSelectionLength = selectedItems.size() ;
if (kSelectionLength> 0 )
{
PMString dbgInfoString("");
PMString nodeName("");
K2Vector<NodeID>::const_iterator iter, startIter, endIter;
startIter = selectedItems.begin();
endIter = selectedItems.end();
Expand All @@ -165,32 +165,28 @@ void MPOLnchListBoxObserver::Update
const MPOLnchNodeID* oneNode = static_cast<const MPOLnchNodeID*>(iter->Get());
PMString item = oneNode->GetName();
item.Translate();
dbgInfoString.Append(item);
nodeName.Append(item);
//dbgInfoString += ", ";
}


//dbgInfoString.Truncate(2); //remove the last ', '
dbgInfoString.SetTranslatable(kFalse); // only for debug- not real code
CAlert::InformationAlert(dbgInfoString);
nodeName.SetTranslatable(kFalse); // only for debug- not real code
CAlert::InformationAlert(nodeName);

IDFile scriptFile;

FileUtils::GetAppInstallationFolder(&scriptFile); //application folder path
FileUtils::AppendPath(&scriptFile, PMString("Scripts"));
FileUtils::AppendPath(&scriptFile, PMString("Scripts Panel"));
PMString fn(dbgInfoString);
PMString ext(".jsx");
FileUtils::AppendPath(&scriptFile, PMString("MPO Launcher"));
if (FileUtils::DoesFileExist(scriptFile)) {

//inside the scripts panel, append path of the folder in which ur script is present.
//Suppose, ScriptsPanel->NewFolder->Link.jsx
//FileUtils::AppendPath(&scriptFile, PMString("NewFolder", -1, PMString::kNoTranslate));
FileUtils::AppendPath(&scriptFile, fn + ext);
PMString fn(nodeName);
PMString ext(".jsx");

//WideString scriptPath("myscript.jsx");
//IDFile scriptFile(scriptPath);
try {

FileUtils::AppendPath(&scriptFile, fn + ext);

InterfacePtr<IScriptRunner>scriptRunner(Utils<IScriptUtils>()->QueryScriptRunner(scriptFile));
bool filestatus=scriptRunner->CanHandleFile(scriptFile);
Expand All @@ -202,16 +198,15 @@ void MPOLnchListBoxObserver::Update


if(filestatus==1)
{
{
scriptRunner->RunFile(scriptFile,scriptParams);
}

}
catch (int e) {
CAlert::InformationAlert("Could not find the accioated scriptfile");
}// close filestatus
}else {
CAlert::InformationAlert("Got an error. You need the MPO Launcher Folder in the Scripts Panel");
}

}

}

} while(0);
}
Expand Down
2 changes: 1 addition & 1 deletion MPOLnchTreeViewWidgetMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

/**
* Tree view manager
@ingroup wlistboxcomposite
@ingroup mpolauncher
*/
class MPOLnchTVWidgetMgr : public CTreeViewWidgetMgr
{
Expand Down
24 changes: 12 additions & 12 deletions MPOLnch_enUS.fr
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ resource StringTable (kSDKDefStringsResourceID + index_enUS)
// ----- Misc strings
kMPOLnchAboutBoxStringKey, kMPOLnchPluginName "[US], version " kMPOLnchVersion " by " kMPOLnchAuthor "\n\n" kSDKDefCopyrightStandardValue "\n\n" kSDKDefPartnersStandardValue_enUS,
//
kMPOLnchItemBaseKey "1", "scriptfile01",
kMPOLnchItemBaseKey "2", "scriptfile02",
kMPOLnchItemBaseKey "3", "scriptfile03",
kMPOLnchItemBaseKey "4", "scriptfile04",
kMPOLnchItemBaseKey "1", "newscriptfile01",
kMPOLnchItemBaseKey "2", "newscriptfile02",
kMPOLnchItemBaseKey "3", "newscriptfile03",
kMPOLnchItemBaseKey "4", "newscriptfile04",

kMPOLnchItemBaseKey "5", "scriptfile05",
kMPOLnchItemBaseKey "6", "scriptfile06",
kMPOLnchItemBaseKey "7", "scriptfile07",
kMPOLnchItemBaseKey "8", "scriptfile08",
kMPOLnchItemBaseKey "5", "newscriptfile05",
kMPOLnchItemBaseKey "6", "newscriptfile06",
kMPOLnchItemBaseKey "7", "newscriptfile07",
kMPOLnchItemBaseKey "8", "newscriptfile08",

kMPOLnchItemBaseKey "9", "scriptfile09",
kMPOLnchItemBaseKey "10", "scriptfile10",
kMPOLnchItemBaseKey "11", "scriptfile11",
kMPOLnchItemBaseKey "12", "scriptfile12",
kMPOLnchItemBaseKey "9", "newscriptfile09",
kMPOLnchItemBaseKey "10", "newscriptfile10",
kMPOLnchItemBaseKey "11", "newscriptfile11",
kMPOLnchItemBaseKey "12", "newscriptfile12",
kMPOLnchAddedElementKey, " + Added Element",
}

Expand Down
Empty file added WLBCmpMacRez.rsrc
Empty file.
34 changes: 0 additions & 34 deletions mpolnchicopng.fr

This file was deleted.

Loading

0 comments on commit b2659f1

Please sign in to comment.