示例#1
0
def move_script_warning():
    """Warn the user to move qat_script directory into Scripting Plugin
       directory
    """
    scriptingPluginDir = PluginHandler.getPlugin("scripting").getPluginDir()
    pane = JPanel(GridLayout(3, 1, 5, 5))
    warningTitle = "Warning: qat_script directory not found"
    pane.add(
        JLabel(
            "Please, move qat_script directory to the following location and start the script again:\n"
        ))
    defaultPathTextField = JTextField(scriptingPluginDir,
                                      editable=0,
                                      border=None,
                                      background=None)
    pane.add(defaultPathTextField)

    if not Desktop.isDesktopSupported():
        JOptionPane.showMessageDialog(Main.parent, pane, warningTitle,
                                      JOptionPane.WARNING_MESSAGE)
    else:
        #add a button to open default path with the files manager
        pane.add(JLabel("Do you want to open this folder?"))
        options = ["No", "Yes"]
        answer = JOptionPane.showOptionDialog(Main.parent, pane, warningTitle,
                                              JOptionPane.YES_NO_OPTION,
                                              JOptionPane.QUESTION_MESSAGE,
                                              None, options, options[1])
        if answer == 1:
            Desktop.getDesktop().open(File(scriptingPluginDir))
示例#2
0
def move_script_warning():
    """Warn the user to move qat_script directory into Scripting Plugin
       directory
    """
    scriptingPluginDir = PluginHandler.getPlugin("scripting").getPluginDir()
    pane = JPanel(GridLayout(3, 1, 5, 5))
    warningTitle = "Warning: qat_script directory not found"
    pane.add(JLabel("Please, move qat_script directory to the following location and start the script again:\n"))
    defaultPathTextField = JTextField(scriptingPluginDir,
                                      editable=0,
                                      border=None,
                                      background=None)
    pane.add(defaultPathTextField)

    if not Desktop.isDesktopSupported():
        JOptionPane.showMessageDialog(
            Main.parent,
            pane,
            warningTitle,
            JOptionPane.WARNING_MESSAGE)
    else:
        #add a button to open default path with the files manager
        pane.add(JLabel("Do you want to open this folder?"))
        options = ["No", "Yes"]
        answer = JOptionPane.showOptionDialog(
            Main.parent,
            pane,
            warningTitle,
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            None,
            options,
            options[1])
        if answer == 1:
            Desktop.getDesktop().open(File(scriptingPluginDir))
示例#3
0
 def mouseClicked(self, event):
     if event.source == self.jDocs:
         uri = URI.create("https://github.com/DanNegrea/PyRules")
         if uri and Desktop.isDesktopSupported() and Desktop.getDesktop(
         ).isSupported(Desktop.Action.BROWSE):
             Desktop.getDesktop().browse(uri)
     return
示例#4
0
 def _open_website(self, url):
     uri = URI(url)
     desktop = None
     if Desktop.isDesktopSupported():
         desktop = Desktop.getDesktop()
     if desktop and desktop.isSupported(Desktop.Action.BROWSE):
         desktop.browse(uri)
示例#5
0
 def open(self, url, new=0, autoraise=1):
     if not Desktop.isDesktopSupported():
         raise Error("webbrowswer.py not supported in your environment")
     try:
         Desktop.getDesktop().browse(URI(url))
         return True
     except IOError as e:
         raise Error(e)
示例#6
0
 def open(self, url, new=0, autoraise=1):    
     if not Desktop.isDesktopSupported():
         raise Error("webbrowswer.py not supported in your environment")
     try:
         Desktop.getDesktop().browse(URI(url))
         return True
     except IOError as e:
         raise Error(e)
示例#7
0
popup("Hello from Git showcase Jython")

import java.awt.Desktop as DT
import java.net.URI as URI

if not DT.isDesktopSupported():
	exit(1)

dt = DT.getDesktop()
dt.browse(URI("http://sikulix.com"))

Debug.on(3)
r = ALL.wait("sxpower.png", 30)
r.below(100).click("quickstart.png")

popup("Click OK:\n- to close the browser window\n- and terminate")

if RUNTIME.runningMac:
  write("#M.w")
else:
  write("#C.w")
示例#8
0
    def actionPerformed(self, event):
        #Load button was clicked
        #> opens the file chooser
        #> opens and parses the file
        #> populates the persistand value and script panes
        #> display path inside FileName field
        if self.jLoad == event.getSource():
            if self.jFileName.getText() == Strings.jFileName_default:
                jFileChooser = JFileChooser()
            else:
                jFileChooser = JFileChooser(self.jFileName.getText())
            result = jFileChooser.showOpenDialog(None)

            if result == JFileChooser.APPROVE_OPTION:
                selectedFile = jFileChooser.getSelectedFile()

                #Update the Tab Title if it contains a file name or default name
                currentTitle = self._ui.getTabName(self)
                currentFile = FileSystems.getDefault().getPath(
                    self.jFileName.getText()).getFileName().toString()

                if self.jFileName.getText(
                ) == Strings.jFileName_default or currentTitle == currentFile:
                    self._ui.setTabName(
                        self,
                        selectedFile.toPath().getFileName().toString())

                # read from file
                (vars, script) = FileUtils.read(selectedFile.toPath())

                if vars is None or script is None:
                    # content could not be parsed
                    JOptionPane.showMessageDialog(None,
                                                  Strings.FileUtils_error,
                                                  Strings.FileUtils_error,
                                                  JOptionPane.ERROR_MESSAGE)

                else:
                    # update var and scipt content
                    self.jVarsPane.setText(vars)
                    self.jScriptPane.setText(script)
                    self._executor.init(vars)

                    # update the File Name to the current choosen file
                    self.jFileName.setText(selectedFile.getAbsolutePath())

        #Save button clicked
        #> open the file chooser
        #> creates the file content
        #> writes the file on disk
        if self.jSave == event.getSource():
            if self.jFileName.getText() == Strings.jFileName_default:
                jFileChooser = JFileChooser()
            else:
                jFileChooser = JFileChooser(self.jFileName.getText())
            #self.jFileName.setText(selectedFile.getAbsolutePath())
            result = jFileChooser.showSaveDialog(None)
            if result == JFileChooser.APPROVE_OPTION:
                selectedFile = jFileChooser.getSelectedFile()
                self.jFileName.setText(selectedFile.getAbsolutePath())

                FileUtils.write(selectedFile.toPath(),
                                self.jVarsPane.getText(),
                                self.jScriptPane.getText())

        #Wiki button clicked
        if self.jWiki == event.getSource():
            uri = URI.create("https://github.com/DanNegrea/PyRules")
            if uri and Desktop.isDesktopSupported() and Desktop.getDesktop(
            ).isSupported(Desktop.Action.BROWSE):
                Desktop.getDesktop().browse(uri)

        #Exit button clicked
        if self.jExit == event.getSource():
            result = JOptionPane.showConfirmDialog(
                None, Strings.jExit_confim_question,
                Strings.jExit_confim_title, JOptionPane.YES_NO_OPTION)
            if result == 0:
                self._ui.deleteTab(self)

        #Clear button clicked
        if self.jClear == event.getSource():
            self.jConsoleText.setText("")
            self.log(self._executor.getVars(), "state")

        #Run once button clicked
        if self.jRun == event.getSource():
            if self.isRequestFocusEnabled():
                print "is RequestFocusEnabled"
            else:
                print "is NOT RequestFocusEnabled"
            if self.isFocusOwner():
                print "is FocusOwner"
            else:
                print "is NOT FocusOwner"
            # request to init the vars (if edited)
            self.initVars()
            # request execution with toolFlag set to 999 (Run once)
            self.execute(999)