Skip to content

Commit

Permalink
added MPOLnchHelper Class
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiantheblind committed Aug 1, 2011
1 parent d9b6cea commit 3b3fca5
Show file tree
Hide file tree
Showing 23 changed files with 3,782 additions and 1,339 deletions.
Binary file modified Iconic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified IconicR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions MPOLnch.fr
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ resource MPOLnchNodeWidget (kMPOLnchListElementRsrcID + index_enUS)
__FILE__, __LINE__,
kMPOLnchListParentWidgetId, kPMRsrcID_None, // WidgetId, RsrcId
kBindLeft | kBindRight, // Frame binding
Frame(0, 0, 194, 38), // Frame
Frame(0, 0, 194, 35), // // Frame: left, top, right, bottom.
kTrue, kTrue, // Visible, Enabled
"", // Panel name
{
Expand All @@ -441,7 +441,7 @@ resource MPOLnchNodeWidget (kMPOLnchListElementRsrcID + index_enUS)
(
kMPOLnchListElementEyeballWidgetID, kMPOLnchPNGIconRsrcID, kMPOLnchPluginID, // WidgetId, RsrcId
kBindLeft, // Frame binding
Frame(3,3,36,35) // Frame
Frame(2,3,32,33) // // Frame: left, top, right, bottom.
kTrue, kTrue, // Visible, Enabled
kADBEIconSuiteButtonType,
),
Expand All @@ -452,7 +452,7 @@ resource MPOLnchNodeWidget (kMPOLnchListElementRsrcID + index_enUS)
(
kMPOLnchListElementPenWidgetID, kMPOLnchPNGHelpIconRsrcID, kMPOLnchPluginID, // WidgetId, RsrcId
kBindLeft, // Frame binding
Frame(37,3,69,35) // Frame
Frame(35,3,65,33) // // Frame: left, top, right, bottom.
kTrue, kTrue, // Visible, Enabled
kADBEIconSuiteButtonType,
),
Expand All @@ -462,12 +462,12 @@ resource MPOLnchNodeWidget (kMPOLnchListElementRsrcID + index_enUS)
(
kMPOLnchTextWidgetID, kPMRsrcID_None, // WidgetId, RsrcId
kBindLeft | kBindRight, // Frame binding
Frame(75,3,194,35) // Frame
Frame(70,3,194,33) // // Frame: left, top, right, bottom.
kTrue, kTrue, kAlignLeft,kEllipsizeEnd,kTrue, // Visible, Enabled, ellipsize style, convert ampersands
"", // Initial text
0, // Associated widget for focus
kDialogWindowFontId, // default font
kDialogWindowFontId, // for highlight state.
kPaletteWindowFontId, // default font
kPaletteWindowHiliteFontId, // for highlight state.
),


Expand Down
132 changes: 12 additions & 120 deletions MPOLnchActionComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,64 +226,10 @@ void MPOLnchActionComponent::DoAbout()
*/
void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)
{
/*
InterfacePtr<IControlView> treeWidget(static_cast<IControlView*>(Utils<IWidgetUtils>()->QueryRelatedWidget(invokedWidget, kMPOLnchListBoxWidgetID, IID_ICONTROLVIEW)));
InterfacePtr<ITreeViewMgr> treeMgr(treeWidget, UseDefaultIID());
InterfacePtr<IStringListData> iListData(treeWidget, IID_ISTRINGLISTDATA);
K2Vector<PMString> lists = iListData->GetStringList();
PMString item(kMPOLnchAddedElementKey);
item.Translate();
K2Vector<PMString>::const_iterator iter = std::find(lists.begin(), lists.end(), item);
int32 addIndex = 2;
while (iter != lists.end())
{
item.Insert("+ ", 2, 2);
iter = std::find(lists.begin(), lists.end(), item);
}
if (iter == lists.end())
{
lists.insert(lists.begin(), item);
iListData->SetStringList(lists);
//make sure that the node added has been processed
NodeID node = MPOLnchNodeID::Create(item);
//create a file in script the directory
IDFile file;
FileUtils::GetAppInstallationFolder(&file);
FileUtils::AppendPath(&file, PMString("Scripts"));
FileUtils::AppendPath(&file, PMString("Scripts Panel"));
PMString fn("newscriptfile");
PMString ext(".jsx");
FileUtils::AppendPath(&file, fn + ext);
FileUtils::OpenFile(file, "wt");
treeMgr->NodeAdded(node);
}
*/

// building the scripts



using namespace std;

const int MAXITEMS = 12;

PMString scriptfiles[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"};

PMString newscriptfiles[MAXITEMS] = {
"newscriptfile01.jsx",
Expand Down Expand Up @@ -313,13 +259,7 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)
"help_newscriptfile10.jsx",
"help_newscriptfile11.jsx",
"help_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++) {

Expand Down Expand Up @@ -347,7 +287,7 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)
FileUtils::AppendPath(&theHelpSource, PMString("Resources"));


FileUtils::AppendPath(&theSource, PMString(scriptfiles[i]));
FileUtils::AppendPath(&theSource, PMString(newscriptfiles[i]));
FileUtils::AppendPath(&theHelpSource, PMString(helpfiles[i]));

PMString sourceFileStringUrl = FileUtils::SysFileToFileURL(theSource);
Expand Down Expand Up @@ -390,69 +330,21 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)
FileUtils::AppendPath(&theTarget, fn);
FileUtils::AppendPath(&theHelpTarget, fnh);

//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");


}
if(!FileUtils::CopyFile(theSource, theTarget)){
CAlert::InformationAlert("Could not copy "+fn+". Sorry");
}
}
if(!FileUtils::DoesFileExist(theHelpTarget)){

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

if(!FileUtils::CopyFile(theHelpSource, theHelpTarget)){

CAlert::InformationAlert("Could not copy "+fnh+". 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");
if(!FileUtils::DoesFileExist(theHelpTarget)){
CAlert::InformationAlert("I will try to copy "+fnh+ " to the folder: Scripts Panel/MPO Launcher/help");
if(!FileUtils::CopyFile(theHelpSource, theHelpTarget)){
CAlert::InformationAlert("Could not copy "+fnh+". Sorry");
}
}
}

//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();

//}



Expand Down
34 changes: 34 additions & 0 deletions MPOLnchHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* MPOLnchHelpfiles.cpp
* MPOLauncher
*
* Created by fabiantheblind on 01.08.11.
* Copyright 2011 tmn. All rights reserved.
*
*/

#include "MPOLnchHelper.h"

// constructor
MPOLnchHelper::MPOLnchHelper();
//{
//}

// Helpfile function

PMString MPOLnchHelper::ReadAllAsText(IPMStream *s)
{
PMString text;
uchar oneChar;
s->XferByte(oneChar);
while (s->GetStreamState() == kStreamStateGood)
{
text.Append((char)oneChar);

// Read the next character
s->XferByte(oneChar);

} // end while streamstategood

return text;
}
26 changes: 26 additions & 0 deletions MPOLnchHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* MPOLnchHelpfiles.h
* MPOLauncher
*
* Created by fabiantheblind on 01.08.11.
* Copyright 2011 tmn. All rights reserved.
*
*/

#ifndef DATE_H
#define DATE_H
#include "IPMStream.h"

class MPOLnchHelper
{
public:


MPOLnchHelper() { } // default constructor

PMString ReadAllAsText(IPMStream *s);


};

#endif
67 changes: 42 additions & 25 deletions MPOLnchPenObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@
#include "FileUtils.h"
#include "StreamUtil.h"
#include "IPMStream.h"
#include "MPOLnchHelper.h"

#include <iostream>
#include <fstream>
#include <string>

/**
Expand Down Expand Up @@ -117,6 +115,7 @@ class MPOLnchPenObserver : public CObserver
*/
virtual void Update(const ClassID& theChange, ISubject* theSubject, const PMIID &protocol, void* changedBy);

//PMString ReadAllAsText(IPMStream *s);


};
Expand Down Expand Up @@ -215,12 +214,17 @@ void MPOLnchPenObserver::Update


IDFile helpFile;
FileUtils::GetAppInstallationFolder(&helpFile); //application folder path
FileUtils::AppendPath(&helpFile, PMString("Scripts"));
FileUtils::AppendPath(&helpFile, PMString("Scripts Panel"));
FileUtils::AppendPath(&helpFile, PMString("MPO Launcher"));
FileUtils::AppendPath(&helpFile, PMString("help"));


FileUtils::GetAppInstallationFolder(&helpFile); // Application Folder Path

FileUtils::AppendPath(&helpFile, PMString("Plug-Ins"));
FileUtils::AppendPath(&helpFile, PMString("tmn"));
FileUtils::AppendPath(&helpFile, PMString("MPOLauncher.InDesignPlugin"));
//
FileUtils::AppendPath(&helpFile, PMString("Versions"));
FileUtils::AppendPath(&helpFile, PMString("A"));
FileUtils::AppendPath(&helpFile, PMString("Resources"));

PMString pre("help_");
PMString fn(nodeName);
PMString exth(".jsx");
Expand All @@ -230,27 +234,24 @@ void MPOLnchPenObserver::Update


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

MPOLnchHelper helper;

//CAlert::InformationAlert(helper.ReadAllAsText(s));
CAlert::ModalAlert(helper.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);


// for debug
//FileUtils::OpenFile(scriptFile);
InterfacePtr<IScriptRunner>scriptRunner(Utils<IScriptUtils>()->QueryScriptRunner(helpFile));
bool filestatus=scriptRunner->CanHandleFile(helpFile);

RunScriptParams scriptParams(scriptRunner);
scriptParams.SetShowErrorAlert(kTrue);
scriptParams.SetInvokeDebugger(kFalse);



if(filestatus==1)
{
scriptRunner->RunFile(helpFile,scriptParams);
}// close filestatus

}else {
CAlert::InformationAlert("Got an error. You need the MPO Launcher Folder in the Scripts Panel");
CAlert::InformationAlert("Got an error reading in the "+nodeName
+" help. Something went teribly wrong."+
" Contact [email protected] for more help");
}


Expand All @@ -265,5 +266,21 @@ void MPOLnchPenObserver::Update
}


//PMString MPOLnchPenObserver::ReadAllAsText(IPMStream *s)
//{
// PMString text;
// uchar oneChar;
// s->XferByte(oneChar);
// while (s->GetStreamState() == kStreamStateGood)
// {
// text.Append((char)oneChar);
//
// // Read the next character
// s->XferByte(oneChar);
//
// } // end while streamstategood
//
// return text;
//}


Binary file modified help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified helpR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion help_newscriptfile01.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
alert("This is the Help for: " + $.fileName);
alert("This is the Help for: " + $.fileName);

var myString = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur";
Loading

0 comments on commit 3b3fca5

Please sign in to comment.