In Eclipse plugin development How to open standard View like InternalWebBrowser or bring up/activate Console View (all those standard things)?
To open the Internal Browser you need this code:
int style = IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.STATUS;
IWebBrowser browser = WorkbenchBrowserSupport.getInstance().createBrowser(style, "MyBrowserID", "MyBrowserName", "MyBrowser Tooltip");
browser.openURL(new URL("http://www.google.de"));
Alternative:
final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser("abc");
browser.openURL(new URL("http://www.google.de"));
To open a view use this:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(arg0);
Related
In my current project, there is a situation where we have one file let's say "File1.cfg" in project explorer. There is a default editor "Editor 1" registered using "*.editors" extension.
Requirement Function:
When a user double click on the File1.cfg, it should be opened with an "Editor 1" by default and all the time.
There is one more option provided in Toolbar which will be used to open "Editor 2". And this editor should use the resource "File1.cfg" and display the contents as per the UI.
How can this be achieved in the Eclipse?
A plug-in can specify the editor id to be used when opening an editor. See IWorkbenchPage.openEditor and IDE.openEditor.
Normally these APIs check for an editor (of any id) already being open on the file. If you want to force the editor with the given id to open regardless you need to use the IWorkbenchPage method:
IEditorPart openEditor(IEditorInput input, String editorId, boolean activate,
int matchFlags)
with the matchFlags value set to:
IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT
to only match an existing editor with the same id and input.
When our application is installed by install4j on a Gnome 3 desktop in Linux, and the application runs: the Application menu, located beside the Activities button which shows the name of the active application is showing "com-install4j-runtime-launcher-UnixLauncher".
Is there a setting in install4j so that our application name shows up properly instead?
As of install4j 7, there is only a hack to achieve this:
Define the compiler variable
sys.ext.windowClass.<nn>=MyAppName
where <nn> is the ID of the launcher and MyAppName must not contain spaces.
This will add a "StartupWMClass" entry to the .desktop file.
For the AWT, the actual window class has to be set to the same value programmatically. This is not possible with an API, but just by using reflection:
String wmClass = ...;
Toolkit toolkit = Toolkit.getDefaultToolkit();
Class<?> toolkitClass = toolkit.getClass();
if (Objects.equals("sun.awt.X11.XToolkit", toolkitClass.getName())) {
//noinspection JavaReflectionMemberAccess
Field awtAppClassName = toolkitClass.getDeclaredField("awtAppClassName");
awtAppClassName.setAccessible(true);
awtAppClassName.set(null, wmClass);
}
I'm new to IntelliJ Idea and working with IntelliJ Idea 15. I'm working on a react project. I want something which can generate a react component by the direct click in that folder. e.g.
Now there should be an option for making a new React Component. Upon clicking that a pop-up should open which should ask what files I want to add in the Component's Directory. e.g. the structure should be :
e.g.
Component
Component.js
index.js
component.scss
test Directory
Component.test.js
These should be configured according to the need of user. I don't know java and anything about IntelliJ plugins development. How can I do it?
Go to the template settings:
Windows and Linux: File | Settings | Editor | File and Code Templates
macOS: IntelliJ IDEA | Preferences | Editor | File and Code Templates
Click on the plus button and add a new template:
Name: React Component
Extension: js
This template works well for me:
import React, { PropTypes, Component } from 'react';
class ${NAME} extends Component {
render() {
const { } = this.props;
return (
<div>
</div>
);
}
}
${NAME}.propTypes = {
};
export default ${NAME};
You can also PureComponent or add some default props if you like.
I don't think so that you need such a structure of the component. React components are pretty much straight forward. You just create a JavaScript file and write like that.
import React, {Component} from 'react';
class YourComponent extends Component {
render() {
return(
<h1>Hello React</h1>
)
}
}
export default YourComponent;
In my eclipse plugin I need to get the selection in the package explorer.
I found out that this works like this:
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ISelectionService service = window.getSelectionService();
IStructuredSelection structured = (IStructuredSelection) service.getSelection("org.eclipse.jdt.ui.PackageExplorer");
Object selection = structured.getFirstElement();
This works fine in 99% of all cases but I recently ran into a case where the getSelection("org.eclipse.jdt.ui.PackageExplorer"); returns null although I can clearly see that I have something selected in the package explorer...
How can that be?
Check that the view is not the Project Explorer rather than Package Explorer. They can look very similar and both default to appearing in the same place.
My question is: I want to find the name of currently opened dialog(being displayed on top of all views) and finally reload it. Can anyone guide me for this ?
If the dialog is focused, you can access its Shell via:
Shell active = Display.getCurrent().getActiveShell();
String title = active.getText();
If you are using Eclipse RCP, you can do the same by using:
Shell active = PlatformUI.getWorkbench().getDisplay().getActiveShell();
String title = active.getText();