1+ /*
2+ ------------------------------------------------------------------
3+
4+ This file is part of the Open Ephys GUI
5+ Copyright (C) 2016 Open Ephys
6+
7+ ------------------------------------------------------------------
8+
9+ This program is free software: you can redistribute it and/or modify
10+ it under the terms of the GNU General Public License as published by
11+ the Free Software Foundation, either version 3 of the License, or
12+ (at your option) any later version.
13+
14+ This program is distributed in the hope that it will be useful,
15+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ GNU General Public License for more details.
18+
19+ You should have received a copy of the GNU General Public License
20+ along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+ #include " JuliaEditor.h"
24+ #include " JuliaProcessor.h"
25+ #include < stdio.h>
26+
27+ JuliaEditor::JuliaEditor (GenericProcessor* parentNode, bool useDefaultParameterEditors=true )
28+ : GenericEditor(parentNode, useDefaultParameterEditors)
29+ {
30+ juliaProcessor = (JuliaProcessor*) parentNode;
31+
32+ lastFilePath = File::getCurrentWorkingDirectory ();
33+
34+ fileButton = new UtilityButton (" Select file" ,Font (" Small Text" , 13 , Font::plain));
35+ fileButton->addListener (this );
36+ fileButton->setBounds (10 ,85 ,100 ,25 );
37+ addAndMakeVisible (fileButton);
38+
39+ reloadFileButton = new UtilityButton (" refresh" ,Font (" Small Text" , 13 , Font::plain));
40+ reloadFileButton->addListener (this );
41+ reloadFileButton->setBounds (100 +10 ,85 ,60 ,25 );
42+ addAndMakeVisible (reloadFileButton);
43+
44+ fileNameLabel = new Label (" FileNameLabel" , " No file selected." );
45+ fileNameLabel->setBounds (10 ,85 +20 ,140 ,25 );
46+ addAndMakeVisible (fileNameLabel);
47+
48+ bufferSizeSelection = new Label (" Buffer Size" ," 30000" ); // this is currently set in RHD2000Thread, the cleaner would be to set it here again
49+ bufferSizeSelection->setEditable (true ,false ,false );
50+ bufferSizeSelection->addListener (this );
51+ bufferSizeSelection->setBounds (120 ,60 ,60 ,20 );
52+ bufferSizeSelection->setColour (Label::textColourId, Colours::darkgrey);
53+ addAndMakeVisible (bufferSizeSelection);
54+
55+ bufferSizeSelectionLabel = new Label (" " ," NBuf.:" );
56+ bufferSizeSelectionLabel->attachToComponent (bufferSizeSelection,true );
57+ addAndMakeVisible (bufferSizeSelectionLabel);
58+
59+ // Image im;
60+ // im = ImageCache::getFromMemory(BinaryData::JuliaIconActive_png,
61+ // BinaryData::JuliaIconActive_pngSize);
62+
63+ // icon = new ImageIcon(im);
64+ // addAndMakeVisible(icon);
65+ // icon->setBounds(15,25,61,54);
66+ // icon->setOpacity(0.3f);
67+
68+ desiredWidth = 200 ;
69+
70+ setEnabledState (false );
71+ }
72+
73+ JuliaEditor::~JuliaEditor ()
74+ {
75+
76+ }
77+
78+ void JuliaEditor::setFile (String file)
79+ {
80+ File fileToRead (file);
81+ lastFilePath = fileToRead.getParentDirectory ();
82+ juliaProcessor->setFile (fileToRead.getFullPathName ());
83+ fileNameLabel->setText (fileToRead.getFileName (), dontSendNotification);
84+
85+
86+ // setEnabledState(true);
87+ // icon->setOpacity(1.0f); // tie this to hasJuliaInstance instead of just setting it!
88+ // repaint();
89+ }
90+
91+ void JuliaEditor::buttonEvent (Button* button)
92+ {
93+ if (!acquisitionIsActive)
94+ {
95+ if (button == fileButton)
96+ {
97+ // std::cout << "Button clicked." << std::endl;
98+ // FileChooser chooseJuliaProcessorFile("Please select the file you want to load...", lastFilePath, "*");
99+
100+
101+ // file dialogs are screwed up in current xubuntu, so we'll do this for now.
102+ setFile (" /home/jvoigts/Documents/Github/plugin-GUI/Source/Plugins/JuliaProcessor/exampleProcessor.jl" );
103+
104+
105+ // if (chooseJuliaProcessorFile.browseForFileToOpen())
106+ {
107+ // Use the selected file
108+ // setFile(chooseJuliaProcessorFile.getResult().getFullPathName());
109+
110+ // lastFilePath = fileToRead.getParentDirectory();
111+ // thread->setFile(fileToRead.getFullPathName());
112+ // fileNameLabel->setText(fileToRead.getFileName(),false);
113+ }
114+ }
115+ if (button == reloadFileButton)
116+ {
117+ juliaProcessor->reloadFile ();
118+ }
119+ }
120+ }
121+
122+ void JuliaEditor::labelTextChanged (Label* label)
123+ {
124+ if (!acquisitionIsActive)
125+ {
126+ if (label == bufferSizeSelection)
127+ {
128+ Value val = label->getTextValue ();
129+ juliaProcessor->setBuffersize (int (val.getValue ()));
130+ }
131+ }
132+ }
133+
134+ void JuliaEditor::saveEditorParameters (XmlElement* xml)
135+ {
136+ // XmlElement* fileName = xml->createNewChildElement("FILENAME");
137+ // fileName->addTextElement(lastFilePath.getFullPathName());
138+ }
139+
140+ void JuliaEditor::loadEditorParameters (XmlElement* xml)
141+ {
142+ // forEachXmlChildElement(*xml, xmlNode)
143+ // {
144+ // if (xmlNode->hasTagName("FILENAME"))
145+ // {
146+ // lastFilePath = File(xmlNode->getText());
147+ // thread->setFile(lastFilePath.getFullPathName());
148+ // fileNameLabel->setText(lastFilePath.getFullPathName(),false);
149+ // }
150+ // }
151+ }
0 commit comments