Created
February 7, 2017 08:53
-
-
Save itsakt/72f43f526ba34af71ff706704a0eb4a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.akt.awesomeplugin; | |
import com.intellij.openapi.project.Project; | |
import com.intellij.openapi.wm.ToolWindow; | |
import com.intellij.openapi.wm.ToolWindowFactory; | |
import com.intellij.ui.content.Content; | |
import com.intellij.ui.content.ContentFactory; | |
import org.jetbrains.annotations.NotNull; | |
import javax.swing.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
public class ToolWindowHandler implements ToolWindowFactory { | |
private JPanel toolWindowContent; | |
private JTextField txtName; | |
private JButton btnGo; | |
private JLabel lblHello; | |
@Override | |
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { | |
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); | |
Content content = contentFactory.createContent(toolWindowContent, "", false); | |
toolWindow.getContentManager().addContent(content); | |
StorageHelper storageHelper = StorageHelper.getInstance(project); | |
StorageHelper.State mState = storageHelper.getState(); | |
txtName.setText(mState.name); | |
lblHello.setText("Hello " + mState.name + " o/"); | |
btnGo.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
String name = txtName.getText(); | |
lblHello.setText("Hello " + name + " o/"); | |
mState.name = name; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment