def __init__(self):
     swing.JMenu.__init__(self)
     self.widget = None
     pu = self.getPopupMenu()
     pu.setBackground(awt.Color.ORANGE)
     tborder = sborder.TitledBorder("Yup")
     pu.setBorder(Border2())
    def run(self):
        self.splash = splash = swing.JWindow()
        splash.setAlwaysOnTop(1)
        cpane = splash.getContentPane()
        rp = splash.getRootPane()
        tb = sborder.TitledBorder("Leo")
        tb.setTitleJustification(tb.CENTER)
        rp.setBorder(tb)
        splash.setBackground(awt.Color.ORANGE)
        dimension = awt.Dimension(400, 400)
        splash.setPreferredSize(dimension)
        splash.setSize(400, 400)

        sicon = g.os_path_join(g.app.loadDir, "..", "Icons", "Leosplash.GIF")
        #ii = swing.ImageIcon( "../Icons/Leosplash.GIF" )
        ii = swing.ImageIcon(sicon)
        image = swing.JLabel(ii)
        image.setBackground(awt.Color.ORANGE)
        cpane.add(image)
        self.splashlabel = splashlabel = swing.JLabel("Leo Starting....")
        splashlabel.setBackground(awt.Color.ORANGE)
        splashlabel.setForeground(awt.Color.BLUE)
        cpane.add(splashlabel, awt.BorderLayout.SOUTH)
        w, h = self._calculateCenteredPosition(splash)
        splash.setLocation(w, h)
        splash.visible = True
    def create_labeled_frame(self,
                             parent,
                             caption=None,
                             relief="groove",
                             bd=2,
                             padx=0,
                             pady=0):
        """Create a labeled frame."""

        w = swing.JPanel()
        parent.add(w)
        if caption:
            border = w.getBorder()
            tborder = sborder.TitledBorder(border)
            tborder.setTitle(caption)
            w.setBorder(tborder)

        sl = swing.SpringLayout()
        w.setLayout(sl)
        f = swing.JPanel()
        w.add(f)
        sl.putConstraint(sl.NORTH, f, 5, sl.NORTH, w)
        sl.putConstraint(sl.WEST, f, 5, sl.WEST, w)
        sl.putConstraint(sl.SOUTH, w, 5, sl.SOUTH, f)
        sl.putConstraint(sl.EAST, w, 5, sl.EAST, f)

        return w, f
Esempio n. 4
0
 def __init__(self, jd, data):
     swing.JTextField.__init__(self)
     self.jd = jd
     self.data = data
     border = self.getBorder()
     tborder = sborder.TitledBorder(border)
     tborder.setTitle("Choose Reference Name:")
     self.setBorder(tborder)
     self.addKeyListener(self)
     self.rmv_spot = None
Esempio n. 5
0
        def createWidgets(self):

            self.dialog = swing.JDialog()
            self.dialog.setTitle("Spell Checker")
            cpane = self.dialog.getContentPane()
            blayout = swing.BoxLayout(cpane, swing.BoxLayout.Y_AXIS)
            cpane.setLayout(blayout)
            self.word = swing.JTextField()
            self.word.setEditable(False)
            cwborder = sborder.TitledBorder("Current Word:")
            self.word.setBorder(cwborder)
            cpane.add(self.word)
            self.possible = swing.JTextField()
            pborder = sborder.TitledBorder("Change To:")
            self.possible.setBorder(pborder)
            cpane.add(self.possible)
            center = swing.JPanel()
            blayout = swing.BoxLayout(center, swing.BoxLayout.X_AXIS)
            center.setLayout(blayout)
            self.jlist = swing.JList()
            self.jlist.setSelectionMode(
                swing.ListSelectionModel.SINGLE_SELECTION)
            self.jlist.setVisibleRowCount(5)

            class _listSelectionListener(sevent.ListSelectionListener):
                def __init__(self, jlist, possible):
                    self.jlist = jlist
                    self.possible = possible

                def valueChanged(self, event):
                    self.possible.setText(str(self.jlist.getSelectedValue()))

            self.jlist.addListSelectionListener(
                _listSelectionListener(self.jlist, self.possible))
            spane = swing.JScrollPane(self.jlist)
            spborder = sborder.TitledBorder("Suggestions")
            spane.setBorder(spborder)
            center.add(spane)
            bpanel = swing.JPanel()
            blayout = swing.BoxLayout(bpanel, swing.BoxLayout.Y_AXIS)
            bpanel.setLayout(blayout)
            center.add(bpanel)
            change = swing.JButton("Change")
            change.actionPerformed = self.change
            changeall = swing.JButton("Change All")
            changeall.actionPerformed = self.changeAll
            ignore = swing.JButton("Ignore All")
            ignore.actionPerformed = self.ignore
            add = swing.JButton("Add")
            add.actionPerformed = self.add
            bpanel.add(change)
            bpanel.add(changeall)
            bpanel.add(ignore)
            bpanel.add(add)
            cpane.add(center)
            self.next = swing.JButton("Next")
            self.next.actionPerformed = self.checkNextWord
            self.close = swing.JButton("Close")
            self.close.actionPerformed = lambda event: self.dialog.hide()
            jpanel = swing.JPanel()
            jpanel.add(self.next)
            jpanel.add(self.close)
            cpane.add(jpanel)
            self.dialog.pack()
    def runAskOkCancelNumberDialog(self, title, message):
        """Create and run askOkCancelNumber dialog ."""
        dialog = self._getDialog(title)
        cpane = dialog.getContentPane()
        holder = swing.JPanel()
        gbl = awt.GridBagLayout()
        holder.setLayout(gbl)
        gbc = awt.GridBagConstraints()
        gbc.fill = 1
        gbc.weightx = 1
        gbc.weighty = 1
        jtf = swing.JTextField()
        gbl.setConstraints(jtf, gbc)
        holder.add(jtf)
        tborder = sborder.TitledBorder(message)
        holder.setBorder(tborder)
        cpane.add(holder)

        class _Search(swing.AbstractAction):
            source = None

            def __init__(self, dialog, message):
                swing.AbstractAction.__init__(self, message)
                self.dialog = dialog
                self.message = message

            def actionPerformed(self, ae):
                _Search.source = ae.getSource()
                self.dialog.dispose()

        jb = swing.JButton(_Search(dialog, "Ok"))
        jb2 = swing.JButton(_Search(dialog, "Cancel"))

        class _Enter(aevent.ActionListener):
            def __init__(self, ok_but):
                self.ok_but = ok_but

            def actionPerformed(self, aE):
                _Search.source = self.ok_but
                dialog.dispose()

        jtf.addActionListener(_Enter(jb))

        class _AcceptOnlyNumbers(aevent.KeyAdapter):
            def __init__(self):
                aevent.KeyAdapter.__init__(self)
                self.consume = False

            def keyPressed(self, ke):

                kc = ke.getKeyCode()
                if kc in (ke.VK_ENTER, ke.VK_BACK_SPACE): return
                c = ke.getKeyChar()
                if not java.lang.Character.isDigit(c):
                    self.consume = True
                    ke.consume()

            def keyReleased(self, ke):
                if self.consume:
                    self.consume = False
                    ke.consume()

            def keyTyped(self, ke):
                if self.consume:
                    ke.consume()

        jtf.addKeyListener(_AcceptOnlyNumbers())
        bottom = swing.JPanel()
        bottom.add(jb, awt.BorderLayout.WEST)
        bottom.add(jb2, awt.BorderLayout.EAST)
        cpane.add(bottom, awt.BorderLayout.SOUTH)
        dialog.pack()
        w, h = self._calculateCenteredPosition(dialog)
        dialog.setLocation(w, h)
        dialog.setAlwaysOnTop(1)
        dialog.setVisible(True)
        if _Search.source is jb:
            return int(jtf.getText())
        else:
            return -1
    def runAskLeoIDDialog(self):
        """Create and run a dialog to get g.app.LeoID."""
        message = ("leoID.txt not found\n\n" +
                   "Please enter an id that identifies you uniquely.\n" +
                   "Your cvs login name is a good choice.\n\n" +
                   "Your id must contain only letters and numbers\n" +
                   "and must be at least 3 characters in length.")

        dialog = swing.JDialog()
        dialog.title = "Create a Leo ID"
        dialog.modal = 1
        cpane = dialog.getContentPane()
        jta = swing.JTextArea()
        jta.setText(message)
        jta.editable = 0
        cpane.add(jta, awt.BorderLayout.NORTH)
        jtf = swing.JTextField()
        jp = swing.JPanel()
        jp.setBorder(sborder.TitledBorder("Your ID:"))
        gbl = awt.GridBagLayout()
        jp.setLayout(gbl)
        gbc = awt.GridBagConstraints()
        gbc.fill = 1
        gbc.weightx = 1
        gbc.weighty = 1
        gbl.setConstraints(jtf, gbc)
        jp.add(jtf)
        cpane.add(jp, awt.BorderLayout.CENTER)

        class _OK(swing.AbstractAction):
            def __init__(self):
                swing.AbstractAction.__init__(self, "OK")

            def actionPerformed(self, ae):
                dialog.dispose()

        jb = swing.JButton(_OK())

        jb.setEnabled(False)
        jpanel2 = swing.JPanel()
        jpanel2.add(jb)
        cpane.add(jpanel2, awt.BorderLayout.SOUTH)

        class _Enabler(sevent.DocumentListener):
            def __init__(self):
                pass

            def changedUpdate(self, de):
                pass

            def insertUpdate(self, de):

                l = de.getDocument().getLength()
                if l >= 3: jb.setEnabled(True)

            def removeUpdate(self, de):

                l = de.getDocument().getLength()
                if l < 3: jb.setEnabled(False)

        jtf.getDocument().addDocumentListener(_Enabler())
        dialog.pack()
        w, h = self._calculateCenteredPosition(dialog)
        dialog.setLocation(w, h)
        dialog.setAlwaysOnTop(1)
        splash.toBack()
        dialog.visible = 1
        g.app.leoID = jtf.getText()
        splash.toFront()
 def createNodeSearchFrame( self, clnpanel ):
     
     clnpanel.setLayout( awt.BorderLayout() )
     oclnpanel = clnpanel
     clnpanel = swing.Box.createHorizontalBox()
     oclnpanel.add( clnpanel, awt.BorderLayout.CENTER )
     
     
     jta = swing.JTextArea()
     self.CutCopyPaste( jta )
     tp = swing.JPanel( awt.GridLayout( 1, 1 ))
     self.nstext = jta
     sp = swing.JScrollPane( jta )
 
     border = sp.getBorder()
     tborder = sborder.TitledBorder( border )
     tborder.setTitle( "Base Text" )
     sp.setBorder( tborder )
     tp.add( sp )
     clnpanel.add( tp )
     
     
     bpanel = swing.JPanel()
     spl = swing.SpringLayout()
     bpanel.setLayout( spl )  
     executebox = swing.Box.createHorizontalBox()
     border = executebox.getBorder()
     tborder = sborder.TitledBorder( border )
     tborder.setTitle( "Searching" )
     executebox.setBorder( tborder )
     bpanel.add( executebox )
     spl.putConstraint( spl.NORTH, executebox, 5, spl.NORTH, bpanel )
     clnsearch = swing.JButton( "Clone Search" )
     clnsearch.actionPerformed = self.nodeSearch
     executebox.add( clnsearch )
     #spl.putConstraint( spl.NORTH, clnsearch, 5, spl.NORTH, bpanel )
     cpysearch = swing.JButton( "Copy Search" )
     cpysearch.actionPerformed = lambda event: self.nodeSearch( event, type='copy' ) 
     #bpanel.add( cpysearch )
     #spl.putConstraint( spl.NORTH, cpysearch, 5, spl.SOUTH, clnsearch )
     executebox.add( cpysearch )
     
     self.all_searches = rb1 = swing.JCheckBox( "Match Searches" )
     mtext = """Selecting causes the search system to only recognize a node if all searches match"""
     rb1.setToolTipText( mtext ) 
     bpanel.add( rb1 )
     spl.putConstraint( spl.NORTH, rb1, 5, spl.NORTH, bpanel )
     spl.putConstraint( spl.WEST, rb1, 5, spl.EAST, executebox )
     
     
     self.all_filters = rb2 = swing.JCheckBox( "Match Filters" )
     mtext = """Selecting causes the filter system to only filter out a node if all searches match"""
     rb2.setToolTipText( mtext )
     bpanel.add( rb2 )
     spl.putConstraint( spl.NORTH, rb2, 5, spl.SOUTH, rb1 )
     spl.putConstraint( spl.WEST, rb2, 5, spl.EAST, executebox )
     
     spl2 = swing.SpringLayout()
     sandf = swing.JPanel( spl2 )
     sandf.setPreferredSize( awt.Dimension( 275, 85 ) )
     border = sandf.getBorder()
     tborder = sborder.TitledBorder( border )
     tborder.setTitle( "Derive Searches and Filters" )
     sandf.setBorder( tborder )
     bpanel.add( sandf )
     spl.putConstraint( spl.NORTH, sandf, 5, spl.SOUTH, executebox )
     
     b1 = swing.JButton( "+ as Search" )
     b1.setActionCommand( "search" )
     b1.actionPerformed = self.addAsSearchOrExclude
     b2 = swing.JButton( "+ as Filter" )
     b2.setActionCommand( "filter" )
     b2.actionPerformed = self.addAsSearchOrExclude
     sandf.add( b1 ); sandf.add( b2 )
     spl2.putConstraint( spl2.NORTH, b1, 5, spl2.NORTH, executebox )
     spl2.putConstraint( spl2.NORTH, b2, 5, spl2.SOUTH, b1 )
     b3 = swing.JButton( "+ as Regex-Search" )
     b3.setActionCommand( "regex-search" )
     b3.actionPerformed = self.addAsSearchOrExclude
     sandf.add( b3 )
     spl2.putConstraint( spl2.NORTH, b3,5, spl2.NORTH, executebox )
     spl2.putConstraint( spl2.WEST, b3,5, spl2.EAST, b1 )
     #spl2.putConstraint( spl2.EAST, b3, 5, spl2.EAST, executebox )
     b4 = swing.JButton( "+ as Regex-Filter" )
     b4.setActionCommand( "regex-filter" )
     b4.actionPerformed = self.addAsSearchOrExclude
     sandf.add( b4 )
     spl2.putConstraint( spl2.NORTH, b4, 5, spl2.SOUTH, b1 )
     spl2.putConstraint( spl2.WEST, b4, 5, spl2.EAST, b2 )
     clear = swing.JButton( "Clear Text" )
     def clear_txt( event, text = jta ):
         
         jta.setText( "" )
     clear.actionPerformed = clear_txt
     bpanel.add( clear )
     spl.putConstraint( spl.NORTH, clear, 5, spl.SOUTH, sandf )
     
     
     clnpanel.add( bpanel )
     tp.setPreferredSize( awt.Dimension( 200, 100 ) )
     clnpanel.setPreferredSize( awt.Dimension( 200, 100 )) 
     
     class dtm2( stable.DefaultTableModel ):
         
         def __int__( self ):
             stable.DefaultTableModel.__init__( self )
             
         def isCellEditable( self, a, b ):
             if b == 1:
                 return False
             return True
         
     self.dtm = dtm = dtm2()
     dtm.addColumn( "Text" )
     dtm.addColumn( "Type" )
     jp = swing.JPanel( awt.BorderLayout() )
     self.table = jt = swing.JTable( dtm )
     jt.getColumn( "Text" ).setCellEditor( self._LeoTableCellEditor() )
     jt.getColumn( "Text" ).setCellRenderer( self._LeoTableCellRenderer() )
     
     rmv = swing.JButton( "Remove" )
     def rmv_row( event, jt = jt, dtm = dtm ):
         
         row = jt.getSelectedRow()
         if row != -1:
             dtm.removeRow( row )
         
     rmv.actionPerformed = rmv_row
     rmva = swing.JButton( "Clear" )
     def rmv_all( event, jt = jt, dtm = dtm ):
         
         rc = dtm.getRowCount()
         for z in xrange( rc ):
             dtm.removeRow( 0 )       
         
     rmva.actionPerformed = rmv_all   
     rmvp = swing.Box.createVerticalBox()
     rmvp.add( rmv )
     rmvp.add( rmva )
     jp.add( rmvp, awt.BorderLayout.EAST )
     jtsp = swing.JScrollPane( jt )
     border = jtsp.getBorder()
     tborder = sborder.TitledBorder( border )
     tborder.setTitle( "Searchers and Filters" )
     jtsp.setBorder( tborder )
     jp.add( jtsp )
 
     jp.setPreferredSize( clnpanel.getPreferredSize() )
     oclnpanel.add( jp, awt.BorderLayout.SOUTH )