use of com.perl5.lang.htmlmason.idea.configuration.HTMLMasonCustomTagRole in project Perl5-IDEA by Camelcade.
the class HTMLMasonBaseLexer method processCustomSimpleOpenTag.
protected IElementType processCustomSimpleOpenTag() {
CharSequence tokenText = yytext();
CharSequence tokenKey = tokenText.subSequence(0, tokenText.length() - 1);
assert myCustomTagsMap != null;
HTMLMasonCustomTag customTag = myCustomTagsMap.get(tokenKey.toString());
if (customTag != null) {
HTMLMasonCustomTagRole tagRole = customTag.getRole();
if (tagRole == HTMLMasonCustomTagRole.ARGS) {
return processArgsOpenTag(ARGS_WITH_CUSTOM_CLOSER);
} else if (tagRole == HTMLMasonCustomTagRole.PERL) {
return processPerlOpenTag(PERL_WITH_CUSTOM_CLOSER);
}
}
return processOpenTagFallback();
}
use of com.perl5.lang.htmlmason.idea.configuration.HTMLMasonCustomTagRole in project Perl5-IDEA by Camelcade.
the class HTMLMasonBaseLexer method processCustomCloseTag.
protected IElementType processCustomCloseTag() {
CharSequence tokenText = yytext();
CharSequence tokenKey = tokenText.subSequence(0, tokenText.length() - 1);
assert myCustomTagsMap != null;
HTMLMasonCustomTag customTag = myCustomTagsMap.get(tokenKey.toString());
if (customTag != null) {
HTMLMasonCustomTagRole tagRole = customTag.getRole();
if (tagRole == HTMLMasonCustomTagRole.METHOD) {
return processMethodCloseTag();
} else if (tagRole == HTMLMasonCustomTagRole.DEF) {
return processDefCloseTag();
}
}
return processCloseTagFallback();
}
use of com.perl5.lang.htmlmason.idea.configuration.HTMLMasonCustomTagRole in project Perl5-IDEA by Camelcade.
the class HTMLMasonParserTest method addCustomTag.
private void addCustomTag(String text, HTMLMasonCustomTagRole role) {
HTMLMasonSettings settings = HTMLMasonSettings.getInstance(getProject());
settings.customTags.add(new HTMLMasonCustomTag(text, role));
settings.settingsUpdated();
}
use of com.perl5.lang.htmlmason.idea.configuration.HTMLMasonCustomTagRole in project Perl5-IDEA by Camelcade.
the class HTMLMasonSettingsConfigurable method createCustomTagsComponent.
protected void createCustomTagsComponent(FormBuilder builder) {
myTagNameColumnInfo myTagNameColumnInfo = new myTagNameColumnInfo();
customTagsModel = new ListTableModel<>(myTagNameColumnInfo, new myTagRoleColumInfo());
myTagNameColumnInfo.setCustomTagsModel(customTagsModel);
customTagsTable = new JBTable(customTagsModel);
final TableColumn secondColumn = customTagsTable.getColumnModel().getColumn(1);
ComboBoxTableRenderer<HTMLMasonCustomTagRole> roleComboBoxTableRenderer = new ComboBoxTableRenderer<HTMLMasonCustomTagRole>(HTMLMasonCustomTagRole.values()) {
@Override
protected String getTextFor(@NotNull HTMLMasonCustomTagRole value) {
return value.getTitle();
}
@Override
public boolean isCellEditable(EventObject event) {
if (event instanceof MouseEvent) {
return ((MouseEvent) event).getClickCount() >= 1;
}
return true;
}
};
secondColumn.setCellRenderer(roleComboBoxTableRenderer);
secondColumn.setCellEditor(roleComboBoxTableRenderer);
builder.addLabeledComponent(new JLabel("Custom tags that mimics built-in HTML::Mason tags:"), ToolbarDecorator.createDecorator(customTagsTable).setAddAction(anActionButton -> {
final TableCellEditor cellEditor = customTagsTable.getCellEditor();
if (cellEditor != null) {
cellEditor.stopCellEditing();
}
final TableModel model = customTagsTable.getModel();
int indexToEdit = -1;
for (HTMLMasonCustomTag entry : customTagsModel.getItems()) {
if (StringUtil.isEmpty(entry.getText())) {
indexToEdit = customTagsModel.indexOf(entry);
break;
}
}
if (indexToEdit == -1) {
customTagsModel.addRow(new HTMLMasonCustomTag("customTag" + customTagsModel.getItems().size(), HTMLMasonCustomTagRole.PERL));
indexToEdit = model.getRowCount() - 1;
}
TableUtil.editCellAt(customTagsTable, indexToEdit, 0);
}).disableDownAction().disableUpAction().setPreferredSize(JBUI.size(0, PerlConfigurationUtil.WIDGET_HEIGHT)).createPanel());
}
Aggregations