use of com.intellij.openapi.ui.Splitter 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.openapi.ui.Splitter in project intellij-community by JetBrains.
the class FocusDebugger method init.
private JComponent init() {
final JPanel result = new JPanel(new BorderLayout());
myLogModel = new DefaultListModel();
myLog = new JBList(myLogModel);
myLog.setCellRenderer(new FocusElementRenderer());
myAllocation = new JEditorPane();
final DefaultCaret caret = new DefaultCaret();
myAllocation.setCaret(caret);
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
myAllocation.setEditable(false);
final Splitter splitter = new Splitter(true);
splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myLog));
splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myAllocation));
myLog.addListSelectionListener(this);
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);
result.add(splitter, BorderLayout.CENTER);
final DefaultActionGroup group = new DefaultActionGroup();
group.add(new ClearAction());
result.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.NORTH);
return result;
}
use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class PlaybackDebugger method initUi.
private void initUi() {
myComponent = new JPanel(new BorderLayout());
myLog = new JEditorPane();
myLog.setEditorKit(new StyledEditorKit());
myLog.setEditable(false);
myState = ServiceManager.getService(PlaybackDebuggerState.class);
final DefaultActionGroup controlGroup = new DefaultActionGroup();
controlGroup.add(new RunOnFameActivationAction());
controlGroup.add(new ActivateFrameAndRun());
controlGroup.add(new StopAction());
JPanel north = new JPanel(new BorderLayout());
north.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, controlGroup, true).getComponent(), BorderLayout.WEST);
final JPanel right = new JPanel(new BorderLayout());
right.add(myCurrentScript, BorderLayout.CENTER);
myCurrentScript.setText(myState.currentScript);
myCurrentScript.setEditable(false);
final DefaultActionGroup fsGroup = new DefaultActionGroup();
SaveAction saveAction = new SaveAction();
saveAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("control S")), myComponent);
fsGroup.add(saveAction);
SetScriptFileAction setScriptFileAction = new SetScriptFileAction();
setScriptFileAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("control O")), myComponent);
fsGroup.add(setScriptFileAction);
AnAction newScriptAction = new NewScriptAction();
newScriptAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("control N")), myComponent);
fsGroup.add(newScriptAction);
final ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, fsGroup, true);
tb.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
right.add(tb.getComponent(), BorderLayout.EAST);
north.add(right, BorderLayout.CENTER);
myComponent.add(north, BorderLayout.NORTH);
myCodeEditor = new JTextArea();
myCodeEditor.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
myChanged = true;
}
@Override
public void removeUpdate(DocumentEvent e) {
myChanged = true;
}
@Override
public void changedUpdate(DocumentEvent e) {
myChanged = true;
}
});
if (pathToFile() != null) {
loadFrom(pathToFile());
}
final Splitter script2Log = new Splitter(true);
script2Log.setFirstComponent(ScrollPaneFactory.createScrollPane(myCodeEditor));
script2Log.setSecondComponent(ScrollPaneFactory.createScrollPane(myLog));
myComponent.add(script2Log, BorderLayout.CENTER);
myVfsListener = new VirtualFileAdapter() {
@Override
public void contentsChanged(@NotNull VirtualFileEvent event) {
final VirtualFile file = pathToFile();
if (file != null && file.equals(event.getFile())) {
loadFrom(event.getFile());
}
}
};
LocalFileSystem.getInstance().addVirtualFileListener(myVfsListener);
}
use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class ExtractMethodDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myCenterPanel = new JPanel(new BorderLayout());
createParametersPanel();
final Splitter splitter = new Splitter(true);
splitter.setShowDividerIcon(false);
splitter.setFirstComponent(myCenterPanel);
splitter.setSecondComponent(createSignaturePanel());
return splitter;
}
use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class NullableNotNullDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject);
final Splitter splitter = new Splitter(true);
myNullablePanel = new AnnotationsPanel("Nullable", manager.getDefaultNullable(), manager.getNullables(), NullableNotNullManager.DEFAULT_NULLABLES);
splitter.setFirstComponent(myNullablePanel.getComponent());
myNotNullPanel = new AnnotationsPanel("NotNull", manager.getDefaultNotNull(), manager.getNotNulls(), ArrayUtil.toStringArray(manager.getPredefinedNotNulls()));
splitter.setSecondComponent(myNotNullPanel.getComponent());
splitter.setHonorComponentsMinimumSize(true);
splitter.setPreferredSize(JBUI.size(300, 400));
return splitter;
}
Aggregations