Skip to content

Commit

Permalink
fix deprecated API usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Aug 9, 2021
1 parent 96ecb5b commit f5b89e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/zkoss/zkidea/lang/ZulIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
* @author by jumperchen
*/
public class ZulIcons {
public static final Icon FILE = IconLoader.getIcon("/org/zkoss/zkidea/lang/icons/zul.png");
public static final Icon FILE = IconLoader.getIcon("/org/zkoss/zkidea/lang/icons/zul.png", ZulIcons.class);
}
33 changes: 8 additions & 25 deletions src/main/java/org/zkoss/zkidea/project/ZKProjectsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.utils.MavenUtil;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
Expand All @@ -42,34 +44,24 @@
/**
* @author by jumperchen
*/
public class ZKProjectsManager extends AbstractProjectComponent {
public class ZKProjectsManager implements StartupActivity.DumbAware {

private static final Logger LOG = Logger.getInstance(ZKProjectsManager.class);

private final AtomicBoolean isInitialized = new AtomicBoolean();

protected ZKProjectsManager(Project project) {
super(project);
}

public void initComponent() {
StartupManagerEx startupManager = StartupManagerEx.getInstanceEx(this.myProject);

public void runActivity(@NotNull Project project) {
// fix for issue #20
if (!this.myProject.isDefault()) {
startupManager.registerStartupActivity(new Runnable() {
public void run() {
ZKProjectsManager.this.doInit();
}
});
if (!project.isDefault()) {
ZKProjectsManager.this.doInit(project);
}
}

private void doInit() {
private void doInit(@NotNull Project project) {
synchronized (this.isInitialized) {
if (!this.isInitialized.getAndSet(true)) {
// fetch last zul.xsd file
MavenUtil.runWhenInitialized(this.myProject, new DumbAwareRunnable() {
MavenUtil.runWhenInitialized(project, new DumbAwareRunnable() {
public void run() {
// TODO: support with project's ZK version
updateZulSchema();
Expand Down Expand Up @@ -240,13 +232,4 @@ private double getSchemaVersion(File file) {
}
return 0;
}

public void disposeComponent() {
}

public void projectOpened() {
}

public void projectClosed() {
}
}
13 changes: 3 additions & 10 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,9 @@
<projectService serviceImplementation="org.zkoss.zkidea.dom.ZulDomElementDescriptorHolder"/>
</extensions>

<application-components>
<!-- Add your application components here -->
</application-components>

<project-components>
<component>
<implementation-class>org.zkoss.zkidea.project.ZKProjectsManager</implementation-class>
<loadForDefaultProject/>
</component>
</project-components>
<extensions defaultExtensionNs="com.intellij">
<postStartupActivity implementation="org.zkoss.zkidea.project.ZKProjectsManager"/>
</extensions>

<actions>
<!-- Add your actions here -->
Expand Down

0 comments on commit f5b89e2

Please sign in to comment.