Esempio n. 1
0
def pushMe(event):
    print 'pyaction push from actions.py'
    print event
    node = event.getSource()
    print node
    print Platform.isFxApplicationThread()
    loadFile(event) 
Esempio n. 2
0
    def handleHistoryShortcuts(self, keysPressed, *eventArgs):
        '''
			Designate various shortcut key and combo-shortcut key combinations
			[0]BrowserSession, [1]ToggleTheme(CheckMenuItem), [2]CM_CLHIST
		'''

        ##Shortcuts come FIRST##

        #Grab CTRL + Q
        if ComboShortcutKeys.QUIT.getCombo().match(keysPressed):
            keysPressed.consume()
            print(
                'Log: Shortcut Combo-Key Action: Quit action triggered by CTRL + Q'
            )
            BrowserSession.closeHistoryWriter(eventArgs[0])
            self.app.closeStages(
                self.app.getStageList())  #Not a static call...
            Platform.exit()
        #Grab CTRL + T
        elif ComboShortcutKeys.THEME_TOGGLE.getCombo().match(keysPressed):
            keysPressed.consume()
            print(
                'Log: Shortcut Combo-Key Action: Theme-Switch action triggered by CTRL + T'
            )
            eventArgs[1].fire()
            #Breaks when scene changes.
        #Grab CTRL + D
        elif ComboShortcutKeys.CLEAR_HIST.getCombo().match(keysPressed):
            eventArgs[2].fire()
            keysPressed.consume()
            print(
                'Log: Shortcut Combo-Key Action: History Cleared triggered by CTRL + D'
            )
        else:
            pass
Esempio n. 3
0
    def registerExtenderCallbacks(self, callbacks):
        """Register the Burp Suite extension.

        Args:
            callbacks (obj): The Burp Suite callbacks.

        """

        ExtensionDetails.initialize()

        self._layout = JFXPanel()
        self._graph = GraphWave()
        self._config = GraphWaveConfig(callbacks)
        self._loadConfig = callbacks.loadConfigFromJson
        self._listener = GraphWaveHttpListener(self._config, self._graph,
                                               self.refreshInterface,
                                               callbacks.getHelpers())

        Platform.runLater(ExtensionRunnable(self.initializeInterface))

        self.burpThreadLooper()

        callbacks.addSuiteTab(self)
        callbacks.setExtensionName(ExtensionDetails.TITLE)
        callbacks.registerHttpListener(self._listener)
Esempio n. 4
0
 def getUiComponent(self):
     try:
         Platform.runLater(EditorTabUI(self))
         return self._panel
     except Exception as e:
         exc_type, exc_obj, exc_tb = sys.exc_info()
         fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
         print(exc_type, fname, exc_tb.tb_lineno)
Esempio n. 5
0
    def initializeInterface(self):
        """Initialize the graphical user interface using JavaFX."""

        fxml = File(self.resourcePath + "ExtensionTab.fxml")
        root = FXMLLoader.load(fxml.toURL())

        self._scene = Scene(root)
        self._layout.setScene(self._scene)

        Platform.runLater(ExtensionRunnable(self.initializeElements))
Esempio n. 6
0
    def burpThreadLooper(self):
        """This method runs every 0.5 seconds on the main Burp Suite thread and
        executes certain methods if the corresponding atomic booleans are positive."""

        if self.shouldLoadConfigFromJson:
            self.shouldLoadConfigFromJson = False
            self._loadConfig(json.dumps(self._config.data))

        if self.shouldRefreshInterface:
            self.shouldRefreshInterface = False
            Platform.runLater(ExtensionRunnable(self.refreshInterfaceFunc))

        threading.Timer(0.5, self.burpThreadLooper).start()
Esempio n. 7
0
 def start(self, stage):
     from javafx.application import Platform
     self.ctrl  = _window__ctrl_table
     self.stage = stage
     self.stage.setTitle("FxApp Example")
     if self.title: self.stage.setTitle(self.title)
     if self.icon: self.stage.getIcons().add(Image(FileInputStream(self.icon)))   
     if self.closeHandler: self.stage.setOnCloseRequest(self.closeHandler)
     Platform.setImplicitExit(True)
     pane = EzBorderPane(self)
     self.scene = Scene(pane.ctrl, 640, 400)
     self.stage.setScene(self.scene)
     if self.createdHandler: self.createdHandler()
     self.stage.show()
    def changed(self, observable, oldValue, newValue):
        """The change trigger that is called if the observable value changed.

        Note:
            The callback is executed on the GUI thread.

        Args:
            observable (obj): The element that triggered the event.
            oldValue (float): The previous value of the element.
            newValue (float): The current value of the element.

        """

        runnable = ExtensionRunnable(self.callback, self.key, observable,
                                     oldValue, newValue)

        Platform.runLater(runnable)
Esempio n. 9
0
 def handle(self, action):
     if (yes.isSelected()) ^ (no.isSelected()):
         if self.app._EmeraldFX__LICENSE_ACCEPTANCE == "YES":
             #We're done here
             self.outer.license_check_stage.close()
             #Update properties.json
             self.license_check_stage_json['license'][
                 'value'] = "YES"
             #Write Data, close stream
             with open("../resources/config/properties.json",
                       "w") as prop:
                 json.dump(self.license_check_stage_json, prop)
         else:
             # checked == "NO":
             BrowserSession.closeHistoryWriter(self.BS)
             Thread.sleep(300)
             Platform.exit()
Esempio n. 10
0
    def _generate_model(self, e):
        if len(self._messages) <= 0:
            frame = JFrame("Error")
            JOptionPane.showMessageDialog(frame, "No messages!", "Error",
                                          JOptionPane.ERROR_MESSAGE)
            return
        if self._sql_file == None:
            frame = JFrame("Error")
            replay = JOptionPane.showConfirmDialog(
                frame, "No SQL file selected!\nDo you want to continue?",
                "Info", JOptionPane.YES_NO_OPTION)
            if replay == JOptionPane.NO_OPTION:
                return

        # create a new AslanppModel
        model = AslanppModel()
        # save _sql_file
        model._sql_file = self._sql_file

        for c in self._messages:
            # from byte to char Request and Response
            # for some reason b can be a negative value causing a crash
            # so I put a check to ensure b is in the right range
            msg = c[0]
            if msg.getRequest() == None or msg.getResponse() == None:
                # do not convert empty messages
                continue
            http_request = "".join(
                chr(b) for b in msg.getRequest() if b >= 0 and b <= 256)
            http_response = "".join(
                chr(b) for b in msg.getResponse() if b >= 0 and b <= 256)
            protocol = msg.getHttpService().getProtocol()
            # save the tag number generate by _parseHttpRequestResponse in the _messages array
            c[1] = converter._parseHttpRequestResponse(model, http_request,
                                                       http_response, protocol)

        # generate the ASLan++ code
        self._model, self._concrete = converter._generateWAFExModel(model)
        Platform.runLater(
            UpdateEditor(self._jfxp_aslanpp._editor,
                         self._jfxp_concretization._editor, self._model,
                         self._concrete))
Esempio n. 11
0
 def start(self, stage):
     print('EzWindow.start()');
     from javafx.application import Platform
     __vars.ctrl  = _window__ctrl_table
     __vars.stage = stage
     if __vars.title: __vars.stage.setTitle(__vars.title)
     if __vars.icon: __vars.stage.getIcons().add(Image(FileInputStream(__vars.icon)))   
     if __vars.closeHandler: __vars.stage.setOnCloseRequest(__vars.closeHandler)
     Platform.setImplicitExit(True)
     vbox = EzVBox()
     if __vars.menu: vbox.addItem(EzMenuBar(__vars.menu))
     for m in __vars.tool: vbox.addItem(EzToolBar(m))
     pane = EzBorderPane()
     if __vars.content: pane.setCenter(EzLayout(__vars.content,pane.ctrl))
     pane.setTop(vbox.ctrl)
     pane.setBottom(EzStatusBar(__vars.status))
     __vars.scene = Scene(pane.ctrl, __vars.width, __vars.height)
     __vars.stage.setScene(__vars.scene)
     if __vars.createdHandler: __vars.createdHandler()
     __vars.stage.show()      
Esempio n. 12
0
	def call(self):
		#CountdownLatch
		latch = CountDownLatch(1)

		#Read History.txt into TextArea
		br = BufferedReader(FileReader(self.hist_file))

		#Runnable Inner Class
		class HistoryTaskRunnable (Runnable):
			def __init__(self, textArea, br):
				self.textArea = textArea
				self.br = br
				self.sbf = StringBuffer()
			#@Override
			def run(self):
				while True:
					line = self.br.readLine()
					if line != None:
						self.sbf.append(line + "\n")
						# self.textArea.appendText(line + "\n") - Very slow
					else:
						break
				#Add Text to TextArea
				self.textArea.setText(self.sbf.toString())
				self.textArea.appendText("") #Used to trigger event handler
				#Close Buffered Reader
				br.close()

		#Run Later
		Platform.runLater(HistoryTaskRunnable(self.textArea, br))
			
		#Set Starting positions
		textArea.setScrollLeft(Double.MAX_VALUE)
		textArea.setScrollTop(Double.MAX_VALUE)

		#Make the Application Thread wait
		latch.await()
Esempio n. 13
0
    def internalRun(*args, **kwargs):
        class InternalRunnable(Runnable):
            def run(self):
                function(*args, **kwargs)

        Platform.runLater(InternalRunnable())
Esempio n. 14
0
    def show(self):
        from javafx.scene.control import CheckBox, Button

        #Make Stage always on top
        self.license_check_stage.setAlwaysOnTop(True)
        #Set Max Height/Width
        self.license_check_stage.setMaxWidth(900)
        self.license_check_stage.setMaxHeight(500)
        #Disallow resizing
        self.license_check_stage.setResizable(False)
        #Center on screen
        self.license_check_stage.centerOnScreen()
        #Get input focus
        self.license_check_stage.requestFocus()

        #Block Main Stage from recieving events!
        self.license_check_stage.initModality(
            Modality.APPLICATION_MODAL
        )  #Why is this not in setter bean notation? Hmm.

        #License Check
        self.license_check_stage.setTitle(
            "License Terms & Conditions  -  EmeraldFX")
        #License Answer Placeholder
        license_answer = str()

        #Buttons
        yes = CheckBox()
        no = CheckBox()
        enter = Button()

        #Grab, icon, graphics, button graphics
        try:
            self.license_check_stage.getIcons().addAll(self.icons.get(0),
                                                       self.icons.get(1),
                                                       self.icons.get(2),
                                                       self.icons.get(3),
                                                       self.icons.get(4))
            license_graphic = ImageView(
                Image(
                    String(
                        File('../resources/icons/license.png').toURI().
                        toString()), True))
            yes.setGraphic(
                ImageView(
                    Image(
                        String(
                            File('../resources/icons/YES.png').toURI().
                            toString()), True)))
            no.setGraphic(
                ImageView(
                    Image(
                        String(
                            File('../resources/icons/NO.png').toURI().toString(
                            )), True)))
            enter.setGraphic(
                ImageView(
                    Image(
                        String(
                            File('../resources/icons/GO.png').toURI().toString(
                            )), True)))
        except NullPointerException:
            print(
                "Log: One or more Application resouce files could not be found."
            )

        #Disallow Indeterminate
        yes.setAllowIndeterminate(False)
        no.setAllowIndeterminate(False)

        #Header
        if self.app.getCurrentTheme() == "Dark":
            top = ImageView(
                Image(
                    File('../resources/icons/top_bar_license_dt.png').toURI().
                    toString()))
        elif self.app.getCurrentTheme() == "Light":
            top = ImageView(
                Image(
                    File('../resources/icons/top_bar_license_lt.png').toURI().
                    toString()))

        #Middle
        middle = HBox(15)
        #Set up WebEngine
        license_webView = WebView()
        webEng = license_webView.getEngine()
        webEng.load(self.app._EmeraldFX__LICENSE)

        #License Image
        license_logo = VBox()
        license_logo.getChildren().add(
            ImageView(
                Image(
                    String(
                        File('../resources/icons/license.png').toURI().
                        toString()), True)))
        license_logo.setAlignment(Pos.CENTER)

        #Put it all together
        middle.getChildren().addAll(license_logo, license_webView)
        middle.setPadding(Insets(0, 10, 0, 10))

        #CheckBox Grouping
        bottom = HBox()
        bottom.getChildren().addAll(yes, no, enter)
        bottom.setSpacing(50)
        bottom.setPadding(Insets(0, 0, 0, 200))

        #Set Theme Accordingly
        try:
            if self.app.getCurrentTheme() == "Dark":
                BKG = File(
                    '../resources/icons/bottom_bar_dt.png').toURI().toString()
            elif self.app.getCurrentTheme() == "Light":
                BKG = File(
                    '../resources/icons/bottom_bar_lt.png').toURI().toString()
            else:
                pass
        except NullPointerException:
            print(
                "Log: One or more Application resouce files could not be found."
            )

        #Footer
        background_bottom = Background(
            array(BackgroundImage, [
                BackgroundImage(Image(BKG), BackgroundRepeat.NO_REPEAT,
                                BackgroundRepeat.NO_REPEAT,
                                BackgroundPosition.DEFAULT,
                                BackgroundSize.DEFAULT)
            ]))
        bottom.setBackground(background_bottom)
        bottom.setAlignment(Pos.CENTER)
        bottom.setPrefHeight(15)

        #Root Pane
        license_check_stage_root = VBox()
        license_check_stage_root.getChildren().addAll(top, middle, bottom)

        #Scene
        license_check_scene = Scene(license_check_stage_root, 895, 498)
        #Shortcuts not available for this scene. We will use defaults, for now.

        #Set Scene on Stage
        self.license_check_stage.setScene(license_check_scene)

        #Handle Selection
        class AnonInnerCL_E(EventHandler):
            def __init__(self, outer, yes, no):
                self.outer = outer
                self.app = outer.app
                self.BS = outer.BS
                self.YES = yes
                self.NO = no
                self.license_check_stage_json = self.app._EmeraldFX__config

            #@Override
            def handle(self, action):
                if (yes.isSelected()) ^ (no.isSelected()):
                    if self.app._EmeraldFX__LICENSE_ACCEPTANCE == "YES":
                        #We're done here
                        self.outer.license_check_stage.close()
                        #Update properties.json
                        self.license_check_stage_json['license'][
                            'value'] = "YES"
                        #Write Data, close stream
                        with open("../resources/config/properties.json",
                                  "w") as prop:
                            json.dump(self.license_check_stage_json, prop)
                    else:
                        # checked == "NO":
                        BrowserSession.closeHistoryWriter(self.BS)
                        Thread.sleep(300)
                        Platform.exit()

        class AnonInnerCL_Y(EventHandler):
            def __init__(self, YES, NO, ENTER, app):
                self.YES = YES
                self.NO = NO
                self.ENTER = ENTER
                self.app = app

            #@Override
            def handle(self, action):
                if self.YES.isSelected():
                    self.NO.setSelected(False)
                    self.ENTER.setDisabled(
                        False) if self.ENTER.isDisabled() else None
                    self.app._EmeraldFX__LICENSE_ACCEPTANCE = "YES"
                elif not self.YES.isSelected() and not self.NO.isSelected():
                    self.ENTER.setDisabled(True)

        class AnonInnerCL_N(EventHandler):
            def __init__(self, NO, YES, ENTER, app):
                self.NO = NO
                self.YES = YES
                self.ENTER = ENTER
                self.app = app

            #@Override
            def handle(self, action):
                if self.NO.isSelected():
                    self.YES.setSelected(False)
                    self.ENTER.setDisabled(
                        False) if self.ENTER.isDisabled() else None
                    self.app._EmeraldFX__LICENSE_ACCEPTANCE = "NO"
                elif not self.NO.isSelected() and not self.YES.isSelected():
                    self.ENTER.setDisabled(True)

        #Disable Enter by Default
        enter.setDisabled(True)

        #Enter hit
        enter.setOnAction(AnonInnerCL_E(self, yes, no))
        #Yes Checked
        yes.setOnAction(AnonInnerCL_Y(yes, no, enter, self.app))
        #No Checked
        no.setOnAction(AnonInnerCL_N(no, yes, enter, self.app))

        #If they enter no selection, exit
        self.license_check_stage.setOnCloseRequest(
            lambda event:
            [BrowserSession.closeHistoryWriter(self.BS),
             Platform.exit()])

        #Display stage
        self.license_check_stage.show()
Esempio n. 15
0
from javafx.application import Platform
from javafx.embed.swing import JFXPanel

from java.lang import Runnable
from javafx.scene.input import KeyEvent
from javafx.scene.input import KeyCode

# this should implicitly starts the JavaFX runtime
# so that I can put the imports here
JFXPanel()

# prevent the JavaFX runtime to finish after the extention loaded
# otherwise if I try to reload the extension the JavaFX runtime won't
# load again.
Platform.setImplicitExit(False)

# custom import
from aslanppmodel import AslanppModel
from aslanppeditor import AslanppEditor
from concretizationeditor import ConcretizationEditor
import converter


class BurpExtender(IBurpExtender, IContextMenuFactory, ITab, ComponentListener,
                   ActionListener, MouseAdapter):
    # contains the messages to show in the messages table
    _table_data = []

    # contains the messages to translate
    _messages = []
Esempio n. 16
0
 def onExit(self,event):
     from javafx.application import Platform
     Platform.exit()
Esempio n. 17
0
def RunLater(handler):
    from javafx.application import Platform
    Platform.runLater(handler)
Esempio n. 18
0
 def internalRun(*args, **kwargs):
     class InternalRunnable(Runnable):
         def run(self):
             function(*args, **kwargs)
     Platform.runLater(InternalRunnable())
Esempio n. 19
0
# Close all other tabs within the same pane
#
# Can be attached to a display, triggered by "loc://init(0)"
# to run when display is opened.
#
# Example for obtaining the DisplayRuntimeInstance and DockItem
# of a display to then interact with them

from java.lang import Runnable
from javafx.application import Platform
from org.csstudio.display.builder.runtime.app import DisplayRuntimeInstance

display = widget.getTopDisplayModel()


# Interactions with UI must run on the UI thread
class CloseOther(Runnable):
    def run(self):
        # Get DockItem for this display
        this_item = DisplayRuntimeInstance.ofDisplayModel(
            display).getDockItem()
        # Close all _other_ items (tabs) within this pane
        for item in this_item.getDockPane().getDockItems():
            if item != this_item:
                print "CLOSE " + str(item)
                item.close()


Platform.runLater(CloseOther())