def actionPerformed(self, event): 
		 
		source = event.getSource() # test here if it is a button 
		 
		if isinstance(source, Button): # if type is a button get label, and check command, otherwise pass to GenericDialogPlus.actionPeformed 
			 
			sourceLabel = source.getLabel() 
			 
			if sourceLabel == CategoryDialog.ADD_CATEGORY: 
				newCategory = IJ.getString("Enter new category name", "new category") 
				if not newCategory: return # if Cancelled (ie newCat=="") or empty field just dont go further  
				 
				self.panel.add(TextField(newCategory)) # Add new text field with the new category 
				self.pack() # recompute the layout and update the display 
		 
		# Anyway do the mother class usual action handling 
		GenericDialogPlus.actionPerformed(self, event) 
Exemplo n.º 2
0
    def actionPerformed(self, event):
        '''
		Handle buttons clicks, delegates to custom methods
		OK: save parameters in memory
		Add new category: delegate to addCategoryComponent() (should be overwritten in daughter)
		Add: delegate to addAction()
		NB: NEVER use getNext methods here, since we call them several time 
		'''
        source = event.getSource()  # test here if it is a button

        if isinstance(
                source, Button
        ):  # if type is a button get label, and check command, otherwise pass to GenericDialogPlus.actionPeformed

            sourceLabel = source.getLabel()

            if sourceLabel == CustomDialog.LABEL_OK:
                # Check options and save them in persistence
                checkboxes = self.getCheckboxes()

                doNext = checkboxes[-1].getState()
                Prefs.set("annot.doNext", doNext)

                # Save selected dimension if mode stack
                if self.browseMode == "stack":
                    Prefs.set("annot.dimension", self.getSelectedDimension())

            elif sourceLabel == "Add new category":
                self.addCategoryComponent()

            elif sourceLabel == self.LABEL_ADD:
                self.addAction()

            else:
                pass

        # Anyway do the mother class usual action handling
        GenericDialogPlus.actionPerformed(self, event)