Java Code Examples for com.intellij.ui.ToolbarDecorator#setAddAction()

The following examples show how to use com.intellij.ui.ToolbarDecorator#setAddAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonConfigView.java    From easy_javadoc with Apache License 2.0 5 votes vote down vote up
private void createUIComponents() {
    typeMapList = new JBList<>(new CollectionListModel<>(Lists.newArrayList()));
    typeMapList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    typeMapList.setCellRenderer(new ListCellRendererWrapper<Entry<String, String>>() {
        @Override
        public void customize(JList list, Entry<String, String> value, int index, boolean selected, boolean hasFocus) {
            setText(value.getKey() + " -> " + value.getValue());
        }
    });

    typeMapList.setEmptyText("请添加单词映射");
    typeMapList.setSelectedIndex(0);
    ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(typeMapList);
    toolbarDecorator.setAddAction(button -> {
        WordMapAddView wordMapAddView = new WordMapAddView();
        if (wordMapAddView.showAndGet()) {
            if (config != null) {
                Entry<String, String> entry = wordMapAddView.getMapping();
                config.getWordMap().put(entry.getKey(), entry.getValue());
                refreshWordMap();
            }
        }
    });
    toolbarDecorator.setRemoveAction(anActionButton -> {
        if (config != null) {
            Map<String, String> typeMap = config.getWordMap();
            typeMap.remove(typeMapList.getSelectedValue().getKey());
            refreshWordMap();
        }
    });
    wordMapPanel = toolbarDecorator.createPanel();
}
 
Example 2
Source File: LatteVariableSettingsForm.java    From intellij-latte with MIT License 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
	ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<LatteVariableSettings>() {
		@Override
		public LatteVariableSettings createElement() {
			//IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true);
			return null;
		}

		@Override
		public boolean canCreateElement() {
			return true;
		}
	});

	tablePanel.setEditAction(anActionButton ->
			LatteVariableSettingsForm.this.openVariablePathDialog(LatteVariableSettingsForm.this.tableView.getSelectedObject())
	);

	tablePanel.setAddAction(anActionButton ->
			LatteVariableSettingsForm.this.openVariablePathDialog(null)
	);

	tablePanel.disableUpAction();
	tablePanel.disableDownAction();

	this.panelConfigTableView.add(tablePanel.createPanel());

	return this.panel1;
}
 
Example 3
Source File: LatteCustomFunctionSettingsForm.java    From intellij-latte with MIT License 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
	ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<LatteFunctionSettings>() {
		@Override
		public LatteFunctionSettings createElement() {
			//IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true);
			return null;
		}

		@Override
		public boolean canCreateElement() {
			return true;
		}
	});

	tablePanel.setEditAction(anActionButton ->
			LatteCustomFunctionSettingsForm.this.openFunctionDialog(LatteCustomFunctionSettingsForm.this.tableView.getSelectedObject())
	);

	tablePanel.setAddAction(anActionButton ->
			LatteCustomFunctionSettingsForm.this.openFunctionDialog(null)
	);

	tablePanel.disableUpAction();
	tablePanel.disableDownAction();

	this.panelConfigTableView.add(tablePanel.createPanel());

	return this.panel1;
}
 
Example 4
Source File: LatteCustomMacroSettingsForm.java    From intellij-latte with MIT License 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
	ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<LatteTagSettings>() {
		@Override
		public LatteTagSettings createElement() {
			//IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true);
			return null;
		}

		@Override
		public boolean canCreateElement() {
			return true;
		}
	});

	tablePanel.setEditAction(anActionButton ->
			LatteCustomMacroSettingsForm.this.openMacroDialog(LatteCustomMacroSettingsForm.this.tableView.getSelectedObject())
	);

	tablePanel.setAddAction(anActionButton ->
			LatteCustomMacroSettingsForm.this.openMacroDialog(null)
	);

	tablePanel.disableUpAction();
	tablePanel.disableDownAction();

	this.panelConfigTableView.add(tablePanel.createPanel());

	return this.panel1;
}
 
Example 5
Source File: LatteCustomModifierSettingsForm.java    From intellij-latte with MIT License 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
	ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<LatteFilterSettings>() {
		@Override
		public LatteFilterSettings createElement() {
			//IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true);
			return null;
		}

		@Override
		public boolean canCreateElement() {
			return true;
		}
	});

	tablePanel.setEditAction(anActionButton ->
			LatteCustomModifierSettingsForm.this.openModifierDialog(LatteCustomModifierSettingsForm.this.tableView.getSelectedObject())
	);

	tablePanel.setAddAction(anActionButton ->
			LatteCustomModifierSettingsForm.this.openModifierDialog(null)
	);

	tablePanel.disableUpAction();
	tablePanel.disableDownAction();

	this.panelConfigTableView.add(tablePanel.createPanel());

	return this.panel1;
}
 
Example 6
Source File: MethodSignatureTypeSettingsForm.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
    ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<MethodSignatureSetting>() {
        @Override
        public MethodSignatureSetting createElement() {
            //IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true);
            return null;
        }

        @Override
        public boolean canCreateElement() {
            return true;
        }
    });

    tablePanel.setEditAction(anActionButton ->
        MethodSignatureTypeSettingsForm.this.openTwigPathDialog(MethodSignatureTypeSettingsForm.this.tableView.getSelectedObject())
    );

    tablePanel.setAddAction(anActionButton ->
        MethodSignatureTypeSettingsForm.this.openTwigPathDialog(null)
    );

    tablePanel.disableUpAction();
    tablePanel.disableDownAction();

    this.panelConfigTableView.add(tablePanel.createPanel());

    return this.panel1;
}
 
Example 7
Source File: MethodParameterReferenceSettingsForm.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
    ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<MethodParameterSetting>() {
        @Override
        public MethodParameterSetting createElement() {
            //IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true);
            return null;
        }

        @Override
        public boolean canCreateElement() {
            return true;
        }
    });

    tablePanel.setEditAction(anActionButton ->
        MethodParameterReferenceSettingsForm.this.openTwigPathDialog(MethodParameterReferenceSettingsForm.this.tableView.getSelectedObject())
    );

    tablePanel.setAddAction(anActionButton ->
        MethodParameterReferenceSettingsForm.this.openTwigPathDialog(null)
    );

    tablePanel.disableUpAction();
    tablePanel.disableDownAction();

    this.panelConfigTableView.add(tablePanel.createPanel());

    return this.panel1;
}
 
Example 8
Source File: UseAliasListForm.java    From idea-php-annotation-plugin with MIT License 4 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
    ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<UseAliasOption>() {
        @Override
        public UseAliasOption createElement() {
            return null;
        }

        @Override
        public boolean canCreateElement() {
            return true;
        }
    });

    tablePanel.setEditAction(anActionButton -> {

        UseAliasOption useAliasOption = tableView.getSelectedObject();
        if(useAliasOption == null) {
            return;
        }

        UseAliasForm.create(panel1, useAliasOption, option -> {
            tableView.getTableViewModel().fireTableDataChanged();
            changed = true;
        });
    });

    tablePanel.setAddAction(anActionButton -> UseAliasForm.create(panel1, option -> {
        tableView.getListTableModel().addRow(option);
        changed = true;
    }));

    tablePanel.setRemoveAction(anActionButton -> {
        modelList.removeRow(tableView.getSelectedRow());
        tableView.getTableViewModel().fireTableDataChanged();
        changed = true;
    });

    tablePanel.disableDownAction();
    tablePanel.disableUpAction();

    this.panel1.add(tablePanel.createPanel());

    return this.panel;
}