Skip to content

Commit

Permalink
read in listnames from helper class
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiantheblind committed Aug 1, 2011
1 parent 3b3fca5 commit 680d39c
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 80 deletions.
87 changes: 28 additions & 59 deletions MPOLnchActionComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@
#include "FileUtils.h"
#include "CoreFileUtils.h"
#include "StreamUtil.h"
#include <fstream>
#include <cstdlib>
#include <string>

#include "MPOLnchHelper.h"


/** MPOLnchActionComponent
Expand Down Expand Up @@ -228,67 +227,37 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)
{
// building the scripts

const int MAXITEMS = 12;


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"};


PMString helpfiles[MAXITEMS] = {
"help_newscriptfile01.jsx",
"help_newscriptfile02.jsx",
"help_newscriptfile03.jsx",
"help_newscriptfile04.jsx",
"help_newscriptfile05.jsx",
"help_newscriptfile06.jsx",
"help_newscriptfile07.jsx",
"help_newscriptfile08.jsx",
"help_newscriptfile09.jsx",
"help_newscriptfile10.jsx",
"help_newscriptfile11.jsx",
"help_newscriptfile12.jsx"};

MPOLnchHelper helper;


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


IDFile theSource;//scriptfiles[i];
IDFile theSource = helper.GetInternalResourceFolder();//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"));

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

IDFile theHelpSource = helper.GetInternalResourceFolder();//scriptfiles[i];

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


FileUtils::AppendPath(&theSource, PMString(newscriptfiles[i]));
FileUtils::AppendPath(&theHelpSource, PMString(helpfiles[i]));
FileUtils::AppendPath(&theSource, PMString(helper.GetScriptFile(i)));
FileUtils::AppendPath(&theHelpSource, PMString(helper.GetHelpFile(i)));

PMString sourceFileStringUrl = FileUtils::SysFileToFileURL(theSource);
PMString sourceHelpFileStringUrl = FileUtils::SysFileToFileURL(theHelpSource);
Expand Down Expand Up @@ -324,8 +293,8 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)

FileUtils::CreateFolderIfNeeded(theHelpTarget,kTrue);

PMString fn(newscriptfiles[i]);
PMString fnh(helpfiles[i]);
PMString fn(helper.GetScriptFile(i));
PMString fnh(helper.GetHelpFile(i));

FileUtils::AppendPath(&theTarget, fn);
FileUtils::AppendPath(&theHelpTarget, fnh);
Expand Down
66 changes: 65 additions & 1 deletion MPOLnchHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,55 @@ MPOLnchHelper::MPOLnchHelper();

// Helpfile function

int MPOLnchHelper::MAXITEMS = 12;

PMString MPOLnchHelper::GetScriptFile(int i){

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


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

PMString MPOLnchHelper::GetHelpFile(int i){

PMString theFileName[12] = {
"help_newscriptfile01.jsx",
"help_newscriptfile02.jsx",
"help_newscriptfile03.jsx",
"help_newscriptfile04.jsx",
"help_newscriptfile05.jsx",
"help_newscriptfile06.jsx",
"help_newscriptfile07.jsx",
"help_newscriptfile08.jsx",
"help_newscriptfile09.jsx",
"help_newscriptfile10.jsx",
"help_newscriptfile11.jsx",
"help_newscriptfile12.jsx"};



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

PMString MPOLnchHelper::ReadAllAsText(IPMStream *s)
{
PMString text;
Expand All @@ -31,4 +80,19 @@ PMString MPOLnchHelper::ReadAllAsText(IPMStream *s)
} // end while streamstategood

return text;
}
}

IDFile MPOLnchHelper::GetInternalResourceFolder(){
IDFile theSource;

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

return theSource;
}
15 changes: 12 additions & 3 deletions MPOLnchHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@
*
*/

#ifndef DATE_H
#define DATE_H
#ifndef MPOLNCHHELPER_H
#define MPOLNCHHELPER_H

#include "IPMStream.h"
#include "FileUtils.h"


class MPOLnchHelper
{
public:


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

PMString ReadAllAsText(IPMStream *s);

PMString GetScriptFile(int i);
PMString GetHelpFile(int i);

IDFile GetInternalResourceFolder();

static int MAXITEMS;

};

#endif
16 changes: 4 additions & 12 deletions MPOLnchPenObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,11 @@ void MPOLnchPenObserver::Update



MPOLnchHelper helper;

// look for the internal resource files
IDFile helpFile = helper.GetInternalResourceFolder();

IDFile helpFile;

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);
Expand All @@ -236,7 +229,6 @@ 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),
Expand Down
19 changes: 14 additions & 5 deletions MPOLnchTreeViewAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ListTreeViewAdapter.h"
#include "MPOLnchNodeID.h"
#include "MPOLnchID.h"
#include "MPOLnchHelper.h"

/**
* TreeViewAdapter.
Expand All @@ -52,12 +53,20 @@ MPOLnchTreeViewAdapter::MPOLnchTreeViewAdapter(IPMUnknown* boss):ListTreeViewAda
{
//initialize the list with the default list string name
K2Vector<PMString> lists;
for (int32 i = 0; i< 12; i++)
MPOLnchHelper helper;

for (int32 i = 0; i< helper.MAXITEMS; i++)
{
PMString name(kMPOLnchItemBaseKey);
name.AppendNumber(i+1);
name.Translate();
lists.push_back(name);
PMString nodeName = helper.GetScriptFile(i);
nodeName.Truncate(4);

// this is from the original code
// if you need ranslateable names
//PMString name(kMPOLnchItemBaseKey);
//name.AppendNumber(i+1);
//name.Translate();

lists.push_back(nodeName);
}
InterfacePtr<IStringListData> iListData(this, IID_ISTRINGLISTDATA);
iListData->SetStringList(lists);
Expand Down

0 comments on commit 680d39c

Please sign in to comment.