public void initComponent() { log.info("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); // System.out.println("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); // Set runtime constants IDE_NAME = PlatformUtils.getPlatformPrefix(); IDE_VERSION = ApplicationInfo.getInstance().getFullVersion(); if (!Dependencies.isCLIInstalled()) { log.info("Downloading and installing wakatime-cli ..."); Dependencies.installCLI(); } else if (Dependencies.isCLIOld()) { log.info("Upgrading wakatime-cli ..."); Dependencies.upgradeCLI(); } if (Dependencies.isPythonInstalled()) { WakaTime.DEBUG = WakaTime.isDebugEnabled(); if (WakaTime.DEBUG) { log.setLevel(Level.DEBUG); log.debug("Logging level set to DEBUG"); } log.debug("Python location: " + Dependencies.getPythonLocation()); log.debug("CLI location: " + Dependencies.getCLILocation()); // prompt for apiKey if it does not already exist if (ApiKey.getApiKey().equals("")) { Project project = ProjectManager.getInstance().getDefaultProject(); ApiKey apiKey = new ApiKey(project); apiKey.promptForApiKey(); } log.debug("Api Key: " + ApiKey.getApiKey()); // add WakaTime item to File menu ActionManager am = ActionManager.getInstance(); PluginMenu action = new PluginMenu(); am.registerAction("WakaTimeApiKey", action); DefaultActionGroup fileMenu = (DefaultActionGroup) am.getAction("FileMenu"); fileMenu.addSeparator(); fileMenu.add(action); // Setup message listeners MessageBus bus = ApplicationManager.getApplication().getMessageBus(); connection = bus.connect(); connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new CustomSaveListener()); EditorFactory.getInstance() .getEventMulticaster() .addDocumentListener(new CustomDocumentListener()); log.debug("Finished initializing WakaTime plugin"); } else { Messages.showErrorDialog( "WakaTime requires Python to be installed.\nYou can install it from https://www.python.org/downloads/\nAfter installing Python, restart your IDE.", "Error"); } }
/** Marshall the given parameter object, and output to a JSONWriter */ public void marshall(ApiKey apiKey, JSONWriter jsonWriter) { if (apiKey == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonWriter.object(); if (apiKey.getId() != null) { jsonWriter.key("id").value(apiKey.getId()); } if (apiKey.getName() != null) { jsonWriter.key("name").value(apiKey.getName()); } if (apiKey.getDescription() != null) { jsonWriter.key("description").value(apiKey.getDescription()); } if (apiKey.getEnabled() != null) { jsonWriter.key("enabled").value(apiKey.getEnabled()); } java.util.List<String> stageKeysList = apiKey.getStageKeys(); if (stageKeysList != null) { jsonWriter.key("stageKeys"); jsonWriter.array(); for (String stageKeysListValue : stageKeysList) { if (stageKeysListValue != null) { jsonWriter.value(stageKeysListValue); } } jsonWriter.endArray(); } if (apiKey.getCreatedDate() != null) { jsonWriter.key("createdDate").value(apiKey.getCreatedDate()); } if (apiKey.getLastUpdatedDate() != null) { jsonWriter.key("lastUpdatedDate").value(apiKey.getLastUpdatedDate()); } jsonWriter.endObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }