Skip to content

Commit

Permalink
modify plugin 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shenhuanet committed Feb 1, 2018
1 parent ddbeaaa commit 172bbd9
Show file tree
Hide file tree
Showing 16 changed files with 334 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Quoit-idea.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

![](https://github.com/shenhuanet/Quoit-idea/blob/master/.idea/icon.png)

A plug-in that generates a two-dimensional code of a specific text.
A plug-in that generates QR Code of a specific text.

## About Me
CSDN:http://blog.csdn.net/klxh2009<br>
Expand Down
66 changes: 34 additions & 32 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
<idea-plugin>
<id>com.shenhua.idea.plugin.quoit</id>
<name>Quoit</name>
<version>1.0.0</version>
<vendor email="shenhuanet@126.com" url="http://www.shenhuanet.com">ShenhuaTech</vendor>
<id>com.shenhua.idea.plugin.quoit</id>
<name>Quoit</name>
<version>1.0.1</version>
<vendor email="shenhuanet@126.com" url="http://www.shenhuanet.com">ShenhuaTech</vendor>

<description><![CDATA[
<description><![CDATA[
A plug-in that generates a two-dimensional code of a specific text.<br>
]]></description>

<change-notes><![CDATA[
<change-notes><![CDATA[
First release.<br>
]]>
</change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="145.0"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<!-- uncomment to enable plugin in all products-->
<depends>com.intellij.modules.lang</depends>

<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<toolWindow id="Quoit" icon="/icon/logo_13.png" anchor="bottom"
canCloseContents="true"
factoryClass="com.shenhua.idea.plugin.quoit.ui.QuoitView"/>
</extensions>

<project-components>
<component>
<implementation-class>com.shenhua.idea.plugin.quoit.MainComponent</implementation-class>
</component>
</project-components>

<actions>
<!-- Add your actions here -->
</actions>
</change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="145.0"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<!-- uncomment to enable plugin in all products-->
<depends>com.intellij.modules.lang</depends>

<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<toolWindow id="Quoit" icon="/icon/logo_13.png" anchor="bottom"
canCloseContents="true"
factoryClass="com.shenhua.idea.plugin.quoit.ui.QuoitView"/>
<projectService serviceInterface="com.shenhua.idea.plugin.quoit.core.HistoryConfig"
serviceImplementation="com.shenhua.idea.plugin.quoit.core.HistoryConfig"/>
</extensions>

<project-components>
<component>
<implementation-class>com.shenhua.idea.plugin.quoit.MainComponent</implementation-class>
</component>
</project-components>

<actions>
<!-- Add your actions here -->
</actions>

</idea-plugin>
1 change: 1 addition & 0 deletions src/com/shenhua/idea/plugin/quoit/MainComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.shenhua.idea.plugin.quoit.actions.*;
import com.shenhua.idea.plugin.quoit.core.HistoryConfigImpl;
import com.shenhua.idea.plugin.quoit.tabs.QuoitContent;
import com.shenhua.idea.plugin.quoit.ui.ToolWindowPanel;
import org.jetbrains.annotations.NotNull;
Expand Down
13 changes: 10 additions & 3 deletions src/com/shenhua/idea/plugin/quoit/actions/ExecAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.shenhua.idea.plugin.quoit.core.ApiImpl;
import com.shenhua.idea.plugin.quoit.tabs.ITabs;
import com.shenhua.idea.plugin.quoit.tabs.QuoitContent;
import com.shenhua.idea.plugin.quoit.ui.ContentWidget;
import org.apache.http.util.TextUtils;

import javax.swing.*;

/**
* Created by shenhua on 2018-01-31-0031.
*
Expand All @@ -35,12 +38,16 @@ public void actionPerformed(AnActionEvent anActionEvent) {
}
String text = contentWidget.getText();
if (TextUtils.isEmpty(text)) {
contentWidget.setInfo("Please Input content.");
return;
}
ApplicationManager.getApplication().invokeLater(() -> {
System.out.println("---- " + text);
// Icon icon = new ApiImpl().getCode(text);
// quoitContent.getInnerWidget().setQRcode(icon);
System.out.println("执行文本:" + text);
Icon icon = new ApiImpl().getCode(text);
contentWidget.setQRcode(icon);
if (!quoitContent.getHistoryWidget().hasSame(text)) {
quoitContent.getHistoryWidget().insert(text);
}
});
}
}
4 changes: 4 additions & 0 deletions src/com/shenhua/idea/plugin/quoit/actions/SaveAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.shenhua.idea.plugin.quoit.core.History;
import com.shenhua.idea.plugin.quoit.core.HistoryConfigImpl;
import com.shenhua.idea.plugin.quoit.tabs.QuoitContent;

/**
Expand Down
8 changes: 7 additions & 1 deletion src/com/shenhua/idea/plugin/quoit/core/History.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shenhua.idea.plugin.quoit.core;

import java.io.Serializable;
import java.util.Date;

/**
Expand All @@ -8,12 +9,17 @@
*
* @author shenhua
*/
public class History {
public class History implements Serializable {

private static final long serialVersionUID = 9009838685298110158L;
private String text;
private Date date;
private String cache;

public History(String text) {
this.text = text;
}

public String getText() {
return text;
}
Expand Down
52 changes: 52 additions & 0 deletions src/com/shenhua/idea/plugin/quoit/core/HistoryConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.shenhua.idea.plugin.quoit.core;

import com.intellij.openapi.components.*;
import com.intellij.openapi.project.Project;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

/**
* Created by shenhua on 2018-02-01-0001.
*
* @author shenhua
* Email shenhuanet@126.com
*/
@State(
name = "Quoit.History",
storages = {@Storage(id = "Quoit", file = StoragePathMacros.WORKSPACE_FILE)}
)
public class HistoryConfig implements PersistentStateComponent<HistoryConfig> {

private HistoryConfig() {
}

private List<String> histories;

static HistoryConfig getInstance(Project project) {
return ServiceManager.getService(project, HistoryConfig.class);
}

@Nullable
@Override
public HistoryConfig getState() {
System.out.println("--- getState");
return this;
}

@Override
public void loadState(HistoryConfig historyConfig) {
System.out.println("--- loadState");
XmlSerializerUtil.copyBean(historyConfig, this);
}

List<String> getHistories() {
return histories;
}

void setHistories(List<String> histories) {
this.histories = histories;
}
}
74 changes: 74 additions & 0 deletions src/com/shenhua/idea/plugin/quoit/core/HistoryConfigImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.shenhua.idea.plugin.quoit.core;

import b.c.H;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

/**
* Created by shenhua on 2018-02-01-0001.
*
* @author shenhua
* Email shenhuanet@126.com
*/
public class HistoryConfigImpl implements Configurable {

private final HistoryConfig historyConfig;
private List<String> histories = new ArrayList<>();

public HistoryConfigImpl(Project project) {
historyConfig = HistoryConfig.getInstance(project);
}

@Nls
@Override
public String getDisplayName() {
return null;
}

@Nullable
@Override
public JComponent createComponent() {
return null;
}

@Override
public boolean isModified() {
return false;
}

/**
* 1.set the histories object want to save;
*
* @param histories histories
*/
public void setHistories(List<String> histories) {
this.histories = histories;
}

/**
* 2.apply;
*
* @throws ConfigurationException e
*/
@Override
public void apply() throws ConfigurationException {
historyConfig.setHistories(histories);
System.out.println("添加成功!" + histories.size());
}

/**
* get histories that it saved.
*
* @return ArrayList<History>
*/
public List<String> getHistories() {
return historyConfig.getHistories();
}
}
40 changes: 40 additions & 0 deletions src/com/shenhua/idea/plugin/quoit/core/HistoryListModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.shenhua.idea.plugin.quoit.core;

import javax.swing.*;
import javax.swing.event.ListDataListener;
import java.util.List;

/**
* Created by shenhua on 2018-02-01-0001.
*
* @author shenhua
* Email shenhuanet@126.com
*/
public class HistoryListModel implements ListModel<String> {

private List<String> histories;

public HistoryListModel(List<String> histories) {
this.histories = histories;
}

@Override
public int getSize() {
return histories == null ? 0 : histories.size();
}

@Override
public String getElementAt(int index) {
return histories.get(index);
}

@Override
public void addListDataListener(ListDataListener l) {

}

@Override
public void removeListDataListener(ListDataListener l) {

}
}
8 changes: 7 additions & 1 deletion src/com/shenhua/idea/plugin/quoit/tabs/QuoitContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public class QuoitContent extends JPanel implements ITabbedWidget {
* main first add
*/
private JComponent mJComponent;
private HistoryWidget historyWidget;

public QuoitContent(Project mProject, Disposable mDisposable) {
super(new BorderLayout());
this.mProject = mProject;
this.mDisposable = mDisposable;
this.add(new HistoryWidget().historyPanel, BorderLayout.EAST);
historyWidget = new HistoryWidget(mProject,this);
this.add(historyWidget.historyPanel, BorderLayout.EAST);
}

@Override
Expand Down Expand Up @@ -84,6 +86,10 @@ public ITabs getTabs() {
return mTabs;
}

public HistoryWidget getHistoryWidget() {
return historyWidget;
}

private static String generateUniqueName(String suggestedName, ITabs tabs) {
Set<String> names = Sets.newHashSet();
for (int i = 0; i < tabs.getTabCount(); i++) {
Expand Down
Loading

0 comments on commit 172bbd9

Please sign in to comment.