Bringing up my a Jpanel/Jframe when file of type .lite is opened

Hi,

I want to open up my custom editor when a file with extension .lite is opned( using double click or Ctrl + Shift + N). To start with i am trying to bring up a Jpanel. I have implemented

1. FileEditorProvider

2. FileEditor

I guess something is wrong with component registration. Can some one point out what i am missing?

0
13 comments

Hello Deeps,

1. There is no need to register your FileEditorProvider as both an application
component and an extension. It should be only registered as an extension.
2. If some method is annotated as @NotNull, it means that "return null;"
is not an acceptable implementation of the method. Please implement all methods
correctly.

Hi,

I want to open up my custom editor when a file with extension .lite is
opned( using double click or Ctrl + Shift + N). To start with i am
trying to bring up a Jpanel. I have implemented

1. FileEditorProvider
2. FileEditor
I guess something is wrong with component registration. Can some one
point out what i am missing?

//EditorProvider

public class BswLiteEditorProvider implements
ApplicationComponent,FileEditorProvider, DumbAware {
@Override
*public boolean accept(@NotNull Project project, @NotNull
VirtualFile virtualFile) {
return virtualFile.getExtension().equals("lite");
}*
@NotNull
@Override
*public FileEditor createEditor(@NotNull Project project, @NotNull
VirtualFile virtualFile) {
return new BswLiteEditor(project, virtualFile);
}*
@Override
*public void disposeEditor(@NotNull FileEditor fileEditor) {
Disposer.dispose(fileEditor);
}*
@NotNull
@Override
*public FileEditorState readState(@NotNull Element element,
@NotNull Project project, @NotNull VirtualFile virtualFile) {
return new FileEditorState() {
public boolean canBeMergedWith(FileEditorState otherState,
FileEditorStateLevel level) {
return false;
}
};
}*
@Override
public void writeState(@NotNull FileEditorState fileEditorState,
@NotNull Project project, @NotNull Element element) {
}
@NotNull
@Override
public String getEditorTypeId() {
return null;
}
@NotNull
@Override

  • public FileEditorPolicy getPolicy() {

return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
}*
@Override
public void initComponent() {
}
@Override
public void disposeComponent() {
}
@NotNull
@Override
public String getComponentName() {
return null;
}
}
//FileEditor

public class BswLiteEditor implements FileEditor {
JPanel panel = new JPanel();
public BswLiteEditor(Project project, VirtualFile file) {
panel.setVisible(true);
}
public BswLiteEditor() {
}
@NotNull
@Override

  • public JComponent getComponent() {

return panel;
}*
@Override
public JComponent getPreferredFocusedComponent() {
return panel;
}
@NotNull
@Override
public String getName() {
return null;
}
@NotNull
@Override
public FileEditorState getState(@NotNull FileEditorStateLevel
fileEditorStateLevel) {
return null;
}
@Override
public void setState(@NotNull FileEditorState fileEditorState) {
}
@Override
public boolean isModified() {
return false;
}
@Override
public boolean isValid() {
return false;
}
@Override
public void selectNotify() {
}
@Override
public void deselectNotify() {
}
@Override
public void addPropertyChangeListener(@NotNull
PropertyChangeListener propertyChangeListener) {
}
@Override
public void removePropertyChangeListener(@NotNull
PropertyChangeListener propertyChangeListener) {
}
@Override
public BackgroundEditorHighlighter getBackgroundHighlighter() {
return null;
}
@Override
public FileEditorLocation getCurrentLocation() {
return null;
}
@Override
public StructureViewBuilder getStructureViewBuilder() {
return null;
}
@Override
public void dispose() {
}
@Override
public <T> T getUserData(@NotNull Key<T> tKey) {
return null;
}
@Override
public <T> void putUserData(@NotNull Key<T> tKey, @Nullable T t) {
}
}
//Plugin.xml

<idea-plugin version="2">
<name>Plugin name here</name>
<description>short description of the plugin</description>
<version>1.0</version>
<vendor>YourCompany</vendor>
<idea-version since-build="8000"/>
<application-components>
<component>

<implementation-class>com.gs.plugin.BswLiteEditor.BswLiteEditorProvide
r</implementation-class>
</component>
</application-components>
<project-components>
<!-- Add your project components here -->
</project-components>
<actions>
<!-- Add your actions here -->
<action id="com.gs.plugin.BswLiteEditor.BswLiteEditorAction"

text="com.gs.plugin.BswLiteEditor.BswLiteEditorAction"

description="com.gs.plugin.BswLiteEditor.BswLiteEditorAction">
<add-to-group group-id="FileMenu" anchor="first"/>
</action>
</actions>
<extensions defaultExtensionNs="com.intellij">
<fileEditorProvider
implementation="com.gs.plugin.BswLiteEditor.BswLiteEditorProvider"/>
</extensions>
</idea-plugin>
---
Original message URL:
http://devnet.jetbrains.net/message/5303937#5303937


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

Thanks Dmitry.

I have implemented all the methods annotated as nonnull but still I do not see a Jpanel on double clicking a  the file  abc.lite.

0

Hello Deeps,

I have implemented all the methods annotated as nonnull but still I do
not see a Jpanel on double clicking a  the file  abc.lite.


You should see two tabs at the bottom of the window, one of them with the
standard text editor and another with your editor.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

Hello,

Thanks for your help.

But I do not see tabs at the bottom, am i missing something. I tried debugging it by adding a break point in BswLiteEditorProvider, but it never stopeed there.

0

Hello Deeps,

Is your plugin shown in the list of plugins on the Welcome screen when you
run the plugin run configuration?

Hello,

Thanks for your help.

But I do not see tabs at the bottom, am i missing something. I tried
debugging it by adding a break point in BswLiteEditorProvider, but it
never stopeed there.

---
Original message URL:
http://devnet.jetbrains.net/message/5303954#5303954


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

Hi Dmitry.


I do not see the current editor on welcome screen. It shows few other plugins that i have tried under "My plugins" header and a strange 'Non higlighted "  one with "plugin name disabled" title which can not be clicked.
Is it necessary to have an action registered in plugin.xml, to get it working?

Thank you very much for the help.

Deeps.

0

Hello Deeps,

I do not see the current editor on welcome screen. It shows few other
plugins that i have tried under "My plugins" header and a strange 'Non
higlighted "  one with "plugin name disabled" title which can not be
clicked.


Are you trying to get your plugin running in IntelliJ IDEA or in some other
IntelliJ Platform-based IDE?

Is it necessary to have an action registered in plugin.xml, to get it
working?


No, that's not necessary.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

Thanks Dmitry. It worked when i changed the name field in plugin.xml.

Is there any way to get java input and output files from Virtual Files so that i can use the parsers i have written for my standalone editor. I am using stream tokenizer in my editor for parsing.

Thanks a ton.

0
Avatar
Permanently deleted user

It worked, i can open up I/O streams for the virtual file caught by the editorProvider. I am able to change the content through my editor and save them. But I am not able to see them immediately in the textEditor. It takes some time for the text editor to show the changes.

Is there any way to refresh the text editor?

Deepanshu.

0

Hello Deeps,

It worked, i can open up I/O streams for the virtual file caught by
the editorProvider. I am able to change the content through my editor
and save them. But I am not able to see them immediately in the
textEditor. It takes some time for the text editor to show the
changes.

Is there any way to refresh the text editor?


You should be performing modifications through a Document, not through a
VirtualFile.
See http://confluence.jetbrains.net/display/IDEADEV/IntelliJIDEAArchitectural+Overview
for more information.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

Thanks Dmitry.

But it is working now. Using the virtualFile caught in the FileEditor i am getting the filePath. And uding the filepath i am opening a filestream and doing my editing etc.

After i save using the ouputFileStream i do not see the changes reflected in the textFileEditor tab. Is there any way i can refresh it.

0

Hello Deeps,

There are many ways to accomplish a task in an IntelliJ IDEA plugin that
seem to be working, and fewer correct ways to accomplish the task. If you
are modifying the contents of a text file in IntelliJ IDEA, the correct way
to accomplish this task is through the Document interface.

Thanks Dmitry.

But it is working now. Using the virtualFile caught in the FileEditor
i am getting the filePath. And uding the filepath i am opening a
filestream and doing my editing etc.

After i save using the ouputFileStream i do not see the changes
reflected in the textFileEditor tab. Is there any way i can refresh
it.

---
Original message URL:
http://devnet.jetbrains.net/message/5304227#5304227


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.