Button callback to show the file selector
6022
@Override
  public void actionPerformed(ActionEvent e) {
    // Use a new JFileChooser. Inconsistent behaviour otherwise!
    final JFileChooser fc = new JFileChooser(new File("."));
    if(param.isDefined()) {
      fc.setSelectedFile(param.getValue());
    }

    if(e.getSource() == button) {
      int returnVal = fc.showOpenDialog(button);
      if(returnVal == JFileChooser.APPROVE_OPTION) {
        textfield.setText(fc.getSelectedFile().getPath());
        fireValueChanged();
      }
      // else: do nothing on cancel.
    }
    else if(e.getSource() == textfield) {
      fireValueChanged();
    }
    else {
      LoggingUtil.warning("actionPerformed triggered by unknown source: " + e.getSource());
    }
  }
979679
function bindToClick(selector, handler) {
    var elems = document.querySelectorAll(selector);
    var i = -1;
    var len = elems.length;
    while (++i < len) {
      elems[i].addEventListener('click', handler);
    }
  }
1105958
protected void openFileChooser()
   {
      if (m_model.getShowDialog())
      {
         if (m_fileChooser.showOpenDialog(m_parent) == JFileChooser.APPROVE_OPTION)
         {
            m_model.setFile(m_fileChooser.getSelectedFile());
         }
         m_model.setShowDialog(false);
      }
   }
588856
function _attachChangeAndDefaultFileEvent(form_id) {
        var _this = this;

        var elements = this._collection[form_id].getInputs();
        [].forEach.call(elements, function (form_control) {

            _this.__attachSingleChangeEvent(form_id, form_control);
            _this.__observeSingleValueChange(form_id, form_control);

            // set default file input value
            if (form_control.type === 'file' && form_control.hasAttribute('value')) {
                var url = form_control.getAttribute('value');
                if (url !== '') {
                    _this.setFileFromUrl(form_id, form_control.name, url);
                }
            }
        });
    }
1035984
function makeCallbackButton (labelIndex) {
        return function () {
            if (modalWindow) {
                modalWindow.removeEventListener('unload', onUnload, false);
                modalWindow.close();
            }
          // checking if prompt
            var promptInput = modalDocument.getElementById('prompt-input');
            var response;
            if (promptInput) {
                response = {
                    input1: promptInput.value,
                    buttonIndex: labelIndex
                };
            }
            response = response || labelIndex;
            callback(response);
        };
    }
1359138
def _on_click(self, event):
        
        if callable(self.__callback):
            self.__callback(self.selection)
529670
@Override
    public File showDialog(WindowBasedTextGUI textGUI) {
        selectedFile = null;
        super.showDialog(textGUI);
        return selectedFile;
    }
221522
function openFile(themeId, folderName, fileName) {
        if (themeId && folderName && fileName) {
            //if image then display it
            if (folderName === "images") {
                showImage(themeId, folderName, fileName);
                return;
            }

            var options = {
                url:getURL("show") + "/" + themeId + "/" + folderName + "/" + fileName,
                success:function (response) {
                    if (response.status === "error") {
                        util.showErrorFlash(response.message);
                    }
                    else {
                        // if js, css or jade file then show in editor
                        var mode = "scss";
                        if (fileName.indexOf(".js") > -1) {
                            mode = "javascript";
                        }
                        else if (fileName.indexOf(".css") > -1) {
                            mode = "css";
                        }

                        initAceEditor(themeId, folderName, fileName, response, mode);
                    }
                }
            };
            Rocket.ajax(options);
        }
    }
840805
private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed
		final File dir = lastOpenDirectory();
		final JFileChooser chooser = dir != null
			? new JFileChooser(dir)
			: new JFileChooser();
		chooser.setDialogTitle("Choose Image");
		chooser.setDialogType(JFileChooser.OPEN_DIALOG);
		chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
		chooser.setMultiSelectionEnabled(false);
		chooser.addChoosableFileFilter(new FileNameExtensionFilter(
			format(
				"Images (%s)",
				Stream.of(ImageIO.getReaderFileSuffixes())
					.map(s -> format(" *.%s", s))
					.collect(Collectors.joining(","))
			),
			ImageIO.getReaderFileSuffixes()
		));

		final int returnVal = chooser.showOpenDialog(this);
		if (returnVal == JFileChooser.APPROVE_OPTION) {
			final File imageFile = chooser.getSelectedFile();
			try {
				update(ImageIO.read(imageFile));
				if (imageFile.getParentFile() != null) {
					lastOpenDirectory(imageFile.getParentFile());
				}
			} catch (IOException e) {
				JOptionPane.showMessageDialog(
					rootPane,
					format("Error while loading image '%s'.", imageFile),
					e.toString(),
					JOptionPane.ERROR_MESSAGE
				);
			}
		}
	}
1180951
public function viewFileManager()
    {
        $this->setFileFileManager();
        $this->setAccessFileManager();
        $this->setDataMessagesFileManager();

        $this->setData('access', $this->data_access);
        $this->setData('command', $this->data_command);
        $this->setData('selected', $this->data_selected);
        $this->setData('tabs', $this->getTabsFileManager());
        $this->setData('actions', $this->getActionsFileManager());
        $this->setData('process_selected', $this->isQuery('selected'));

        $this->submitFileManager();
        $this->setDataContendFileManager();

        $rendered = $this->render('file_manager|filemanager', $this->data);

        if ($this->isQuery('output')) {
            $this->response->outputHtml($rendered);
        }

        $this->setJsFileManager();
        $this->setCssFileManager();

        $this->setTitleFileManager();
        $this->setBreadcrumbFileManager();

        $this->setData('rendered_filemanager', $rendered);
        $this->outputViewFileManager();
    }
1070727
private void selectAlbum() {
        Album.album(this)
                .multipleChoice()
                .filterMimeType(new Filter<String>() { // MimeType of File.
                    @Override
                    public boolean filter(String attributes) {
                        // MimeType: image/jpeg, image/png, video/mp4, video/3gp...
                        return attributes.contains("jpeg");
                    }
                })
                // .filterSize() // File size.
                // .filterDuration() // Video duration.
                .afterFilterVisibility(mAfterFilterVisibility)
                .columnCount(2)
                .selectCount(6)
                .camera(true)
                .checkedList(mAlbumFiles)
                .widget(
                        Widget.newDarkBuilder(this)
                                .title(mToolbar.getTitle().toString())
                                .build()
                )
                .onResult(new Action<ArrayList<AlbumFile>>() {
                    @Override
                    public void onAction(@NonNull ArrayList<AlbumFile> result) {
                        mAlbumFiles = result;
                        mAdapter.notifyDataSetChanged(mAlbumFiles);
                        mTvMessage.setVisibility(result.size() > 0 ? View.VISIBLE : View.GONE);
                    }
                })
                .onCancel(new Action<String>() {
                    @Override
                    public void onAction(@NonNull String result) {
                        Toast.makeText(AlbumFilterActivity.this, R.string.canceled, Toast.LENGTH_LONG).show();
                    }
                })
                .start();
    }
1114450
def show_extent_selector(self):
        """"""
        # import here only so that it is AFTER i18n set up
        from safe.gui.tools.extent_selector_dialog import ExtentSelectorDialog
        widget = ExtentSelectorDialog(
            self.iface,
            self.iface.mainWindow(),
            extent=self.dock_widget.extent.user_extent,
            crs=self.dock_widget.extent.crs)
        widget.clear_extent.connect(
            self.dock_widget.extent.clear_user_analysis_extent)
        widget.extent_defined.connect(
            self.dock_widget.define_user_analysis_extent)
        # This ensures that run button state is updated on dialog close
        widget.extent_selector_closed.connect(
            self.dock_widget.validate_impact_function)
        # Needs to be non modal to support hide -> interact with map -> show
        widget.show()
214843
def bind_download_buttons(cls):
        
        def on_click(ev):
            button_el = ev.target
            form_el = button_el.parent.parent.parent

            # this allows to use disabled <textearea>, which is normally not
            # sent
            content = form_el.get(selector="textarea")[0].text

            # change filename according to output
            suffix = form_el.name
            download_path = "as_file/%s.%s" % (cls.filename, suffix)
            form_el.action = join(settings.API_PATH, download_path)

            input_el = form_el.get(selector="input")[0]
            input_el.value = content

        for el in document.get(selector="button.output_download_button"):
            el.bind("click", on_click)
62782
function fileRef(item, network, bucket, selected){

		this.els = [];
		this.selected = false;

		this.item = {};

		// Item contents change
		this.update = function(item){
			if(!item){
				return this.item;
			}
			else {
				// Merge the two together
				this.item = hello.utils.merge(this.item, item);
			}

			// Loop through the elements and update their content
			for(var i=0;i<this.els.length;i++){
				this.els[i].getElementsByTagName('span')[0].innerHTML = this.item.name;
				if(this.item.thumbnail){
					this.els[i].getElementsByTagName('img')[0].src = this.item.thumbnail;
				}
			}
		};

		// Create an element in the given bucket,
		// adding on click event handlers
		this.create = function(bucket){
			var item = this.item;
			var self = this;
			var el = doc.createElement('li');
			el.title = item.name;
			el.innerHTML = "<img "+(item.thumbnail?"src='"+item.thumbnail+"'":"")+"/>"
							+"<span>"+(item.name||'')+"</span>";
			el.onclick = function(){
				// Is this a folder?
				if(item.type==='folder'||item.type==='album'){
					getBucket(network+":"+(item.files?item.files:item.id+"/files"), item.name, bucket.id );
				}
				else {
					// Toggle selected
					self.toggleSelect();
				}
			};
			// Add to bucket
			bucket.appendChild(el);

			// Add to local store
			this.els.push(el);

			return el;
		};


		this.toggleSelect = function(bool){

			if(bool===this.selected){
				// nothing
				return;
			}
			// else change

			// toggle
			this.selected = !this.selected;

			// Selected
			if(this.selected){
				// Does the element exist within the local bucket
				var local = false;
				for(i=0;i<this.els.length;i++){
					if( this.els[i].parentNode === select_el ){
						local=true;
						break;
					}
				}
				if(!local){
					// create it
					this.create(select_el);
				}
			}

			// Loop through the elements and update their content
			for(i=0;i<this.els.length;i++){
				this.els[i].className = this.selected ? "select" : "";
			}

			// get the number of selected items in ref and update
			info_el.innerHTML = ( this.selected ? ++global_counter : --global_counter );
		};

		// Create the initial element
		this.update(item);
		this.create(bucket);

		// if this is selected
		if(selected){
			this.toggleSelect();
		}
	}
1091514
def make_button_widget(cls, label, file_path=None, handler=None, style=None, layout=Layout(width='auto')):
        ""
        btn = widgets.Button(description=label, layout=layout)
        if handler is not None: btn.on_click(handler)
        if style is not None: btn.button_style = style
        btn.file_path = file_path
        btn.flagged_for_delete = False
        return btn
1315401
function _eventHandler(filePath) {
  // Ignore hidden files
  if (/^\..*/.test(filePath)) return;

  if (extname(filePath).match(reSass)) {
    setTimeout(() => {
      this.callback();
      this.refresh(filePath);
    });
    return;
  }

  this.callback();
  Logger.info(`LiveReload: ${filePath}`);
}
1160695
def directory_button_status(self):
        """"""
        if self.layer.currentLayer():
            self.directory_button.setEnabled(True)
        else:
            self.directory_button.setEnabled(False)