mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
yeoman: finally — add generator to project wizard
This commit is contained in:
+46
-31
@@ -50,8 +50,8 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
|||||||
private final NullableConsumer<ProjectSettingsStepBase> myCallback;
|
private final NullableConsumer<ProjectSettingsStepBase> myCallback;
|
||||||
protected TextFieldWithBrowseButton myLocationField;
|
protected TextFieldWithBrowseButton myLocationField;
|
||||||
protected File myProjectDirectory;
|
protected File myProjectDirectory;
|
||||||
private JButton myCreateButton;
|
protected JButton myCreateButton;
|
||||||
private JLabel myErrorLabel;
|
protected JLabel myErrorLabel;
|
||||||
|
|
||||||
public ProjectSettingsStepBase(DirectoryProjectGenerator projectGenerator,
|
public ProjectSettingsStepBase(DirectoryProjectGenerator projectGenerator,
|
||||||
NullableConsumer<ProjectSettingsStepBase> callback) {
|
NullableConsumer<ProjectSettingsStepBase> callback) {
|
||||||
@@ -71,10 +71,45 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
|||||||
public JPanel createPanel() {
|
public JPanel createPanel() {
|
||||||
final JPanel mainPanel = new JPanel(new BorderLayout());
|
final JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
myErrorLabel = new JLabel("");
|
final JLabel label = createErrorLabel();
|
||||||
myErrorLabel.setForeground(JBColor.RED);
|
final JButton button = createActionButton();
|
||||||
myCreateButton = new JButton("Create");
|
button.addActionListener(createCloseActionListener());
|
||||||
myCreateButton.addActionListener(new ActionListener() {
|
final JPanel scrollPanel = createAndFillContentPanel();
|
||||||
|
initGeneratorListeners();
|
||||||
|
registerValidators();
|
||||||
|
final JBScrollPane scrollPane = new JBScrollPane(scrollPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||||
|
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
scrollPane.setBorder(null);
|
||||||
|
mainPanel.add(scrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
final JPanel bottomPanel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
|
bottomPanel.add(label, BorderLayout.NORTH);
|
||||||
|
bottomPanel.add(button, BorderLayout.EAST);
|
||||||
|
mainPanel.add(bottomPanel, BorderLayout.SOUTH);
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final JLabel createErrorLabel() {
|
||||||
|
JLabel errorLabel = new JLabel("");
|
||||||
|
errorLabel.setForeground(JBColor.RED);
|
||||||
|
|
||||||
|
myErrorLabel = errorLabel;
|
||||||
|
|
||||||
|
return errorLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final JButton createActionButton() {
|
||||||
|
JButton button = new JButton("Create");
|
||||||
|
button.putClientProperty(DialogWrapper.DEFAULT_ACTION, Boolean.TRUE);
|
||||||
|
|
||||||
|
myCreateButton = button;
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
protected final ActionListener createCloseActionListener() {
|
||||||
|
return new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
boolean isValid = checkValid();
|
boolean isValid = checkValid();
|
||||||
@@ -86,22 +121,7 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
|||||||
myCallback.consume(ProjectSettingsStepBase.this);
|
myCallback.consume(ProjectSettingsStepBase.this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
myCreateButton.putClientProperty(DialogWrapper.DEFAULT_ACTION, Boolean.TRUE);
|
|
||||||
final JPanel scrollPanel = createAndFillContentPanel();
|
|
||||||
initGeneratorListeners();
|
|
||||||
registerValidators();
|
|
||||||
final JBScrollPane scrollPane = new JBScrollPane(scrollPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
|
|
||||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
|
||||||
scrollPane.setBorder(null);
|
|
||||||
mainPanel.add(scrollPane, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
final JPanel bottomPanel = new JPanel(new BorderLayout());
|
|
||||||
|
|
||||||
bottomPanel.add(myErrorLabel, BorderLayout.NORTH);
|
|
||||||
bottomPanel.add(myCreateButton, BorderLayout.EAST);
|
|
||||||
mainPanel.add(bottomPanel, BorderLayout.SOUTH);
|
|
||||||
return mainPanel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final JPanel createContentPanelWithAdvancedSettingsPanel() {
|
protected final JPanel createContentPanelWithAdvancedSettingsPanel() {
|
||||||
@@ -126,7 +146,7 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Icon getIcon() {
|
protected final Icon getIcon() {
|
||||||
return myProjectGenerator.getLogo();
|
return myProjectGenerator.getLogo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,11 +159,6 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
protected JPanel extendBasePanel() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void registerValidators() {
|
protected void registerValidators() {
|
||||||
myLocationField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
myLocationField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||||
@Override
|
@Override
|
||||||
@@ -250,15 +265,15 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
|||||||
return myProjectGenerator;
|
return myProjectGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectLocation() {
|
public final String getProjectLocation() {
|
||||||
return myLocationField.getText();
|
return myLocationField.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(@NotNull final String location) {
|
public final void setLocation(@NotNull final String location) {
|
||||||
myLocationField.setText(location);
|
myLocationField.setText(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LabeledComponent<TextFieldWithBrowseButton> createLocationComponent() {
|
protected final LabeledComponent<TextFieldWithBrowseButton> createLocationComponent() {
|
||||||
myLocationField = new TextFieldWithBrowseButton();
|
myLocationField = new TextFieldWithBrowseButton();
|
||||||
myProjectDirectory = findSequentNonExistingUntitled();
|
myProjectDirectory = findSequentNonExistingUntitled();
|
||||||
myLocationField.setText(myProjectDirectory.toString());
|
myLocationField.setText(myProjectDirectory.toString());
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2015 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.platform;
|
||||||
|
|
||||||
|
import com.intellij.openapi.wm.impl.welcomeScreen.AbstractActionWithPanel;
|
||||||
|
import com.intellij.util.NullableConsumer;
|
||||||
|
|
||||||
|
public interface CustomStepProjectGenerator {
|
||||||
|
AbstractActionWithPanel createStep(DirectoryProjectGenerator projectGenerator,
|
||||||
|
NullableConsumer<? extends AbstractActionWithPanel> callback);
|
||||||
|
}
|
||||||
+1
-2
@@ -133,11 +133,10 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
|
||||||
protected JPanel extendBasePanel() {
|
protected JPanel extendBasePanel() {
|
||||||
if (myProjectGenerator instanceof PythonProjectGenerator)
|
if (myProjectGenerator instanceof PythonProjectGenerator)
|
||||||
return ((PythonProjectGenerator)myProjectGenerator).extendBasePanel();
|
return ((PythonProjectGenerator)myProjectGenerator).extendBasePanel();
|
||||||
return super.extendBasePanel();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user