use of com.perl5.lang.mason2.idea.configuration.VariableDescription in project Perl5-IDEA by Camelcade.
the class AbstractMasonSettingsConfigurable method createGlobalsComponent.
public void createGlobalsComponent(FormBuilder builder) {
globalsModel = new ListTableModel<>(new myVariableNameColumnInfo(), new myVariableTypeColumnInfo());
globalsTable = new JBTable(globalsModel);
builder.addLabeledComponent(new JLabel("Components global variables (allow_globals option):"), ToolbarDecorator.createDecorator(globalsTable).setAddAction(anActionButton -> {
final TableCellEditor cellEditor = globalsTable.getCellEditor();
if (cellEditor != null) {
cellEditor.stopCellEditing();
}
final TableModel model = globalsTable.getModel();
int indexToEdit = -1;
for (VariableDescription variableDescription : globalsModel.getItems()) {
if (StringUtil.isEmpty(variableDescription.variableName)) {
indexToEdit = globalsModel.indexOf(variableDescription);
break;
}
}
if (indexToEdit == -1) {
globalsModel.addRow(new VariableDescription());
indexToEdit = model.getRowCount() - 1;
}
TableUtil.editCellAt(globalsTable, indexToEdit, 0);
}).disableDownAction().disableUpAction().setPreferredSize(JBUI.size(0, PerlConfigurationUtil.WIDGET_HEIGHT)).createPanel());
}
use of com.perl5.lang.mason2.idea.configuration.VariableDescription in project Perl5-IDEA by Camelcade.
the class HTMLMasonSettingsConfigurable method apply.
@Override
public void apply() {
boolean forceReparse = isStructureModified();
Set<String> extDiff = getDiff(mySettings.substitutedExtensions, substitutedExtensionsModel.getItems());
mySettings.substitutedExtensions.clear();
mySettings.substitutedExtensions.addAll(substitutedExtensionsModel.getItems());
mySettings.autoHandlerName = autohandlerName.getText();
mySettings.defaultHandlerName = defaulthandlerName.getText();
mySettings.globalVariables.clear();
for (VariableDescription variableDescription : new ArrayList<>(globalsModel.getItems())) {
if (StringUtil.isNotEmpty(variableDescription.variableName)) {
mySettings.globalVariables.add(variableDescription);
} else {
globalsModel.removeRow(globalsModel.indexOf(variableDescription));
}
}
mySettings.customTags.clear();
mySettings.customTags.addAll(customTagsModel.getItems());
mySettings.settingsUpdated();
if (!extDiff.isEmpty() || forceReparse) {
// fixme move this logic to the settings
WriteAction.run(() -> FileTypeManagerEx.getInstanceEx().fireFileTypesChanged());
}
}
use of com.perl5.lang.mason2.idea.configuration.VariableDescription in project Perl5-IDEA by Camelcade.
the class HTMLMasonArgsDefVariablesResolveTest method doTestResolve.
@Override
public void doTestResolve() {
HTMLMasonSettings settings = HTMLMasonSettings.getInstance(getProject());
settings.globalVariables.add(new VariableDescription("$product", "Foo::Bar"));
settings.settingsUpdated();
super.doTestResolve();
}
use of com.perl5.lang.mason2.idea.configuration.VariableDescription in project Perl5-IDEA by Camelcade.
the class HTMLMasonSettingsConfigurable method reset.
@Override
public void reset() {
substitutedExtensionsModel.removeAll();
substitutedExtensionsModel.add(mySettings.substitutedExtensions);
autohandlerName.setText(mySettings.autoHandlerName);
defaulthandlerName.setText(mySettings.defaultHandlerName);
customTagsModel.setItems(new ArrayList<>());
for (HTMLMasonCustomTag htmlMasonCustomTag : mySettings.customTags) {
customTagsModel.addRow(htmlMasonCustomTag.clone());
}
globalsModel.setItems(new ArrayList<>());
for (VariableDescription variableDescription : mySettings.globalVariables) {
globalsModel.addRow(variableDescription.clone());
}
}
use of com.perl5.lang.mason2.idea.configuration.VariableDescription in project Perl5-IDEA by Camelcade.
the class MasonCoreUtil method fillVariablesList.
public static void fillVariablesList(PsiElement parent, List<PerlVariableDeclarationElement> targetList, List<VariableDescription> sourceList) {
for (VariableDescription variableDescription : sourceList) {
String variableType = variableDescription.variableType;
if (StringUtil.isEmpty(variableType)) {
variableType = null;
}
targetList.add(PerlImplicitVariableDeclaration.createGlobal(parent, variableDescription.variableName, variableType));
}
}
Aggregations