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

The following examples show how to use com.intellij.ui.ToolbarDecorator#createDecorator() . 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: DataSourcesView.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 6 votes vote down vote up
public void initToolWindow(Project project, ToolWindow toolWindow) {
    if (!initialized) {
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        Content content = contentFactory.createContent(toolWindowContent, "", false);
        toolWindow.getContentManager().addContent(content);

        component = project.getComponent(DataSourcesComponent.class);
        componentMetadata = project.getComponent(DataSourcesComponentMetadata.class);
        dataSourceMetadataUi = new DataSourceMetadataUi(componentMetadata);
        treeRoot = new PatchedDefaultMutableTreeNode(new RootTreeNodeModel());
        treeModel = new DefaultTreeModel(treeRoot, false);
        decorator = ToolbarDecorator.createDecorator(dataSourceTree);
        decorator.addExtraAction(new RefreshDataSourcesAction(this));

        configureDataSourceTree();
        decorateDataSourceTree();

        interactions = new DataSourceInteractions(project, this);

        replaceTreeWithDecorated();
        showDataSources();
        refreshDataSourcesMetadata();

        initialized = true;
    }
}
 
Example 2
Source File: ProjectSettingsPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public JComponent getMainComponent() {
  final JPanel panel = new JPanel(new BorderLayout(0, 10));
  final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>();
  component.setText("Default &project copyright:");
  component.setLabelLocation(BorderLayout.WEST);
  component.setComponent(myProfilesComboBox);
  panel.add(component, BorderLayout.NORTH);
  ElementProducer<ScopeSetting> producer = new ElementProducer<ScopeSetting>() {
    @Override
    public ScopeSetting createElement() {
      return new ScopeSetting(DefaultScopesProvider.getAllScope(), myProfilesModel.getAllProfiles().values().iterator().next());
    }

    @Override
    public boolean canCreateElement() {
      return !myProfilesModel.getAllProfiles().isEmpty();
    }
  };
  ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myScopeMappingTable, producer);
  panel.add(decorator.createPanel(), BorderLayout.CENTER);
  panel.add(myScopesLink, BorderLayout.SOUTH);
  return panel;
}
 
Example 3
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 4
Source File: PatcherDialog.java    From patcher with Apache License 2.0 5 votes vote down vote up
private void createUIComponents() {
    VirtualFile[] data = event.getData(DataKeys.VIRTUAL_FILE_ARRAY);
    fieldList = new JBList(data);
    fieldList.setEmptyText("No File Selected!");
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList);
    filePanel = decorator.createPanel();
}
 
Example 5
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 6
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 7
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 8
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 9
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 10
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 11
Source File: PatternFilterEditor.java    From KodeBeagle with Apache License 2.0 4 votes vote down vote up
public PatternFilterEditor(final Project project, final String patternsHelpId) {
    super(new BorderLayout());
    myPatternsHelpId = patternsHelpId;
    myTable = new JBTable();
    myProject = project;
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable);
    decorator.addExtraAction(new AnActionButton(getAddPatternButtonText(),
            getAddPatternButtonIcon()) {
        @Override
        public void actionPerformed(final AnActionEvent e) {
            addPatternFilter();
        }
    });

    add(decorator.setRemoveAction(new AnActionButtonRunnable() {
        @Override
        public void run(final AnActionButton button) {
            TableUtil.removeSelectedItems(myTable);
        }
    }).setButtonComparator(getAddPatternButtonText(), "Remove")
            .disableUpDownActions().createPanel(), BorderLayout.CENTER);

    myTableModel = new FilterTableModel();
    myTable.setModel(myTableModel);
    myTable.setShowGrid(false);
    myTable.setShowGrid(false);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setTableHeader(null);
    myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    myTable.setColumnSelectionAllowed(false);
    myTable.setPreferredScrollableViewportSize(new Dimension(WIDTH,
            myTable.getRowHeight() * PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS));

    TableColumnModel columnModel = myTable.getColumnModel();
    TableColumn column = columnModel.getColumn(FilterTableModel.CHECK_MARK);
    TableUtil.setupCheckboxColumn(column);
    column.setCellRenderer(new EnabledCellRenderer(myTable.getDefaultRenderer(Boolean.class)));
    columnModel.getColumn(FilterTableModel.FILTER).setCellRenderer(new FilterCellRenderer());

    getEmptyText().setText(EMPTY_PATTERNS);
}
 
Example 12
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;
}