Skip to content

Commit

Permalink
chore: Added owner field in module wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
satran004 committed Sep 24, 2024
1 parent 808a40a commit 509ed29
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
Expand All @@ -49,6 +50,8 @@ public class AikenModuleBuilder extends ModuleBuilder implements ModuleBuilderLi

private List<Pair<String,String>> mySourcePaths;

private OwnerInputField ownerInputField;

public AikenModuleBuilder() {
addListener(this);
}
Expand Down Expand Up @@ -187,7 +190,9 @@ public void setupRootModel(@NotNull ModifiableRootModel rootModel) throws Config
rootModel.inheritSdk();

String moduleName = rootModel.getModule().getName();
String owner = System.getProperty("user.name");

String ownerInputFieldVal= ownerInputField.getValue();
String owner = ownerInputFieldVal != null? ownerInputFieldVal.trim(): System.getProperty("user.name");

Project project = rootModel.getProject();
String basePath = project.getBasePath();
Expand Down Expand Up @@ -248,7 +253,9 @@ public void setupRootModel(@NotNull ModifiableRootModel rootModel) throws Config

@Override
protected List<WizardInputField<?>> getAdditionalFields() {
return Collections.emptyList();
if (ownerInputField == null)
ownerInputField = new OwnerInputField("owner", System.getProperty("user.name"));
return Collections.singletonList(ownerInputField);
}

@Override
Expand All @@ -272,4 +279,28 @@ public List<Pair<String, String>> getSourcePaths() throws ConfigurationException
return mySourcePaths;
}

class OwnerInputField extends WizardInputField<JTextField> {
private JTextField jt;
protected OwnerInputField(String id, String defaultValue) {
super(id, defaultValue);
jt = new JTextField();
jt.setText(defaultValue);
}

@Override
public @NlsContexts.Label String getLabel() {
return "Owner";
}

@Override
public JTextField getComponent() {
return jt;
}

@Override
public String getValue() {
return jt.getText();
}
}

}

0 comments on commit 509ed29

Please sign in to comment.