Exemplo n.º 1
0
    def run(self):
        frame = JFrame('Table11',
                       size=(300, 170),
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        menuBar = JMenuBar()
        resize = JMenu('AUTO_RESIZE')

        bGroup = ButtonGroup()
        for name, value in self.info:
            rb = JRadioButtonMenuItem(name,
                                      actionPerformed=self.handler,
                                      selected=(name == 'Rest'))
            bGroup.add(rb)
            resize.add(rb)
        menuBar.add(resize)
        frame.setJMenuBar(menuBar)

        headings = 'T/F,Date,Integer,Float,Double'.split(',')
        model = myTM(self.data, headings)
        self.table = table = JTable(
            model, selectionMode=ListSelectionModel.SINGLE_SELECTION)
        table.getColumnModel().getColumn(model.getColumnCount() -
                                         1  # i.e., last column
                                         ).setCellRenderer(myRenderer())
        setColumnWidths(table)

        frame.add(JScrollPane(table))
        frame.setVisible(1)
Exemplo n.º 2
0
    def init(self):
        w, h, aa, threads = (512, 512, 1, 2)
        canvas = RayTracePanel(w, h, aa, threads)
        self.getContentPane().add(JScrollPane(canvas))

        #Save FileChooser
        #fcS = JFileChooser()
        #fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp']))
        #fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg']))
        #fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png']))
        #def saveFile(event):
        #    '''Performed when the save button is pressed'''
        #    result = fcS.showSaveDialog(frame)
        #    if result == JFileChooser.APPROVE_OPTION:
        #        file = fcS.getSelectedFile()
        #        fname = file.getPath()
        #        ext = fcS.getFileFilter().getExtensions()[0]
        #        if not fname.endswith('.' + ext):
        #            file = File(fname + '.' + ext)
        #        canvas.saveToFile(file, ext)

        #Open FileChooser
        #fcO = JFileChooser()
        #fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts']))
        #def openFile(event):
        #    '''Performed when the open button is pressed'''
        #    result = fcO.showOpenDialog(frame)
        #    if result == JFileChooser.APPROVE_OPTION:
        #        fname = fcO.getSelectedFile().getPath()
        #        if fname.endswith('.rts'):
        #            f = open(fname, 'rb')
        #            newScene = SceneFactory().buildScene(f)
        #            f.close()
        #            Painter(canvas, newScene, openButton, saveButton, stopButton).start()

        def stop(event):
            '''Peformed when the stop button is pressed'''
            canvas.stopRendering()

        #Setup Menu
        menuBar = JMenuBar()
        menu = JMenu("File")
        menuBar.add(menu)
        #openButton = JMenuItem("Open...", actionPerformed=openFile)
        #openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
        #menu.add(openButton)
        #saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
        #saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
        #menu.add(saveButton)
        menu.addSeparator()
        stopButton = JMenuItem('Stop Render', actionPerformed=stop)
        stopButton.setAccelerator(KeyStroke.getKeyStroke(
            KeyEvent.VK_ESCAPE, 0))
        stopButton.setEnabled(False)
        menu.add(stopButton)
        menu.addSeparator()
        #closeButton = JMenuItem('Close', actionPerformed=exit)
        #closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
        #menu.add(closeButton)
        self.setJMenuBar(menuBar)
Exemplo n.º 3
0
 def menuBar(self):
     result = JMenuBar()
     newMenu = result.add(JMenu('New'))
     newMenu.add(JMenuItem('InnerFrame', actionPerformed=self.addIframe))
     newMenu.addSeparator()
     newMenu.add(JMenuItem('Exit', actionPerformed=self.exit))
     return result
Exemplo n.º 4
0
    def init(self):
        w, h, aa, threads = (512, 512, 1, 2)
        canvas = RayTracePanel(w, h, aa, threads)
        self.getContentPane().add(JScrollPane(canvas))

        # Save FileChooser
        # fcS = JFileChooser()
        # fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp']))
        # fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg']))
        # fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png']))
        # def saveFile(event):
        #    '''Performed when the save button is pressed'''
        #    result = fcS.showSaveDialog(frame)
        #    if result == JFileChooser.APPROVE_OPTION:
        #        file = fcS.getSelectedFile()
        #        fname = file.getPath()
        #        ext = fcS.getFileFilter().getExtensions()[0]
        #        if not fname.endswith('.' + ext):
        #            file = File(fname + '.' + ext)
        #        canvas.saveToFile(file, ext)

        # Open FileChooser
        # fcO = JFileChooser()
        # fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts']))
        # def openFile(event):
        #    '''Performed when the open button is pressed'''
        #    result = fcO.showOpenDialog(frame)
        #    if result == JFileChooser.APPROVE_OPTION:
        #        fname = fcO.getSelectedFile().getPath()
        #        if fname.endswith('.rts'):
        #            f = open(fname, 'rb')
        #            newScene = SceneFactory().buildScene(f)
        #            f.close()
        #            Painter(canvas, newScene, openButton, saveButton, stopButton).start()

        def stop(event):
            """Peformed when the stop button is pressed"""
            canvas.stopRendering()

        # Setup Menu
        menuBar = JMenuBar()
        menu = JMenu("File")
        menuBar.add(menu)
        openButton = JMenuItem("Open...", actionPerformed=openFile)
        openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
        menu.add(openButton)
        # saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
        # saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
        # menu.add(saveButton)
        menu.addSeparator()
        stopButton = JMenuItem("Stop Render", actionPerformed=stop)
        stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0))
        stopButton.setEnabled(False)
        menu.add(stopButton)
        menu.addSeparator()
        # closeButton = JMenuItem('Close', actionPerformed=exit)
        # closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
        # menu.add(closeButton)
        self.setJMenuBar(menuBar)
Exemplo n.º 5
0
    def __init__(self):
        self.running = True
        menuBar = JMenuBar()

        menu = JMenu("File")
        menu.add(OpenAction(self))
        menu.add(CloseAction(self))
        menu.addSeparator()
        menu.add(QuitAction(self))
        self.addWindowListener(ProfelisWindowAdapter(self))
        menuBar.add(menu)

        self.setJMenuBar(menuBar)

        self.contentPane = JPanel()
        self.contentPane.layout = GridBagLayout()
        constraints = GridBagConstraints()

        self.blastLocation = JTextField(
            System.getProperty("user.home") + "/blast")
        self.databaseLocation = JTextField(
            System.getProperty("user.home") + "/blast/db")
        self.projects = JTabbedPane()

        constraints.gridx, constraints.gridy = 0, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JLabel("Blast Location"), constraints)
        constraints.gridx, constraints.gridy = 1, 0
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.weightx, constraints.weighty = 1, 0
        self.contentPane.add(self.blastLocation, constraints)
        constraints.gridx, constraints.gridy = 2, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JButton(BlastAction(self)), constraints)
        constraints.gridx, constraints.gridy = 3, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JLabel("Database Location"), constraints)
        constraints.gridx, constraints.gridy = 4, 0
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.weightx, constraints.weighty = 1, 0
        self.contentPane.add(self.databaseLocation, constraints)
        constraints.gridx, constraints.gridy = 5, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JButton(DatabaseAction(self)), constraints)
        constraints.gridx, constraints.gridy = 0, 1
        constraints.gridwidth, constraints.gridheight = 6, 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        self.contentPane.add(self.projects, constraints)
Exemplo n.º 6
0
    def __init__(self):
        self.running = True
        menuBar = JMenuBar()
        
        menu = JMenu("File")
        menu.add(OpenAction(self))
        menu.add(CloseAction(self))
        menu.addSeparator()
        menu.add(QuitAction(self))
        self.addWindowListener(ProfelisWindowAdapter(self))
        menuBar.add(menu)

        self.setJMenuBar(menuBar)

        self.contentPane = JPanel()
        self.contentPane.layout = GridBagLayout()
        constraints = GridBagConstraints()

        self.blastLocation = JTextField(System.getProperty("user.home") + "/blast")
        self.databaseLocation = JTextField(System.getProperty("user.home") + "/blast/db")
        self.projects = JTabbedPane()
        
        constraints.gridx, constraints.gridy = 0, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JLabel("Blast Location"), constraints)
        constraints.gridx, constraints.gridy = 1, 0
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.weightx, constraints.weighty = 1, 0
        self.contentPane.add(self.blastLocation, constraints)
        constraints.gridx, constraints.gridy = 2, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JButton(BlastAction(self)), constraints)
        constraints.gridx, constraints.gridy = 3, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JLabel("Database Location"), constraints)
        constraints.gridx, constraints.gridy = 4, 0
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.weightx, constraints.weighty = 1, 0
        self.contentPane.add(self.databaseLocation, constraints)
        constraints.gridx, constraints.gridy = 5, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JButton(DatabaseAction(self)), constraints)
        constraints.gridx, constraints.gridy = 0, 1
        constraints.gridwidth, constraints.gridheight = 6, 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        self.contentPane.add(self.projects, constraints)
Exemplo n.º 7
0
    def createMenuBar(self):
        menuBar = JMenuBar()

        fileMenu = JMenu('File')
        exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit))
        menuBar.add(fileMenu)

        codeMenu = JMenu('Encoding')

        data = ['ANSI', 'UTF-8', 'UCS-2 Big Endian', 'UCS-2 Little Endian']

        bGroup = ButtonGroup()
        for suffix in data:
            name = 'Encoding in ' + suffix
            rb = JRadioButtonMenuItem(name, selected=(suffix == 'ANSI'))
            bGroup.add(rb)
            codeMenu.add(rb)
        menuBar.add(codeMenu)

        viewMenu = JMenu('View')
        viewMenu.add(JCheckBoxMenuItem('Full screen'))
        viewMenu.add(JSeparator())  # Using JSeparator()
        #       viewMenu.addSeparator()        # Using addSeparator()
        #       viewMenu.insertSeparator( 1 )  #
        viewMenu.add(JCheckBoxMenuItem('Word wrap'))
        menuBar.add(viewMenu)

        return menuBar
Exemplo n.º 8
0
 def __init__(self, text):
     self.frame = JFrame()
     self.frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
     self.frame.getContentPane().setLayout(GridLayout(1,1))
     self.settings = Settings()
     self.text = text
     self + text
     m = JMenuBar()
     self.menubar = m
     self.filemenu = self.menu()
     m.add(self.filemenu)
     self.frame.setJMenuBar(self.menubar)
     self.frame.setSize(1000, 600)
     self.frame.setVisible(1)
Exemplo n.º 9
0
 def __init__(self, text):
     self.frame = JFrame()
     self.frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
     self.frame.getContentPane().setLayout(GridLayout(1, 1))
     self.settings = Settings()
     self.text = text
     self + text
     m = JMenuBar()
     self.menubar = m
     self.filemenu = self.menu()
     m.add(self.filemenu)
     self.frame.setJMenuBar(self.menubar)
     self.frame.setSize(1000, 600)
     self.frame.setVisible(1)
Exemplo n.º 10
0
 def setMenuBar(self):
     menuBar = JMenuBar()
     
     menuApp = JMenu("Apps")
     menuApp.setMnemonic('A')
     
     menuSettings = JMenu("Settings")
     menuSettings.setMnemonic('S')
     
     #set submenus
     menuPlayNow = JMenu("PlayNow" )
     
     menuPlayNowOpen = JMenuItem("Open", actionPerformed = (lambda x, param="open": self.playNowApp_startThread(param)) )
     menuPlayNow.add(menuPlayNowOpen)
     
     menuPlayNowLogin = JMenuItem("Login", actionPerformed = lambda x, action="playNowLogin": self.playNowApp_startThread(action) )
     menuPlayNow.add(menuPlayNowLogin)
     
     menuPlayNowClose = JMenuItem("Close", actionPerformed = lambda x, action="playNowClose": self.playNowApp_startThread(action) )
     menuPlayNow.add(menuPlayNowClose)
     
     menuPokerTable = JMenu("PokerTable")
     menuPokerTableJoin = JMenuItem("Find Practice Table", actionPerformed = lambda x, action="practiceTable": self.playNowApp_startThread(action) )
     menuPokerTable.add(menuPokerTableJoin)
     
     menuPokerTableJoin = JMenuItem("Join Table", actionPerformed = lambda x, action="joinTable": self.playNowApp_startThread(action) )
     menuPokerTable.add(menuPokerTableJoin)
     
     menuPokerTableAddChips = JMenuItem("Add Chips", actionPerformed = lambda x, action="addChips": self.playNowApp_startThread(action) )
     menuPokerTable.add(menuPokerTableAddChips)
     
     menuPokerTableSitOut = JMenuItem("Sit Out", actionPerformed = lambda x, action="sitOut": self.playNowApp_startThread(action) )
     menuPokerTable.add(menuPokerTableSitOut)
     
     menuPokerTableLeaveTable = JMenuItem("Leave Table", actionPerformed = lambda x, action="leaveTable": self.playNowApp_startThread(action) )
     menuPokerTable.add(menuPokerTableLeaveTable)
     
     menuPokerAppExit = JMenuItem("Exit")
     
     menuApp.add(menuPlayNow)
     menuApp.add(menuPokerTable)
     menuApp.addSeparator()
     menuApp.add(menuPokerAppExit)
     
     menuBar.add(menuApp)
     menuBar.add(menuSettings)
     
     self._frame.setJMenuBar(menuBar)
Exemplo n.º 11
0
 def run(self):
     frame = JFrame('Menu1',
                    size=(200, 125),
                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     frame.setJMenuBar(
         JMenuBar(background=Color.blue, preferredSize=(200, 25)))
     frame.setVisible(1)
Exemplo n.º 12
0
 def __init__(self):
     self.setAlwaysOnTop(False);
     self.setSize(500, 500);
     menubar = JMenuBar();
     menu = JMenu("A Menu");
     menu_ac = menu.getAccessibleContext();
     menu_ac.setAccessibleDescription("The only menu in this program");
     menuitem = JMenuItem("A Menu Item");
     menu.add(menuitem);
     menubar.add(menu);
     self.setJMenuBar(menubar);
     lbl = JLabel("A Label");
     lbl.setHorizontalAlignment(JLabel.CENTER);
     lbl.setVerticalAlignment(JLabel.CENTER);
     self.setContentPane(lbl);
     self.setVisible(True);
Exemplo n.º 13
0
def studentLogined(stObj):
    global panel
    global table
    global heading
    global frame

    frame = JFrame("Student  Page ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500, 600)
    frame.setLocation(200, 200)
    frame.setLayout(None)

    panel = JPanel()
    panel.setSize(500, 580)
    panel.setLocation(0, 20)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.WHITE)

    heading = JLabel()
    heading.setBounds(210, 10, 200, 30)

    table = JTable()
    table.setBounds(0, 50, 500, 470)
    sp = JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                     ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS)

    bar = JMenuBar()

    profile = JMenu("Profile")
    showProfile = JMenuItem("Show Profile",
                            actionPerformed=clickShowStudentProfile)
    changePassword = JMenuItem("Change Password",
                               actionPerformed=changeStudentPassword)
    profile.add(showProfile)
    profile.add(changePassword)
    bar.add(profile)

    attendence = JMenu("Attendence")
    showAllAttendence = JMenuItem("Show All Attendence",
                                  actionPerformed=clickAllAttendence)
    showAttendenceInMonth = JMenuItem("show attendence in month",
                                      actionPerformed=clickAttendenceInMonth)
    attendence.add(showAllAttendence)
    attendence.add(showAttendenceInMonth)
    bar.add(attendence)

    logout = JMenuItem("logout", actionPerformed=clickLogout)
    bar.add(logout)

    panel.add(table)

    frame.setJMenuBar(bar)
    frame.add(panel)

    frame.setVisible(True)
Exemplo n.º 14
0
 def createMenuBar(self):
     #JMenuBar menuBar;
     #JMenu soccerHub, subscriptions,skin,suggestions,help;
 
     menuBar = JMenuBar();
 
     #SoccerHub menu
     seniorDesign = JMenu("SeniorDesign");
     #seniorDesign.setMnemonic(KeyEvent.VK_0);
     menuBar.add(seniorDesign);
 
     #subscription menu
     statistics = JMenu("Statistics");
     #subscriptions.setMnemonic(KeyEvent.VK_1);
     menuBar.add(statistics);
 
     return menuBar;
def DisplayStreetTable (collection):
    columns=list(
        (
            ("Name","name"),
            )
        )
    tm= ObjectTableModel(collection,columns)
    frame = MyFrame("Street Table")
    frame.setSize(800, 1200)
    frame.setLayout(BorderLayout())
    table = JTable(tm)
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS)
    header = table.getTableHeader()
    header.setUpdateTableInRealTime(True)
    header.setReorderingAllowed(True);
    scrollPane = JScrollPane()
    scrollPane.getViewport().setView((table))
#    copyButton = JButton('Merge') #,actionPerformed=self.noAction
#    frame.add(copyButton)

    listener=MyListener(table)
    table.addMouseListener(listener)
    table.addKeyListener(listener)

    menubar = JMenuBar()
    file = JMenu("Edit")
    file.setMnemonic(KeyEvent.VK_E)

    lookup = JMenuItem("Lookup",actionPerformed=frame.LookupEvent)
    lookup.setMnemonic(KeyEvent.VK_L)

    file.add(lookup)


    menubar.add(file)



    frame.setJMenuBar(menubar)

    frame.add(scrollPane)


    frame.pack();
    frame.setSize(frame.getPreferredSize());
    frame.show()
Exemplo n.º 16
0
    def run(self):
        #-----------------------------------------------------------------------
        # Create and set up the window.
        #-----------------------------------------------------------------------
        frame = JFrame('GlassPaneDemo')
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

        #-----------------------------------------------------------------------
        # Start creating and adding components.
        #-----------------------------------------------------------------------
        changeButton = JCheckBox('Glass pane "visible"')
        changeButton.setSelected(0)

        #-----------------------------------------------------------------------
        # Set up the content pane, where the 'main GUI' lives.
        #-----------------------------------------------------------------------
        contentPane = frame.getContentPane()
        contentPane.setLayout(FlowLayout())
        contentPane.add(changeButton)
        contentPane.add(JButton('Button 1'))
        contentPane.add(JButton('Button 2'))

        #-----------------------------------------------------------------------
        # Set up the menu bar, which appears above the content pane.
        #-----------------------------------------------------------------------
        menuBar = JMenuBar()
        menu = JMenu('Menu')
        menu.add(JMenuItem('Do nothing'))
        menuBar.add(menu)
        frame.setJMenuBar(menuBar)

        #-----------------------------------------------------------------------
        # Set up the glass pane, which appears over both menu bar and
        # content pane and is an item listener on the change button
        #-----------------------------------------------------------------------
        myGlassPane = MyGlassPane(changeButton, menuBar, contentPane)
        changeButton.addItemListener(myGlassPane)
        frame.setGlassPane(myGlassPane)

        #-----------------------------------------------------------------------
        # Resize the frame to display the visible components contain therein,
        # and have the frame (application) make itself visisble.
        #-----------------------------------------------------------------------
        frame.pack()
        frame.setVisible(1)
Exemplo n.º 17
0
    def makeMenu(self):
        menuBar = JMenuBar(background=Color.blue, foreground=Color.white)

        showMenu = JMenu('Show', background=Color.blue, foreground=Color.white)

        self.deprecated = JCheckBoxMenuItem('Deprecated',
                                            1,
                                            actionPerformed=self.showItems)
        showMenu.add(self.deprecated)

        self.protected = JCheckBoxMenuItem('Protected',
                                           1,
                                           actionPerformed=self.showItems)
        showMenu.add(self.protected)

        showMenu.addSeparator()
        showMenu.add(JMenuItem('Exit', actionPerformed=self.exit))
        menuBar.add(showMenu)
        return menuBar
Exemplo n.º 18
0
    def MenuBar(self):

        #-----------------------------------------------------------------------
        # Start by creating our application menubar
        #-----------------------------------------------------------------------
        menu = JMenuBar()

        #-----------------------------------------------------------------------
        # "Show" entry
        #-----------------------------------------------------------------------
        show = JMenu('Show')

        show.add(JMenuItem('Highlight text', actionPerformed=self.hilightText))

        show.add(JSeparator())
        show.add(JMenuItem('Exit', actionPerformed=self.Exit))
        menu.add(show)

        #-----------------------------------------------------------------------
        # "Help" entry
        #-----------------------------------------------------------------------
        help = JMenu('Help')
        help.add(JMenuItem('About', actionPerformed=self.about))
        help.add(JMenuItem('Notice', actionPerformed=self.notice))
        menu.add(help)

        return menu
Exemplo n.º 19
0
    def createMenuBar(self):
        menuBar = JMenuBar()

        fileMenu = JMenu('File')

        data = [['Spam', self.spam], ['Eggs', self.eggs],
                ['Bacon', self.bacon]]

        bGroup = ButtonGroup()
        for name, handler in data:
            rb = JRadioButtonMenuItem(name,
                                      actionPerformed=handler,
                                      selected=(name == 'Spam'))
            bGroup.add(rb)
            fileMenu.add(rb)

        fileMenu.add(JSeparator())  # Using JSeparator()
        for name, handler in data:
            fileMenu.add(JCheckBoxMenuItem(name, actionPerformed=handler))

        fileMenu.addSeparator()  # Using addSeparator()
        exitItem = fileMenu.add(
            JMenuItem('Exit',
                      KeyEvent.VK_X,
                      actionPerformed=self.exit,
                      accelerator=KeyStroke.getKeyStroke(
                          'x', InputEvent.ALT_DOWN_MASK)))
        menuBar.add(fileMenu)

        helpMenu = JMenu('Help')
        aboutItem = helpMenu.add(
            JMenuItem('About', KeyEvent.VK_A, actionPerformed=self.about))
        menuBar.add(helpMenu)

        return menuBar
Exemplo n.º 20
0
    def MenuBar(self):

        #-----------------------------------------------------------------------
        # Start by creating our application menubar
        #-----------------------------------------------------------------------
        menu = JMenuBar()

        #-----------------------------------------------------------------------
        # Build the "File" -> "Changes" (nested) menu
        #-----------------------------------------------------------------------
        self.ChangesMI = JMenu('Changes', enabled=0)
        self.ChangesMI.add(JMenuItem('Save', actionPerformed=self.save))
        self.ChangesMI.add(JMenuItem('Discard', actionPerformed=self.discard))

        #-----------------------------------------------------------------------
        # "File" entry
        #-----------------------------------------------------------------------
        jmFile = JMenu('File')
        jmFile.add(self.ChangesMI)
        jmFile.add(JMenuItem('Exit', actionPerformed=self.Exit))
        menu.add(jmFile)

        #-----------------------------------------------------------------------
        # "Help" entry
        #-----------------------------------------------------------------------
        jmHelp = JMenu('Help')
        jmHelp.add(JMenuItem('About', actionPerformed=self.about))
        jmHelp.add(JMenuItem('Notice', actionPerformed=self.notice))
        menu.add(jmHelp)

        return menu
Exemplo n.º 21
0
    def MenuBar( self ) :
        #-----------------------------------------------------------------------
        # Start by creating our application menubar
        #-----------------------------------------------------------------------
        menu = JMenuBar()

        #-----------------------------------------------------------------------
        # "File" entry
        #-----------------------------------------------------------------------
        jmFile   = JMenu( 'File' )
        jmiExit  = JMenuItem(
            'Exit',
            actionPerformed = self.Exit
        )
        jmFile.add( jmiExit )
        menu.add( jmFile )

        #-----------------------------------------------------------------------
        # "Help" entry
        #-----------------------------------------------------------------------
        jmHelp   = JMenu( 'Help' )
        jmiAbout = JMenuItem(
            'About',
            actionPerformed = self.about
        )
        jmiNote  = JMenuItem(
            'Notice',
            actionPerformed = self.notice
        )
        jmHelp.add( jmiAbout )
        jmHelp.add( jmiNote  )
        menu.add( jmHelp )

        return menu
Exemplo n.º 22
0
    def menuBar( self ) :
        menu = JMenuBar()

        #-----------------------------------------------------------------------
        # "File" entry
        #-----------------------------------------------------------------------
        jmFile   = JMenu( 'File' )
        jmiExit  = JMenuItem(
            'Exit',
            actionPerformed = self.Exit
        )
        jmFile.add( jmiExit )
        menu.add( jmFile )

        #-----------------------------------------------------------------------
        # "Help" entry
        #-----------------------------------------------------------------------
        jmHelp   = JMenu( 'Help' )
        jmiAbout = JMenuItem(
            'About',
            actionPerformed = self.about
        )
        jmiNote  = JMenuItem(
            'Notice',
            actionPerformed = self.notice
        )
        jmHelp.add( jmiAbout )
        jmHelp.add( jmiNote  )
        menu.add( jmHelp )

        return menu
Exemplo n.º 23
0
    def createMenuBar(self):
        menuBar = JMenuBar()

        fileMenu = JMenu('File')

        data = [['Spam', self.spam], ['Eggs', self.eggs],
                ['Bacon', self.bacon]]

        bGroup = ButtonGroup()
        for name, handler in data:
            rb = JRadioButtonMenuItem(name,
                                      actionPerformed=handler,
                                      selected=(name == 'Spam'))
            bGroup.add(rb)
            fileMenu.add(rb)

        exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit))
        menuBar.add(fileMenu)

        helpMenu = JMenu('Help')
        aboutItem = helpMenu.add(JMenuItem('About',
                                           actionPerformed=self.about))
        menuBar.add(helpMenu)

        return menuBar
Exemplo n.º 24
0
    def MenuBar(self):

        #-----------------------------------------------------------------------
        # Start by creating our application menubar
        #-----------------------------------------------------------------------
        menu = JMenuBar()

        #-----------------------------------------------------------------------
        # "Show" entry
        #-----------------------------------------------------------------------
        show = JMenu('Show')

        show.add(JMenuItem('Collapse all', actionPerformed=self.collapse))
        show.add(JMenuItem('Expand all', actionPerformed=self.expand))

        show.add(JSeparator())
        show.add(JMenuItem('Find...', actionPerformed=self.Find))

        show.add(JSeparator())
        show.add(JMenuItem('Exit', actionPerformed=self.Exit))
        menu.add(show)

        #-----------------------------------------------------------------------
        # "Help" entry
        #-----------------------------------------------------------------------
        help = JMenu('Help')
        help.add(JMenuItem('About', actionPerformed=self.about))
        help.add(JMenuItem('Notice', actionPerformed=self.notice))
        menu.add(help)

        return menu
Exemplo n.º 25
0
    def run(self):
        frame = JFrame('Menu2',
                       size=(200, 125),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        menuBar = JMenuBar(background=Color.blue, foreground=Color.white)
        fileMenu = JMenu('File')
        fileMenu.add(JMenuItem('Exit'))
        menuBar.add(fileMenu)

        helpMenu = JMenu('Help')
        helpMenu.add(JMenuItem('About'))
        menuBar.add(helpMenu)

        frame.setJMenuBar(menuBar)
        frame.setVisible(1)
Exemplo n.º 26
0
    def createMenuBar(self):
        menuBar = JMenuBar()

        fileMenu = JMenu('File')
        exitItem = fileMenu.add(
            JMenuItem('Exit',
                      KeyEvent.VK_X,
                      actionPerformed=self.exit,
                      accelerator=KeyStroke.getKeyStroke(
                          KeyEvent.VK_X, ActionEvent.ALT_MASK)))
        menuBar.add(fileMenu)

        codeMenu = JMenu('Encoding')

        data = [['ANSI', KeyEvent.VK_A], ['UTF-8', KeyEvent.VK_U],
                ['UCS-2 Big Endian', KeyEvent.VK_B],
                ['UCS-2 Little Endian', KeyEvent.VK_L]]

        bGroup = ButtonGroup()
        for suffix, mnemonic in data:
            name = 'Encoding in ' + suffix
            rb = JRadioButtonMenuItem(name,
                                      mnemonic=mnemonic,
                                      selected=(suffix == 'ANSI'))
            bGroup.add(rb)
            codeMenu.add(rb)
        menuBar.add(codeMenu)

        viewMenu = JMenu('View')
        viewMenu.add(JCheckBoxMenuItem('Full screen'))
        viewMenu.add(JSeparator())  # Using JSeparator()
        #       viewMenu.addSeparator()        # Using addSeparator()
        #       viewMenu.insertSeparator( 1 )  #
        viewMenu.add(JCheckBoxMenuItem('Word wrap'))
        menuBar.add(viewMenu)

        return menuBar
Exemplo n.º 27
0
    def run(self):
        frame = JFrame('Menu3',
                       size=(200, 125),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        menuBar = JMenuBar(background=Color.blue)
        #       print '\nmenuBar size before:', menuBar.getPreferredSize()

        fileMenu = JMenu('File', foreground=Color.white)
        fileMenu.add(JMenuItem('Exit'))
        menuBar.add(fileMenu)
        #       print 'menuBar size  after:', menuBar.getPreferredSize()

        helpMenu = JMenu('Help', foreground=Color.white)
        helpMenu.add(JMenuItem('About'))
        menuBar.add(helpMenu)

        frame.setJMenuBar(menuBar)
        frame.setVisible(1)
Exemplo n.º 28
0
    def run(self):
        frame = JFrame('Menu4',
                       size=(200, 125),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        menuBar = JMenuBar()

        fileMenu = JMenu('File')
        exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit))
        menuBar.add(fileMenu)

        helpMenu = JMenu('Help')
        aboutItem = helpMenu.add(JMenuItem('About',
                                           actionPerformed=self.about))
        menuBar.add(helpMenu)

        frame.setJMenuBar(menuBar)

        frame.setVisible(1)
Exemplo n.º 29
0
    def createMenuBar(self):
        menuBar = JMenuBar()

        fileMenu = JMenu('File')

        data = [['Spam', self.spam], ['Eggs', self.eggs],
                ['Bacon', self.bacon]]

        for name, handler in data:
            fileMenu.add(JCheckBoxMenuItem(name, actionPerformed=handler))

        exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit))
        menuBar.add(fileMenu)

        helpMenu = JMenu('Help')
        aboutItem = helpMenu.add(JMenuItem('About',
                                           actionPerformed=self.about))
        menuBar.add(helpMenu)

        return menuBar
Exemplo n.º 30
0
 def __init__(self):
     '''
     Constructor
     '''
     #Create classifiers
     #Character classifier
     path_to_this_dir = File(str(inspect.getfile( inspect.currentframe() ))).getParent()
     character_classifier_file = open(File(path_to_this_dir,"character_classifier.dat").getPath(),'r')
     self.character_classifier = CharacterClassifier(from_string_string=character_classifier_file.read())
     character_classifier_file.close()
     #Word classifier
     word_classifier_file = open(File(path_to_this_dir,"word_classifier.dat").getPath(),'r')
     self.word_classifier= WordClassifier(from_string_string=word_classifier_file.read())
     word_classifier_file.close()
     #Set up window
     self.setTitle("HandReco Writer")
     self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
     self.setLocationRelativeTo(None)
     self.setLayout(BorderLayout())
     #Set up menu
     menu_bar = JMenuBar()
     info_menu = JMenu("Info")
     def instructions(event):
         instr = '''
         The program can just recognise capital English characters.
         See Info -> Available Words... for available word corrections.
         
         Good Luck with the writing!'''
         JOptionPane.showMessageDialog(self, instr, 
                       "Instructions", 
                       JOptionPane.INFORMATION_MESSAGE)
     instructions_menu_item = JMenuItem("Instructions...",actionPerformed=instructions)
     info_menu.add(instructions_menu_item)
     def word_corrections(event):
         words_string = ""
         for word in self.word_classifier.words:
             words_string = words_string + word.upper() + "\n"
         text = "The words that can be corrected are:\n\n" +words_string
         dialog = JOptionPane(text, 
                              JOptionPane.INFORMATION_MESSAGE)
         dialog_wrapper = JDialog(self,"Available Words",False)
         dialog_wrapper.setContentPane(dialog)
         dialog_wrapper.pack()
         dialog_wrapper.setVisible(True)
     word_corrections_menu_item = JMenuItem("Available Words...",actionPerformed=word_corrections)
     info_menu.add(word_corrections_menu_item)
     menu_bar.add(info_menu)
     self.setJMenuBar(menu_bar)
     #Input panel
     input_panel = JPanel()
     input_panel.setLayout(BoxLayout(input_panel, BoxLayout.X_AXIS))
     input_panel.setBorder(BorderFactory.createTitledBorder("Input"))
     self.paint_area = PaintArea(100,100)
     input_panel.add(self.paint_area)
     input_options_panel = JPanel()
     input_options_panel.setLayout(BoxLayout(input_options_panel, BoxLayout.Y_AXIS))
     #Write Char
     write_char_panel = JPanel(BorderLayout())
     def write_char(event):
         char = self.character_classifier.classify_image(self.paint_area.image())
         self.text_area.setText(self.text_area.getText() + char)
         self.paint_area.clear()
     write_char_panel.add(JButton("Write Char", actionPerformed=write_char), BorderLayout.NORTH)
     input_options_panel.add(write_char_panel)
     #Space and Correct
     space_and_correct_panel = JPanel(BorderLayout())
     def space_and_correct(event):
         text = self.text_area.getText()
         words = text.split(" ")
         string = words[-1]
         try:
             word = self.word_classifier.classify(string.lower())
             words[-1] = word.upper()
         except:
             JOptionPane.showMessageDialog(self, "Have you entered a character which is not in the alphabet?", 
                           "Could not Correct", 
                           JOptionPane.ERROR_MESSAGE)
             self.text_area.setText(text + " ")
             return
         newText = ""
         for w in words:
             newText = newText + w + " "
         self.text_area.setText(newText)
     space_and_correct_panel.add(JButton("Space and Correct", actionPerformed=space_and_correct), BorderLayout.NORTH)
     input_options_panel.add(space_and_correct_panel)
     #Space
     space_panel = JPanel(BorderLayout())
     def space(event):
         self.text_area.setText(self.text_area.getText() + " ")
     space_panel.add(JButton("Space", actionPerformed=space), BorderLayout.NORTH)
     input_options_panel.add(space_panel)
     #Clear Input Area
     clear_input_area_panel = JPanel(BorderLayout())
     def clear(event):
         self.paint_area.clear()
     clear_input_area_panel.add(JButton("Clear Input Area", actionPerformed=clear), BorderLayout.NORTH)
     input_options_panel.add(clear_input_area_panel)
     input_panel.add(input_options_panel)
     self.add(input_panel, BorderLayout.NORTH)
     text_area_panel = JPanel()
     text_area_panel.setLayout(BorderLayout())
     text_area_panel.setBorder(BorderFactory.createTitledBorder("Text"))
     self.text_area = JTextArea()
     self.text_area.setLineWrap(True)
     #Increase font size
     font = self.text_area.getFont() 
     self.text_area.setFont(Font(font.getName(), Font.BOLD, 24))
     
     text_area_panel.add(JScrollPane(self.text_area), BorderLayout.CENTER)
     self.add(text_area_panel, BorderLayout.CENTER)
     self.pack()
     self.setSize(Dimension(300,300))
     self.setVisible(True)
Exemplo n.º 31
0
Arquivo: init.py Projeto: curran/jyvis
from jyVis import JyVis
from jyVis.widgets import JLMenuItem
from javax.swing import JMenuBar, JMenu

baseWindow = JyVis.getBaseWindow()

menuBar = JMenuBar()

fileMenu = JMenu("File")

fileMenu.add(JLMenuItem("Open Dataset",JyVis.promptUserToOpenDataTable))

fileMenu.add(JLMenuItem("Save Session",JyVis.promptUserToSaveSession))

fileMenu.add(JLMenuItem("Load Session",JyVis.promptUserToReplaySession))

fileMenu.add(JLMenuItem("Export Selection as CSV",JyVis.promptUserToExportSelection))

fileMenu.add(JLMenuItem("Export Image as PNG",JyVis.promptUserToExportImageAsPNG))

fileMenu.addSeparator() 
fileMenu.add(JLMenuItem("Properties","JyVis.showSystemPropertyPanel()"))

#TODO remove this
fileMenu.add(JLMenuItem("RTest","JyVis.doRTest()"))

menuBar.add(fileMenu)

# build the Visualizations menu from the contents of the plugin directory
visMenu = JyVis.createMenuForScriptDirectory("run//Visualizations")
if(visMenu != None): menuBar.add(visMenu)
Exemplo n.º 32
0
def run(scene, w=512, h=512, aa=1, threads=1):
        '''Create GUI and perform ray-tracing.'''
        #Make Swing not look like garbage (so much)
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
        #Setup frame
        frame = JFrame(
            "RayTracer",
            defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
            size=(w, h)
        )
        frame.setIconImage(ImageIcon('resources/icon.png').getImage())
        canvas = RayTracePanel(w, h, aa, threads)
        frame.getContentPane().add(JScrollPane(canvas))
        
        #Save FileChooser
        fcS = JFileChooser()
        fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp']))
        fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg']))
        fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png']))
        def saveFile(event):
            '''Performed when the save button is pressed'''
            result = fcS.showSaveDialog(frame)
            if result == JFileChooser.APPROVE_OPTION:
                file = fcS.getSelectedFile()
                fname = file.getPath()
                ext = fcS.getFileFilter().getExtensions()[0]
                if not fname.endswith('.' + ext):
                    file = File(fname + '.' + ext)
                canvas.saveToFile(file, ext)
        
        #Open FileChooser
        fcO = JFileChooser()
        fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts']))
        def openFile(event):
            '''Performed when the open button is pressed'''
            result = fcO.showOpenDialog(frame)
            if result == JFileChooser.APPROVE_OPTION:
                fname = fcO.getSelectedFile().getPath()
                if fname.endswith('.rts'):
                    f = open(fname, 'rb')
                    newScene = SceneFactory().buildScene(f)
                    f.close()
                    Painter(canvas, newScene, openButton, saveButton).start()
                    
        def exit(event):
            '''Performed when the exit button is pressed'''
            import sys
            sys.exit(0)
        
        #Setup Menu
        menuBar = JMenuBar()
        menu = JMenu("File")
        menuBar.add(menu)
        openButton = JMenuItem("Open...", actionPerformed=openFile)
        openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
        menu.add(openButton)
        saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
        saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
        menu.add(saveButton)
        menu.addSeparator()
        closeButton = JMenuItem('Close', actionPerformed=exit)
        closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
        menu.add(closeButton)
        frame.setJMenuBar(menuBar)
        
        #Finish initializing GUI
        frame.pack()
        #frame.setLocationRelativeTo(None)
        frame.setVisible(True)
        
        #Perform ray-tracing
        if scene is not None:
            Thread(Painter(canvas, scene, openButton, saveButton)).start()
Exemplo n.º 33
0
    def __init__(self, repository):
        self.repository = repository
        # want a better solution, with domains, perhaps user specifies
        self.currentUserReference = System.getProperty("user.name")
        
        self.currentRecord = None
                
        self.window = JFrame("Pointrel browser", windowClosing=self.exit)
        self.window.contentPane.layout = BorderLayout() # redundant as the default
        self.window.bounds = (100, 100, 800, 600)
        
        self.menuBar = JMenuBar()
        self.window.JMenuBar = self.menuBar
        fileMenu = JMenu("File")
        fileMenu.add(JMenuItem("Open...", actionPerformed=self.open))
        fileMenu.add(JMenuItem("Reload", actionPerformed=self.reloadPressed))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Import from other repository...", actionPerformed=self.importFromOtherRepository))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Close", actionPerformed=self.close))
        self.menuBar.add(fileMenu)

        exportMenu = JMenu("Export")
        exportMenu.add(JMenuItem("Choose current export file...", actionPerformed=self.exportChooseCurrentFile))
        exportMenu.addSeparator()        
        exportMenu.add(JMenuItem("Export selected record", actionPerformed=self.exportSelectedRecord))
        exportMenu.add(JMenuItem("Export record history for selected attribute", actionPerformed=self.exportAllRecordsForSelectedAttribute))
        exportMenu.addSeparator()
        exportMenu.add(JMenuItem("Export current records for all attributes of selected entity", actionPerformed=self.exportLatestRecordsForSelectedEntity))
        exportMenu.add(JMenuItem("Export entire record history for all attributes of selected entity", actionPerformed=self.exportAllRecordsForSelectedEntity))
        self.menuBar.add(exportMenu)
        
        self.exportFileName = "export.pointrel"

        #self.reloadButton = JButton("Reload Repository", actionPerformed=self.reloadPressed)
                        
        self.entitiesList = JList(DefaultListModel(), mouseClicked=self.entitiesListClicked)
        self.entitiesList.model.addElement("root")
        self.entitiesList.mousePressed = self.entitiesListMousePressed
        self.entitiesList.mouseReleased = self.entitiesListMousePressed
        
        self.attributesList = JList(DefaultListModel(), mouseClicked=self.attributesListClicked)
        
        self.versionsList = JList(DefaultListModel(), mouseClicked=self.versionsListClicked)
        
        self.listPanel = JPanel(layout=GridLayout(1, 2))
        self.listPanel.add(JScrollPane(self.entitiesList))
        self.listPanel.add(JScrollPane(self.attributesList))
        self.listPanel.add(JScrollPane(self.versionsList))
        
        self.navigationPanel = JPanel(layout=BorderLayout())
        #self.navigationPanel.add(self.reloadButton, BorderLayout.NORTH)
        self.navigationPanel.add(self.listPanel, BorderLayout.CENTER)
                
        self.entityTextField = JTextField(preferredSize=(200,20))
        self.attributeTextField = JTextField(preferredSize=(200,20))
        self.deletedButton = JCheckBox("Deleted", actionPerformed=self.deletedPressed)
        
        # only one right now -- and no support for switching editor panels yet
        examples = ["pointrel:text/utf-8", ]
        self.valueTypeComboBox = JComboBox(examples, preferredSize=(200,20), editable=True)

        self.attributePanel = Box(BoxLayout.X_AXIS) 
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Entity:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.entityTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Attribute:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.attributeTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Value type:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.valueTypeComboBox)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(self.deletedButton)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        
        self.showAllDeletedButton = JCheckBox("Show all deleted", actionPerformed=self.showAllDeletedPressed)
        self.statusText = JTextField(preferredSize=(100,20))
        self.saveButton = JButton("Save", actionPerformed=self.savePressed)
        self.normalSaveButtonColor = self.saveButton.background
        self.changedSaveButtonColor = Color.YELLOW

        self.statusPanel = Box(BoxLayout.X_AXIS)
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.showAllDeletedButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(25,0)))
        self.statusPanel.add(JLabel("Message:") )
        self.statusPanel.add(Box.createRigidArea(Dimension(2,0)))
        self.statusPanel.add(self.statusText) 
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.saveButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(1,0)))       
        
        self.currentEditorPanel = EditorPanel_text_utf_8(self, "pointrel:text/utf-8")
        
        self.topPanel = Box(BoxLayout.Y_AXIS)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        self.topPanel.add(self.attributePanel)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        
        self.editorPanel = JPanel(layout=BorderLayout())
        self.editorPanel.add(self.topPanel, BorderLayout.NORTH)
        self.editorPanel.add(self.currentEditorPanel, BorderLayout.CENTER)
        self.editorPanel.add(self.statusPanel, BorderLayout.SOUTH)
        
        self.browserPanel = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.browserPanel.add(self.navigationPanel)
        self.browserPanel.add(self.editorPanel)
        
        self.window.contentPane.add(self.browserPanel, BorderLayout.CENTER)
        
        self.setTitleForRepository()
        self.window.show()
        
        # background timer for updating save button color
        self.timer = Timer(1000, CallbackActionListener(self.timerEvent))
        self.timer.initialDelay = 1000
        self.timer.start()
Exemplo n.º 34
0
    def initUI(self):
        menubar = JMenuBar()

        start = JMenu("Start")
        start.setMnemonic(KeyEvent.VK_S)

        apps = JMenu("Applications")
        apps.setPreferredSize(Dimension(200, 35))
        apps.setToolTipText("Stylus Applications")
        web = JMenuItem("Internet", actionPerformed=self.internet)
        web.setPreferredSize(Dimension(200, 35))
        web.setToolTipText("Stylus Web Browser")
        apps.add(web)
        image = JMenuItem("Image Viewer", actionPerformed=self.photos)
        image.setPreferredSize(Dimension(200, 35))
        image.setToolTipText("Stylus Image Viewer")
        apps.add(image)
        start.add(apps)

        utility = JMenu("Utility")
        utility.setPreferredSize(Dimension(200, 35))
        utility.setToolTipText("Stylus Utility")
        voice = JMenuItem("Anna", actionPerformed=self.vocal)
        voice.setPreferredSize(Dimension(200, 35))
        voice.setToolTipText("Anna Vocal Assistant")
        utility.add(voice)
        clc = JMenuItem("Calculator", actionPerformed=self.calc)
        clc.setPreferredSize(Dimension(200, 35))
        clc.setToolTipText("Stylus Calculator")
        utility.add(clc)
        fman = JMenuItem("File Manager", actionPerformed=self.file_manager)
        fman.setPreferredSize(Dimension(200, 35))
        fman.setToolTipText("Stylus File Manager")
        utility.add(fman)
        txted = JMenuItem("Notepad", actionPerformed=self.notepad)
        txted.setPreferredSize(Dimension(200, 35))
        txted.setToolTipText("Stylus Notepad")
        utility.add(txted)
        terminal = JMenuItem("Terminal (as root)",
                             actionPerformed=self.lxterminal)
        terminal.setPreferredSize(Dimension(200, 35))
        terminal.setToolTipText("Stylus Terminal")
        utility.add(terminal)
        start.add(utility)

        games = JMenu("Games")
        games.setPreferredSize(Dimension(200, 35))
        games.setToolTipText("PyOS Games")
        g1 = JMenuItem("2048", actionPerformed=self.d2048)
        g1.setPreferredSize(Dimension(200, 35))
        g1.setToolTipText("Play 2048 Game")
        games.add(g1)

        g2 = JMenuItem("Ping Pong", actionPerformed=self.ppong)
        g2.setPreferredSize(Dimension(200, 35))
        g2.setToolTipText("Play Ping Pong Game")
        games.add(g2)

        start.add(games)

        start.addSeparator()

        exit = JMenuItem("Exit", actionPerformed=self.onExit)
        exit.setPreferredSize(Dimension(200, 35))
        exit.setToolTipText("Stylus Exit")
        start.add(exit)

        menubar.add(start)

        file = JMenu("File")
        file.setMnemonic(KeyEvent.VK_F)

        tk = Toolkit.getDefaultToolkit()
        xSize = (int(tk.getScreenSize().getWidth()))
        ySize = (int(tk.getScreenSize().getHeight()))

        self.setSize(xSize, ySize)

        filebg = open("/icons/background.txt", "r")
        path = filebg.readline()

        filebg.close()

        panel2 = bg.background(path, self.getWidth(), self.getHeight() - 100)

        theme = JMenuItem("Change background",
                          actionPerformed=lambda e: self.bg(panel2, e))
        theme.setPreferredSize(Dimension(200, 35))
        theme.setToolTipText("Stylus Background")

        file.add(theme)

        menubar.add(file)

        info = JMenu("?")
        info.setMnemonic(KeyEvent.VK_I)

        inf = JMenuItem("Info", actionPerformed=self.onInfo)
        inf.setToolTipText("Stylus Information")

        info.add(inf)

        menubar.add(info)

        menubar.add(Box.createHorizontalGlue())

        timedate = JMenu(time.strftime("%a, %Y %b %d, %H:%M"))
        timedate.setMnemonic(KeyEvent.VK_C)
        calendar = JMenuItem("Calendar", actionPerformed=self.calendar)
        calendar.setPreferredSize(Dimension(200, 35))
        timedate.add(calendar)

        menubar.add(timedate)
        menubar.add(JLabel("  "))

        menubar.setPreferredSize(Dimension(200, 35))

        self.setJMenuBar(menubar)

        self.setTitle("Stylus OS")
        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        #self.setSize(1360, 768)
        self.setLocationRelativeTo(None)
        """time = JPanel()
        time.setBorder(BorderFactory.createEtchedBorder())
        time.setBackground(Color(153, 203, 255))
        time.setLayout(GridLayout(0, 1))
        
        f = Font("", Font.PLAIN, 60)
        t = JLabel("11:51")
        t.setHorizontalAlignment(JLabel.CENTER)
        t.setFont(f)
        time.add(t)
        
        f2 = Font("", Font.PLAIN, 50)
        d = JLabel("Tuesday, 2016/07/12")
        d.setHorizontalAlignment(JLabel.CENTER)
        d.setFont(f2)
        time.add(d)
        
        self.getContentPane().add(time)
        self.add(time, BorderLayout.NORTH)"""

        panel = JPanel()
        self.getContentPane().add(panel)

        b0 = JButton(ImageIcon("/icons/file-manager.png"),
                     actionPerformed=self.file_manager)
        b0.setToolTipText("File Manager")
        panel.add(b0)
        b1 = JButton(ImageIcon("/icons/internet.png"),
                     actionPerformed=self.internet)
        b1.setToolTipText("Internet")
        panel.add(b1)
        b2 = JButton(ImageIcon("/icons/mail.png"))
        b2.setToolTipText("Mail")
        #panel.add(b2)
        b3 = JButton(ImageIcon("/icons/music.png"))
        b3.setToolTipText("Music")
        #panel.add(b3)
        b4 = JButton(ImageIcon("/icons/video.png"))
        b4.setToolTipText("Video")
        #panel.add(b4)
        b5 = JButton(ImageIcon("/icons/photos.png"),
                     actionPerformed=self.photos)
        b5.setToolTipText("Photos")
        panel.add(b5)
        b6 = JButton(ImageIcon("/icons/calculator.png"),
                     actionPerformed=self.calc)
        b6.setToolTipText("Calculator")
        panel.add(b6)
        b7 = JButton(ImageIcon("/icons/notepad.png"),
                     actionPerformed=self.notepad)
        b7.setToolTipText("Notepad")
        panel.add(b7)
        b8 = JButton(ImageIcon("/icons/settings.png"))
        b8.setToolTipText("Settings")
        #panel.add(b8)
        b9 = JButton(ImageIcon("/icons/trash.png"))
        b9.setToolTipText("Trash")
        #panel.add(b9)

        #panel.setBackground(Color(153, 203, 255))

        self.add(panel, BorderLayout.SOUTH)

        self.getContentPane().add(panel2)

        #panel2.setBorder(BorderFactory.createEtchedBorder())
        #panel2.setLayout(GridLayout(0, 1))
        #panel.setLayout(None)
        #panel2.setBackground(Color(153, 203, 255))

        #panel2.add(JLabel(ImageIcon("logo.png")))

        #panel2.add(JButton("Icon 0"))
        #panel2.add(JButton("Icon 1"))
        #panel2.add(JButton("Icon 2"))
        #panel2.add(JButton("Icon 3"))
        #panel2.add(JButton("Icon 4"))
        #panel2.add(JButton("Icon 5"))
        #panel2.add(JButton("Icon 6"))
        #panel2.add(JButton("Icon 7"))
        #panel2.add(JButton("Icon 8"))
        #panel2.add(JButton("Icon 9"))

        self.add(panel2)

        self.setExtendedState(JFrame.MAXIMIZED_BOTH)
        self.setUndecorated(True)
        self.setVisible(True)
Exemplo n.º 35
0
   if e.getSource() == exitItem:
      dispose()
   if e.getSource() == aboutItem:
      msgDlg("Pyramides Version 1.0")

def doIt():
   clear()
   for i in range(1, 30):
      setColor(getRandomX11Color())
      fillRectangle(i/2, i - 0.35, 30 - i/2, i + 0.35)

fileMenu = JMenu("File")
goItem = JMenuItem("Go", actionPerformed = actionCallback)
exitItem = JMenuItem("Exit", actionPerformed = actionCallback)
fileMenu.add(goItem)
fileMenu.add(exitItem)

aboutItem = JMenuItem("About", actionPerformed = actionCallback)

menuBar = JMenuBar()
menuBar.add(fileMenu)
menuBar.add(aboutItem)

makeGPanel(menuBar, 0, 30, 0, 30)

while not isDisposed():
   putSleep()
   if not isDisposed():
      doIt()

Exemplo n.º 36
0
    def make_menubar(self):
        shortcut = Toolkit.getDefaultToolkit().menuShortcutKeyMask
        menubar = JMenuBar()

        def new_item(title, cmd, key, mod=shortcut):
            item = JMenuItem(title, actionCommand=cmd)
            item.accelerator = KeyStroke.getKeyStroke(key, mod)
            item.addActionListener(self)
            return item
        filemenu = JMenu("File")
        menubar.add(filemenu)

        fm = self.file_manager = FileManager(self)
        
        item = new_item("Run Python File...", "load", KeyEvent.VK_L)
        filemenu.add(item)

        item = new_item("Run Python File", "reload", KeyEvent.VK_R)
        item.enabled = False
        self.reload_menuitem = item
        filemenu.add(item)

        filemenu.addSeparator()
        
        item = new_item("Open Python Script...", "open", KeyEvent.VK_O)
        filemenu.add(item)

        item = new_item("Save Python Script", "save", KeyEvent.VK_S)
        item.enabled = False
        self.save_menuitem = item
        filemenu.add(item)

        item = new_item("Save Python Script As...", "save_as", KeyEvent.VK_S,
                        mod = shortcut + ActionEvent.SHIFT_MASK)
        filemenu.add(item)

        editmenu = JMenu("Edit")
        menubar.add(editmenu)

        editmenu.add(new_item("Cut", "cut", KeyEvent.VK_X))
        editmenu.add(new_item("Copy", "copy", KeyEvent.VK_C))
        editmenu.add(new_item("Paste", "paste", KeyEvent.VK_V))

        editmenu.addSeparator()

        item = new_item("Run Script", "runscript", KeyEvent.VK_E)
        editmenu.add(item)
        
        item = new_item("Run Selection", "runselection", KeyEvent.VK_E,
                        mod=shortcut | ActionEvent.SHIFT_MASK)
        editmenu.add(item)

        editmenu.addSeparator()
        
        item = new_item("Indent Selection", "indentselection",
                        KeyEvent.VK_CLOSE_BRACKET)
        editmenu.add(item)
        
        item = new_item("Dedent Selection", "dedentselection",
                        KeyEvent.VK_OPEN_BRACKET)
        editmenu.add(item)
        
        shellmenu = JMenu("Interactive")
        menubar.add(shellmenu)
        
        item = new_item("Previous Input", "up", KeyEvent.VK_UP,
            mod=ActionEvent.ALT_MASK)
        shellmenu.add(item)
        
        item = new_item("Next Input", "down", KeyEvent.VK_DOWN,
                         mod=ActionEvent.ALT_MASK)
        shellmenu.add(item)


        self.frame.setJMenuBar(menubar)
def adminLogined(instObj):
    global panel
    global table
    global heading
    global btnUpdate
    global frame

    frame = JFrame("Admin Page ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(700, 640)
    frame.setLocation(200, 200)
    frame.setLayout(None)

    panel = JPanel()
    panel.setSize(700, 620)
    panel.setLocation(0, 20)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.WHITE)

    heading = JLabel()
    heading.setBounds(310, 10, 200, 30)

    table = JTable()
    table.setBounds(0, 50, 700, 450)
    sp = JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                     ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS)

    btnUpdate = JButton("Update", actionPerformed=clickUpdate)
    btnUpdate.setBounds(300, 530, 100, 30)

    bar = JMenuBar()
    courses = JMenu("Course")
    addCourse = JMenuItem("Add Course", actionPerformed=clickAddCourse)
    showCourseList = JMenuItem("Show Course List",
                               actionPerformed=clickShowCourseList)
    courses.add(addCourse)
    courses.add(showCourseList)
    bar.add(courses)

    teacher = JMenu("Teacher")
    addTeacher = JMenuItem("Add Teacher", actionPerformed=clickAddTeacher)
    showTeacherList = JMenuItem("Show Teacher List",
                                actionPerformed=clickShowTeacherList)
    showTeacherIdPassword = JMenuItem(
        "Show Teacher Id Password", actionPerformed=clickShowTeacherIdPassword)
    teacher.add(addTeacher)
    teacher.add(showTeacherList)
    teacher.add(showTeacherIdPassword)
    bar.add(teacher)

    student = JMenu("Student")
    addStudent = JMenuItem("Add Student", actionPerformed=clickAddStudent)
    showAllStudentList = JMenuItem("Show All Student",
                                   actionPerformed=clickShowAllStudent)
    showStudentsByCourse = JMenuItem("Show Student By course",
                                     actionPerformed=clickShowStudentByCourse)
    showStudentsByTeacher = JMenuItem(
        "Show Student By Teacher", actionPerformed=clickShowStudentByTeacher)
    showStudentIdPassword = JMenuItem(
        "Show Student Id Password", actionPerformed=clickShowStudentIdPassword)
    student.add(addStudent)
    student.add(showAllStudentList)
    student.add(showStudentsByCourse)
    student.add(showStudentsByTeacher)
    student.add(showStudentIdPassword)
    bar.add(student)

    attendence = JMenu(" Teacher Attendence")
    teacherAttendence = JMenuItem(" Take Teacher Attendence",
                                  actionPerformed=clickTotalAttendence)
    specificTeacherAttendence = JMenuItem(
        "Show Specific Teacher Attendence",
        actionPerformed=clickShowSpecificTeacherAttendence)
    allTeacherAttendenceMonth = JMenuItem(
        "All Teacher Attendence In Month",
        actionPerformed=clickShowAllSTeacherAttendenceMonth)
    specificTeacherAttendenceInMonth = JMenuItem(
        "Specific Teacher Attendence In Month",
        actionPerformed=clickShowSpecificSTeacherAttendenceMonth)
    allTeacherAttendenceStatisticsInMonth = JMenuItem(
        "All Teacher Attendence Statistics In Month",
        actionPerformed=clickShowAllTeacherAttendenceStatisticsMonth)
    attendence.add(teacherAttendence)
    attendence.add(specificTeacherAttendence)
    attendence.add(allTeacherAttendenceMonth)
    attendence.add(specificTeacherAttendenceInMonth)
    attendence.add(allTeacherAttendenceStatisticsInMonth)
    bar.add(attendence)

    studentAttendence = JMenu(" Student Attendence")
    specificTeacherStudentsAttendence = JMenuItem(
        "Show Specific Teacher Students Attendence",
        actionPerformed=clickShowSpecificTeacherStudentsAttendence)
    specificCourseStudentsAttendence = JMenuItem(
        "Show Specific course Students Attendence",
        actionPerformed=clickShowSpecificCourseStudentsAttendence)
    specificTeacherStudentsAttendenceInMonth = JMenuItem(
        "Show Specific teacher Students Attendence In month",
        actionPerformed=clickShowSpecificTeacherStudentsAttendenceInMonth)
    specificCourseStudentsAttendenceInMonth = JMenuItem(
        "Show Specific course Students Attendence In month",
        actionPerformed=clickShowSpecificCourseStudentsAttendenceInMonth)
    allStudentsAttendenceStatisticsInMonth = JMenuItem(
        "All Students Attendence Statistics In month",
        actionPerformed=clickShowAllStudentsAttendenceStatisticsInMonth)
    specificTeacherStudentsAttendenceStatisticsInMonth = JMenuItem(
        "Specific Teacher Students Attendence Statistics In month",
        actionPerformed=
        clickShowSpecificTeacherStudentsAttendenceStatisticsInMonth)
    specificCourseStudentsAttendenceStatisticsInMonth = JMenuItem(
        "Specific Course Students Attendence Statistics In month",
        actionPerformed=
        clickShowSpecificCourseStudentsAttendenceStatisticsInMonth)
    specificStudentAttendenceInMonth = JMenuItem(
        "Specific  Student Attendence In month",
        actionPerformed=clickShowSpecificStudentAttendenceInMonth)
    studentAttendence.add(specificTeacherStudentsAttendence)
    studentAttendence.add(specificCourseStudentsAttendence)
    studentAttendence.add(specificTeacherStudentsAttendenceInMonth)
    studentAttendence.add(specificCourseStudentsAttendenceInMonth)
    studentAttendence.add(allStudentsAttendenceStatisticsInMonth)
    studentAttendence.add(specificTeacherStudentsAttendenceStatisticsInMonth)
    studentAttendence.add(specificCourseStudentsAttendenceStatisticsInMonth)
    studentAttendence.add(specificStudentAttendenceInMonth)
    bar.add(studentAttendence)

    studentFee = JMenu("Student Fee ")
    payStudentFee = JMenuItem("Pay", actionPerformed=clickPayStudentFee)
    showStudentFeeListByCourse = JMenuItem(
        "Student Fee list By Course",
        actionPerformed=clickShowStudentFeeListByCourse)
    studentFee.add(payStudentFee)
    studentFee.add(showStudentFeeListByCourse)
    bar.add(studentFee)

    logout = JMenuItem("logout", actionPerformed=clickLogout)
    bar.add(logout)

    btnUpdate.setVisible(False)
    panel.add(table)
    panel.add(btnUpdate)

    frame.setJMenuBar(bar)
    frame.add(panel)

    frame.setVisible(True)
Exemplo n.º 38
0
def run(scene, w=512, h=512, aa=1, threads=1):
    '''Create GUI and perform ray-tracing.'''
    #Make Swing not look like garbage (so much)
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
    #Setup frame
    frame = JFrame("RayTracer",
                   defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
                   size=(w, h))
    frame.setIconImage(ImageIcon('resources/icon.png').getImage())
    canvas = RayTracePanel(w, h, aa, threads)
    frame.getContentPane().add(JScrollPane(canvas))

    #Save FileChooser
    fcS = JFileChooser()
    fcS.addChoosableFileFilter(
        FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp']))
    fcS.addChoosableFileFilter(
        FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg']))
    fcS.addChoosableFileFilter(
        FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png']))

    def saveFile(event):
        '''Performed when the save button is pressed'''
        result = fcS.showSaveDialog(frame)
        if result == JFileChooser.APPROVE_OPTION:
            file = fcS.getSelectedFile()
            fname = file.getPath()
            ext = fcS.getFileFilter().getExtensions()[0]
            if not fname.endswith('.' + ext):
                file = File(fname + '.' + ext)
            canvas.saveToFile(file, ext)

    #Open FileChooser
    fcO = JFileChooser()
    fcO.addChoosableFileFilter(
        FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts']))

    def openFile(event):
        '''Performed when the open button is pressed'''
        result = fcO.showOpenDialog(frame)
        if result == JFileChooser.APPROVE_OPTION:
            fname = fcO.getSelectedFile().getPath()
            if fname.endswith('.rts'):
                f = open(fname, 'rb')
                newScene = SceneFactory().buildScene(f)
                f.close()
                Painter(canvas, newScene, openButton, saveButton).start()

    def exit(event):
        '''Performed when the exit button is pressed'''
        import sys
        sys.exit(0)

    #Setup Menu
    menuBar = JMenuBar()
    menu = JMenu("File")
    menuBar.add(menu)
    openButton = JMenuItem("Open...", actionPerformed=openFile)
    openButton.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
    menu.add(openButton)
    saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
    saveButton.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
    menu.add(saveButton)
    menu.addSeparator()
    closeButton = JMenuItem('Close', actionPerformed=exit)
    closeButton.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
    menu.add(closeButton)
    frame.setJMenuBar(menuBar)

    #Finish initializing GUI
    frame.pack()
    #frame.setLocationRelativeTo(None)
    frame.setVisible(True)

    #Perform ray-tracing
    if scene is not None:
        Thread(Painter(canvas, scene, openButton, saveButton)).start()
Exemplo n.º 39
0
class main(JFrame):
    def __init__(self):
        super(main,self).__init__()
        self.Config()
        self.windows()
        self.ruta=""

    def windows(self):
        self.setTitle("IDE Meta Compilador")
        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        self.setLayout(None)
        self.setLocationRelativeTo(None)
        self.setVisible(True)



    def Config(self):
        self.panel = JScrollPane()
        self.txtArea_Principal =JTextArea()
        self.jScrollPane1 =JScrollPane()
        self.txtTerminal =JTextArea()
        self.Menu =JMenuBar()
        self.menu_Archivo =JMenu()
        self.menu_Nuevo =JMenuItem()
        self.menuabrir =JMenuItem()
        self.menucerrar =JMenuItem()
        self.menuguardar =JMenuItem()
        self.menuguardarcomo =JMenuItem()
        self.menusalir =JMenuItem()
        self.menu_Edicion =JMenu()
        self.menu_cortar =JMenuItem()
        self.menu_copiar =JMenuItem()
        self.menu_pegar =JMenuItem()
        self.menu_Tablas =JMenu()
        self.menu_TablasEstaticas =JMenu()
        self.submenu_palabrasReservadas =JMenuItem()
        self.submenu_CaracteresEspeciales =JMenuItem()
        self.submenu_operadores =JMenu()
        self.ta_di_conu_enteros =JMenuItem()
        self.ta_di_conu_reales =JMenuItem()
        self.ta_di_conu_cientificos =JMenuItem()
        self.menu_TablaasDinamicas =JMenu()
        self.submenu_simbolos =JMenuItem()
        self.submenu_identificadores =JMenuItem()
        self.submenu_errores =JMenuItem()
        self.submenu_constantesNumericas =JMenu()
        self.ta_es_op_aritmeticos =JMenuItem()
        self.ta_es_op_relacionales =JMenuItem()
        self.ta_es_op_logicos =JMenuItem()
        self.submenu_Constantes_No_Numericas =JMenu()
        self.tab_caracteres =JMenuItem()
        self.tab_cadenas =JMenuItem()
        self.menu_Analisis =JMenu()
        self.ana_lexico =JMenuItem()
        self.ana_sintactico =JMenuItem()
        self.ana_semantico =JMenuItem()
        self.menu_Acerca_de =JMenu()
        self.btn_integrantes =JMenuItem()
        #########################
        self.jf = JFileChooser()

        #########################


        self.txtArea_Principal.setColumns(20)
        self.txtArea_Principal.setRows(5)
        self.txtArea_Principal.setAutoscrolls(False)
        self.txtArea_Principal.setEnabled(False)
        self.panel.setViewportView(self.txtArea_Principal)
        self.getContentPane().add(self.panel)
        self.panel.setBounds(0, 0, 1080, 450)


        self.txtTerminal.setColumns(20)
        self.txtTerminal.setRows(5)
        self.txtTerminal.setAutoscrolls(False)
        self.txtTerminal.setFocusable(False)
        self.jScrollPane1.setViewportView(self.txtTerminal)

        self.getContentPane().add(self.jScrollPane1)
        self.jScrollPane1.setBounds(0, 460, 1080, 150)
        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ARCHIVOS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        self.menu_Archivo.setText("Archivo")
        
        self.menu_Nuevo.addActionListener(lambda event : self.nuevo(event))
        self.menu_Nuevo.setText("Nuevo")
        self.menu_Archivo.add(self.menu_Nuevo)

        self.menuabrir.setText("Abrir")
        self.menuabrir.addActionListener(lambda event : self.abrir(event))
        self.menu_Archivo.add(self.menuabrir)

        self.menucerrar.setText("Cerrar")
        self.menucerrar.addActionListener(lambda event : self.cerrar(event))
        self.menu_Archivo.add(self.menucerrar)

        self.menuguardar.setText("Guardar")
        self.menuguardar.addActionListener(lambda event : self.guardar(event))
        self.menu_Archivo.add(self.menuguardar)
        
        self.menuguardarcomo.setText("Guardar como")
        self.menuguardarcomo.addActionListener(lambda event : self.guardarcomo(event))
        self.menu_Archivo.add(self.menuguardarcomo)

        self.menusalir.setText("Salir")
        self.menusalir.addActionListener(lambda event : self.salir(event))
        self.menu_Archivo.add(self.menusalir)
        
        
        self.Menu.add(self.menu_Archivo)
        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU EDICION<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        self.menu_Edicion.setText("Edicion")

        self.menu_cortar.setText("Cortar")
        self.menu_cortar.addActionListener(lambda event : self.cortar(event))
        self.menu_Edicion.add(self.menu_cortar)

        self.menu_copiar.setText("Copiar")
        self.menu_copiar.addActionListener(lambda event : self.copiar(event))
        self.menu_Edicion.add(self.menu_copiar)

        self.menu_pegar.setText("Pegar")
        self.menu_pegar.addActionListener(lambda event : self.pegar(event))
        self.menu_Edicion.add(self.menu_pegar)

        self.Menu.add(self.menu_Edicion)
        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU TABLAS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        self.menu_Tablas.setText("Tablas")

        self.menu_TablasEstaticas.setText("Tablas Estaticas")

        self.submenu_palabrasReservadas.setText("Tabla de palabras reservadas")
        self.menu_TablasEstaticas.add(self.submenu_palabrasReservadas)

        self.submenu_CaracteresEspeciales.setText("Tabla de caracteres especiales")
        self.menu_TablasEstaticas.add(self.submenu_CaracteresEspeciales)

        self.submenu_operadores.setText("Tabla de operadores")

        self.ta_es_op_aritmeticos.setText("Aritmeticos")
        self.submenu_operadores.add(self.ta_es_op_aritmeticos)

        self.ta_es_op_relacionales.setText("Relacionales")
        self.submenu_operadores.add(self.ta_es_op_relacionales)

        self.ta_es_op_logicos.setText("Logicos")
        self.submenu_operadores.add(self.ta_es_op_logicos)

        self.menu_TablasEstaticas.add(self.submenu_operadores)

        self.menu_Tablas.add(self.menu_TablasEstaticas)

        self.menu_TablaasDinamicas.setText("Tablas Dinamicas")

        self.submenu_simbolos.setText("Tabla de simbolos")
        self.menu_TablaasDinamicas.add(self.submenu_simbolos)

        self.submenu_identificadores.setText("Tabla de identificadores")
        self.menu_TablaasDinamicas.add(self.submenu_identificadores)

        self.submenu_errores.setText("Tabla de errores")
        self.menu_TablaasDinamicas.add(self.submenu_errores)

        self.submenu_constantesNumericas.setText("Tabla de constantes numericas")

        self.ta_di_conu_enteros.setText("Enteros")
        self.ta_di_conu_enteros.addActionListener(lambda event : self.numeroenteros(event))        
        self.submenu_constantesNumericas.add(self.ta_di_conu_enteros)

        self.ta_di_conu_reales.setText("Reales")
        self.ta_di_conu_reales.addActionListener(lambda event : self.numeroreales(event))
        self.submenu_constantesNumericas.add(self.ta_di_conu_reales)

        self.ta_di_conu_cientificos.setText("Cientificos")
        self.submenu_constantesNumericas.add(self.ta_di_conu_cientificos)

        self.menu_TablaasDinamicas.add(self.submenu_constantesNumericas)

        self.submenu_Constantes_No_Numericas.setText("Tabla de constantes no numericas")

        self.tab_caracteres.setText("Caracteres")
        self.submenu_Constantes_No_Numericas.add(self.tab_caracteres)

        self.tab_cadenas.setText("Cadenas")
        self.submenu_Constantes_No_Numericas.add(self.tab_cadenas)

        self.menu_TablaasDinamicas.add(self.submenu_Constantes_No_Numericas)

        self.menu_Tablas.add(self.menu_TablaasDinamicas)

        self.Menu.add(self.menu_Tablas)

        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ANALISIS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        
        self.menu_Analisis.setText("Analisis")

        self.ana_lexico.setText("Lexico")
        self.ana_lexico.addActionListener(lambda event : self.lexico(event))
        self.menu_Analisis.add(self.ana_lexico)

        self.ana_sintactico.setText("Sintactico")
        self.ana_sintactico.addActionListener(lambda event : self.sintactico(event))        
        self.menu_Analisis.add(self.ana_sintactico)

        self.ana_semantico.setText("Semantico")
        self.menu_Analisis.add(self.ana_semantico)

        self.Menu.add(self.menu_Analisis)

        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ACERCA DE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        self.menu_Acerca_de.setText("Acerca de")

        self.btn_integrantes.setText("Integrante del proyecto")
        self.btn_integrantes.addActionListener(lambda event : self.integrantes(event))
        self.menu_Acerca_de.add(self.btn_integrantes)

        self.Menu.add(self.menu_Acerca_de)

        





        self.setJMenuBar(self.Menu)
        self.setBounds(0, 0, 1095, 670)
        
######################################    
    def integrantes(self,event):
        informacion()
    def cortar(self,event): 
        self.txtArea_Principal.cut()    
    def copiar(self,event): 
        self.txtArea_Principal.copy()
    def pegar(self,event): 
        self.txtArea_Principal.paste()
    def salir(self,event): 
        self.dispose()
######################################    



    def guardarcomo(self,event): pass
    def guardar(self,event):
        if self.ruta == "":
            self.txtTerminal.setText("no hay un directorio abierto")
        else:
            agregar(self.ruta,str(self.txtArea_Principal.getText()))

    def cerrar(self,event): 
        self.txtArea_Principal.setText("")
        self.txtArea_Principal.setEnabled(False)
        
        self.ruta=""
        

    
    def abrir(self,event):   
        self.jf.showOpenDialog(self)
        self.ruta = self.jf.getSelectedFile()    
        self.txtArea_Principal.setEnabled(True)
        self.txtArea_Principal.setText(abrir(self.ruta)) 




    def nuevo(self,event):
        if self.ruta == "":
            print("no pasa nada")
        else:
            print("hay un archivo existente")
            self.ruta =""
            
        self.txtArea_Principal.setEnabled(True)
        self.txtArea_Principal.setText("")
######################################    
    def lexico(self,event):
        self.txtTerminal.setText("")
        archivo = open("{}".format(self.ruta),"r")
        texto = ""
        for a in prueba(self.txtArea_Principal.getText()):
            texto += a+"\n"
        
        self.txtTerminal.setText(texto)


    def sintactico(self,event):
        self.txtTerminal.setText("")
        texto=""
        for a in prueba_sintactica(self.txtArea_Principal.getText()):
            texto +=a+"\n"

        self.txtTerminal.setText(texto)
Exemplo n.º 40
0
def createMenuBar(manager):
    global menuHandles, isDominant, isTemporal
    menuHandles = {}
    menuBar = JMenuBar()

    fmenu = JMenu("File")
    menuHandles['File'] = fmenu
    fmenu.setMnemonic(KeyEvent.VK_F)
    menuBar.add(fmenu)
    fmenu.add(createMenuItem('Open Genepop data', "Open", manager))
    fmenu.add(createMenuItem('Use Example data', "Example", manager))
    fmenu.addSeparator()
    fmenu.add(createMenuItem('Citation', "Citation", manager))
    fmenu.addSeparator()
    fmenu.add(createMenuItem("Exit", "Exit", manager))

    if not isTemporal:
        pmenu = JMenu("Populations")
        menuHandles['Populations'] = pmenu
        pmenu.setEnabled(False)
        pmenu.setMnemonic(KeyEvent.VK_P)
        menuBar.add(pmenu)
        pmenu.add(createMenuItem('Load population names', "LoadPop", manager))
        pmenu.add(createMenuItem('Edit population names', "EditPop", manager))
        pmenu.add(createMenuItem('Save population names', "SavePop", manager))

    umenu = JMenu("Data used")
    menuHandles['Data used'] = umenu
    umenu.setEnabled(False)
    umenu.setMnemonic(KeyEvent.VK_U)
    menuBar.add(umenu)
    umenu.add(createMenuItem('Loci Analyzed', "ChooseLoci", manager))
    if isTemporal:
        umenu.add(createMenuItem('Samples Analyzed', "ChoosePops", manager))
    else:
        umenu.add(createMenuItem('Populations Analyzed', "ChoosePops", manager))

    if isDominant:
        fdmenu = JMenu("DFDist")
    elif isTemporal:
        fdmenu = JMenu("FTemp")
    else:
        fdmenu = JMenu("FDist")
    menuHandles['FDist'] = fdmenu
    fdmenu.setEnabled(False)
    fdmenu.setMnemonic(KeyEvent.VK_D)
    menuBar.add(fdmenu)
    if isTemporal:
        fdmenu.add(createMenuItem('Run FTemp', "RunFDist", manager))
    else:
        fdmenu.add(createMenuItem('Run FDist', "RunFDist", manager))
    item5000 = createMenuItem('Run more 5000 sims', "Run5000", manager)
    item5000.setEnabled(False)
    menuHandles['item5000'] = item5000
    fdmenu.add(item5000)
    checkLoci = createMenuItem('Check Loci Status', "CheckLoci", manager)
    checkLoci.setEnabled(False)
    menuHandles['checkLoci'] = checkLoci
    fdmenu.add(checkLoci)

    gmenu = JMenu("Graphic")
    gmenu.setEnabled(False)
    menuHandles['Graphic'] = gmenu
    gmenu.setMnemonic(KeyEvent.VK_G)
    menuBar.add(gmenu)
    gmenu.add(createMenuItem('Colors and loci labels', "ConfGrp", manager))
    #gmenu.add(createMenuItem('Save Graphic as PNG', "SavePNG", manager))
    gmenu.add(createMenuItem('Save as PNG', "SavePNG", manager))
    gmenu.add(createMenuItem('Export as PDF', "SavePDF", manager))
    gmenu.add(createMenuItem('Export as SVG', "SaveSVG", manager))

    menuBar.add(Box.createHorizontalGlue())

    hmenu = JMenu("Help")
    hmenu.setMnemonic(KeyEvent.VK_H)
    menuBar.add(hmenu)
    hmenu.add(createMenuItem('Help', "Help", manager))

    return menuBar
Exemplo n.º 41
0
def makeEditorFrame(ldPath, compiler):
    mb = JMenuBar()
    
    file = JMenu("File")
    edit = JMenu("Edit")
    run = JMenu("Run")
    
    newMenu = menu_with_accelerator("New",(KeyEvent.VK_N,ActionEvent.META_MASK))
    file.add(newMenu)
           
    open = menu_with_accelerator("Open",(KeyEvent.VK_O,ActionEvent.META_MASK))
    file.add(open)
    
    save = menu_with_accelerator("Save",(KeyEvent.VK_S,ActionEvent.META_MASK))
    file.add(save)
    
    file.add(JSeparator());
    
    resetPipe = menu_with_accelerator("Reset Pipeline",(KeyEvent.VK_N,ActionEvent.META_MASK | ActionEvent.SHIFT_MASK))
    file.add(resetPipe)
            
    openPipe = menu_with_accelerator("Open Pipeline",(KeyEvent.VK_O,ActionEvent.META_MASK | ActionEvent.SHIFT_MASK))
    file.add(openPipe)
            
    compile = menu_with_accelerator("Compile",(KeyEvent.VK_ENTER, ActionEvent.META_MASK))
    run.add(compile)
            
    mb.add(file)
    mb.add(edit)
    mb.add(run)
            
    f = JFrame("SFGP Shader Editor")
    f.setJMenuBar(mb)
    c = f.getContentPane()
    c.setLayout(BorderLayout())
    editor = GLSLEditorPane("",ldPath,compiler)
    c.add(editor, BorderLayout.CENTER)
    c.doLayout()
    
    f.setSize(1000, 700);
    f.setVisible(True);
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            
    class EditorActionListener(ActionListener):
        def makeRelay(srcObj):
            return (lambda e: editor.actionPerformed(ActionEvent(srcObj, e.getID(), e.getActionCommand())))
        editorActions = {
            save : (lambda e: editor.saveCurrent()),
            compile : (lambda e: editor.compileCurrent()),
            open : makeRelay(editor.openShader),
            newMenu : makeRelay(editor.newShader),
            openPipe : makeRelay(editor.openPipeline),
            resetPipe : makeRelay(editor.resetPipeline)
                        }
        def actionPerformed(self, e):
            editorActions = EditorActionListener.editorActions
            evtSrc = e.getSource()
            if evtSrc in editorActions:
                editorActions[evtSrc](e)
            else:
                raise IllegalStateException("Imaginary menu item registered an ActionEvent: " + evtSrc)
    menuListener = EditorActionListener()
    compile.addActionListener(menuListener);
    newMenu.addActionListener(menuListener);
    open.addActionListener(menuListener);
    save.addActionListener(menuListener);
    resetPipe.addActionListener(menuListener);
    openPipe.addActionListener(menuListener);
Exemplo n.º 42
0
def run(scene, w=512, h=512, aa=1, threads=1):
    """Create GUI and perform ray-tracing."""
    # Make Swing not look like garbage (so much)
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
    # Setup frame
    frame = JFrame("RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h))
    frame.setIconImage(ImageIcon("resources/icon.png").getImage())
    canvas = RayTracePanel(w, h, aa, threads)
    frame.getContentPane().add(JScrollPane(canvas))

    # Save FileChooser
    fcS = JFileChooser()
    fcS.addChoosableFileFilter(FileNameExtensionFilter("Windows Bitmap (*.bmp)", ["bmp"]))
    fcS.addChoosableFileFilter(FileNameExtensionFilter("JPEG / JFIF (*.jpg)", ["jpg"]))
    fcS.addChoosableFileFilter(FileNameExtensionFilter("Portable Network Graphics (*.png)", ["png"]))

    def saveFile(event):
        """Performed when the save button is pressed"""
        result = fcS.showSaveDialog(frame)
        if result == JFileChooser.APPROVE_OPTION:
            file = fcS.getSelectedFile()
            fname = file.getPath()
            ext = fcS.getFileFilter().getExtensions()[0]
            if not fname.endswith("." + ext):
                file = File(fname + "." + ext)
            canvas.saveToFile(file, ext)

    # Open FileChooser
    fcO = JFileChooser()
    fcO.addChoosableFileFilter(FileNameExtensionFilter("RayTrace Scene File (*.rts)", ["rts"]))

    def openFile(event):
        """Performed when the open button is pressed"""
        result = fcO.showOpenDialog(frame)
        if result == JFileChooser.APPROVE_OPTION:
            fname = fcO.getSelectedFile().getPath()
            if fname.endswith(".rts"):
                f = open(fname, "rb")
                newScene = SceneFactory().buildScene(f)
                f.close()
                Painter(canvas, newScene, openButton, saveButton, stopButton).start()

    def exit(event):
        """Performed when the exit button is pressed"""
        import sys

        sys.exit(0)

    def stop(event):
        """Peformed when the stop button is pressed"""
        canvas.stopRendering()

    # Setup Menu
    menuBar = JMenuBar()
    menu = JMenu("File")
    menuBar.add(menu)
    openButton = JMenuItem("Open...", actionPerformed=openFile)
    openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
    menu.add(openButton)
    saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
    saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
    menu.add(saveButton)
    menu.addSeparator()
    stopButton = JMenuItem("Stop Render", actionPerformed=stop)
    stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0))
    stopButton.setEnabled(False)
    menu.add(stopButton)
    menu.addSeparator()
    closeButton = JMenuItem("Close", actionPerformed=exit)
    closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
    menu.add(closeButton)
    frame.setJMenuBar(menuBar)

    # Finish initializing GUI
    self.pack()
Exemplo n.º 43
0
    def Config(self):
        self.panel = JScrollPane()
        self.txtArea_Principal =JTextArea()
        self.jScrollPane1 =JScrollPane()
        self.txtTerminal =JTextArea()
        self.Menu =JMenuBar()
        self.menu_Archivo =JMenu()
        self.menu_Nuevo =JMenuItem()
        self.menuabrir =JMenuItem()
        self.menucerrar =JMenuItem()
        self.menuguardar =JMenuItem()
        self.menuguardarcomo =JMenuItem()
        self.menusalir =JMenuItem()
        self.menu_Edicion =JMenu()
        self.menu_cortar =JMenuItem()
        self.menu_copiar =JMenuItem()
        self.menu_pegar =JMenuItem()
        self.menu_Tablas =JMenu()
        self.menu_TablasEstaticas =JMenu()
        self.submenu_palabrasReservadas =JMenuItem()
        self.submenu_CaracteresEspeciales =JMenuItem()
        self.submenu_operadores =JMenu()
        self.ta_di_conu_enteros =JMenuItem()
        self.ta_di_conu_reales =JMenuItem()
        self.ta_di_conu_cientificos =JMenuItem()
        self.menu_TablaasDinamicas =JMenu()
        self.submenu_simbolos =JMenuItem()
        self.submenu_identificadores =JMenuItem()
        self.submenu_errores =JMenuItem()
        self.submenu_constantesNumericas =JMenu()
        self.ta_es_op_aritmeticos =JMenuItem()
        self.ta_es_op_relacionales =JMenuItem()
        self.ta_es_op_logicos =JMenuItem()
        self.submenu_Constantes_No_Numericas =JMenu()
        self.tab_caracteres =JMenuItem()
        self.tab_cadenas =JMenuItem()
        self.menu_Analisis =JMenu()
        self.ana_lexico =JMenuItem()
        self.ana_sintactico =JMenuItem()
        self.ana_semantico =JMenuItem()
        self.menu_Acerca_de =JMenu()
        self.btn_integrantes =JMenuItem()
        #########################
        self.jf = JFileChooser()

        #########################


        self.txtArea_Principal.setColumns(20)
        self.txtArea_Principal.setRows(5)
        self.txtArea_Principal.setAutoscrolls(False)
        self.txtArea_Principal.setEnabled(False)
        self.panel.setViewportView(self.txtArea_Principal)
        self.getContentPane().add(self.panel)
        self.panel.setBounds(0, 0, 1080, 450)


        self.txtTerminal.setColumns(20)
        self.txtTerminal.setRows(5)
        self.txtTerminal.setAutoscrolls(False)
        self.txtTerminal.setFocusable(False)
        self.jScrollPane1.setViewportView(self.txtTerminal)

        self.getContentPane().add(self.jScrollPane1)
        self.jScrollPane1.setBounds(0, 460, 1080, 150)
        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ARCHIVOS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        self.menu_Archivo.setText("Archivo")
        
        self.menu_Nuevo.addActionListener(lambda event : self.nuevo(event))
        self.menu_Nuevo.setText("Nuevo")
        self.menu_Archivo.add(self.menu_Nuevo)

        self.menuabrir.setText("Abrir")
        self.menuabrir.addActionListener(lambda event : self.abrir(event))
        self.menu_Archivo.add(self.menuabrir)

        self.menucerrar.setText("Cerrar")
        self.menucerrar.addActionListener(lambda event : self.cerrar(event))
        self.menu_Archivo.add(self.menucerrar)

        self.menuguardar.setText("Guardar")
        self.menuguardar.addActionListener(lambda event : self.guardar(event))
        self.menu_Archivo.add(self.menuguardar)
        
        self.menuguardarcomo.setText("Guardar como")
        self.menuguardarcomo.addActionListener(lambda event : self.guardarcomo(event))
        self.menu_Archivo.add(self.menuguardarcomo)

        self.menusalir.setText("Salir")
        self.menusalir.addActionListener(lambda event : self.salir(event))
        self.menu_Archivo.add(self.menusalir)
        
        
        self.Menu.add(self.menu_Archivo)
        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU EDICION<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        self.menu_Edicion.setText("Edicion")

        self.menu_cortar.setText("Cortar")
        self.menu_cortar.addActionListener(lambda event : self.cortar(event))
        self.menu_Edicion.add(self.menu_cortar)

        self.menu_copiar.setText("Copiar")
        self.menu_copiar.addActionListener(lambda event : self.copiar(event))
        self.menu_Edicion.add(self.menu_copiar)

        self.menu_pegar.setText("Pegar")
        self.menu_pegar.addActionListener(lambda event : self.pegar(event))
        self.menu_Edicion.add(self.menu_pegar)

        self.Menu.add(self.menu_Edicion)
        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU TABLAS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        self.menu_Tablas.setText("Tablas")

        self.menu_TablasEstaticas.setText("Tablas Estaticas")

        self.submenu_palabrasReservadas.setText("Tabla de palabras reservadas")
        self.menu_TablasEstaticas.add(self.submenu_palabrasReservadas)

        self.submenu_CaracteresEspeciales.setText("Tabla de caracteres especiales")
        self.menu_TablasEstaticas.add(self.submenu_CaracteresEspeciales)

        self.submenu_operadores.setText("Tabla de operadores")

        self.ta_es_op_aritmeticos.setText("Aritmeticos")
        self.submenu_operadores.add(self.ta_es_op_aritmeticos)

        self.ta_es_op_relacionales.setText("Relacionales")
        self.submenu_operadores.add(self.ta_es_op_relacionales)

        self.ta_es_op_logicos.setText("Logicos")
        self.submenu_operadores.add(self.ta_es_op_logicos)

        self.menu_TablasEstaticas.add(self.submenu_operadores)

        self.menu_Tablas.add(self.menu_TablasEstaticas)

        self.menu_TablaasDinamicas.setText("Tablas Dinamicas")

        self.submenu_simbolos.setText("Tabla de simbolos")
        self.menu_TablaasDinamicas.add(self.submenu_simbolos)

        self.submenu_identificadores.setText("Tabla de identificadores")
        self.menu_TablaasDinamicas.add(self.submenu_identificadores)

        self.submenu_errores.setText("Tabla de errores")
        self.menu_TablaasDinamicas.add(self.submenu_errores)

        self.submenu_constantesNumericas.setText("Tabla de constantes numericas")

        self.ta_di_conu_enteros.setText("Enteros")
        self.ta_di_conu_enteros.addActionListener(lambda event : self.numeroenteros(event))        
        self.submenu_constantesNumericas.add(self.ta_di_conu_enteros)

        self.ta_di_conu_reales.setText("Reales")
        self.ta_di_conu_reales.addActionListener(lambda event : self.numeroreales(event))
        self.submenu_constantesNumericas.add(self.ta_di_conu_reales)

        self.ta_di_conu_cientificos.setText("Cientificos")
        self.submenu_constantesNumericas.add(self.ta_di_conu_cientificos)

        self.menu_TablaasDinamicas.add(self.submenu_constantesNumericas)

        self.submenu_Constantes_No_Numericas.setText("Tabla de constantes no numericas")

        self.tab_caracteres.setText("Caracteres")
        self.submenu_Constantes_No_Numericas.add(self.tab_caracteres)

        self.tab_cadenas.setText("Cadenas")
        self.submenu_Constantes_No_Numericas.add(self.tab_cadenas)

        self.menu_TablaasDinamicas.add(self.submenu_Constantes_No_Numericas)

        self.menu_Tablas.add(self.menu_TablaasDinamicas)

        self.Menu.add(self.menu_Tablas)

        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ANALISIS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        
        self.menu_Analisis.setText("Analisis")

        self.ana_lexico.setText("Lexico")
        self.ana_lexico.addActionListener(lambda event : self.lexico(event))
        self.menu_Analisis.add(self.ana_lexico)

        self.ana_sintactico.setText("Sintactico")
        self.ana_sintactico.addActionListener(lambda event : self.sintactico(event))        
        self.menu_Analisis.add(self.ana_sintactico)

        self.ana_semantico.setText("Semantico")
        self.menu_Analisis.add(self.ana_semantico)

        self.Menu.add(self.menu_Analisis)

        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ACERCA DE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        self.menu_Acerca_de.setText("Acerca de")

        self.btn_integrantes.setText("Integrante del proyecto")
        self.btn_integrantes.addActionListener(lambda event : self.integrantes(event))
        self.menu_Acerca_de.add(self.btn_integrantes)

        self.Menu.add(self.menu_Acerca_de)

        





        self.setJMenuBar(self.Menu)
        self.setBounds(0, 0, 1095, 670)
Exemplo n.º 44
0
	def __init__(self, windowManager, commandConsoleFactory, subject, windowTitle):
		self._windowManager = windowManager





		self.onCloseRequestListener = None



		# EDIT MENU

		transferActionListener = _TransferActionListener()

		editMenu = JMenu( 'Edit' )

		if Platform.getPlatform() is Platform.MAC:
			command_key_mask = ActionEvent.META_MASK
		else:
			command_key_mask = ActionEvent.CTRL_MASK;

		self.__editUndoItem = JMenuItem( 'Undo' )
		undoAction = _action( 'undo', self.__onUndo )
		self.__editUndoItem.setActionCommand( undoAction.getValue( Action.NAME ) )
		self.__editUndoItem.addActionListener( undoAction )
		self.__editUndoItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_Z, command_key_mask ) )
		self.__editUndoItem.setMnemonic( KeyEvent.VK_U )
		editMenu.add( self.__editUndoItem )

		self.__editRedoItem = JMenuItem( 'Redo' )
		redoAction = _action( 'redo', self.__onRedo )
		self.__editRedoItem.setActionCommand( redoAction.getValue( Action.NAME ) )
		self.__editRedoItem.addActionListener( redoAction )
		self.__editRedoItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_Y, command_key_mask ) )
		self.__editRedoItem.setMnemonic( KeyEvent.VK_R )
		editMenu.add( self.__editRedoItem )

		editMenu.addSeparator()

		editCutItem = JMenuItem( 'Cut' )
		editCutItem.setActionCommand( TransferHandler.getCutAction().getValue( Action.NAME ) )
		editCutItem.addActionListener( transferActionListener )
		editCutItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_X, command_key_mask ) )
		editCutItem.setMnemonic( KeyEvent.VK_T )
		editMenu.add( editCutItem )

		editCopyItem = JMenuItem( 'Copy' )
		editCopyItem.setActionCommand( TransferHandler.getCopyAction().getValue( Action.NAME ) )
		editCopyItem.addActionListener( transferActionListener )
		editCopyItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_C, command_key_mask ) )
		editCopyItem.setMnemonic( KeyEvent.VK_C )
		editMenu.add( editCopyItem )

		editPasteItem = JMenuItem( 'Paste' )
		editPasteItem.setActionCommand( TransferHandler.getPasteAction().getValue( Action.NAME ) )
		editPasteItem.addActionListener( transferActionListener )
		editPasteItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_V, command_key_mask ) )
		editPasteItem.setMnemonic( KeyEvent.VK_P )
		editMenu.add( editPasteItem )

		editMenu.addSeparator()

		self.__showUndoHistoryItem = JMenuItem( 'Show undo history' )
		self.__showUndoHistoryItem.addActionListener( _action( 'Show undo history', self.__onShowUndoHistory ) )
		editMenu.add( self.__showUndoHistoryItem )




		# HELP MENU

		helpMenu = JMenu( 'Help' )

		helpToggleTooltipHighlightsItem = JMenuItem( 'Toggle tooltip highlights' )
		toggleTooltipHighlightsAction = _action( 'Toggle tooltip highlights', self.__onToggleTooltipHighlights )
		helpToggleTooltipHighlightsItem.setActionCommand( toggleTooltipHighlightsAction.getValue( Action.NAME ) )
		helpToggleTooltipHighlightsItem.addActionListener( toggleTooltipHighlightsAction )
		helpToggleTooltipHighlightsItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_F2, 0 ) )
		helpMenu.add( helpToggleTooltipHighlightsItem )

		helpMenu.add( _action( 'Show all tip boxes', self.__onShowAllTipBoxes ) )


		# MENU BAR

		menuBar = JMenuBar()
		menuBar.add( editMenu )
		menuBar.add( helpMenu )




		# BROWSER

		# Initialise here, as the browser listener may invoke methods upon the browser's creation
		class _BrowserListener (TabbedBrowser.TabbedBrowserListener):
			def createNewBrowserWindow(_self, subject):
				self._onOpenNewWindow( subject )

			def onTabbledBrowserChangePage(_self, browser):
				pass


		def inspectFragment(fragment, sourceElement, triggeringEvent):
			return self._windowManager.world.inspectFragment( fragment, sourceElement, triggeringEvent )



		def onChangeHistoryChanged(history):
			self.__refreshChangeHistoryControls( history )

		self._browser = TabbedBrowser( self._windowManager.world.rootSubject, subject, inspectFragment, _BrowserListener(), commandConsoleFactory )
		self._browser.getComponent().setPreferredSize( Dimension( 800, 600 ) )
		changeHistory = self._browser.getChangeHistory()
		self._browser.getChangeHistory().addChangeHistoryListener(onChangeHistoryChanged)





		# MAIN PANEL

		windowPanel = JPanel()
		windowPanel.setLayout( BoxLayout( windowPanel, BoxLayout.Y_AXIS ) )
		windowPanel.add( self._browser.getComponent() )




		# WINDOW

		class _WindowLister (WindowListener):
			def windowActivated(listenerSelf, event):
				pass

			def windowClosed(listenerSelf, event):
				pass

			def windowClosing(listenerSelf, event):
				if self.onCloseRequestListener is not None:
					self.onCloseRequestListener( self )

			def windowDeactivated(listenerSelf, event):
				pass

			def windowDeiconified(listenerSelf, event):
				pass

			def windowIconified(listenerSelf, event):
				pass

			def windowOpened(listenerSelf, event):
				pass


		self.__frame = JFrame( windowTitle )

		self.__frame.setJMenuBar( menuBar )

		self.__frame.add( windowPanel )
		self.__frame.addWindowListener( _WindowLister() )
		self.__frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE )

		self.__frame.pack()


		# Cause command history controls to refresh
		self.__refreshChangeHistoryControls( None )
Exemplo n.º 45
0
class Browser:
    def __init__(self, repository):
        self.repository = repository
        # want a better solution, with domains, perhaps user specifies
        self.currentUserReference = System.getProperty("user.name")
        
        self.currentRecord = None
                
        self.window = JFrame("Pointrel browser", windowClosing=self.exit)
        self.window.contentPane.layout = BorderLayout() # redundant as the default
        self.window.bounds = (100, 100, 800, 600)
        
        self.menuBar = JMenuBar()
        self.window.JMenuBar = self.menuBar
        fileMenu = JMenu("File")
        fileMenu.add(JMenuItem("Open...", actionPerformed=self.open))
        fileMenu.add(JMenuItem("Reload", actionPerformed=self.reloadPressed))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Import from other repository...", actionPerformed=self.importFromOtherRepository))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Close", actionPerformed=self.close))
        self.menuBar.add(fileMenu)

        exportMenu = JMenu("Export")
        exportMenu.add(JMenuItem("Choose current export file...", actionPerformed=self.exportChooseCurrentFile))
        exportMenu.addSeparator()        
        exportMenu.add(JMenuItem("Export selected record", actionPerformed=self.exportSelectedRecord))
        exportMenu.add(JMenuItem("Export record history for selected attribute", actionPerformed=self.exportAllRecordsForSelectedAttribute))
        exportMenu.addSeparator()
        exportMenu.add(JMenuItem("Export current records for all attributes of selected entity", actionPerformed=self.exportLatestRecordsForSelectedEntity))
        exportMenu.add(JMenuItem("Export entire record history for all attributes of selected entity", actionPerformed=self.exportAllRecordsForSelectedEntity))
        self.menuBar.add(exportMenu)
        
        self.exportFileName = "export.pointrel"

        #self.reloadButton = JButton("Reload Repository", actionPerformed=self.reloadPressed)
                        
        self.entitiesList = JList(DefaultListModel(), mouseClicked=self.entitiesListClicked)
        self.entitiesList.model.addElement("root")
        self.entitiesList.mousePressed = self.entitiesListMousePressed
        self.entitiesList.mouseReleased = self.entitiesListMousePressed
        
        self.attributesList = JList(DefaultListModel(), mouseClicked=self.attributesListClicked)
        
        self.versionsList = JList(DefaultListModel(), mouseClicked=self.versionsListClicked)
        
        self.listPanel = JPanel(layout=GridLayout(1, 2))
        self.listPanel.add(JScrollPane(self.entitiesList))
        self.listPanel.add(JScrollPane(self.attributesList))
        self.listPanel.add(JScrollPane(self.versionsList))
        
        self.navigationPanel = JPanel(layout=BorderLayout())
        #self.navigationPanel.add(self.reloadButton, BorderLayout.NORTH)
        self.navigationPanel.add(self.listPanel, BorderLayout.CENTER)
                
        self.entityTextField = JTextField(preferredSize=(200,20))
        self.attributeTextField = JTextField(preferredSize=(200,20))
        self.deletedButton = JCheckBox("Deleted", actionPerformed=self.deletedPressed)
        
        # only one right now -- and no support for switching editor panels yet
        examples = ["pointrel:text/utf-8", ]
        self.valueTypeComboBox = JComboBox(examples, preferredSize=(200,20), editable=True)

        self.attributePanel = Box(BoxLayout.X_AXIS) 
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Entity:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.entityTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Attribute:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.attributeTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Value type:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.valueTypeComboBox)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(self.deletedButton)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        
        self.showAllDeletedButton = JCheckBox("Show all deleted", actionPerformed=self.showAllDeletedPressed)
        self.statusText = JTextField(preferredSize=(100,20))
        self.saveButton = JButton("Save", actionPerformed=self.savePressed)
        self.normalSaveButtonColor = self.saveButton.background
        self.changedSaveButtonColor = Color.YELLOW

        self.statusPanel = Box(BoxLayout.X_AXIS)
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.showAllDeletedButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(25,0)))
        self.statusPanel.add(JLabel("Message:") )
        self.statusPanel.add(Box.createRigidArea(Dimension(2,0)))
        self.statusPanel.add(self.statusText) 
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.saveButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(1,0)))       
        
        self.currentEditorPanel = EditorPanel_text_utf_8(self, "pointrel:text/utf-8")
        
        self.topPanel = Box(BoxLayout.Y_AXIS)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        self.topPanel.add(self.attributePanel)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        
        self.editorPanel = JPanel(layout=BorderLayout())
        self.editorPanel.add(self.topPanel, BorderLayout.NORTH)
        self.editorPanel.add(self.currentEditorPanel, BorderLayout.CENTER)
        self.editorPanel.add(self.statusPanel, BorderLayout.SOUTH)
        
        self.browserPanel = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.browserPanel.add(self.navigationPanel)
        self.browserPanel.add(self.editorPanel)
        
        self.window.contentPane.add(self.browserPanel, BorderLayout.CENTER)
        
        self.setTitleForRepository()
        self.window.show()
        
        # background timer for updating save button color
        self.timer = Timer(1000, CallbackActionListener(self.timerEvent))
        self.timer.initialDelay = 1000
        self.timer.start()
        
    def close(self, event):
        System.exit(0)
        
    def open(self, event):
        dialog = FileDialog(self.window)
        fileName = dialog.go(PointrelFileTypes)
        if not fileName:
            return
        repository = Repository(fileName)
        self.repository = repository
        self.currentRecord = None
        self.clearAllEntityNames()
        self.refreshBrowser()
        self.setTitleForRepository()
        
    def setTitleForRepository(self):
        self.window.title = "Pointrel browser on %s" % self.repository.fileName

    def setStatus(self, messageText):
        self.statusText.text = messageText
        
    def getCurrentEntityName(self):
        return self.entityTextField.text

    def setCurrentEntityName(self, newAttributeName):
        self.entityTextField.text = newAttributeName
           
    def getCurrentAttributeName(self):
        return self.attributeTextField.text

    def setCurrentAttributeName(self, newAttributeName):
        self.attributeTextField.text = newAttributeName
           
    def getCurrentValueType(self):
        #return self.valueTypeComboBox.selectedItem
        return self.valueTypeComboBox.editor.editorComponent.text
    
    def setCurrentValueType(self, newValueType):
        self.valueTypeComboBox.selectedItem = newValueType
        # PDF FIX __ NEED TO CHANGE EDITOR TYPE
            
    def reportStatistics(self):
        contents = self.currentEditorPanel.getCurrentValueBytes()
        words = len(contents.split())
        lines = contents.count('\n')
        characters = len(contents)
        report = "%d lines; %d words; %d characters" % (lines, words, characters)
        self.setStatus(report)
        
    def timerEvent(self, event):
        self.manageSaveButtonColor()
        self.reportStatistics()
        
    def exit(self, event=None):
        System.exit(0)
        
    def reloadPressed(self, event):
        print "reloading repository; ", 
        self.repository.reload()
        self.refreshBrowser()
        print "done"
        
    def importCodeFromRepository(self, name, globals=None, locals=None, fromlist=None):
        # seems to fail with stack overflow if print while importing while trying jconsole (it reassigns stdio)
        debug = 0
        self.importLevel += 1
        if debug: print "  " * self.importLevel,
        if debug: print "importCodeFromRepository", name
        try:
            if debug: print "  " * self.importLevel,
            if debug: print "  globals: ", globals
            if debug: print "  " * self.importLevel,
            if debug: print "  locals", locals
            if debug: print "  " * self.importLevel,
            if debug: print "  fromlist", fromlist
        except UnboundLocalError:
            if debug: print "  " * self.importLevel,
            if debug: print "unbound error"
        # Fast path: see if the module has already been imported.
        # though this is wrong -- as need to check repository if code has been changed
        # broken as does not consider fromlist
        #try:
        #    return sys.modules[name]
        #except KeyError:
        #    pass
        # check if local module
        record = self.repository.findLatestRecordForEntityAttribute(self.contextUUID, name + ".py")
        if record:
            if debug: print "  " * self.importLevel,
            if debug: print "  Loading from repository"
            #file = StringIO.StringIO(record.valueBytes)
            #try:
            #module = imp.load_source(name, name, file)
            #print module
            modifiedName = self.contextUUID[7:] + "." + name
            modifiedName = modifiedName.replace("-", "_")
            if debug: print "modifiedName", modifiedName
            if debug: print "sys.module.items", sys.modules.items()
            try:
                module = sys.modules[modifiedName]
            except KeyError:
                module = None
            # use the latest if this one is not
            if module:
                if module.__pointrelIdentifier__ != record.identifierString:
                    module = None
            if not module:
                file = ByteArrayInputStream(record.valueBytes)
                module = imp.load_module(modifiedName, file, modifiedName + ".py", (".py", "r", imp.PY_SOURCE))
                module.__pointrelIdentifier__ = record.identifierString
            if fromlist:
                if debug: print "  " * self.importLevel,
                if debug: print "processing fromlist"
                for fromItemName in fromlist:
                    if debug: print "  " * self.importLevel,
                    if debug: print "fromitemname", fromItemName
                    if fromItemName == "*":
                        for moduleItemName in dir(module):
                            if debug: print "  " * self.importLevel,
                            if debug: print "moduleItemName", moduleItemName
                            if moduleItemName[1] != '_':
                                result = getattr(module, moduleItemName)
                                #print "  " * self.importLevel,
                                #print "result", result
                                #print "  " * self.importLevel,
                                #print "globals", globals
                                globals[moduleItemName] = result
                    else:
                        result = getattr(module, fromItemName)
                        globals[fromItemName] = result
                        if debug: print "finished set", fromItemName
                
            #finally:
            #    file.close()
            if debug: print "  " * self.importLevel,
            if debug: print "  Done loading"
            self.importLevel -= 1
            result = module
        else:
            if debug: print "  " * self.importLevel,
            if debug: print "default loading", name, fromlist
            try:
                result = self.oldimport(name, globals, locals, fromlist)
            except UnboundLocalError:
                # deal with strange Jython error
                result = self.oldimport(name)
            self.importLevel -= 1
        return result
    
    def importFromOtherRepository(self, event):
        dialog = FileDialog(self.window, loadOrSave="load")
        fileName = dialog.go(PointrelFileTypes)
        if not fileName:
            return
        
        print "Importing from: ", fileName
        self.repository.importRecordsFromAnotherRepository(fileName)
        print "Done with import"
        
        self.refreshBrowser()
    
    def exportChooseCurrentFile(self, event):
        dialog = FileDialog(self.window, loadOrSave="save")
        fileName = dialog.go(PointrelFileTypes)
        if not fileName:
            return
        self.exportFileName = fileName
        print "File selected for exports:", self.exportFileName
             
    def exportSelectedRecord(self, event):
        if not self.currentRecord:
            print "No record selected"
            return
        oldRecords = [self.currentRecord]
        print "Exporting current record to repository %s" % self.exportFileName
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
    
    def exportAllRecordsForSelectedAttribute(self, event):
        entityName = self.getCurrentEntityName()
        if not entityName:
           print "No entity selected" 
           return
        attributeName = self.getCurrentAttributeName()
        if not attributeName:
           print "No attribute selected"   
           return   
        print "Exporting all records for entity '%s' attribute '%s' to repository %s" % (entityName, attributeName, self.exportFileName)
        oldRecords = self.repository.findAllRecordsForEntityAttribute(entityName, attributeName)
        oldRecords.reverse()
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
            
    def exportLatestRecordsForSelectedEntity(self, event):
        entityName = self.getCurrentEntityName()
        if not entityName:
           print "No entity selected" 
           return
        print "Exporting latest records for all entity '%s' attributes to repository %s" % (entityName, self.exportFileName)
        oldRecords = self.repository.findLatestRecordsForAllEntityAttributes(entityName)
        oldRecords.reverse()
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
        
    def exportAllRecordsForSelectedEntity(self, event):
        entityName = self.getCurrentEntityName()
        if not entityName:
           print "No entity selected" 
           return
        print "Exporting all records for entity '%s' to repository %s" % (entityName, self.exportFileName)
        oldRecords = self.repository.findAllRecordsForEntity(entityName)
        oldRecords.reverse()
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
               
    def setCurrentRecord(self, aRecord):
        self.currentRecord = aRecord
        if aRecord:
            self.setCurrentEntityName(aRecord.entity)
            self.entityTextField.caretPosition = 0
            self.setCurrentAttributeName(aRecord.attribute)
            self.attributeTextField.caretPosition = 0
            self.setCurrentValueType(aRecord.valueType)
            self.currentEditorPanel.setCurrentValueBytes(aRecord.valueBytes)
            self.deletedButton.model.setSelected(aRecord.deleted)
        else:
            entityName = self.entitiesList.selectedValue
            if entityName == None:
                entityName = ""
            self.setCurrentEntityName(entityName)
            self.entityTextField.caretPosition = 0
            self.setCurrentAttributeName("")
            self.setCurrentValueType(DefaultValueType)
            self.currentEditorPanel.setCurrentValueBytes("") 
            self.deletedButton.model.selected = False
                
    def manageSaveButtonColor(self):
        if self.isCurrentRecordChanged():
            self.saveButton.background = self.changedSaveButtonColor
        else:
            self.saveButton.background = self.normalSaveButtonColor
            
    def isCurrentRecordChanged(self):
        if not self.currentRecord:
            if self.getCurrentAttributeName() or self.currentEditorPanel.getCurrentValueBytes():
                return True
            return False
        if self.getCurrentEntityName() != self.currentRecord.entity:
            return True
        if self.getCurrentAttributeName() != self.currentRecord.attribute:
            return True
        if self.getCurrentValueType() != self.currentRecord.valueType:
            return True
        if self.currentEditorPanel.isChangedFromOriginal():
             return True
        # funky comparison because may be booleans and integers?
        # decided not to test as not really linked to save button
        #if (self.deletedButton.model.selected and not self.currentRecord.deleted) or (not self.deletedButton.model.selected and self.currentRecord.deleted):
        #    return True
        return False

    def deletedPressed(self, event):
        deleteFlag = self.deletedButton.model.selected
        if self.currentRecord == None:
            return 
        self.repository.deleteOrUndelete(self.currentRecord, self.currentUserReference, deleteFlag=deleteFlag)
        if not self.isDeletedViewable():
            self.refreshBrowser()
            
    def refreshBrowser(self):
        entityName = self.entitiesList.selectedValue
        attributeName = self.attributesList.selectedValue
        versionName = self.versionsList.selectedValue
        self.entitiesListClicked(None, entityName, attributeName, versionName)
                    
    def showAllDeletedPressed(self, event):
        self.refreshBrowser()
        
    def isDeletedViewable(self):
        return self.showAllDeletedButton.model.selected
                  
    def savePressed(self, event):
        #entityName = self.entitiesList.selectedValue
        entityName = self.getCurrentEntityName()
        if entityName:
            attributeName = self.getCurrentAttributeName()
            if attributeName:
                attributeValue = self.currentEditorPanel.getCurrentValueBytes()
                attributeType = self.getCurrentValueType()
                newRecord = self.repository.add(entityName, attributeName, attributeValue, attributeType, self.currentUserReference)
                self.setCurrentRecord(newRecord)
                self.entitiesListClicked(None, self.entitiesList.selectedValue, attributeName)
                # refresh list if changed
                if attributeName != self.attributesList.selectedValue:
                    # ? self.attributesList.model.addElement(attributeName)
                    # need to select new version
                    self.entitiesListClicked(None)
                        
    def test(self):
        print "test OK"

    def clearAllEntityNames(self):
        self.entitiesList.model.clear()
        self.addEntityNameToEntitiesList("root")
            
    def deleteEntityNameFromList(self):
        entityName = self.entitiesList.selectedValue
        if entityName:
           self.entitiesList.model.removeElement(entityName)
            
    def addEntitytNameToList(self):
        entityName = JOptionPane.showInputDialog("Enter an entity name: ")
        if entityName:
            self.addEntityNameToEntitiesList(entityName)
            
    def addAllEntityNamesToList(self, addMeta):
        entityNames = self.repository.lastUser.keys()
        entityNames.sort()
        for entityName in entityNames:
            if addMeta or entityName.find("pointrel://tripleID/") != 0:
                self.addEntityNameToEntitiesList(entityName)
           
    def entitiesListMousePressed(self, event):
        if event.isPopupTrigger():
            # options should be a list of (name, function, [arg1, [arg2]]) tuples
            options = [
                       ("add to list..", self.addEntitytNameToList),
                       ("delete from list", self.deleteEntityNameFromList), 
                       (None),
                       ("clear", self.clearAllEntityNames), 
                       (None),
                       ("add all except meta", self.addAllEntityNamesToList, False), 
                       ("add all", self.addAllEntityNamesToList, True), 
                       ]
            menu = OptionsCallbackPopupMenu(event.component, event.x, event.y, options)

    def entitiesListClicked(self, event, entityName=None, attributeName=None, versionName=None):
        if event:
            self.setCurrentRecord(None)
        if entityName:
            self.entitiesList.setSelectedValue(entityName, True)
        else:
            entityName = self.entitiesList.selectedValue
        if entityName:
            self.versionsList.model.clear()
            model = self.attributesList.model 
            model.clear()
            attributes = self.repository.allAttributesForEntity(entityName, self.isDeletedViewable())
            attributes.sort()
            for attribute in attributes:
                model.addElement(attribute)
            if attributeName:
                self.attributesList.setSelectedValue(attributeName, True)
                self.attributesListClicked(None, versionName)
        
    def attributesListClicked(self, event, versionName=None):
        if event:
            self.setCurrentRecord(None)
        entityName = self.entitiesList.selectedValue
        if entityName:
            attributeName = self.attributesList.selectedValue
            if event:
                self.setCurrentAttributeName(attributeName)
            if attributeName:
                model = self.versionsList.model 
                model.clear()
                versions = self.repository.findAllRecordsForEntityAttribute(entityName, attributeName, self.isDeletedViewable())
                for version in versions:
                    versionDescription = "%s %s" % (version.timestamp, version.userReference)
                    model.addElement(versionDescription)
                selectedRecord = None
                if versions:
                    if versionName == None or not model.contains(versionName):
                        self.versionsList.selectedIndex = 0
                        selectedRecord = versions[0]
                    else:
                        versionIndex = model.indexOf(versionName)
                        self.versionsList.selectedIndex = versionIndex
                        selectedRecord = versions[versionIndex]
                self.setCurrentRecord(selectedRecord)
        
                if event and event.clickCount == 2:
                    self.followResource(self.currentRecord)
            else:
                self.setCurrentRecord(None)
        else:
            self.setCurrentRecord(None)
                    
    def versionsListClicked(self, event):
        entityName = self.entitiesList.selectedValue
        if entityName:
            attributeName = self.attributesList.selectedValue
            if event:
                self.setCurrentAttributeName(attributeName)
            if attributeName:
                index = self.versionsList.selectedIndex
                versions = self.repository.findAllRecordsForEntityAttribute(entityName, attributeName, self.isDeletedViewable())
                if versions:
                    versionRecord = versions[index]
                    self.setCurrentRecord(versionRecord)

                    if event and event.clickCount == 2:
                        self.followResource(versionRecord)
                else:
                    self.setCurrentRecord(None)
                    
    def followResource(self, record):
        if not record:
            return
        if '\n' in record.valueBytes:
            print "not following a resource with a newline"
            return
        self.addEntityNameToEntitiesList(record.valueBytes)

    def addEntityNameToEntitiesList(self, entityName):
        self.entitiesList.model.addElement(entityName)
        self.entitiesList.selectedIndex = self.entitiesList.model.size() - 1
        self.entitiesListClicked(None)
        self.setCurrentRecord(None)