-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Alireza-Moh/development
Development
- Loading branch information
Showing
44 changed files
with
1,061 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/at/alirezamoh/whisperer_for_laravel/actions/InertiaPageAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package at.alirezamoh.whisperer_for_laravel.actions; | ||
|
||
import at.alirezamoh.whisperer_for_laravel.actions.views.InertiaPageView; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.project.Project; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class InertiaPageAction extends BaseAction { | ||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent anActionEvent) { | ||
Project project = anActionEvent.getProject(); | ||
InertiaPageView inertiaPageView = new InertiaPageView(project); | ||
|
||
if (inertiaPageView.showAndGet()) { | ||
this.create( | ||
inertiaPageView.getInertiaPageModel(), | ||
"inertiaPage.ftl", | ||
true, | ||
project | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/at/alirezamoh/whisperer_for_laravel/actions/models/InertiaPageModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package at.alirezamoh.whisperer_for_laravel.actions.models; | ||
|
||
import at.alirezamoh.whisperer_for_laravel.settings.SettingsState; | ||
|
||
/** | ||
* Model representing an inertia page | ||
*/ | ||
public class InertiaPageModel extends BaseModel { | ||
private String pageName; | ||
|
||
private boolean withOptionsApi; | ||
|
||
private boolean vue; | ||
|
||
/** | ||
* @param name The name of the inertia page | ||
* @param unformattedModuleFullPath The unformatted module full path | ||
* @param formattedModuleFullPath The formatted module full path | ||
*/ | ||
public InertiaPageModel( | ||
SettingsState settingsState, | ||
String name, | ||
String unformattedModuleFullPath, | ||
String formattedModuleFullPath, | ||
String defaultDestination, | ||
boolean withOptionsApi, | ||
String pageType | ||
) | ||
{ | ||
super( | ||
settingsState, | ||
name, | ||
unformattedModuleFullPath, | ||
formattedModuleFullPath, | ||
defaultDestination, | ||
"", | ||
pageType, | ||
"" | ||
); | ||
|
||
this.pageName = getName(); | ||
this.withOptionsApi = withOptionsApi; | ||
this.vue = pageType.equals(".vue"); | ||
} | ||
|
||
@Override | ||
public void setWithoutModuleSrc() { | ||
this.withoutModuleSrcPath = true; | ||
} | ||
|
||
public String getPageName() { | ||
return pageName; | ||
} | ||
|
||
public boolean isWithOptionsApi() { | ||
return withOptionsApi; | ||
} | ||
|
||
public boolean isVue() { | ||
return vue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
src/main/java/at/alirezamoh/whisperer_for_laravel/actions/views/InertiaPageView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package at.alirezamoh.whisperer_for_laravel.actions.views; | ||
|
||
import at.alirezamoh.whisperer_for_laravel.actions.models.InertiaPageModel; | ||
import at.alirezamoh.whisperer_for_laravel.packages.inertia.InertiaPageCollector; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.ui.ComboBox; | ||
import com.intellij.openapi.ui.ValidationInfo; | ||
import com.intellij.util.ui.JBUI; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.util.Objects; | ||
|
||
public class InertiaPageView extends BaseDialog { | ||
/** | ||
* Text field for entering the inertia page name | ||
*/ | ||
private JTextField inertiaPageNameTextField; | ||
|
||
/** | ||
* Select the destination path | ||
*/ | ||
protected ComboBox<String> resourcePageDirectoryComboBox; | ||
|
||
/** | ||
* Select the page variant | ||
*/ | ||
protected ComboBox<String> pageVariantComboBox; | ||
|
||
/** | ||
* Select the page type | ||
*/ | ||
protected ComboBox<String> pageTypeComboBox; | ||
|
||
/** | ||
* @param project The current project | ||
*/ | ||
public InertiaPageView(Project project) { | ||
super(project); | ||
|
||
setTitle("Create Inertia Page"); | ||
setSize(500, 200); | ||
setResizable(false); | ||
init(); | ||
} | ||
|
||
/** | ||
* Returns the Inertia page model representing an inertia page | ||
* @return The inertia page model | ||
*/ | ||
public InertiaPageModel getInertiaPageModel() { | ||
return new InertiaPageModel( | ||
projectSettingState, | ||
inertiaPageNameTextField.getText(), | ||
"", | ||
"", | ||
resourcePageDirectoryComboBox.getItem(), | ||
Objects.equals(pageVariantComboBox.getItem(), "Options API"), | ||
pageTypeComboBox.getItem() | ||
); | ||
} | ||
|
||
/** | ||
* Returns the focused component when the dialog opens | ||
* @return The preferred focused component | ||
*/ | ||
@Override | ||
public @Nullable JComponent getPreferredFocusedComponent() { | ||
return inertiaPageNameTextField; | ||
} | ||
|
||
/** | ||
* Validates the dialog input | ||
* @return Validation info if there are errors, null otherwise | ||
*/ | ||
@Override | ||
protected @Nullable ValidationInfo doValidate() { | ||
String text = inertiaPageNameTextField.getText().trim(); | ||
|
||
if (text.isEmpty()) { | ||
return new ValidationInfo("", inertiaPageNameTextField); | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Creates the center panel of the dialog | ||
* @return The center panel | ||
*/ | ||
@Override | ||
protected JComponent createCenterPanel() { | ||
contentPane = new JPanel(); | ||
contentPane.setLayout(new GridBagLayout()); | ||
|
||
inertiaPageNameTextField = new JTextField(); | ||
resourcePageDirectoryComboBox = new ComboBox<>(InertiaPageCollector.getInertiaPaths(project).toArray(new String[0])); | ||
pageVariantComboBox = new ComboBox<>(new String[]{"Options API", "Composition API"}); | ||
pageTypeComboBox = new ComboBox<>(new String[]{".vue", ".jsx"}); | ||
|
||
gbc.fill = GridBagConstraints.HORIZONTAL; | ||
gbc.weightx = 1.0; | ||
|
||
gbc.gridx = 0; | ||
gbc.gridy = 0; | ||
|
||
gbc.insets = JBUI.insetsLeft(3); | ||
contentPane.add(new JLabel("Enter page name:"), gbc); | ||
gbc.insets = JBUI.insetsLeft(0); | ||
gbc.insets = JBUI.insetsBottom(15); | ||
gbc.gridy++; | ||
contentPane.add(inertiaPageNameTextField, gbc); | ||
inertiaPageNameTextField.requestFocusInWindow(); | ||
|
||
gbc.gridy++; | ||
gbc.insets = JBUI.insetsLeft(3); | ||
contentPane.add(new JLabel("Page type:"), gbc); | ||
gbc.insets = JBUI.insetsLeft(0); | ||
gbc.insets = JBUI.insetsBottom(15); | ||
gbc.gridy++; | ||
contentPane.add(pageTypeComboBox, gbc); | ||
|
||
gbc.gridy++; | ||
gbc.insets = JBUI.insetsLeft(3); | ||
contentPane.add(new JLabel("Page variant: (Ignore if it's not a Vue file)"), gbc); | ||
gbc.insets = JBUI.insetsLeft(0); | ||
gbc.insets = JBUI.insetsBottom(15); | ||
gbc.gridy++; | ||
contentPane.add(pageVariantComboBox, gbc); | ||
|
||
gbc.gridy++; | ||
this.gbc.insets = JBUI.insetsLeft(3); | ||
this.contentPane.add(new JLabel("Page resource directory:"), this.gbc); | ||
this.gbc.gridy++; | ||
this.gbc.insets = JBUI.insetsLeft(0); | ||
this.gbc.insets = JBUI.insetsBottom(15); | ||
this.contentPane.add(resourcePageDirectoryComboBox, this.gbc); | ||
|
||
return contentPane; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.