def __present_contents__(self, fragment, inheritedState):
        self._incr.onAccess()

        dirPres = self._presentDir()
        note = NotesText([
            'Note: please choose the location of the GraphViz ',
            EmphSpan('bin'), ' directory.'
        ])
        columnContents = [note, dirPres]
        if self._config is not None:
            columnContents.append(self._presentConfig())
        pathContents = Column(columnContents)
        pathSection = Section(SectionHeading2('GraphViz path'), pathContents)

        downloadText = ''
        if self.__isConfigured():
            downloadText = 'GraphViz appears to be installed on this machine and configured. If it does not work correctly, you may need to install it. You can download it from the '
        else:
            downloadText = 'If GraphViz is not installed on this machine, please install it. You can download it from the '

        downloadLink = Hyperlink('GraphViz homepage',
                                 URI('http://www.graphviz.org/'))
        download = NormalText([downloadText, downloadLink, '.'])
        downloadSec = Section(
            SectionHeading2('GraphViz download/installation'), download)

        return Body([pathSection, downloadSec])
 def _showEditorPopup(self, element, popupMenu):
     settingsPres = self._createSettingsPres()
     newEditorPres = self._createNewEditorPres()
     if settingsPres is not None or newEditorPres is not None:
         if settingsPres is not None:
             popupMenu.add(
                 Section(SectionHeading2('Settings'), settingsPres))
         if newEditorPres is not None:
             popupMenu.add(
                 Section(SectionHeading2('New editor'), newEditorPres))
         return True
     else:
         return False
def _documentContextMenuFactory(element, menu):
	region = element.getRegion()
	rootElement = element.getRootElement()
	
	def makeParagraphStyleFn(style):
		def setParagraphStyle(model):
			model.style = style
		
		def _onLink(link, event):
			caret = rootElement.getCaret()
			if caret is not None and caret.isValid():
				caretElement = caret.getElement()
				if caretElement.getRegion() is region:
					GUIRichTextController.instance.modifyParagraphAtMarker(caret.getMarker(), setParagraphStyle)
		return _onLink
	
	normalStyle = Hyperlink('Normal', makeParagraphStyleFn('normal'))
	h1Style = Hyperlink('H1', makeParagraphStyleFn('h1'))
	h2Style = Hyperlink('H2', makeParagraphStyleFn('h2'))
	h3Style = Hyperlink('H3', makeParagraphStyleFn('h3'))
	h4Style = Hyperlink('H4', makeParagraphStyleFn('h4'))
	h5Style = Hyperlink('H5', makeParagraphStyleFn('h5'))
	h6Style = Hyperlink('H6', makeParagraphStyleFn('h6'))
	titleStyle = Hyperlink('Title', makeParagraphStyleFn('title'))
	paraStyles = ControlsRow([normalStyle, h1Style, h2Style, h3Style, h4Style, h5Style, h6Style, titleStyle])
	menu.add(Section(SectionHeading2('Paragraph styles'), paraStyles))

	
	def makeStyleFn(attrName):
		def computeStyleValues(listOfSpanAttrs):
			value = bool(listOfSpanAttrs[0].getValue(attrName, 0))
			value = not value
			attrs = RichTextAttributes()
			attrs.putOverride(attrName, '1'   if value   else None)
			return attrs

		def onButton(button, event):
			selection = rootElement.getSelection()
			if isinstance(selection, TextSelection):
				if selection.getRegion() == region:
					GUIRichTextController.instance.applyStyleToSelection(selection, computeStyleValues)
		return onButton
	
	italicStyle = Button.buttonWithLabel('I', makeStyleFn('italic'))
	boldStyle = Button.buttonWithLabel('B', makeStyleFn('bold'))
	styles = ControlsRow([italicStyle, boldStyle]).alignHLeft()

	menu.add(Section(SectionHeading2('Selection styles'), styles))

	
	return True
Beispiel #4
0
	def __present__(self , fragment, inherited_state):
		title = TitleBarWithSubtitle('Mallard editor', 'development prototype - SAVE FUNCTIONALITY NOT IMPLEMENTED')
		path_heading = SectionHeading2(['Displaying contents of: ', _dir_style(RichSpan(self.__path))])

		links = [Hyperlink(p.filename, editor_page.EditorPageSubject(p, fragment.subject))   for p in self._pages]

		if self._example_pages is not None:
			examples_heading = SectionHeading2('Example mallard documents:')
			example_links = [Hyperlink(p.filename, editor_page.EditorPageSubject(p, fragment.subject))   for p in self._example_pages]
			examples_section = [Spacer(0.0, 20.0), examples_heading, Column(example_links)]
		else:
			examples_section = []

		return _page_style(Page([title, path_heading, Column(links)] + examples_section))
Beispiel #5
0
 def _onReset(button, event):
     project.reset()
     modules = document.unloadAllImportedModules()
     heading = SectionHeading2('Unloaded modules:')
     modules = Column([Label(module) for module in modules])
     report = Section(heading, modules)
     BubblePopup.popupInBubbleAdjacentTo(report, button.getElement(),
                                         Anchor.BOTTOM, True, True)
def _worksheetContextMenuFactory(element, menu):
    def _onRefresh(button, event):
        model.refreshResults()

    model = element.getFragmentContext().getModel()

    refreshButton = Button.buttonWithLabel('Refresh', _onRefresh)
    worksheetControls = ControlsRow([refreshButton.alignHPack()])
    menu.add(Section(SectionHeading2('Worksheet'), worksheetControls))
    return True
	def __present__(self, fragment, inheritedState):
		title = SectionHeading2( 'Unit tests' )

		nameEntry = _nameBorder.surround( EditableLabel( self._name, _notSet ).regexValidated( Tokens.identifierPattern, 'Please enter a valid identifier' ) )

		header = Row( [ title, Spacer( 25.0, 0.0 ), nameEntry ] )

		if self._tableEditor is NotImplemented:
			raise NotImplementedError, 'Table editor is abstract'

		table = self._tableEditor.editTable( self._tests )

		return _inlineTestTableBorder.surround( Column( [ header, Spacer( 0.0, 5.0 ), table ] ) )
Beispiel #8
0
	def __present__(self, fragment, inheritedState):
		self._incr.onAccess()

		title = SectionHeading2( 'Unit tests' )

		nameEntry = _nameBorder.surround( EditableLabel( self._name, _notSet ).regexValidated( Tokens.identifierPattern, 'Please enter a valid identifier' ) )

		header = Row( [ title, Spacer( 25.0, 0.0 ), nameEntry ] )

		contents = [ header.padY( 0.0, 5.0 ), _standardCodeBorder.surround( self._suite ).padY( 3.0 ).alignHExpand() ]

		if self.__passes is not None  and  self.__failures is not None:
			resultsTitle = SectionHeading3( 'Test results:' )
			passes = _standardPassStyle( Label( '%d / %d test(s) passed' % ( self.__passes, self.__passes + len( self.__failures ) ) ) )
			failuresLabel = _standardFailStyle( Label( '%d test(s) failed:' % len( self.__failures ) ) )
			failures = [ Column( [ _standardFailedTestStyle( Label( name ) ), Pres.coerce( exception ).padX( 5.0, 0.0 ) ] ).padX( 5.0, 0.0 )   for name, exception in self.__failures ]
			results = _standardResultsBorder.surround( Column( [ resultsTitle, passes, failuresLabel ] + failures ) ).pad( 3.0, 3.0 )
			contents.append( results )


		return _standardInlineTestBorder.surround( Column( contents ) )
Beispiel #9
0
	def pathsSection(self, title, pathList):
		pathsPres = self.presentPathList( pathList )
		return Section( SectionHeading2( title ), pathsPres )
Beispiel #10
0
 def __present__(self, fragment, inh):
     title = Row([SectionHeading2('Section: '), self.title_elem])
     return _section_border.surround(Column([title, self.text]))
Beispiel #11
0
def _documentContextMenuFactory(element, menu):
	region = element.getRegion()
	rootElement = element.getRootElement()
	
	def makeParagraphStyleFn(style):
		def setStyle(model):
			model.setStyle(style)
		
		def _onLink(link, event):
			caret = rootElement.getCaret()
			if caret is not None and caret.isValid():
				caretElement = caret.getElement()
				if caretElement.getRegion() is region:
					_controller.modifyParagraphAtMarker(caret.getMarker(), setStyle)
		return _onLink
	
	def insertEmbedPara(link, event):
		def _newEmbedPara():
			img = _imageFileChooser(link.element, lambda f: _ParaImage(f))
			return embed.ParaEmbed(img)   if img is not None   else None
		
		caret = rootElement.getCaret()
		if caret is not None and caret.isValid():
			caretElement = caret.getElement()
			if caretElement.getRegion() is region:
				_controller.insertParagraphAtCaret(caret, _newEmbedPara)
	
	normalStyle = Hyperlink('Normal', makeParagraphStyleFn('normal'))
	h1Style = Hyperlink('H1', makeParagraphStyleFn('h1'))
	h2Style = Hyperlink('H2', makeParagraphStyleFn('h2'))
	h3Style = Hyperlink('H3', makeParagraphStyleFn('h3'))
	h4Style = Hyperlink('H4', makeParagraphStyleFn('h4'))
	h5Style = Hyperlink('H5', makeParagraphStyleFn('h5'))
	h6Style = Hyperlink('H6', makeParagraphStyleFn('h6'))
	titleStyle = Hyperlink('Title', makeParagraphStyleFn('title'))
	paraStyles = ControlsRow([normalStyle, h1Style, h2Style, h3Style, h4Style, h5Style, h6Style, titleStyle])
	embedPara = Hyperlink('Embed para', insertEmbedPara)
	paraEmbeds = ControlsRow([embedPara])
	menu.add(Section(SectionHeading2('Paragraph styles'), paraStyles))
	menu.add(Section(SectionHeading2('Paragraph embeds'), paraEmbeds))
	
	
	def makeStyleFn(attrName):
		def computeStyleValues(listOfSpanAttrs):
			value = listOfSpanAttrs[0].getValue(attrName, 0)
			value = not value
			attrs = RichTextAttributes()
			attrs.putOverride(attrName, value)
			return attrs
		
		def onButton(button, event):
			selection = rootElement.getSelection()
			if isinstance(selection, TextSelection):
				if selection.getRegion() == region:
					_controller.applyStyleToSelection(selection, computeStyleValues)
		return onButton
	
	def _onInsertInlineEmbed(button, event):
		def _newInlineEmbedValue():
			return _imageFileChooser(button.element, lambda f: _InlineImage(f))
		
		caret = rootElement.getCaret()
		if caret is not None and caret.isValid():
			caretElement = caret.getElement()
			if caretElement.getRegion() is region:
				_controller.insertInlineEmbedAtMarker(caret.getMarker(), _newInlineEmbedValue)
	
	def style_button(text, on_click, *style_values):
		sty = StyleSheet.instance.withValues(Primitive.fontFace(Primitive.monospacedFontName),
						     *style_values)
		return Button(sty.applyTo(Label(text)), on_click)

	italicStyle = style_button('I', makeStyleFn('i'), Primitive.fontItalic(True))
	boldStyle = style_button('B', makeStyleFn('b'), Primitive.fontBold(True))
	codeStyle = style_button('code', makeStyleFn('code'))
	cmdStyle = style_button('> cmd', makeStyleFn('cmd'))
	appStyle = style_button('app', makeStyleFn('app'))
	sysStyle = style_button('sys', makeStyleFn('sys'))
	styles = ControlsRow([italicStyle, boldStyle, codeStyle, cmdStyle, appStyle, sysStyle]).alignHLeft()
	insertInlineEmbed = Button.buttonWithLabel('Embed', _onInsertInlineEmbed)
	inlineEmbeds = ControlsRow([insertInlineEmbed]).alignHLeft()
	
	menu.add(Section(SectionHeading2('Selection styles'), styles))
	menu.add(Section(SectionHeading2('Inline embeds'), inlineEmbeds))
	
	
	return True
Beispiel #12
0
	def __present__(self, fragment, inh):
		title = Row([SectionHeading2('Title: '), self.title_elem])
		return Column([title, self.text])
Beispiel #13
0
	def __present__(self, fragment, inheritedState):
		title = SectionHeading2( 'Tested block' )

		contents = Column( [ title, self._suite ] )
		return _testedBlockBorder.surround( contents ).withCommands( inlineTestCommands )
def registerPaletteSection(title, items):
    sec = Section(SectionHeading2(title), FlowGrid(4, items))
    _paletteSections.append(sec)