• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package com.update.check.action;
17 
18 import com.update.check.action.view.ConstString;
19 import com.update.check.action.view.MessageBox;
20 import com.update.check.action.view.UpdateCheckWizardDialog;
21 import com.update.check.log.Logger;
22 import com.update.check.utils.MyProjectHelper;
23 import com.intellij.openapi.actionSystem.AnAction;
24 import com.intellij.openapi.actionSystem.AnActionEvent;
25 import com.intellij.openapi.project.Project;
26 import org.jetbrains.annotations.NotNull;
27 
28 import java.io.File;
29 
30 /**
31  * ToCheck
32  *
33  * @since 23-04-07
34  */
35 public class ToCheck extends AnAction {
36     private static final Logger LOGGER = Logger.createLogger();
37 
38     private static final String TAG = ToCheck.class.getName();
39 
40     @Override
actionPerformed(@otNull AnActionEvent e)41     public void actionPerformed(@NotNull AnActionEvent e) {
42         Project project = e.getProject();
43 
44         if (project == null) {
45             return;
46         }
47 
48         if (!MyProjectHelper.isOpenHarmonyProject(project.getBasePath())) {
49             MessageBox.showDialog(project, "", ConstString.get("not.openHarmony.project"));
50             return;
51         }
52         initLogConfig(project.getBasePath().concat(ConstString.get("check.log.path")));
53         LOGGER.info(TAG, "Check start");
54         UpdateCheckWizardDialog.showDialog(project);
55     }
56 
57     /**
58      * initLogConfig
59      *
60      * @param logDir logDir
61      */
initLogConfig(String logDir)62     private void initLogConfig(String logDir) {
63         File logFile = new File(logDir);
64         if (!logFile.exists()) {
65             logFile.mkdirs();
66         }
67         Logger.init(logDir);
68     }
69 }
70