How to add PackageExplorerView's all toolbars and functionalities to eclipse RCP applications? I used PackageExplorer view id to show the PackageExplorer view. It is showing the view in the rcp application. But after creating the project in the PackageExplorer view, it is not showing the project icons for the prjects created. How to ressolve this issue?
This is a known issue in Eclipse RCP applications.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=234252
The work around is to add some code to your ApplicationWorkbenchAdvisor.java
Here's some more documentation about this issue in RCP
http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/guide/cnf_rcp.htm
I've add this code to my initialize method in order to get the images to show up in the Project Explorer, so you'll need to track down the correct images to add for the Package Explorer if those images are different from these.
public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
// here's some of my code that does some typical RCP type configuration
configurer.setSaveAndRestore(true);
PlatformUI.getPreferenceStore().setValue(
IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, false);
// here is the work around code
/*
* This is a hack to get Project tree icons to show up in the Project Explorer.
* It is descriped in the Eclipse Help Documents here.
*
* http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/guide/cnf_rcp.htm
*
*/
IDE.registerAdapters();
final String ICONS_PATH = "icons/full/";
Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
declareWorkbenchImage(
configurer,
ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT,
ICONS_PATH + "obj16/prj_obj.gif",
true);
declareWorkbenchImage(
configurer,
ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED,
ICONS_PATH + "obj16/cprj_obj.gif",
true);
/*
* End of hack in this method...
*/
}
private void declareWorkbenchImage(IWorkbenchConfigurer configurer_p, Bundle ideBundle, String symbolicName, String path, boolean shared)
{
URL url = ideBundle.getEntry(path);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
configurer_p.declareImage(symbolicName, desc, shared);
}
Hope this helps.
Thanks!
Related
I have registered an action in the EditorPopupMenu (this is right click menu). I also have a bunch of components inside a ToolWindow (that I designed using the GUI Designer plugin) that I want to update the values of.
There have been some posts on the IntelliJ forums about this, and the typical answer seems to advice using the ToolWindow's ContentManager, and obtain the JPanel containing all your components. E.g. the following:
Project p = e.getProject();
ToolWindow toolWindow;
toolWindow = ToolWindowManager.getInstance(p).getToolWindow("My ToolWindow ID");
ContentManager contentManager = toolWindow.getContentManager();
JPanel jp = (JPanel) contentManager.getContent(0).getComponent();
This feels counterintuitive... Having to navigate inside JPanel's to find a bunch of components. What if I decided to put my components inside a different container? Suddenly the way I navigate to my components would break down.
Is it really the most practical way to constrain myself to the way my GUI is built? Can't I access these components in a different way?
I found a way to access my custom myToolWindow. This should help quite some people.
Make sure that your custom MyToolWindow extends the class SimpleToolWindowPanel.
In your custom myToolWindowFactory class, pass your custom MyToolWindow to ContentFactory.createContent() as the first argument. NOT one of the JPanel's inside MyToolWindow as is done in the ToolWindow examples given in the official IntelliJ documentation...
In your MyToolWindow constructor, call the method setContent(<YourJPanelContainingYourComponents>).
I found the answer by experimenting on example 5 from this link:
public JBTabbedTerminalWidget getTerminalWidget(ToolWindow window) {
window.show(null);
if (myTerminalWidget == null) {
JComponent parentPanel = window.getContentManager().getContents()[0].getComponent();
if (parentPanel instanceof SimpleToolWindowPanel) {
SimpleToolWindowPanel panel = (SimpleToolWindowPanel) parentPanel;
JPanel jPanel = (JPanel) panel.getComponents()[0];
myTerminalWidget = (JBTabbedTerminalWidget) jPanel.getComponents()[0];
} else {
NotificationUtils.infoNotification("Wait for Freeline to initialize");
}
}
return myTerminalWidget;
}
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.
(Might not be the appropriate forum to ask, but..)
Is there a way to add a custom code snippet as in Xcode. In Xamarin, ToolBox section, I found the prebuilt code snippets. But if I had to add a new one, its asking for the Assembly.
In Xcode, its like we can select the code and drag onto the codesnippets pane to add it as one.
Any info regarding the same in Xamarin would be most helpful.
Thanks!
In Xamarin Studio open the settings menu:
Windows: Tools > Options
OS X: Xamarin Studio > Preferences
Navigate To Text Editor -> Code Templates
Here you can edit snippets that come with Xamarin studio as well as add new ones. For syntax I'd recommend just looking at one of the already present properties.
E.g. default property looks like this:
public $type$ $name$ {
get;
set;
}
You could change that to have a backing store:
private $type$ _$name$;
public $type$ $name$ {
get { return _$name$; }
set { _$name$ = value; }
}
The following code worked when I followed the tutorial using a new project:
http://www.amazedsaint.com/2011/09/hellotiles-simple-c-xaml-application.html
However, I am unable to get the application's tile to update when I plug-in the same code to my real project.
I have rebuilt the package.
I have uninstalled and redeployed the app.
I have updated the wide logo image file.
I have verified that the same code works when creating a new project.
I have verified the app manifest as suggested by the linked tutorial.
How does this work fine in one solution but not the other?
public MainPage()
{
this.InitializeComponent();
ClearTileNotification();
SendTileTextNotification("Why isn't this working!");
}
void ClearTileNotification()
{
// the same TileUpdateManager can be used to clear the tile since
// tile notifications are being sent to the application's default tile
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
}
void SendTileTextNotification(string text)
{
// Get a filled in version of the template by using getTemplateContent
var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText03);
// You will need to look at the template documentation to know how many text fields a particular template has
// get the text attributes for this template and fill them in
var tileAttributes = tileXml.GetElementsByTagName("text");
tileAttributes[0].AppendChild(tileXml.CreateTextNode(text));
// create the notification from the XML
var tileNotification = new TileNotification(tileXml);
// send the notification to the app's default tile
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
}
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.