I am trying to write an Eclipse plugin where one of the features requires listening for when the user switches to another file in the editor via clicking.
For example, consider the screenshot below.
I want to know how to listen for when the user switching over to FakeClass.java via double-clicking on it in the Project Explorer or clicking on the tab in the editor. Furthermore, I would like to get information about the element that was clicked. Note that I am asking specifically about changing a file through the two means I asked above.
I am a beginner with Plugin development. It would be helpful to explain with that in mind. Thanks.
You can use an IPartListener to listen for changes to parts including a part being activated:
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.addPartListener(listener);
The partActivated method of the listener is probably what you want:
#Override
public void partActivated(final IWorkbenchPart part)
{
if (part instanceof IEditorPart) {
IEditorPart editor = (IEditorPart)part;
IEditorInput input = editor.getEditorInput();
IFile file = input.getAdapter(IFile.class);
if (file != null) {
// TODO handle file
}
}
}
I don't know of a way to tell why the part was activated.
Is there a shortcut to run all cells in an IPython notebook?
And if not, does this have a specific reason?
For the latest jupyter notebook, (version 5) you can go to the 'help' tab in the top of the notebook and then select the option 'edit keyboard shortcuts' and add in your own customized shortcut for the 'run all' function.
Easiest solution:
Win/Linux:
Esc (unselect potential cells or edit modes)
CtrlA (select all cells)
ShiftEnter (run all selected)
Mac:
Esc (unselect potential cells or edit modes)
⌘A (select all cells)
ShiftEnter (run all selected)
There is a menu shortcut to run all cells under Cell > "Run All". This isn't bound to a keyboard shortcut by default- you'll have to define your own custom binding from within the notebook, as described here.
For example, to add a keyboard binding that lets you run all the cells in a notebook, you can insert this in a cell:
%%javascript
Jupyter.keyboard_manager.command_shortcuts.add_shortcut('r', {
help : 'run all cells',
help_index : 'zz',
handler : function (event) {
IPython.notebook.execute_all_cells();
return false;
}}
);
If you run this code from within iPython notebook, you should find that you now have a keyboard binding to run all cells (in this case, press ctrl-M followed by r)
Jupyter Lab 1.0.4:
In the top menu, go to: Settings->Advanced Settings Editor->Keyboard Shortcuts
Paste this code in the User Preferences window:
{
"shortcuts": [
{
"command": "runmenu:run-all",
"keys": [
"R",
"R"
],
"selector": "[data-jp-kernel-user]:focus"
}
]
}
Save (top right of the user-preferences window)
This will be effective immediately. Here, two consecutive 'R' presses runs all cells (just like two '0' for kernel restart).
Notably, system defaults has empty templates for all menu commands, including this code (search for run-all). The selector was copied from kernelmenu:restart, to allow printing r within cells. This system defaults copy-paste can be generalized to any command.
I've been trying to do this in Jupyter Lab so thought it might be useful to post the answer here. You can find the shortcuts in settings and also add your own, where a full list of the possible shortcuts can be found here.
For example, I added my own shortcut to run all cells. In Jupyter Lab, under Settings > Advanced Settings, select Keyboard Shortcuts, then add the following code to 'User Overrides':
{
"notebook:run-all-cells": {
"command": "notebook:run-all-cells",
"keys": [
"Shift Backspace"
],
"selector": ".jp-Notebook.jp-mod-editMode"
}
}
Here, Shift + Backspace will run all cells in the notebook.
In windows/linux:
Ctrl + A (Select all)
Ctrl + Enter (Run selected cells)
As of 5.5 you can run Kernel > Restart and Run All
If you're working in JupyterLab, you can edit the JSON settings directly to add a simple keyboard shortcut to "run all cells".
In the Jupyter window, go to "Settings" --> "Advanced Settings Editor".
Click on the "JSON Settings Editor" button in the top right.
In the "User Preferences" window, add the following to the top of the JSON file to bind a key like "F9" to "run all cells":
{
"args": {},
"command": "runmenu:run-all",
"keys": [
"F9"
],
"selector": "[data-jp-code-runner]"
}
If you don't want to keep incrementing your run order numbers and/or want to reset your run order numbers, you can also assign a keybind to "Restart kernel and run all cells", like to "F8":
{
"args": {},
"command": "runmenu:restart-and-run-all",
"keys": [
"F8"
],
"selector": "[data-jp-code-runner]"
},
Also, here's how to run all cells above or below your current cell:
{
"args": {},
"command": "notebook:run-all-above",
"keys": [
"Ctrl Shift A"
],
"selector": "[data-jp-code-runner]"
},
{
"args": {},
"command": "notebook:run-all-below",
"keys": [
"Ctrl Shift B"
],
"selector": "[data-jp-code-runner]"
},
FYI, the "selectors" are CSS selectors, you can inspect the Jupyter window in your browser's dev console to find and see them. The selector "[data-jp-code-runner]" corresponds to the individual Jupyter window tabs.
Also, in JupyterLab, doing "Esc" and "Command + a" and "Shift enter" works but is a bit wrong because it creates a new blank code cell at the bottom of your notebook everytime you do so. What you should do instead is "Ctrl enter" or "Command enter", instead of "Shift enter".
A very simple way to do so with IPython that worked for me in Visual Studio Code is to add the following:
{
"key": "ctrl+space",
"command": "jupyter.runallcells"
}
to the keybindings.json that you can access by typing F1 and 'open keyboard shortcuts'.
For Windows 10
For latest Jupyter Notebook version go to Help > Edit Keyboard Shortcuts > run all cells > Then click + sign to add shortcut I would type Z then click + again to add > then click OK to save.
I want to uncheck and hide the overwriteexisting file in sharepoint 2010 iam opening the addnew item of a list in a popup as shown below .
where to add the jquery to hide this elements.
Without customzing Upload.aspx page, we can uncheck the checkbox and modify the contents of "Overwrite existing file" for a specific library using below steps:
1) Create a js file and refer it in master page.
2) Note down the GUID of library.
3) Add the below code.
$(document).ready(function () {
if (location.href.indexOf('2C63AAA5-BC95-41E4-A199-B7658F44736B') >= 0)
{
$('#ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_OverwriteSingle').prop('checked', false);
$("label[for='ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_OverwriteSingle']").text("My Custom");
}
});
I am creating a directory using Phonegap. I am getting success while using code. But I need to check where my folder is created. I found link they told these link.
/Users/UserName/Library/Application Support/iPhone Simulator/4.3.2/Applications
/Users/loginname/Library/Application Support/iPhone Simulator/6.1/Applications/YOUR_APP/Documents
But I don't have any iPhone simulator folder in application support? Where I will search?
I have Xcode 4.5 version
How to find android directory using the same code .i am able to in Ios
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail);
}
function onFileSystemSuccess(fileSystem) {
console.log(fileSystem.name);
var directoryEntry = fileSystem.root;
directoryEntry.getDirectory("newDir", {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail)
}
function onDirectorySuccess(parent) {
//alert("onSuccess")
console.log(parent);
// alert(parent+"Directory");
}
function onDirectoryFail(error) {
alert("Unable to create new directory: " + error.code);
}
function onFileSystemFail(evt) {
console.log(evt.target.error.code);
alert(evt.target.error.code);
}
The simplest solution is just copy the url
Go to the finder and press command + shift + G and paste your url and press Go
You don't need to enable hidden file.
make sure you're not searching for it because you will get the wrong application folder, you have to go to your "user name" folder and make it show hidden files and that will show the hidden library file so you can start navigating your way to that address... try that and anymore issues with it ill try and help further.
if you dont know how to open terminal go to search magnifying glass top right corner, click it and in the finder search bar type in terminal and press enter. a terminal window will pop up and after you copy this line " defaults write com.apple.Finder AppleShowAllFiles TRUE " copy that without the " " part. now right click "if you have a two buttton mouse " on that terminal window and click paste from the menu that pops up, now press enter. now last thing is to close all finder windows so copy this " killall Finder " without quotes and paste that in terminal and press enter...now your hidden folders will come up in your finder windows and the new faded hidden librarry folder will be under mac/users/"whatever ur username is "/
I am trying to develop my first plug-in.
The plug-in should manipulate the content of the selected text in the active text editor.
I started with the “hello world” example from the “Cheat sheet” which worked perfect.
When tried to modify I found that project not recognizing many types.
I added the following jars to the project build path libraries:
org.eclipse.jface.text_3.5.1.r351_v20090708-0800.jarorg.eclipse.text_3.5.0.v20090513-2000.jarorg.eclipse.ui.editors_3.5.0.v20090527-2000.jar
Now code compiles perfect.
ISelection iSelection = null;
IEditorSite iEditorSite = window.getActivePage().getActiveEditor().getEditorSite();
if (iEditorSite != null) {
ISelectionProvider iSelectionProvider = iEditorSite.getSelectionProvider();
if (iSelectionProvider != null)
{
iSelection = iSelectionProvider.getSelection();
selectedText = ((ITextSelection)iSelection).getText();
}
}
The problem is in line 08. although eclipse recognize the ITextSelection interface, at runtime I get cannot resolve type exception.
When trying to deploy the code I get the following line in the deploy log:
The import org.eclipse.jface.text cannot be resolved
Did you try, in the Run configuration dialog, to open the "Plugins" tab and click the button "add required plug-ins" ?
It might add the right runtime dependencies for you.
See also that same button in the dependencies tab of your plugin project:
alt text http://www.vogella.de/articles/RichClientPlatform/images/product50.gif
(more in the article "Products and Branding")
See also this SO answer for more checks.