Subversion Repositories svn.mios32

Rev

Rev 1763 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1763 Rev 2180
Line 1... Line 1...
1
/* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
1
/* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
2
// $Id: MiosFileBrowser.cpp 1763 2013-04-27 12:19:03Z tk $
2
// $Id: MiosFileBrowser.cpp 2180 2015-06-14 19:21:59Z tk $
3
/*
3
/*
4
 * File browser for MIOS32 applications
4
 * File browser for MIOS32 applications
5
 *
5
 *
6
 * ==========================================================================
6
 * ==========================================================================
7
 *
7
 *
Line 173... Line 173...
173
    , writeBlockCtrDefault(32) // send 32 blocks (=two 512 byte SD Card Sectors) at once to speed-up write operations
173
    , writeBlockCtrDefault(32) // send 32 blocks (=two 512 byte SD Card Sectors) at once to speed-up write operations
174
    , writeBlockSizeDefault(32) // send 32 bytes per block
174
    , writeBlockSizeDefault(32) // send 32 bytes per block
175
{
175
{
176
    addAndMakeVisible(editLabel = new Label(T("Edit"), String::empty));
176
    addAndMakeVisible(editLabel = new Label(T("Edit"), String::empty));
177
    editLabel->setJustificationType(Justification::left);
177
    editLabel->setJustificationType(Justification::left);
178
    editLabel->setText(String::empty, true);
178
    editLabel->setText(String::empty, sendNotification);
179
179
180
    addAndMakeVisible(statusLabel = new Label(T("Status"), String::empty));
180
    addAndMakeVisible(statusLabel = new Label(T("Status"), String::empty));
181
    statusLabel->setJustificationType(Justification::left);
181
    statusLabel->setJustificationType(Justification::left);
182
    statusLabel->setText(T("Please connect to MIOS32 core by pressing the Update button!"), true);
182
    statusLabel->setText(T("Please connect to MIOS32 core by pressing the Update button!"), sendNotification);
183
183
184
    addAndMakeVisible(updateButton = new TextButton(T("Update")));
184
    addAndMakeVisible(updateButton = new TextButton(T("Update")));
185
    updateButton->addListener(this);
185
    updateButton->addListener(this);
186
186
187
    addAndMakeVisible(uploadButton = new TextButton(T("Upload")));
187
    addAndMakeVisible(uploadButton = new TextButton(T("Upload")));
Line 299... Line 299...
299
void MiosFileBrowser::setStatus(const String& str)
299
void MiosFileBrowser::setStatus(const String& str)
300
{
300
{
301
    if( miosStudio->runningInBatchMode() ) {
301
    if( miosStudio->runningInBatchMode() ) {
302
        std::cout << str << std::endl;
302
        std::cout << str << std::endl;
303
    } else {
303
    } else {
304
        statusLabel->setText(str, true);
304
        statusLabel->setText(str, sendNotification);
305
    }
305
    }
306
}
306
}
307
307
308
//==============================================================================
308
//==============================================================================
309
void MiosFileBrowser::buttonClicked(Button* buttonThatWasClicked)
309
void MiosFileBrowser::buttonClicked(Button* buttonThatWasClicked)
Line 371... Line 371...
371
            enableFileButtons();
371
            enableFileButtons();
372
            hexEditor->clear();
372
            hexEditor->clear();
373
            hexEditor->setReadOnly(true);
373
            hexEditor->setReadOnly(true);
374
            textEditor->clear();
374
            textEditor->clear();
375
            textEditor->setReadOnly(true);
375
            textEditor->setReadOnly(true);
376
            editLabel->setText(String::empty, true);
376
            editLabel->setText(String::empty, sendNotification);
377
377
378
            disableFileButtons(); // to disable also editor buttons
378
            disableFileButtons(); // to disable also editor buttons
379
            enableFileButtons();
379
            enableFileButtons();
380
        } else if( buttonThatWasClicked == saveButton ) {
380
        } else if( buttonThatWasClicked == saveButton ) {
381
            if( hexEditor->isVisible() ) {
381
            if( hexEditor->isVisible() ) {
Line 700... Line 700...
700
bool MiosFileBrowser::downloadFinished(void)
700
bool MiosFileBrowser::downloadFinished(void)
701
{
701
{
702
    if( openHexEditorAfterRead ) {
702
    if( openHexEditorAfterRead ) {
703
        openHexEditor(currentReadData);
703
        openHexEditor(currentReadData);
704
        setStatus(T("Editing ") + currentReadFileName);
704
        setStatus(T("Editing ") + currentReadFileName);
705
        editLabel->setText(currentReadFileName, true);
705
        editLabel->setText(currentReadFileName, sendNotification);
706
    } else if( openTextEditorAfterRead ) {
706
    } else if( openTextEditorAfterRead ) {
707
        openTextEditor(currentReadData);
707
        openTextEditor(currentReadData);
708
        setStatus(T("Editing ") + currentReadFileName);
708
        setStatus(T("Editing ") + currentReadFileName);
709
        editLabel->setText(currentReadFileName, true);
709
        editLabel->setText(currentReadFileName, sendNotification);
710
    } else if( currentReadFileStream ) {
710
    } else if( currentReadFileStream ) {
711
        currentReadFileStream->write((uint8 *)&currentReadData.getReference(0), currentReadData.size());
711
        currentReadFileStream->write((uint8 *)&currentReadData.getReference(0), currentReadData.size());
712
        delete currentReadFileStream;
712
        delete currentReadFileStream;
713
        setStatus(T("Saved ") + currentReadFile.getFullPathName());
713
        setStatus(T("Saved ") + currentReadFile.getFullPathName());
714
714