import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrameProvider;
+import org.jetbrains.annotations.NotNull;
public class CheckForUpdateAction extends AnAction implements DumbAware {
@Override
- public void update(AnActionEvent e) {
- final String place = e.getPlace();
+ public void update(@NotNull AnActionEvent e) {
+ String place = e.getPlace();
if (ActionPlaces.WELCOME_SCREEN.equals(place) && FlatWelcomeFrameProvider.isAvailable()) {
e.getPresentation().setEnabledAndVisible(true);
- } else {
+ }
+ else {
e.getPresentation().setVisible(!SystemInfo.isMacSystemMenu || !ActionPlaces.MAIN_MENU.equals(place));
}
}
@Override
- public void actionPerformed(AnActionEvent e) {
- UpdateChecker.updateAndShowResult(e.getData(CommonDataKeys.PROJECT), false, UpdateSettings.getInstance());
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ UpdateChecker.updateAndShowResult(e.getProject(), false, UpdateSettings.getInstance());
}
}
public class PluginDownloader {
private static final Logger LOG = Logger.getInstance("#" + PluginDownloader.class.getName());
- @NonNls private static final String FILENAME = "filename=";
+ private static final String FILENAME = "filename=";
private final String myPluginId;
- private String myPluginUrl;
+ private final String myPluginUrl;
private String myPluginVersion;
private String myFileName;
myPluginVersion = pluginVersion;
}
- public PluginDownloader(String pluginId,
- String pluginUrl,
- String pluginVersion,
- String fileName,
- String pluginName,
- BuildNumber buildNumber) {
- myPluginId = pluginId;
- myPluginUrl = pluginUrl;
- myPluginVersion = pluginVersion;
+ public PluginDownloader(String pluginId, String pluginUrl, String pluginVersion, String fileName, String pluginName, BuildNumber buildNumber) {
+ this(pluginId, pluginUrl, pluginVersion);
myFileName = fileName;
myPluginName = pluginName;
myBuildNumber = buildNumber;
return myDepends;
}
+ public void setDescriptor(IdeaPluginDescriptor descriptor) {
+ myDescriptor = descriptor;
+ }
+
+ public IdeaPluginDescriptor getDescriptor() {
+ return myDescriptor;
+ }
+
public static PluginDownloader createDownloader(IdeaPluginDescriptor descriptor) throws UnsupportedEncodingException {
return createDownloader(descriptor, null);
}
- public static PluginDownloader createDownloader(IdeaPluginDescriptor descriptor,
- BuildNumber buildNumber) throws UnsupportedEncodingException {
- PluginDownloader downloader = new PluginDownloader(descriptor.getPluginId().getIdString(),
- UpdateChecker.getDownloadUrl(descriptor, buildNumber),
- descriptor.getVersion(), null, descriptor.getName(), buildNumber);
+ public static PluginDownloader createDownloader(IdeaPluginDescriptor descriptor, BuildNumber buildNumber) throws UnsupportedEncodingException {
+ String string = descriptor.getPluginId().getIdString();
+ String url = UpdateChecker.getDownloadUrl(descriptor, buildNumber);
+ PluginDownloader downloader = new PluginDownloader(string, url, descriptor.getVersion(), null, descriptor.getName(), buildNumber);
downloader.setDescriptor(descriptor);
return downloader;
}
}
return null;
}
-
- public void setDescriptor(IdeaPluginDescriptor descriptor) {
- myDescriptor = descriptor;
- }
-
- public IdeaPluginDescriptor getDescriptor() {
- return myDescriptor;
- }
}
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
storageChooser = LastStorageChooserForWrite.ElementStateLastStorageChooserForWrite.class
)
public class UpdateSettings implements PersistentStateComponent<Element>, UserUpdateSettings {
- private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.updateSettings.impl.UpdateSettings");
+ private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.updateSettings.impl.UpdateSettings");
- @SuppressWarnings({"WeakerAccess", "CanBeFinal"})
public JDOMExternalizableStringList myPluginHosts = new JDOMExternalizableStringList();
-
- @SuppressWarnings({"WeakerAccess", "CanBeFinal"})
public JDOMExternalizableStringList myKnownUpdateChannels = new JDOMExternalizableStringList();
-
- @SuppressWarnings({"WeakerAccess", "CanBeFinal"})
public JDOMExternalizableStringList myIgnoredBuildNumbers = new JDOMExternalizableStringList();
-
public JDOMExternalizableStringList myOutdatedPlugins = new JDOMExternalizableStringList();
public boolean CHECK_NEEDED = true;
updateDefaultChannel();
}
- public void saveLastCheckedInfo() {
- LAST_TIME_CHECKED = System.currentTimeMillis();
- ApplicationInfo appInfo = ApplicationInfo.getInstance();
- LAST_BUILD_CHECKED = appInfo.getBuild().asString();
- }
-
private void updateDefaultChannel() {
if (ApplicationInfoImpl.getShadowInstance().isEAP()) {
UPDATE_CHANNEL_TYPE = ChannelStatus.EAP_CODE;
}
}
+ @SuppressWarnings("deprecation")
+ @Override
public Element getState() {
Element element = new Element("state");
try {
return element;
}
- public void loadState(final Element state) {
+ @SuppressWarnings("deprecation")
+ @Override
+ public void loadState(Element state) {
try {
DefaultJDOMExternalizer.readExternal(this, state);
}
return ChannelStatus.fromCode(UPDATE_CHANNEL_TYPE);
}
- public void forceCheckForUpdateAfterRestart() {
- LAST_TIME_CHECKED = 0;
- }
-
public List<String> getPluginHosts() {
- ArrayList<String> hosts = new ArrayList<String>(myPluginHosts);
+ List<String> hosts = new ArrayList<String>(myPluginHosts);
final String pluginHosts = System.getProperty("idea.plugin.hosts");
if (pluginHosts != null) {
ContainerUtil.addAll(hosts, pluginHosts.split(";"));
}
return hosts;
}
+
+ public void forceCheckForUpdateAfterRestart() {
+ LAST_TIME_CHECKED = 0;
+ }
+
+ public void saveLastCheckedInfo() {
+ LAST_TIME_CHECKED = System.currentTimeMillis();
+ ApplicationInfo appInfo = ApplicationInfo.getInstance();
+ LAST_BUILD_CHECKED = appInfo.getBuild().asString();
+ }
}