mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 11:20:44 +07:00
default package choosing strategy
This commit is contained in:
+1
-1
@@ -51,7 +51,7 @@
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="com.example"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9ff82" class="javax.swing.JCheckBox" binding="myHelloAndroidCheckBox">
|
||||
|
||||
+33
-4
@@ -45,11 +45,11 @@ public class AndroidAppPropertiesEditor {
|
||||
private JLabel myErrorLabel;
|
||||
private JPanel myContentPanel;
|
||||
|
||||
private final String myModuleName;
|
||||
|
||||
public AndroidAppPropertiesEditor(String moduleName) {
|
||||
myModuleName = moduleName;
|
||||
myApplicationNameField.setText(moduleName);
|
||||
if (moduleName != null) {
|
||||
myApplicationNameField.setText(moduleName);
|
||||
myPackageNameField.setText(getDefaultPackageNameByModuleName(moduleName));
|
||||
}
|
||||
myHelloAndroidCheckBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateActivityPanel();
|
||||
@@ -71,6 +71,31 @@ public class AndroidAppPropertiesEditor {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getDefaultPackageNameByModuleName(@NotNull String moduleName) {
|
||||
return "com.example." + toIdentifier(moduleName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String toIdentifier(@NotNull String s) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
for (int i = 0, n = s.length(); i < n; i++) {
|
||||
final char c = s.charAt(i);
|
||||
|
||||
if (Character.isJavaIdentifierPart(c)) {
|
||||
if (i == 0 && !Character.isJavaIdentifierStart(c)) {
|
||||
result.append('_');
|
||||
}
|
||||
result.append(c);
|
||||
}
|
||||
else {
|
||||
result.append('_');
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public void updateActivityPanel() {
|
||||
myErrorLabel.setForeground(Color.RED);
|
||||
UIUtil.setEnabled(myActivtiyPanel, myHelloAndroidCheckBox.isSelected(), true);
|
||||
@@ -155,6 +180,10 @@ public class AndroidAppPropertiesEditor {
|
||||
return myApplicationNameField;
|
||||
}
|
||||
|
||||
public JTextField getPackageNameField() {
|
||||
return myPackageNameField;
|
||||
}
|
||||
|
||||
public JPanel getActivtiyPanel() {
|
||||
return myActivtiyPanel;
|
||||
}
|
||||
|
||||
@@ -241,8 +241,12 @@ public class AndroidModuleWizardStep extends ModuleWizardStep {
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
myAppPropertiesEditor.getApplicationNameField().setText(myModuleBuilder.getName());
|
||||
final String moduleName = myModuleBuilder.getName();
|
||||
|
||||
if (moduleName != null) {
|
||||
myAppPropertiesEditor.getApplicationNameField().setText(moduleName);
|
||||
myAppPropertiesEditor.getPackageNameField().setText(AndroidAppPropertiesEditor.getDefaultPackageNameByModuleName(moduleName));
|
||||
}
|
||||
Sdk selectedSdk = mySdkComboBoxWithBrowseButton.getSelectedSdk();
|
||||
final PropertiesComponent properties = PropertiesComponent.getInstance();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user