void FCPtrFieldEditor::internalStopEditing (void) { std::string FCId(_EditingTextField->getText()); if(_EditingTextField->getText().compare("NULL") == 0) { FCId = "0"; } else { //Make sure the Id can be cast to a UInt32 try { UInt32 CastTest = boost::lexical_cast<UInt32>(FCId); } catch(boost::bad_lexical_cast &) { //If it can't then cancel editing internalCancelEditing(); return; } } //Call the command to set the Field SetFieldValueCommandPtr SetCommand = SetFieldValueCommand::create(getEditingFC(), getEditingFieldId(), FCId, getEditingFieldIndex()); getCommandManager()->executeCommand(SetCommand); }
void TextFieldEditor::internalStopEditing (void) { //Call the command to set the Field SetFieldValueCommandPtr SetCommand = SetFieldValueCommand::create(getEditingFC(), getEditingFieldId(), _EditingTextArea->getText(), getEditingFieldIndex()); getCommandManager()->executeCommand(SetCommand); }
void BoolFieldEditor::runCommand (bool value) { bool fieldValue; GetFieldHandlePtr TheFieldHandle = getEditingFC()->getField(getEditingFieldId()); if(TheFieldHandle->getCardinality() == FieldType::SingleField) { fieldValue = static_cast<const SFBool*>(TheFieldHandle->getField())->getValue(); } else { fieldValue = static_cast<const MFBool*>(TheFieldHandle->getField())->operator[](getEditingFieldIndex()); } if(value != fieldValue) { //Call the command to set the Field SetFieldValueCommandPtr SetCommand = SetFieldValueCommand::create(getEditingFC(), getEditingFieldId(), (value ? "TRUE" : "FALSE"), getEditingFieldIndex()); getCommandManager()->executeCommand(SetCommand); } }
void ImageFieldEditor::openCreateHandler(void) { //Have the user select the file to import std::vector<WindowEventProducer::FileDialogFilter> Filters; std::list< const Char8 * > ReadableImageSuff; ImageFileHandler::the()->getSuffixList(ReadableImageSuff, ImageFileType::OSG_READ_SUPPORTED); //Determine all of the readable image filetypes Filters.push_back(WindowEventProducer::FileDialogFilter("All Image filetypes","")); std::string AllImageSuffixes; std::string AllImageSuffixesDesc("All Image filetypes ("); for(std::list<const Char8*>::const_iterator SuffixItor(ReadableImageSuff.begin()) ; SuffixItor != ReadableImageSuff.end() ; ++SuffixItor) { if(ImageFileHandler::the()->getFileType(*SuffixItor)) { if(!AllImageSuffixes.empty()) { AllImageSuffixes += ","; AllImageSuffixesDesc += ", "; } AllImageSuffixes += *SuffixItor; AllImageSuffixesDesc = AllImageSuffixesDesc + "*." + *SuffixItor; Filters.push_back(WindowEventProducer::FileDialogFilter(std::string(ImageFileHandler::the()->getFileType(*SuffixItor)->getMimeType()) + " (*." + *SuffixItor + ")",*SuffixItor)); } } AllImageSuffixesDesc += ")"; Filters[0] = WindowEventProducer::FileDialogFilter(AllImageSuffixesDesc,AllImageSuffixes); Filters.push_back(WindowEventProducer::FileDialogFilter("All (*.*)","*")); std::vector<BoostPath> FilesToOpen; FilesToOpen = getParentWindow()->getParentDrawingSurface()->getEventProducer()->openFileDialog("Import a image file.", Filters, BoostPath("."), false); ImageRefPtr NewImage = NULL; if(FilesToOpen.size() > 0) { //Try loading the file using the ImageFileHandler NewImage = ImageFileHandler::the()->read(FilesToOpen[0].string().c_str()); if(NewImage) { FilePathAttachment::setFilePath(NewImage, FilesToOpen[0]); //Set the value of the field SetFieldValueCommandPtr SetCommand = SetFieldValueCommand::create(getEditingFC(), getEditingFieldId(), boost::lexical_cast<std::string>(NewImage->getId()), getEditingFieldIndex()); getCommandManager()->executeCommand(SetCommand); } } }
void FCPtrFieldEditor::handleCreateContainerDialogClosed(DialogWindowEventDetails* const details) { if(details->getOption() != DialogWindowEventDetails::DIALOG_OPTION_CANCEL) { const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(getEditingFC()->getFieldDescription(getEditingFieldId())->getFieldType().getContentType())); const FieldContainerType* TheType(FieldContainerFactory::the()->findType(details->getInput().c_str())); if(TheType != NULL) { //Create the Container CreateFieldContainerCommandPtr CreateCommand; //If the type is a node, then create a NodeCore instead //and then insert it as the core of a newly created node if(*ThePtrType == Node::getClassType()) { CreateFieldContainerCommandPtr CreateCoreCommand = CreateFieldContainerCommand::create(TheType); getCommandManager()->executeCommand(CreateCoreCommand); CreateCommand = CreateFieldContainerCommand::create(&Node::getClassType()); getCommandManager()->executeCommand(CreateCommand); dynamic_cast<Node*>(CreateCommand->getContainer())->setCore(dynamic_cast<NodeCore*>(CreateCoreCommand->getContainer())); } else { CreateCommand = CreateFieldContainerCommand::create(TheType); getCommandManager()->executeCommand(CreateCommand); } //Set the value of the field SetFieldValueCommandPtr SetCommand = SetFieldValueCommand::create(getEditingFC(), getEditingFieldId(), boost::lexical_cast<std::string>(CreateCommand->getContainer()->getId()), getEditingFieldIndex()); getCommandManager()->executeCommand(SetCommand); } } _CreateContainerDialogClosedConnection.disconnect(); }
PMixInterpolationSpaceLayout::PMixInterpolationSpaceLayout(PMixAudioEngine& audioEngine, GraphEditor& graphEditor) : audioEngine(audioEngine) , graphEditor(graphEditor) { audioEngine.getDoc().addChangeListener (this); selectedItems.addChangeListener(this); setMouseClickGrabsKeyboardFocus(true); setWantsKeyboardFocus(true); #if PMIX_PLUGIN==0 getCommandManager().registerAllCommandsForTarget (this); #endif }
void GenericMultiFieldEditor::handleListMouseClicked(MouseEventDetails* const details) { if(details->getButton() == MouseEventDetails::BUTTON1 && details->getClickCount() == 1 && _FieldList->getIndexForDrawingSurfaceLocation(details->getLocation()) == -1) { insertAtIndex(getEditingFC(), getEditingFieldId(), //Size of list, _FieldList->getModel()->getSize(), getParentWindow()->getParentDrawingSurface(), getCommandManager().get()); } }
void FCPtrFieldEditor::handleFindContainerDialogClosed(DialogWindowEventDetails* const details) { if(details->getOption() != DialogWindowEventDetails::DIALOG_OPTION_CANCEL) { FCPtrEditorStore::FieldContianerVector fcStore(_FindFCStore->getList()); //Set the value of the field SetFieldValueCommandPtr SetCommand = SetFieldValueCommand::create(getEditingFC(), getEditingFieldId(), boost::lexical_cast<std::string>(fcStore[details->getInputIndex()]->getId()), getEditingFieldIndex()); getCommandManager()->executeCommand(SetCommand); } _FindContainerDialogClosedConnection.disconnect(); }
MainMenuModel() { setApplicationCommandManagerToWatch (&getCommandManager()); }