use of com.intellij.ui.TabbedPaneWrapper in project intellij-community by JetBrains.
the class AbstractTreeClassChooserDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
myTree = new Tree(model);
ProjectAbstractTreeStructureBase treeStructure = new AbstractProjectTreeStructure(myProject) {
@Override
public boolean isFlattenPackages() {
return false;
}
@Override
public boolean isShowMembers() {
return myIsShowMembers;
}
@Override
public boolean isHideEmptyMiddlePackages() {
return true;
}
@Override
public boolean isAbbreviatePackageNames() {
return false;
}
@Override
public boolean isShowLibraryContents() {
return myIsShowLibraryContents;
}
@Override
public boolean isShowModules() {
return false;
}
};
myBuilder = new ProjectTreeBuilder(myProject, myTree, model, AlphaComparator.INSTANCE, treeStructure);
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
myTree.expandRow(0);
myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
myTree.setCellRenderer(new NodeRenderer());
UIUtil.setLineStyleAngled(myTree);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
scrollPane.setPreferredSize(JBUI.size(500, 300));
myTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
doOKAction();
}
}
});
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent event) {
TreePath path = myTree.getPathForLocation(event.getX(), event.getY());
if (path != null && myTree.isPathSelected(path)) {
doOKAction();
return true;
}
return false;
}
}.installOn(myTree);
myTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
handleSelectionChanged();
}
});
new TreeSpeedSearch(myTree);
myTabbedPane = new TabbedPaneWrapper(getDisposable());
final JPanel dummyPanel = new JPanel(new BorderLayout());
String name = null;
/*
if (myInitialClass != null) {
name = myInitialClass.getName();
}
*/
myGotoByNamePanel = new ChooseByNamePanel(myProject, createChooseByNameModel(), name, myScope.isSearchInLibraries(), getContext()) {
@Override
protected void showTextFieldPanel() {
}
@Override
protected void close(boolean isOk) {
super.close(isOk);
if (isOk) {
doOKAction();
} else {
doCancelAction();
}
}
@NotNull
@Override
protected Set<Object> filter(@NotNull Set<Object> elements) {
return doFilter(elements);
}
@Override
protected void initUI(ChooseByNamePopupComponent.Callback callback, ModalityState modalityState, boolean allowMultipleSelection) {
super.initUI(callback, modalityState, allowMultipleSelection);
dummyPanel.add(myGotoByNamePanel.getPanel(), BorderLayout.CENTER);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(IdeFocusTraversalPolicy.getPreferredFocusedComponent(myGotoByNamePanel.getPanel()), true);
});
}
@Override
protected void showList() {
super.showList();
if (myInitialClass != null && myList.getModel().getSize() > 0) {
myList.setSelectedValue(myInitialClass, true);
myInitialClass = null;
}
}
@Override
protected void chosenElementMightChange() {
handleSelectionChanged();
}
};
Disposer.register(myDisposable, myGotoByNamePanel);
myTabbedPane.addTab(IdeBundle.message("tab.chooser.search.by.name"), dummyPanel);
myTabbedPane.addTab(IdeBundle.message("tab.chooser.project"), scrollPane);
myGotoByNamePanel.invoke(new MyCallback(), getModalityState(), false);
myTabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
handleSelectionChanged();
}
});
return myTabbedPane.getComponent();
}
use of com.intellij.ui.TabbedPaneWrapper in project intellij-community by JetBrains.
the class PrintDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
TabbedPaneWrapper tabbedPaneWrapper = new TabbedPaneWrapper(myDisposable);
tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.settings.tab"), createPrintSettingsPanel());
tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.header.footer.tab"), createHeaderAndFooterPanel());
tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.advanced.tab"), createAdvancedPanel());
return tabbedPaneWrapper.getComponent();
}
use of com.intellij.ui.TabbedPaneWrapper in project intellij-community by JetBrains.
the class AllFileTemplatesConfigurable method createComponent.
@Override
public JComponent createComponent() {
myUIDisposable = Disposer.newDisposable();
myTemplatesList = new FileTemplateTabAsList(TEMPLATES_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
};
myIncludesList = new FileTemplateTabAsList(INCLUDES_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
};
myCodeTemplatesList = new FileTemplateTabAsList(CODE_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
};
myCurrentTab = myTemplatesList;
final List<FileTemplateTab> allTabs = new ArrayList<>(Arrays.asList(myTemplatesList, myIncludesList, myCodeTemplatesList));
final FileTemplateGroupDescriptorFactory[] factories = Extensions.getExtensions(FileTemplateGroupDescriptorFactory.EXTENSION_POINT_NAME);
if (factories.length != 0) {
myOtherTemplatesList = new FileTemplateTabAsTree(OTHER_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
@Override
protected FileTemplateNode initModel() {
SortedSet<FileTemplateGroupDescriptor> categories = new TreeSet<>((o1, o2) -> o1.getTitle().compareTo(o2.getTitle()));
for (FileTemplateGroupDescriptorFactory templateGroupFactory : factories) {
ContainerUtil.addIfNotNull(categories, templateGroupFactory.getFileTemplatesDescriptor());
}
//noinspection HardCodedStringLiteral
return new FileTemplateNode("ROOT", null, ContainerUtil.map2List(categories, s -> new FileTemplateNode(s)));
}
};
allTabs.add(myOtherTemplatesList);
}
myEditor = new FileTemplateConfigurable(myProject);
myEditor.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
onEditorChanged();
}
});
myEditorComponent = myEditor.createComponent();
myEditorComponent.setBorder(JBUI.Borders.empty(10, 0, 10, 10));
myTabs = allTabs.toArray(new FileTemplateTab[allTabs.size()]);
myTabbedPane = new TabbedPaneWrapper(myUIDisposable);
myTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
myLeftPanel = new JPanel(new CardLayout());
myLeftPanel.setBorder(JBUI.Borders.empty(10, 10, 10, 0));
for (FileTemplateTab tab : myTabs) {
myLeftPanel.add(ScrollPaneFactory.createScrollPane(tab.getComponent()), tab.getTitle());
JPanel fakePanel = new JPanel();
fakePanel.setPreferredSize(new Dimension(0, 0));
myTabbedPane.addTab(tab.getTitle(), fakePanel);
}
myTabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
onTabChanged();
}
});
DefaultActionGroup group = new DefaultActionGroup();
AnAction removeAction = new AnAction(IdeBundle.message("action.remove.template"), null, AllIcons.General.Remove) {
@Override
public void actionPerformed(AnActionEvent e) {
onRemove();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
e.getPresentation().setEnabled(selectedItem != null && !isInternalTemplate(selectedItem.getName(), myCurrentTab.getTitle()));
}
};
AnAction addAction = new AnAction(IdeBundle.message("action.create.template"), null, AllIcons.General.Add) {
@Override
public void actionPerformed(AnActionEvent e) {
onAdd();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
e.getPresentation().setEnabled(!(myCurrentTab == myCodeTemplatesList || myCurrentTab == myOtherTemplatesList));
}
};
AnAction cloneAction = new AnAction(IdeBundle.message("action.copy.template"), null, PlatformIcons.COPY_ICON) {
@Override
public void actionPerformed(AnActionEvent e) {
onClone();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
e.getPresentation().setEnabled(myCurrentTab != myCodeTemplatesList && myCurrentTab != myOtherTemplatesList && myCurrentTab.getSelectedTemplate() != null);
}
};
AnAction resetAction = new AnAction(IdeBundle.message("action.reset.to.default"), null, AllIcons.Actions.Reset) {
@Override
public void actionPerformed(AnActionEvent e) {
onReset();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
final FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
e.getPresentation().setEnabled(selectedItem instanceof BundledFileTemplate && !selectedItem.isDefault());
}
};
group.add(addAction);
group.add(removeAction);
group.add(cloneAction);
group.add(resetAction);
addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myCurrentTab.getComponent());
removeAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), myCurrentTab.getComponent());
myToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
myToolBar.setBorder(IdeBorderFactory.createEmptyBorder());
JPanel toolbarPanel = new JPanel(new BorderLayout());
toolbarPanel.add(myToolBar, BorderLayout.WEST);
JComponent schemaComponent = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultCompactActionGroup(new ChangeSchemaCombo(this)), true).getComponent();
JPanel schemaPanel = new JPanel(new BorderLayout());
schemaPanel.add(schemaComponent, BorderLayout.EAST);
schemaPanel.add(new JLabel("Schema:"), BorderLayout.WEST);
toolbarPanel.add(schemaPanel, BorderLayout.EAST);
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.add(myTabbedPane.getComponent(), BorderLayout.NORTH);
Splitter splitter = new Splitter(false, 0.3f);
splitter.setDividerWidth(JBUI.scale(10));
splitter.setFirstComponent(myLeftPanel);
splitter.setSecondComponent(myEditorComponent);
centerPanel.add(splitter, BorderLayout.CENTER);
myMainPanel = new JPanel(new BorderLayout());
myMainPanel.add(toolbarPanel, BorderLayout.NORTH);
myMainPanel.add(centerPanel, BorderLayout.CENTER);
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
final String tabName = propertiesComponent.getValue(CURRENT_TAB);
if (selectTab(tabName)) {
//final String selectedTemplateName = propertiesComponent.getValue(SELECTED_TEMPLATE);
//for (FileTemplate template : myCurrentTab.getTemplates()) {
// if (Comparing.strEqual(template.getName(), selectedTemplateName)) {
// myCurrentTab.selectTemplate(template);
// break;
// }
//}
}
return myMainPanel;
}
use of com.intellij.ui.TabbedPaneWrapper in project intellij-community by JetBrains.
the class TabbedLanguageCodeStylePanel method ensureTabs.
protected void ensureTabs() {
if (myTabs == null) {
myPanel = new JPanel();
myPanel.setLayout(new BorderLayout());
myTabbedPane = new TabbedPaneWrapper(this);
myTabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (myListener != null) {
String title = myTabbedPane.getSelectedTitle();
if (title != null) {
myListener.tabChanged(TabbedLanguageCodeStylePanel.this, title);
}
}
}
});
myTabs = new ArrayList<>();
myPanel.add(myTabbedPane.getComponent());
initTabs(getSettings());
}
assert !myTabs.isEmpty();
}
use of com.intellij.ui.TabbedPaneWrapper in project intellij-community by JetBrains.
the class TabbedModuleEditor method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myTabbedPane = new TabbedPaneWrapper(this);
for (ModuleConfigurationEditor editor : myEditors) {
myTabbedPane.addTab(editor.getDisplayName(), editor.createComponent());
editor.reset();
}
restoreSelectedEditor();
myTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
saveSelectedEditor();
if (myHistory != null) {
myHistory.pushQueryPlace();
}
}
});
return myTabbedPane.getComponent();
}
Aggregations