use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class EditorsSplitters method writePanel.
@SuppressWarnings("HardCodedStringLiteral")
private Element writePanel(@NotNull Component comp) {
if (comp instanceof Splitter) {
final Splitter splitter = (Splitter) comp;
final Element res = new Element("splitter");
res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal");
res.setAttribute("split-proportion", Float.toString(splitter.getProportion()));
final Element first = new Element("split-first");
first.addContent(writePanel(splitter.getFirstComponent().getComponent(0)));
final Element second = new Element("split-second");
second.addContent(writePanel(splitter.getSecondComponent().getComponent(0)));
res.addContent(first);
res.addContent(second);
return res;
} else if (comp instanceof JBTabs) {
final Element res = new Element("leaf");
Integer limit = UIUtil.getClientProperty(((JBTabs) comp).getComponent(), JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY);
if (limit != null) {
res.setAttribute(JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY.toString(), String.valueOf(limit));
}
writeWindow(res, findWindowWith(comp));
return res;
} else if (comp instanceof EditorWindow.TCompForTablessMode) {
EditorWithProviderComposite composite = ((EditorWindow.TCompForTablessMode) comp).myEditor;
Element res = new Element("leaf");
res.addContent(writeComposite(composite.getFile(), composite, false, composite));
return res;
} else {
LOG.error(comp.getClass().getName());
return null;
}
}
use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class CommittedChangesTreeBrowser method initSplitters.
private void initSplitters() {
final Splitter filterSplitter = new Splitter(false, 0.5f);
filterSplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myChangesTree));
myLeftPanel.add(filterSplitter, BorderLayout.CENTER);
final Splitter mainSplitter = new Splitter(false, 0.7f);
mainSplitter.setFirstComponent(myLeftPanel);
mainSplitter.setSecondComponent(myDetailsView);
add(mainSplitter, BorderLayout.CENTER);
myInnerSplitter = new WiseSplitter(new Runnable() {
public void run() {
filterSplitter.doLayout();
updateModel();
}
}, filterSplitter);
Disposer.register(this, myInnerSplitter);
mySplitterProportionsData.externalizeFromDimensionService("CommittedChanges.SplitterProportions");
mySplitterProportionsData.restoreSplitterProportions(this);
}
use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class ActionMacroConfigurationPanel method getPanel.
public JPanel getPanel() {
if (mySplitter == null) {
mySplitter = new Splitter(false, 0.5f);
final String value = PropertiesComponent.getInstance().getValue(SPLITTER_PROPORTION);
if (value != null) {
mySplitter.setProportion(Float.parseFloat(value));
}
mySplitter.setFirstComponent(ToolbarDecorator.createDecorator(myMacrosList).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final int selIndex = myMacrosList.getSelectedIndex();
if (selIndex == -1)
return;
final ActionMacro macro = (ActionMacro) myMacrosModel.getElementAt(selIndex);
String newName;
do {
newName = Messages.showInputDialog(mySplitter, IdeBundle.message("prompt.enter.new.name"), IdeBundle.message("title.rename.macro"), Messages.getQuestionIcon(), macro.getName(), null);
if (newName == null || macro.getName().equals(newName))
return;
} while (!canRenameMacro(newName));
if (myRenamingList == null)
myRenamingList = new ArrayList<>();
myRenamingList.add(Couple.of(macro.getName(), newName));
macro.setName(newName);
myMacrosList.repaint();
}
private boolean canRenameMacro(final String name) {
final Enumeration elements = myMacrosModel.elements();
while (elements.hasMoreElements()) {
final ActionMacro macro = (ActionMacro) elements.nextElement();
if (macro.getName().equals(name)) {
if (Messages.showYesNoDialog(IdeBundle.message("message.macro.exists", name), IdeBundle.message("title.macro.name.already.used"), Messages.getWarningIcon()) != Messages.YES) {
return false;
}
myMacrosModel.removeElement(macro);
break;
}
}
return true;
}
}).disableAddAction().disableUpDownActions().createPanel());
mySplitter.setSecondComponent(ToolbarDecorator.createDecorator(myMacroActionsList).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final int macrosSelectedIndex = myMacrosList.getSelectedIndex();
if (macrosSelectedIndex != -1) {
final ActionMacro macro = (ActionMacro) myMacrosModel.getElementAt(macrosSelectedIndex);
macro.deleteAction(myMacroActionsList.getSelectedIndex());
}
ListUtil.removeSelectedItems(myMacroActionsList);
}
}).disableAddAction().disableUpDownActions().createPanel());
}
return mySplitter;
}
use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class ToolWindowsPane method updateLayout.
private void updateLayout() {
UISettings uiSettings = UISettings.getInstance();
if (myWidescreen != uiSettings.getWideScreenSupport()) {
JComponent documentComponent = (myWidescreen ? myVerticalSplitter : myHorizontalSplitter).getInnerComponent();
myWidescreen = uiSettings.getWideScreenSupport();
if (myWidescreen) {
myVerticalSplitter.setInnerComponent(null);
myHorizontalSplitter.setInnerComponent(myVerticalSplitter);
} else {
myHorizontalSplitter.setInnerComponent(null);
myVerticalSplitter.setInnerComponent(myHorizontalSplitter);
}
myLayeredPane.remove(myWidescreen ? myVerticalSplitter : myHorizontalSplitter);
myLayeredPane.add(myWidescreen ? myHorizontalSplitter : myVerticalSplitter, DEFAULT_LAYER);
setDocumentComponent(documentComponent);
}
if (myLeftHorizontalSplit != uiSettings.getLeftHorizontalSplit()) {
JComponent component = getComponentAt(ToolWindowAnchor.LEFT);
if (component instanceof Splitter) {
Splitter splitter = (Splitter) component;
InternalDecorator first = (InternalDecorator) splitter.getFirstComponent();
InternalDecorator second = (InternalDecorator) splitter.getSecondComponent();
setComponent(splitter, ToolWindowAnchor.LEFT, ToolWindowAnchor.LEFT.isSplitVertically() ? first.getWindowInfo().getWeight() : first.getWindowInfo().getWeight() + second.getWindowInfo().getWeight());
}
myLeftHorizontalSplit = uiSettings.getLeftHorizontalSplit();
}
if (myRightHorizontalSplit != uiSettings.getRightHorizontalSplit()) {
JComponent component = getComponentAt(ToolWindowAnchor.RIGHT);
if (component instanceof Splitter) {
Splitter splitter = (Splitter) component;
InternalDecorator first = (InternalDecorator) splitter.getFirstComponent();
InternalDecorator second = (InternalDecorator) splitter.getSecondComponent();
setComponent(splitter, ToolWindowAnchor.RIGHT, ToolWindowAnchor.RIGHT.isSplitVertically() ? first.getWindowInfo().getWeight() : first.getWindowInfo().getWeight() + second.getWindowInfo().getWeight());
}
myRightHorizontalSplit = uiSettings.getRightHorizontalSplit();
}
}
use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.
the class ApplyPatchDifferentiatedDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
if (myCenterPanel == null) {
myCenterPanel = new JPanel(new GridBagLayout());
final GridBagConstraints centralGb = createConstraints();
myPatchFileLabel = new JLabel(VcsBundle.message("patch.apply.file.name.field"));
myPatchFileLabel.setLabelFor(myPatchFile);
myCenterPanel.add(myPatchFileLabel, centralGb);
centralGb.fill = GridBagConstraints.HORIZONTAL;
++centralGb.gridy;
myCenterPanel.add(myPatchFile, centralGb);
JPanel treePanel = new JPanel(new GridBagLayout());
final GridBagConstraints gb = createConstraints();
final DefaultActionGroup group = new DefaultActionGroup();
final AnAction[] treeActions = myChangesTreeList.getTreeActions();
group.addAll(treeActions);
group.add(new MapDirectory());
final MyShowDiff diffAction = new MyShowDiff();
diffAction.registerCustomShortcutSet(CommonShortcuts.getDiff(), getRootPane());
group.add(diffAction);
group.add(new StripUp());
group.add(new StripDown());
group.add(new ResetStrip());
group.add(new ZeroStrip());
if (myCanChangePatchFile) {
group.add(new AnAction("Refresh", "Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent e) {
syncUpdatePatchFileAndScheduleReloadIfNeeded(null);
}
});
}
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("APPLY_PATCH", group, true);
gb.fill = GridBagConstraints.HORIZONTAL;
treePanel.add(toolbar.getComponent(), gb);
++gb.gridy;
gb.weighty = 1;
gb.fill = GridBagConstraints.BOTH;
treePanel.add(ScrollPaneFactory.createScrollPane(myChangesTreeList), gb);
++gb.gridy;
gb.weighty = 0;
gb.fill = GridBagConstraints.NONE;
gb.insets.bottom = UIUtil.DEFAULT_VGAP;
treePanel.add(myCommitLegendPanel.getComponent(), gb);
++gb.gridy;
Splitter splitter = new Splitter(true, 0.7f);
splitter.setFirstComponent(treePanel);
splitter.setSecondComponent(myChangeListChooser);
++centralGb.gridy;
centralGb.weighty = 1;
centralGb.fill = GridBagConstraints.BOTH;
myCenterPanel.add(splitter, centralGb);
}
return myCenterPanel;
}
Aggregations