summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/openapi/application/ConfigImportSettings.java
blob: b0d4d3f909c2902fad88926031953bfb9ffab3dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * Copyright 2000-2012 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.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.openapi.application;

import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.SystemProperties;
import com.intellij.util.ThreeState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.Collections;
import java.util.List;

/**
 * User: ksafonov
 */
public class ConfigImportSettings {

  public String getExecutableName() {
    return getProductName(ThreeState.NO);
  }

  public String[] getMainJarNames() {
    return new String[]{getProductName(ThreeState.NO)};
  }

  protected String getProductName(ThreeState full) {
    ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
    if (full == ThreeState.YES) {
      return namesInfo.getFullProductName();
    }
    else if (full == ThreeState.NO) {
      return namesInfo.getProductName();
    }
    else {
      return namesInfo.getProductName().equals("IDEA") ? namesInfo.getFullProductName() : namesInfo.getProductName();
    }
  }

  protected String getInaccessibleHomeErrorText(String instHome) {
    return ApplicationBundle.message("error.no.read.permissions", instHome);
  }

  protected String getInvalidHomeErrorText(String productWithVendor, String instHome) {
    return ApplicationBundle.message("error.does.not.appear.to.be.installation.home", instHome,
                                     productWithVendor);
  }

  protected String getCurrentHomeErrorText(String productWithVendor) {
    return ApplicationBundle.message("error.selected.current.installation.home",
                                     productWithVendor, productWithVendor);
  }

  protected String getEmptyHomeErrorText(String productWithVendor) {
    return ApplicationBundle.message("error.please.select.previous.installation.home", productWithVendor);
  }

  protected String getHomeLabel(String productName) {
    return ApplicationBundle.message("editbox.installation.home", productName);
  }

  protected String getAutoImportLabel(File guessedOldConfig) {
    String path = guessedOldConfig.getAbsolutePath();
    if (SystemInfo.isUnix) {
      path = path.replace(SystemProperties.getUserHome(), "~");
    }
    return ApplicationBundle.message("radio.import.auto", path);
  }

  protected String getDoNotImportLabel(String productName) {
    return ApplicationBundle.message("radio.do.not.import", productName);
  }

  protected String getTitleLabel(String productName) {
    return ApplicationBundle.message("label.you.can.import", productName);
  }

  @Nullable
  public String getCustomPathsSelector() {
    return null;
  }

  public String getInstallationHomeRequiredTitle() {
    return ApplicationBundle.message("title.installation.home.required");
  }

  public void importFinished(String newConfigPath) {
  }

  @NotNull
  public List<File> getCustomLaunchFilesCandidates(final File ideInstallationHome, 
                                                   final File ideBinFolder) {
    // custom files where to find config folder or path selector properties.
    // by default "Info.plist", "idea.properties"; "idea.sh,idea.bat,..." and 
    // "product_lower_name.sh, product_lower_name.bat,..." are used
    return Collections.emptyList();
  }
}