private void setStatus(ConnectedSonarLintEngine.State state) { ConnectedSonarLintEngine.State currentState = engine.getState(); StringBuilder builder = new StringBuilder(); switch (currentState) { case NEVER_UPDATED: builder.append("never updated"); break; case UPDATED: GlobalStorageStatus storageStatus = engine.getGlobalStorageStatus(); if (storageStatus != null) { builder.append(DateUtils.toAge(storageStatus.getLastUpdateDate().getTime())); } else { builder.append("up to date"); } break; case UPDATING: builder.append("updating.."); break; case NEED_UPDATE: builder.append("needs update"); break; case UNKNOW: default: builder.append("unknown"); break; } serverStatus.setText(builder.toString()); updateServerButton.setEnabled(state != ConnectedSonarLintEngine.State.UPDATING); }
@Test public void connected() { ConnectedSonarLintEngine engine = factory.createEngine("id"); assertThat(engine).isNotNull(); assertThat(engine.getGlobalStorageStatus()).isNull(); engine.stop(true); verify(log, atLeastOnce()).log(anyString(), any(LogOutput.Level.class)); } }
@Override public void start(boolean forceUpdate) { GlobalStorageStatus globalStorageStatus = engine.getGlobalStorageStatus(); if (forceUpdate) { LOGGER.info("Updating binding.."); update(); } else if (globalStorageStatus == null) { LOGGER.info("No binding storage found. Updating.."); update(); } else if (globalStorageStatus.isStale()) { LOGGER.info("Binding storage is stale. Updating.."); update(); } else { checkModuleStatus(); } }
Server(String id) { this.id = id; ConnectedGlobalConfiguration globalConfig = ConnectedGlobalConfiguration.builder() .setServerId(getId()) .setWorkDir(StoragePathManager.getServerWorkDir(getId())) .setStorageRoot(StoragePathManager.getServerStorageRoot()) .setLogOutput(new SonarLintAnalyzerLogOutput()) .build(); this.client = new ConnectedSonarLintEngineImpl(globalConfig); this.client.addStateListener(this); this.updateStatus = client.getGlobalStorageStatus(); if (client.getState().equals(State.UPDATED)) { reloadProjects(); } }