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
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)
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))
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))
def __init__(self): if formData.get("func") == "open-file": file = formData.get("file") print " * open.py: Opening file %s..." % file Desktop.getDesktop().open(File(file)) writer = response.getPrintWriter("text/plain") writer.println("{}") writer.close()
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)
def onAboutClick(self, event): """Open the about webpage of this extension. Args: event (obj): The Java on click event. """ Desktop.getDesktop().browse(URI("https://github.com/tijme/graphwave"))
def actionPerformed(self, event): import java.awt.Desktop as Desktop import java.net.URI as URI cmd = event.getActionCommand() if cmd == COMMAND_SEND: Desktop.getDesktop().browse(URI("http://code.google.com/p/mediacomp-jes/issues/list")) self.setVisible(0) self.dispose()
def _button_web_browser_pressed(self, msg): url = "http://pages.bao7uo.com" field = self._get_btn_field_value(msg) if field[0] == "phantomJS_args": url = PhantomJS.uri elif field[0] == "url": url = field[1] Desktop.getDesktop().browse(URI(url))
def actionPerformed(self, event): import java.awt.Desktop as Desktop import java.net.URI as URI cmd = event.getActionCommand() if cmd == COMMAND_SEND: Desktop.getDesktop().browse( URI("http://code.google.com/p/mediacomp-jes/issues/list")) self.setVisible(0) self.dispose()
def __init__(self): writer = response.getPrintWriter("text/plain; charset=UTF-8") jsonResponse = "{}" try: oid = formData.get("oid") object = Services.getStorage().getObject(oid); filePath = object.getMetadata().getProperty("file.path") object.close() print "Opening file '%s'..." % filePath Desktop.getDesktop().open(File(filePath)) except Exception, e: jsonResponse = '{ "message": "%s" }' % e.getMessage()
def __activate__(self, context): self.vc = context writer = self.vc["response"].getPrintWriter( "text/plain; charset=UTF-8") jsonResponse = "{}" try: oid = self.vc["formData"].get("oid") object = Services.getStorage().getObject(oid) filePath = object.getMetadata().getProperty("file.path") object.close() print "Opening file '%s'..." % filePath Desktop.getDesktop().open(File(filePath)) except Exception, e: jsonResponse = '{ "message": "%s" }' % e.getMessage()
def __init__(self, program): url = "https://yeswehack.com/programs/{}".format(program.slug) btn = JButton("Open in browser") btn.addActionListener( CallbackActionListener(lambda _: Desktop.getDesktop().browse(URI(url))) ) self.add(btn)
def mess(): print "unicode() - nie chce dzialc/n" +"unicode() - don't work :(" part01 = "Too old java version pleas upgrade to 7u11 or higher.\n" message = part01 + "Zbyt stara wersja Java prosze zaktualizowac do 7u11 lub wyzszej." jop.showMessageDialog(None, message) try: if platform.dist() == ('debian', 'wheezy/sid'):#for ubuntu getjava = "http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html" else: getjava = "http://www.java.com" desk.getDesktop().browse(url(getjava).toURI()) except: pass sys.exit()
def __init__(self, text="Open In Browser"): self.menuitem = JMenuItem(text) self.menuitem.setEnabled(False) self.menuitem.addActionListener(self) self.openers = [ lambda url: Desktop.getDesktop().browse(URI(url)), lambda url: subprocess.call(["xdg-open", url]), lambda url: subprocess.call(["open", url]) ]
def Launch_Application(self, path): Desktop.getDesktop().open(File(path))
def openURL(self,event): try: Desktop.getDesktop().browse(net.URI(self.url)) except: Runtime.getRuntime().exec("xdg-open "+self.url)
def openURL(self, event): if platform.system() == 'Windows' or platform.system() == 'Darwin': Desktop.getDesktop().browse(net.URI(self.url)) else: Runtime.getRuntime().exec("xdg-open " + self.url)
def __openFile(self): value = formData.get("value") print " * detail.py: opening file %s..." % value Desktop.getDesktop().open(File(value))
def hyperlinkUpdate(self, hle): if hle.EventType.ACTIVATED == hle.getEventType(): desktop = Desktop.getDesktop() desktop.browse(hle.getURL().toURI())
def __openFile(self): file = formData.get("file") print " * detail.py: opening file %s..." % file Desktop.getDesktop().open(File(file))
def startFile(filename): from java.awt import Desktop from java.io import File d = Desktop.getDesktop() d.open(File(filename)) return True
def mouseClicked(self, msg): Desktop.getDesktop().browse(URI("https://translate.google.com"))
def send(self): Desktop.getDesktop().browse(WEBSITE_URI) self.visible = False
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)
from com.jcraft.jsch import JSch from java.lang import System import os import time from ij.gui import GenericDialog from fiji.util.gui import GenericDialogPlus from ij import IJ from java.awt import Desktop from java.net import URI desktop = Desktop.getDesktop() uri = URI("https://colab.research.google.com/drive/1PRgFZnd0OtT6p61Ce2y0POEoKPNtTE5N#scrollTo=uU-B_7MwFohd") #test url desktop.browse(uri) session = None channel = None DIALOG = True if (DIALOG): # ----------------- DIALOG TO FILL GLOBAL PARAMETERS ----- gui = GenericDialog("Parameters") gui.addStringField("NGROK Server address :", "0.tcp.ngrok.io") gui.addStringField("PORT :", "") gui.showDialog() HOST = gui.getNextString() PORT = int(gui.getNextString())
def on_link_click(self, event): if event.getEventType() != event.EventType.ACTIVATED: return url = event.getURL() if url: Desktop.getDesktop().browse(url.toURI())
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")
def __init__(self): self.openers = [ lambda url: Desktop.getDesktop().browse(URI(url)), lambda url: subprocess.call(["xdg-open", url]), lambda url: subprocess.call(["open", url]) ]
def openBrowser(url): from java.awt import Desktop from java.net import URI d = Desktop.getDesktop() d.browse(URI(url)) return True