@ -1,5 +1,3 @@ |
|||||||
<component name="CopyrightManager"> |
<component name="CopyrightManager"> |
||||||
<settings default=""> |
<settings default="" /> |
||||||
<module2copyright /> |
|
||||||
</settings> |
|
||||||
</component> |
</component> |
@ -1,3 +1,7 @@ |
|||||||
<component name="ProjectDictionaryState"> |
<component name="ProjectDictionaryState"> |
||||||
<dictionary name="kb" /> |
<dictionary name="kb"> |
||||||
|
<words> |
||||||
|
<w>darcula</w> |
||||||
|
</words> |
||||||
|
</dictionary> |
||||||
</component> |
</component> |
@ -0,0 +1,12 @@ |
|||||||
|
<component name="InspectionProjectProfileManager"> |
||||||
|
<profile version="1.0" is_locked="false"> |
||||||
|
<option name="myName" value="Project Default" /> |
||||||
|
<option name="myLocal" value="false" /> |
||||||
|
<inspection_tool class="UnusedDeclaration" enabled="false" level="WARNING" enabled_by_default="false"> |
||||||
|
<option name="ADD_MAINS_TO_ENTRIES" value="true" /> |
||||||
|
<option name="ADD_APPLET_TO_ENTRIES" value="true" /> |
||||||
|
<option name="ADD_SERVLET_TO_ENTRIES" value="true" /> |
||||||
|
<option name="ADD_NONJAVA_TO_ENTRIES" value="true" /> |
||||||
|
</inspection_tool> |
||||||
|
</profile> |
||||||
|
</component> |
@ -0,0 +1,7 @@ |
|||||||
|
<component name="InspectionProjectProfileManager"> |
||||||
|
<settings> |
||||||
|
<option name="PROJECT_PROFILE" value="Project Default" /> |
||||||
|
<option name="USE_PROJECT_PROFILE" value="true" /> |
||||||
|
<version value="1.0" /> |
||||||
|
</settings> |
||||||
|
</component> |
@ -0,0 +1,9 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="IconLoader"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$PROJECT_DIR$/lib/iconloader.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC /> |
||||||
|
<SOURCES /> |
||||||
|
</library> |
||||||
|
</component> |
@ -1,14 +1,10 @@ |
|||||||
# suppress inspection "UnusedProperty" for whole file |
# suppress inspection "UnusedProperty" for whole file |
||||||
darcula.selectionBackground=4B6EAF |
darcula.selectionBackground=4B6EAF |
||||||
darcula.selectionForeground=bbbbbb |
darcula.selectionForeground=bbbbbb |
||||||
darcula.select=0D293E |
|
||||||
|
|
||||||
PopupMenu.border=com.bulenkov.darcula.ui.DarculaPopupMenuBorder |
PopupMenu.border=com.bulenkov.darcula.ui.DarculaPopupMenuBorder |
||||||
|
|
||||||
MenuBarUI=com.bulenkov.darcula.ui.DarculaMenuBarUI |
|
||||||
MenuBar.border=com.bulenkov.darcula.ui.DarculaMenuBarBorder |
MenuBar.border=com.bulenkov.darcula.ui.DarculaMenuBarBorder |
||||||
|
#InternalFrameUI=com.bulenkov.darcula.ui.DarculaInternalFrameUI |
||||||
ToolBarUI=com.bulenkov.darcula.ui.DarculaToolBarUI |
#InternalFrame.border=com.bulenkov.darcula.ui.DarculaInternalBorder |
||||||
ToggleButton.shadow=0d293e |
#RootPaneUI=com.bulenkov.darcula.ui.DarculaRootPaneUI |
||||||
|
|
||||||
#InternalFrameUI=com.bulenkov.darcula.ui.win.DarculaWindowsInternalFrameUI |
|
@ -0,0 +1,42 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2000-2013 JetBrains s.r.o. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.bulenkov.darcula.ui; |
||||||
|
|
||||||
|
import javax.swing.border.Border; |
||||||
|
import javax.swing.plaf.InsetsUIResource; |
||||||
|
import javax.swing.plaf.UIResource; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Konstantin Bulenkov |
||||||
|
*/ |
||||||
|
public class DarculaInternalBorder implements UIResource, Border { |
||||||
|
@Override |
||||||
|
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { |
||||||
|
g.setColor(Color.ORANGE); |
||||||
|
g.fillRect(x, y, width, height); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Insets getBorderInsets(Component c) { |
||||||
|
return new InsetsUIResource(20, 3, 3, 3); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isBorderOpaque() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2000-2013 JetBrains s.r.o. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.bulenkov.darcula.ui; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.plaf.ComponentUI; |
||||||
|
import javax.swing.plaf.basic.BasicInternalFrameTitlePane; |
||||||
|
import javax.swing.plaf.basic.BasicInternalFrameUI; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Konstantin Bulenkov |
||||||
|
*/ |
||||||
|
public class DarculaInternalFrameUI extends BasicInternalFrameUI { |
||||||
|
public DarculaInternalFrameUI(JInternalFrame b) { |
||||||
|
super(b); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) |
||||||
|
public static ComponentUI createUI(JComponent c) { |
||||||
|
return new DarculaInternalFrameUI((JInternalFrame)c); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JComponent createNorthPane(JInternalFrame w) { |
||||||
|
this.titlePane = new BasicInternalFrameTitlePane(w) { |
||||||
|
@Override |
||||||
|
protected void paintBorder(Graphics g) { |
||||||
|
super.paintBorder(g); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
} |
||||||
|
}; |
||||||
|
return this.titlePane; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,607 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.ui.laf.darcula.ui.DarculaTest"> |
||||||
|
<grid id="27dc6" binding="myRoot" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<xy x="20" y="20" width="740" height="400"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<tabbedpane id="7fdea" class="com.intellij.ui.components.JBTabbedPane"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<grid id="82dae" layout-manager="GridLayoutManager" row-count="8" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Controls"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<component id="18633" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Checkbox 1"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="9cf6e" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Checkbox 2"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="ccfb9" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Checkbox 3"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="cd11b" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Checkbox 4"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="210e8" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<text value="Checkbox 5"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<hspacer id="72565"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
</hspacer> |
||||||
|
<vspacer id="4309a"> |
||||||
|
<constraints> |
||||||
|
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
</vspacer> |
||||||
|
<component id="987f8" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox1" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="57e78" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox2" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<selected value="true"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="3fd84" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox3" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<selected value="true"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="4c4e6" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox4" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<selected value="true"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="4faf4" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox5" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="389e3" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Radio button 1"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="2c501" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Radio button 2"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="74a2d" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Radio button 3"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="8b6b8" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Radio button 4"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="fbe33" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<text value="Radio button 5"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="1935f" class="com.intellij.ui.components.JBRadioButton"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="3443a" class="com.intellij.ui.components.JBRadioButton"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="46c61" class="com.intellij.ui.components.JBRadioButton"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="b4c96" class="com.intellij.ui.components.JBRadioButton"> |
||||||
|
<constraints> |
||||||
|
<grid row="3" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="3f56f" class="com.intellij.ui.components.JBRadioButton"> |
||||||
|
<constraints> |
||||||
|
<grid row="4" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="cee3a" class="javax.swing.JLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Combo 1"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="21050" class="javax.swing.JLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Combo 2"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="402e8" class="javax.swing.JLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Combo 3"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="9de33" class="javax.swing.JLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="3" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<text value="Combo 4"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="786c1" class="javax.swing.JLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<text value="Combo 5"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="cf830" class="javax.swing.JComboBox" binding="myComboBox1" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<model> |
||||||
|
<item value="item 1"/> |
||||||
|
<item value="item 2"/> |
||||||
|
<item value="long item"/> |
||||||
|
<item value="very long item"/> |
||||||
|
<item value="blah blah blah blah"/> |
||||||
|
<item value="hello"/> |
||||||
|
<item value="darcula"/> |
||||||
|
</model> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="70b41" class="javax.swing.JComboBox" binding="myComboBox2" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<model> |
||||||
|
<item value="item 1"/> |
||||||
|
<item value="item 2"/> |
||||||
|
<item value="long item"/> |
||||||
|
<item value="very long item"/> |
||||||
|
<item value="blah blah blah blah"/> |
||||||
|
<item value="hello"/> |
||||||
|
<item value="darcula"/> |
||||||
|
</model> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="fd136" class="javax.swing.JComboBox" binding="myComboBox3" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<editable value="true"/> |
||||||
|
<model> |
||||||
|
<item value="item 1"/> |
||||||
|
<item value="item 2"/> |
||||||
|
<item value="long item"/> |
||||||
|
<item value="very long item"/> |
||||||
|
<item value="blah blah blah blah"/> |
||||||
|
<item value="hello"/> |
||||||
|
<item value="darcula"/> |
||||||
|
</model> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="f8aa2" class="javax.swing.JComboBox" binding="myComboBox4" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="3" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<editable value="true"/> |
||||||
|
<enabled value="false"/> |
||||||
|
<model> |
||||||
|
<item value="item 1"/> |
||||||
|
<item value="item 2"/> |
||||||
|
<item value="long item"/> |
||||||
|
<item value="very long item"/> |
||||||
|
<item value="blah blah blah blah"/> |
||||||
|
<item value="hello"/> |
||||||
|
<item value="darcula"/> |
||||||
|
</model> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="15345" class="javax.swing.JComboBox" binding="myComboBox5" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="4" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<model> |
||||||
|
<item value="item 1"/> |
||||||
|
<item value="item 2"/> |
||||||
|
<item value="long item"/> |
||||||
|
<item value="very long item"/> |
||||||
|
<item value="blah blah blah blah"/> |
||||||
|
<item value="hello"/> |
||||||
|
<item value="darcula"/> |
||||||
|
</model> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<grid id="89ff7" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<grid row="6" column="0" row-span="1" col-span="8" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<component id="9f0fc" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Username:"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="4ae36" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Password:"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="da910" class="com.intellij.ui.components.JBLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<text value="Disabled:"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<hspacer id="fb796"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
</hspacer> |
||||||
|
<component id="4fa3a" class="javax.swing.JTextField" binding="myTextField1" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> |
||||||
|
<preferred-size width="150" height="-1"/> |
||||||
|
</grid> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="55f5c" class="javax.swing.JTextField" binding="myThisTextIsDisabledTextField" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> |
||||||
|
<preferred-size width="150" height="-1"/> |
||||||
|
</grid> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<text value="This text is disabled"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="a89cc" class="javax.swing.JPasswordField" binding="myPasswordField1" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> |
||||||
|
<preferred-size width="150" height="-1"/> |
||||||
|
</grid> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
</children> |
||||||
|
</grid> |
||||||
|
<component id="16094" class="javax.swing.JTextField" binding="myTextField2" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> |
||||||
|
<preferred-size width="150" height="-1"/> |
||||||
|
</grid> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="9ca2c" class="javax.swing.JTextField" binding="myTextField3" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> |
||||||
|
<preferred-size width="150" height="-1"/> |
||||||
|
</grid> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="d3706" class="javax.swing.JTextField" binding="myTextField4" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> |
||||||
|
<preferred-size width="150" height="-1"/> |
||||||
|
</grid> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="b4c72" class="javax.swing.JLabel"> |
||||||
|
<constraints> |
||||||
|
<grid row="5" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Label"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="416fd" class="javax.swing.JSpinner" binding="mySpinner1" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="5" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
</children> |
||||||
|
</grid> |
||||||
|
<grid id="df06" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Table"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<scrollpane id="3105c" class="com.intellij.ui.components.JBScrollPane"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<component id="d2ccf" class="com.intellij.ui.table.JBTable" binding="myTable"> |
||||||
|
<constraints/> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
</children> |
||||||
|
</scrollpane> |
||||||
|
</children> |
||||||
|
</grid> |
||||||
|
<grid id="7e7c9" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Progress"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<component id="e24f4" class="javax.swing.JProgressBar" binding="myProgressBar1" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<indeterminate value="false"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<vspacer id="17deb"> |
||||||
|
<constraints> |
||||||
|
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
</vspacer> |
||||||
|
<component id="9f8b4" class="javax.swing.JButton" binding="myProgressButton"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Start"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="cb89e" class="javax.swing.JProgressBar" binding="myProgressBar2" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
</component> |
||||||
|
<component id="208a5" class="javax.swing.JButton" binding="myStartButton" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Start"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
</children> |
||||||
|
</grid> |
||||||
|
<grid id="3db09" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Untitled"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children/> |
||||||
|
</grid> |
||||||
|
<grid id="9eb6c" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Untitled"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children/> |
||||||
|
</grid> |
||||||
|
<grid id="519ad" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Untitled"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children/> |
||||||
|
</grid> |
||||||
|
<grid id="79d38" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Untitled"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children/> |
||||||
|
</grid> |
||||||
|
<grid id="4847f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Untitled"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children/> |
||||||
|
</grid> |
||||||
|
<grid id="ccad" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<tabbedpane title="Untitled"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children/> |
||||||
|
</grid> |
||||||
|
</children> |
||||||
|
</tabbedpane> |
||||||
|
<grid id="7eadd" layout-manager="GridLayoutManager" row-count="1" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> |
||||||
|
<margin top="0" left="0" bottom="0" right="0"/> |
||||||
|
<constraints> |
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties/> |
||||||
|
<border type="none"/> |
||||||
|
<children> |
||||||
|
<hspacer id="b01de"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
</hspacer> |
||||||
|
<hspacer id="137c6"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
</hspacer> |
||||||
|
<component id="908bc" class="javax.swing.JButton" binding="myHelpButton" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Help"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="fc247" class="javax.swing.JButton" binding="myCancelButton" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Cancel"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="710e8" class="javax.swing.JButton" binding="myDisabledButton" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<enabled value="false"/> |
||||||
|
<text value="Disabled"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
<component id="bcace" class="javax.swing.JButton" binding="myDefaultButton" default-binding="true"> |
||||||
|
<constraints> |
||||||
|
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> |
||||||
|
</constraints> |
||||||
|
<properties> |
||||||
|
<text value="Default"/> |
||||||
|
</properties> |
||||||
|
</component> |
||||||
|
</children> |
||||||
|
</grid> |
||||||
|
</children> |
||||||
|
</grid> |
||||||
|
<buttonGroups> |
||||||
|
<group name="myGroup1"> |
||||||
|
<member id="1935f"/> |
||||||
|
<member id="3443a"/> |
||||||
|
<member id="46c61"/> |
||||||
|
<member id="b4c96"/> |
||||||
|
<member id="3f56f"/> |
||||||
|
</group> |
||||||
|
</buttonGroups> |
||||||
|
</form> |
@ -0,0 +1,729 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2000-2013 JetBrains s.r.o. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.bulenkov.darcula.ui; |
||||||
|
|
||||||
|
import sun.awt.SunToolkit; |
||||||
|
import sun.swing.SwingUtilities2; |
||||||
|
|
||||||
|
import javax.accessibility.AccessibleContext; |
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.border.EmptyBorder; |
||||||
|
import javax.swing.plaf.UIResource; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.WindowAdapter; |
||||||
|
import java.awt.event.WindowEvent; |
||||||
|
import java.awt.event.WindowListener; |
||||||
|
import java.beans.PropertyChangeEvent; |
||||||
|
import java.beans.PropertyChangeListener; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Konstantin Bulenkov |
||||||
|
*/ |
||||||
|
public class DarculaTitlePane extends JComponent { |
||||||
|
private static final int IMAGE_HEIGHT = 16; |
||||||
|
private static final int IMAGE_WIDTH = 16; |
||||||
|
|
||||||
|
private PropertyChangeListener myPropertyChangeListener; |
||||||
|
private JMenuBar myMenuBar; |
||||||
|
private Action myCloseAction; |
||||||
|
private Action myIconifyAction; |
||||||
|
private Action myRestoreAction; |
||||||
|
private Action myMaximizeAction; |
||||||
|
private JButton myToggleButton; |
||||||
|
private JButton myIconifyButton; |
||||||
|
private JButton myCloseButton; |
||||||
|
private Icon myMaximizeIcon; |
||||||
|
private Icon myMinimizeIcon; |
||||||
|
private Image mySystemIcon; |
||||||
|
private WindowListener myWindowListener; |
||||||
|
private Window myWindow; |
||||||
|
private JRootPane myRootPane; |
||||||
|
private int myState; |
||||||
|
private DarculaRootPaneUI rootPaneUI; |
||||||
|
|
||||||
|
|
||||||
|
private Color myInactiveBackground = UIManager.getColor("inactiveCaption"); |
||||||
|
private Color myInactiveForeground = UIManager.getColor("inactiveCaptionText"); |
||||||
|
private Color myInactiveShadow = UIManager.getColor("inactiveCaptionBorder"); |
||||||
|
private Color myActiveBackground = null; |
||||||
|
private Color myActiveForeground = null; |
||||||
|
private Color myActiveShadow = null; |
||||||
|
|
||||||
|
public DarculaTitlePane(JRootPane root, DarculaRootPaneUI ui) { |
||||||
|
this.myRootPane = root; |
||||||
|
rootPaneUI = ui; |
||||||
|
|
||||||
|
myState = -1; |
||||||
|
|
||||||
|
installSubcomponents(); |
||||||
|
determineColors(); |
||||||
|
installDefaults(); |
||||||
|
|
||||||
|
setLayout(createLayout()); |
||||||
|
} |
||||||
|
|
||||||
|
private void uninstall() { |
||||||
|
uninstallListeners(); |
||||||
|
myWindow = null; |
||||||
|
removeAll(); |
||||||
|
} |
||||||
|
|
||||||
|
private void installListeners() { |
||||||
|
if (myWindow != null) { |
||||||
|
myWindowListener = createWindowListener(); |
||||||
|
myWindow.addWindowListener(myWindowListener); |
||||||
|
myPropertyChangeListener = createWindowPropertyChangeListener(); |
||||||
|
myWindow.addPropertyChangeListener(myPropertyChangeListener); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void uninstallListeners() { |
||||||
|
if (myWindow != null) { |
||||||
|
myWindow.removeWindowListener(myWindowListener); |
||||||
|
myWindow.removePropertyChangeListener(myPropertyChangeListener); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private WindowListener createWindowListener() { |
||||||
|
return new WindowHandler(); |
||||||
|
} |
||||||
|
|
||||||
|
private PropertyChangeListener createWindowPropertyChangeListener() { |
||||||
|
return new PropertyChangeHandler(); |
||||||
|
} |
||||||
|
|
||||||
|
public JRootPane getRootPane() { |
||||||
|
return myRootPane; |
||||||
|
} |
||||||
|
|
||||||
|
private int getWindowDecorationStyle() { |
||||||
|
return getRootPane().getWindowDecorationStyle(); |
||||||
|
} |
||||||
|
|
||||||
|
public void addNotify() { |
||||||
|
super.addNotify(); |
||||||
|
|
||||||
|
uninstallListeners(); |
||||||
|
|
||||||
|
myWindow = SwingUtilities.getWindowAncestor(this); |
||||||
|
if (myWindow != null) { |
||||||
|
if (myWindow instanceof Frame) { |
||||||
|
setState(((Frame)myWindow).getExtendedState()); |
||||||
|
} |
||||||
|
else { |
||||||
|
setState(0); |
||||||
|
} |
||||||
|
setActive(myWindow.isActive()); |
||||||
|
installListeners(); |
||||||
|
updateSystemIcon(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void removeNotify() { |
||||||
|
super.removeNotify(); |
||||||
|
|
||||||
|
uninstallListeners(); |
||||||
|
myWindow = null; |
||||||
|
} |
||||||
|
|
||||||
|
private void installSubcomponents() { |
||||||
|
int decorationStyle = getWindowDecorationStyle(); |
||||||
|
if (decorationStyle == JRootPane.FRAME) { |
||||||
|
createActions(); |
||||||
|
myMenuBar = createMenuBar(); |
||||||
|
add(myMenuBar); |
||||||
|
createButtons(); |
||||||
|
add(myIconifyButton); |
||||||
|
add(myToggleButton); |
||||||
|
add(myCloseButton); |
||||||
|
} |
||||||
|
else if (decorationStyle == JRootPane.PLAIN_DIALOG || |
||||||
|
decorationStyle == JRootPane.INFORMATION_DIALOG || |
||||||
|
decorationStyle == JRootPane.ERROR_DIALOG || |
||||||
|
decorationStyle == JRootPane.COLOR_CHOOSER_DIALOG || |
||||||
|
decorationStyle == JRootPane.FILE_CHOOSER_DIALOG || |
||||||
|
decorationStyle == JRootPane.QUESTION_DIALOG || |
||||||
|
decorationStyle == JRootPane.WARNING_DIALOG) { |
||||||
|
createActions(); |
||||||
|
createButtons(); |
||||||
|
add(myCloseButton); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void determineColors() { |
||||||
|
switch (getWindowDecorationStyle()) { |
||||||
|
case JRootPane.FRAME: |
||||||
|
myActiveBackground = UIManager.getColor("activeCaption"); |
||||||
|
myActiveForeground = UIManager.getColor("activeCaptionText"); |
||||||
|
myActiveShadow = UIManager.getColor("activeCaptionBorder"); |
||||||
|
break; |
||||||
|
case JRootPane.ERROR_DIALOG: |
||||||
|
myActiveBackground = UIManager.getColor("OptionPane.errorDialog.titlePane.background"); |
||||||
|
myActiveForeground = UIManager.getColor("OptionPane.errorDialog.titlePane.foreground"); |
||||||
|
myActiveShadow = UIManager.getColor("OptionPane.errorDialog.titlePane.shadow"); |
||||||
|
break; |
||||||
|
case JRootPane.QUESTION_DIALOG: |
||||||
|
case JRootPane.COLOR_CHOOSER_DIALOG: |
||||||
|
case JRootPane.FILE_CHOOSER_DIALOG: |
||||||
|
myActiveBackground = UIManager.getColor("OptionPane.questionDialog.titlePane.background"); |
||||||
|
myActiveForeground = UIManager.getColor("OptionPane.questionDialog.titlePane.foreground"); |
||||||
|
myActiveShadow = UIManager.getColor("OptionPane.questionDialog.titlePane.shadow"); |
||||||
|
break; |
||||||
|
case JRootPane.WARNING_DIALOG: |
||||||
|
myActiveBackground = UIManager.getColor("OptionPane.warningDialog.titlePane.background"); |
||||||
|
myActiveForeground = UIManager.getColor("OptionPane.warningDialog.titlePane.foreground"); |
||||||
|
myActiveShadow = UIManager.getColor("OptionPane.warningDialog.titlePane.shadow"); |
||||||
|
break; |
||||||
|
case JRootPane.PLAIN_DIALOG: |
||||||
|
case JRootPane.INFORMATION_DIALOG: |
||||||
|
default: |
||||||
|
myActiveBackground = UIManager.getColor("activeCaption"); |
||||||
|
myActiveForeground = UIManager.getColor("activeCaptionText"); |
||||||
|
myActiveShadow = UIManager.getColor("activeCaptionBorder"); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void installDefaults() { |
||||||
|
setFont(UIManager.getFont("InternalFrame.titleFont", getLocale())); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected JMenuBar createMenuBar() { |
||||||
|
myMenuBar = new SystemMenuBar(); |
||||||
|
myMenuBar.setFocusable(false); |
||||||
|
myMenuBar.setBorderPainted(true); |
||||||
|
myMenuBar.add(createMenu()); |
||||||
|
return myMenuBar; |
||||||
|
} |
||||||
|
|
||||||
|
private void close() { |
||||||
|
Window window = getWindow(); |
||||||
|
|
||||||
|
if (window != null) { |
||||||
|
window.dispatchEvent(new WindowEvent( |
||||||
|
window, WindowEvent.WINDOW_CLOSING)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void iconify() { |
||||||
|
Frame frame = getFrame(); |
||||||
|
if (frame != null) { |
||||||
|
frame.setExtendedState(myState | Frame.ICONIFIED); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void maximize() { |
||||||
|
Frame frame = getFrame(); |
||||||
|
if (frame != null) { |
||||||
|
frame.setExtendedState(myState | Frame.MAXIMIZED_BOTH); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void restore() { |
||||||
|
Frame frame = getFrame(); |
||||||
|
|
||||||
|
if (frame == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if ((myState & Frame.ICONIFIED) != 0) { |
||||||
|
frame.setExtendedState(myState & ~Frame.ICONIFIED); |
||||||
|
} |
||||||
|
else { |
||||||
|
frame.setExtendedState(myState & ~Frame.MAXIMIZED_BOTH); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void createActions() { |
||||||
|
myCloseAction = new CloseAction(); |
||||||
|
if (getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
myIconifyAction = new IconifyAction(); |
||||||
|
myRestoreAction = new RestoreAction(); |
||||||
|
myMaximizeAction = new MaximizeAction(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private JMenu createMenu() { |
||||||
|
JMenu menu = new JMenu(""); |
||||||
|
if (getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
addMenuItems(menu); |
||||||
|
} |
||||||
|
return menu; |
||||||
|
} |
||||||
|
|
||||||
|
private void addMenuItems(JMenu menu) { |
||||||
|
menu.add(myRestoreAction); |
||||||
|
menu.add(myIconifyAction); |
||||||
|
if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { |
||||||
|
menu.add(myMaximizeAction); |
||||||
|
} |
||||||
|
|
||||||
|
menu.add(new JSeparator()); |
||||||
|
|
||||||
|
menu.add(myCloseAction); |
||||||
|
} |
||||||
|
|
||||||
|
private static JButton createButton(String accessibleName, Icon icon, Action action) { |
||||||
|
JButton button = new JButton(); |
||||||
|
button.setFocusPainted(false); |
||||||
|
button.setFocusable(false); |
||||||
|
button.setOpaque(true); |
||||||
|
button.putClientProperty("paintActive", Boolean.TRUE); |
||||||
|
button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName); |
||||||
|
button.setBorder(new EmptyBorder(0, 0, 0, 0)); |
||||||
|
button.setText(null); |
||||||
|
button.setAction(action); |
||||||
|
button.setIcon(icon); |
||||||
|
return button; |
||||||
|
} |
||||||
|
|
||||||
|
private void createButtons() { |
||||||
|
myCloseButton = createButton("Close", UIManager.getIcon("InternalFrame.closeIcon"), myCloseAction); |
||||||
|
|
||||||
|
if (getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
myMaximizeIcon = UIManager.getIcon("InternalFrame.maximizeIcon"); |
||||||
|
myMinimizeIcon = UIManager.getIcon("InternalFrame.minimizeIcon"); |
||||||
|
|
||||||
|
myIconifyButton = createButton("Iconify", UIManager.getIcon("InternalFrame.iconifyIcon"), myIconifyAction); |
||||||
|
myToggleButton = createButton("Maximize", myMaximizeIcon, myRestoreAction); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private LayoutManager createLayout() { |
||||||
|
return new TitlePaneLayout(); |
||||||
|
} |
||||||
|
|
||||||
|
private void setActive(boolean active) { |
||||||
|
myCloseButton.putClientProperty("paintActive", Boolean.valueOf(active)); |
||||||
|
|
||||||
|
if (getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
myIconifyButton.putClientProperty("paintActive", Boolean.valueOf(active)); |
||||||
|
myToggleButton.putClientProperty("paintActive", Boolean.valueOf(active)); |
||||||
|
} |
||||||
|
|
||||||
|
getRootPane().repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
private void setState(int state) { |
||||||
|
setState(state, false); |
||||||
|
} |
||||||
|
|
||||||
|
private void setState(int state, boolean updateRegardless) { |
||||||
|
Window wnd = getWindow(); |
||||||
|
|
||||||
|
if (wnd != null && getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
if (myState == state && !updateRegardless) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Frame frame = getFrame(); |
||||||
|
|
||||||
|
if (frame != null) { |
||||||
|
JRootPane rootPane = getRootPane(); |
||||||
|
|
||||||
|
if (((state & Frame.MAXIMIZED_BOTH) != 0) && |
||||||
|
(rootPane.getBorder() == null || |
||||||
|
(rootPane.getBorder() instanceof UIResource)) && |
||||||
|
frame.isShowing()) { |
||||||
|
rootPane.setBorder(null); |
||||||
|
} |
||||||
|
else if ((state & Frame.MAXIMIZED_BOTH) == 0) { |
||||||
|
// This is a croak, if state becomes bound, this can
|
||||||
|
// be nuked.
|
||||||
|
rootPaneUI.installBorder(rootPane); |
||||||
|
} |
||||||
|
if (frame.isResizable()) { |
||||||
|
if ((state & Frame.MAXIMIZED_BOTH) != 0) { |
||||||
|
updateToggleButton(myRestoreAction, myMinimizeIcon); |
||||||
|
myMaximizeAction.setEnabled(false); |
||||||
|
myRestoreAction.setEnabled(true); |
||||||
|
} |
||||||
|
else { |
||||||
|
updateToggleButton(myMaximizeAction, myMaximizeIcon); |
||||||
|
myMaximizeAction.setEnabled(true); |
||||||
|
myRestoreAction.setEnabled(false); |
||||||
|
} |
||||||
|
if (myToggleButton.getParent() == null || |
||||||
|
myIconifyButton.getParent() == null) { |
||||||
|
add(myToggleButton); |
||||||
|
add(myIconifyButton); |
||||||
|
revalidate(); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
myToggleButton.setText(null); |
||||||
|
} |
||||||
|
else { |
||||||
|
myMaximizeAction.setEnabled(false); |
||||||
|
myRestoreAction.setEnabled(false); |
||||||
|
if (myToggleButton.getParent() != null) { |
||||||
|
remove(myToggleButton); |
||||||
|
revalidate(); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
// Not contained in a Frame
|
||||||
|
myMaximizeAction.setEnabled(false); |
||||||
|
myRestoreAction.setEnabled(false); |
||||||
|
myIconifyAction.setEnabled(false); |
||||||
|
remove(myToggleButton); |
||||||
|
remove(myIconifyButton); |
||||||
|
revalidate(); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
myCloseAction.setEnabled(true); |
||||||
|
myState = state; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void updateToggleButton(Action action, Icon icon) { |
||||||
|
myToggleButton.setAction(action); |
||||||
|
myToggleButton.setIcon(icon); |
||||||
|
myToggleButton.setText(null); |
||||||
|
} |
||||||
|
|
||||||
|
private Frame getFrame() { |
||||||
|
Window window = getWindow(); |
||||||
|
|
||||||
|
if (window instanceof Frame) { |
||||||
|
return (Frame)window; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
private Window getWindow() { |
||||||
|
return myWindow; |
||||||
|
} |
||||||
|
|
||||||
|
private String getTitle() { |
||||||
|
Window w = getWindow(); |
||||||
|
|
||||||
|
if (w instanceof Frame) { |
||||||
|
return ((Frame)w).getTitle(); |
||||||
|
} |
||||||
|
else if (w instanceof Dialog) { |
||||||
|
return ((Dialog)w).getTitle(); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
if (getFrame() != null) { |
||||||
|
setState(getFrame().getExtendedState()); |
||||||
|
} |
||||||
|
JRootPane rootPane = getRootPane(); |
||||||
|
Window window = getWindow(); |
||||||
|
boolean leftToRight = (window == null) ? |
||||||
|
rootPane.getComponentOrientation().isLeftToRight() : |
||||||
|
window.getComponentOrientation().isLeftToRight(); |
||||||
|
boolean isSelected = (window == null) ? true : window.isActive(); |
||||||
|
int width = getWidth(); |
||||||
|
int height = getHeight(); |
||||||
|
|
||||||
|
Color background; |
||||||
|
Color foreground; |
||||||
|
Color darkShadow; |
||||||
|
|
||||||
|
if (isSelected) { |
||||||
|
background = myActiveBackground; |
||||||
|
foreground = myActiveForeground; |
||||||
|
darkShadow = myActiveShadow; |
||||||
|
} |
||||||
|
else { |
||||||
|
background = myInactiveBackground; |
||||||
|
foreground = myInactiveForeground; |
||||||
|
darkShadow = myInactiveShadow; |
||||||
|
} |
||||||
|
|
||||||
|
g.setColor(background); |
||||||
|
g.fillRect(0, 0, width, height); |
||||||
|
|
||||||
|
g.setColor(darkShadow); |
||||||
|
g.drawLine(0, height - 1, width, height - 1); |
||||||
|
g.drawLine(0, 0, 0, 0); |
||||||
|
g.drawLine(width - 1, 0, width - 1, 0); |
||||||
|
|
||||||
|
int xOffset = leftToRight ? 5 : width - 5; |
||||||
|
|
||||||
|
if (getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5; |
||||||
|
} |
||||||
|
|
||||||
|
String theTitle = getTitle(); |
||||||
|
if (theTitle != null) { |
||||||
|
FontMetrics fm = SwingUtilities2.getFontMetrics(rootPane, g); |
||||||
|
|
||||||
|
g.setColor(foreground); |
||||||
|
|
||||||
|
int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent(); |
||||||
|
|
||||||
|
Rectangle rect = new Rectangle(0, 0, 0, 0); |
||||||
|
if (myIconifyButton != null && myIconifyButton.getParent() != null) { |
||||||
|
rect = myIconifyButton.getBounds(); |
||||||
|
} |
||||||
|
int titleW; |
||||||
|
|
||||||
|
if (leftToRight) { |
||||||
|
if (rect.x == 0) { |
||||||
|
rect.x = window.getWidth() - window.getInsets().right - 2; |
||||||
|
} |
||||||
|
titleW = rect.x - xOffset - 4; |
||||||
|
theTitle = SwingUtilities2.clipStringIfNecessary( |
||||||
|
rootPane, fm, theTitle, titleW); |
||||||
|
} |
||||||
|
else { |
||||||
|
titleW = xOffset - rect.x - rect.width - 4; |
||||||
|
theTitle = SwingUtilities2.clipStringIfNecessary( |
||||||
|
rootPane, fm, theTitle, titleW); |
||||||
|
xOffset -= SwingUtilities2.stringWidth(rootPane, fm, theTitle); |
||||||
|
} |
||||||
|
int titleLength = SwingUtilities2.stringWidth(rootPane, fm, theTitle); |
||||||
|
SwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset); |
||||||
|
xOffset += leftToRight ? titleLength + 5 : -5; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class CloseAction extends AbstractAction { |
||||||
|
public CloseAction() { |
||||||
|
super(UIManager.getString("DarculaTitlePane.closeTitle", getLocale())); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
close(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class IconifyAction extends AbstractAction { |
||||||
|
public IconifyAction() { |
||||||
|
super(UIManager.getString("DarculaTitlePane.iconifyTitle", getLocale())); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
iconify(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class RestoreAction extends AbstractAction { |
||||||
|
public RestoreAction() { |
||||||
|
super(UIManager.getString |
||||||
|
("DarculaTitlePane.restoreTitle", getLocale())); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
restore(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class MaximizeAction extends AbstractAction { |
||||||
|
public MaximizeAction() { |
||||||
|
super(UIManager.getString("DarculaTitlePane.maximizeTitle", getLocale())); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
maximize(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class SystemMenuBar extends JMenuBar { |
||||||
|
public void paint(Graphics g) { |
||||||
|
if (isOpaque()) { |
||||||
|
g.setColor(getBackground()); |
||||||
|
g.fillRect(0, 0, getWidth(), getHeight()); |
||||||
|
} |
||||||
|
|
||||||
|
if (mySystemIcon != null) { |
||||||
|
g.drawImage(mySystemIcon, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, null); |
||||||
|
} |
||||||
|
else { |
||||||
|
Icon icon = UIManager.getIcon("InternalFrame.icon"); |
||||||
|
|
||||||
|
if (icon != null) { |
||||||
|
icon.paintIcon(this, g, 0, 0); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension getMinimumSize() { |
||||||
|
return getPreferredSize(); |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension getPreferredSize() { |
||||||
|
Dimension size = super.getPreferredSize(); |
||||||
|
|
||||||
|
return new Dimension(Math.max(IMAGE_WIDTH, size.width), |
||||||
|
Math.max(size.height, IMAGE_HEIGHT)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class TitlePaneLayout implements LayoutManager { |
||||||
|
public void addLayoutComponent(String name, Component c) { |
||||||
|
} |
||||||
|
|
||||||
|
public void removeLayoutComponent(Component c) { |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension preferredLayoutSize(Container c) { |
||||||
|
int height = computeHeight(); |
||||||
|
//noinspection SuspiciousNameCombination
|
||||||
|
return new Dimension(height, height); |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension minimumLayoutSize(Container c) { |
||||||
|
return preferredLayoutSize(c); |
||||||
|
} |
||||||
|
|
||||||
|
private int computeHeight() { |
||||||
|
FontMetrics fm = myRootPane.getFontMetrics(getFont()); |
||||||
|
int fontHeight = fm.getHeight(); |
||||||
|
fontHeight += 7; |
||||||
|
int iconHeight = 0; |
||||||
|
if (getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
iconHeight = IMAGE_HEIGHT; |
||||||
|
} |
||||||
|
|
||||||
|
return Math.max(fontHeight, iconHeight); |
||||||
|
} |
||||||
|
|
||||||
|
public void layoutContainer(Container c) { |
||||||
|
boolean leftToRight = (myWindow == null) ? |
||||||
|
getRootPane().getComponentOrientation().isLeftToRight() : |
||||||
|
myWindow.getComponentOrientation().isLeftToRight(); |
||||||
|
|
||||||
|
int w = getWidth(); |
||||||
|
int x; |
||||||
|
int y = 3; |
||||||
|
int spacing; |
||||||
|
int buttonHeight; |
||||||
|
int buttonWidth; |
||||||
|
|
||||||
|
if (myCloseButton != null && myCloseButton.getIcon() != null) { |
||||||
|
buttonHeight = myCloseButton.getIcon().getIconHeight(); |
||||||
|
buttonWidth = myCloseButton.getIcon().getIconWidth(); |
||||||
|
} |
||||||
|
else { |
||||||
|
buttonHeight = IMAGE_HEIGHT; |
||||||
|
buttonWidth = IMAGE_WIDTH; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
x = leftToRight ? w : 0; |
||||||
|
|
||||||
|
spacing = 5; |
||||||
|
x = leftToRight ? spacing : w - buttonWidth - spacing; |
||||||
|
if (myMenuBar != null) { |
||||||
|
myMenuBar.setBounds(x, y, buttonWidth, buttonHeight); |
||||||
|
} |
||||||
|
|
||||||
|
x = leftToRight ? w : 0; |
||||||
|
spacing = 4; |
||||||
|
x += leftToRight ? -spacing - buttonWidth : spacing; |
||||||
|
if (myCloseButton != null) { |
||||||
|
myCloseButton.setBounds(x, y, buttonWidth, buttonHeight); |
||||||
|
} |
||||||
|
|
||||||
|
if (!leftToRight) x += buttonWidth; |
||||||
|
|
||||||
|
if (getWindowDecorationStyle() == JRootPane.FRAME) { |
||||||
|
if (Toolkit.getDefaultToolkit().isFrameStateSupported( |
||||||
|
Frame.MAXIMIZED_BOTH)) { |
||||||
|
if (myToggleButton.getParent() != null) { |
||||||
|
spacing = 10; |
||||||
|
x += leftToRight ? -spacing - buttonWidth : spacing; |
||||||
|
myToggleButton.setBounds(x, y, buttonWidth, buttonHeight); |
||||||
|
if (!leftToRight) { |
||||||
|
x += buttonWidth; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (myIconifyButton != null && myIconifyButton.getParent() != null) { |
||||||
|
spacing = 2; |
||||||
|
x += leftToRight ? -spacing - buttonWidth : spacing; |
||||||
|
myIconifyButton.setBounds(x, y, buttonWidth, buttonHeight); |
||||||
|
if (!leftToRight) { |
||||||
|
x += buttonWidth; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class PropertyChangeHandler implements PropertyChangeListener { |
||||||
|
public void propertyChange(PropertyChangeEvent pce) { |
||||||
|
String name = pce.getPropertyName(); |
||||||
|
|
||||||
|
if ("resizable".equals(name) || "state".equals(name)) { |
||||||
|
Frame frame = getFrame(); |
||||||
|
|
||||||
|
if (frame != null) { |
||||||
|
setState(frame.getExtendedState(), true); |
||||||
|
} |
||||||
|
if ("resizable".equals(name)) { |
||||||
|
getRootPane().repaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
else if ("title".equals(name)) { |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
else if ("componentOrientation" == name) { |
||||||
|
revalidate(); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
else if ("iconImage" == name) { |
||||||
|
updateSystemIcon(); |
||||||
|
revalidate(); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void updateSystemIcon() { |
||||||
|
Window window = getWindow(); |
||||||
|
if (window == null) { |
||||||
|
mySystemIcon = null; |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
List<Image> icons = window.getIconImages(); |
||||||
|
assert icons != null; |
||||||
|
|
||||||
|
if (icons.size() == 0) { |
||||||
|
mySystemIcon = null; |
||||||
|
} else if (icons.size() == 1) { |
||||||
|
mySystemIcon = icons.get(0); |
||||||
|
} else { |
||||||
|
mySystemIcon = SunToolkit.getScaledIconImage(icons, IMAGE_WIDTH, IMAGE_HEIGHT); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class WindowHandler extends WindowAdapter { |
||||||
|
public void windowActivated(WindowEvent ev) { |
||||||
|
setActive(true); |
||||||
|
} |
||||||
|
|
||||||
|
public void windowDeactivated(WindowEvent ev) { |
||||||
|
setActive(false); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,423 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2000-2013 JetBrains s.r.o. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.bulenkov.darcula.ui; |
||||||
|
|
||||||
|
|
||||||
|
import com.bulenkov.iconloader.util.SystemInfo; |
||||||
|
import com.bulenkov.iconloader.util.UIUtil; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.border.Border; |
||||||
|
import javax.swing.plaf.ComponentUI; |
||||||
|
import javax.swing.plaf.UIResource; |
||||||
|
import javax.swing.plaf.basic.BasicTreeUI; |
||||||
|
import javax.swing.tree.TreePath; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Konstantin Bulenkov |
||||||
|
*/ |
||||||
|
public class DarculaTreeUI extends BasicTreeUI { |
||||||
|
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) |
||||||
|
public static ComponentUI createUI(JComponent c) { |
||||||
|
return new DarculaTreeUI(); |
||||||
|
} |
||||||
|
|
||||||
|
public static final String TREE_TABLE_TREE_KEY = "TreeTableTree"; |
||||||
|
|
||||||
|
public static final String SOURCE_LIST_CLIENT_PROPERTY = "mac.ui.source.list"; |
||||||
|
public static final String STRIPED_CLIENT_PROPERTY = "mac.ui.striped"; |
||||||
|
|
||||||
|
private static final Border LIST_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListBackgroundPainter"); |
||||||
|
private static final Border LIST_SELECTION_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListSelectionBackgroundPainter"); |
||||||
|
private static final Border LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListFocusedSelectionBackgroundPainter"); |
||||||
|
|
||||||
|
private boolean myOldRepaintAllRowValue; |
||||||
|
private boolean invertLineColor; |
||||||
|
private boolean myForceDontPaintLines = false; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public int getRightChildIndent() { |
||||||
|
return isSkinny() ? 8 : super.getRightChildIndent(); |
||||||
|
} |
||||||
|
|
||||||
|
private static boolean isSkinny() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
private final MouseListener mySelectionListener = new MouseAdapter() { |
||||||
|
boolean handled = false; |
||||||
|
@Override |
||||||
|
public void mousePressed(final MouseEvent e) { |
||||||
|
handled = false; |
||||||
|
if (!isSelected(e)) { |
||||||
|
handled = true; |
||||||
|
handle(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseReleased(final MouseEvent e) { |
||||||
|
if (!handled) { |
||||||
|
handle(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isSelected(MouseEvent e) { |
||||||
|
final JTree tree = (JTree)e.getSource(); |
||||||
|
final int selected = tree.getClosestRowForLocation(e.getX(), e.getY()); |
||||||
|
final int[] rows = tree.getSelectionRows(); |
||||||
|
if (rows != null) { |
||||||
|
for (int row : rows) { |
||||||
|
if (row == selected) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private void handle(MouseEvent e) { |
||||||
|
final JTree tree = (JTree)e.getSource(); |
||||||
|
if (SwingUtilities.isLeftMouseButton(e) && !e.isPopupTrigger()) { |
||||||
|
// if we can't stop any ongoing editing, do nothing
|
||||||
|
if (isEditing(tree) && tree.getInvokesStopCellEditing() && !stopEditing(tree)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
final TreePath pressedPath = getClosestPathForLocation(tree, e.getX(), e.getY()); |
||||||
|
if (pressedPath != null) { |
||||||
|
Rectangle bounds = getPathBounds(tree, pressedPath); |
||||||
|
|
||||||
|
if (e.getY() >= bounds.y + bounds.height) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (bounds.contains(e.getPoint()) || isLocationInExpandControl(pressedPath, e.getX(), e.getY())) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (tree.getDragEnabled() || !startEditing(pressedPath, e)) { |
||||||
|
selectPathForEvent(pressedPath, e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void completeUIInstall() { |
||||||
|
super.completeUIInstall(); |
||||||
|
|
||||||
|
myOldRepaintAllRowValue = UIManager.getBoolean("Tree.repaintWholeRow"); |
||||||
|
UIManager.put("Tree.repaintWholeRow", true); |
||||||
|
|
||||||
|
tree.setShowsRootHandles(true); |
||||||
|
tree.addMouseListener(mySelectionListener); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void uninstallUI(JComponent c) { |
||||||
|
super.uninstallUI(c); |
||||||
|
|
||||||
|
UIManager.put("Tree.repaintWholeRow", myOldRepaintAllRowValue); |
||||||
|
c.removeMouseListener(mySelectionListener); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void installKeyboardActions() { |
||||||
|
super.installKeyboardActions(); |
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(tree.getClientProperty("MacTreeUi.actionsInstalled"))) return; |
||||||
|
|
||||||
|
tree.putClientProperty("MacTreeUi.actionsInstalled", Boolean.TRUE); |
||||||
|
|
||||||
|
final InputMap inputMap = tree.getInputMap(JComponent.WHEN_FOCUSED); |
||||||
|
inputMap.put(KeyStroke.getKeyStroke("pressed LEFT"), "collapse_or_move_up"); |
||||||
|
inputMap.put(KeyStroke.getKeyStroke("pressed RIGHT"), "expand"); |
||||||
|
|
||||||
|
final ActionMap actionMap = tree.getActionMap(); |
||||||
|
|
||||||
|
final Action expandAction = actionMap.get("expand"); |
||||||
|
if (expandAction != null) { |
||||||
|
actionMap.put("expand", new TreeUIAction() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
final Object source = e.getSource(); |
||||||
|
if (source instanceof JTree) { |
||||||
|
JTree tree = (JTree)source; |
||||||
|
int selectionRow = tree.getLeadSelectionRow(); |
||||||
|
if (selectionRow != -1) { |
||||||
|
TreePath selectionPath = tree.getPathForRow(selectionRow); |
||||||
|
if (selectionPath != null) { |
||||||
|
boolean leaf = tree.getModel().isLeaf(selectionPath.getLastPathComponent()); |
||||||
|
int toSelect = -1; |
||||||
|
int toScroll = -1; |
||||||
|
if (!leaf && tree.isExpanded(selectionRow)) { |
||||||
|
if (selectionRow + 1 < tree.getRowCount()) { |
||||||
|
toSelect = selectionRow + 1; |
||||||
|
toScroll = toSelect; |
||||||
|
} |
||||||
|
} else if (leaf) { |
||||||
|
toScroll = selectionRow; |
||||||
|
} |
||||||
|
|
||||||
|
if (toSelect != -1) { |
||||||
|
tree.setSelectionInterval(toSelect, toSelect); |
||||||
|
} |
||||||
|
|
||||||
|
if (toScroll != -1) { |
||||||
|
tree.scrollRowToVisible(toScroll); |
||||||
|
} |
||||||
|
|
||||||
|
if (toSelect != -1 || toScroll != -1) return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
expandAction.actionPerformed(e); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
actionMap.put("collapse_or_move_up", new TreeUIAction() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(final ActionEvent e) { |
||||||
|
final Object source = e.getSource(); |
||||||
|
if (source instanceof JTree) { |
||||||
|
JTree tree = (JTree)source; |
||||||
|
int selectionRow = tree.getLeadSelectionRow(); |
||||||
|
if (selectionRow == -1) return; |
||||||
|
|
||||||
|
TreePath selectionPath = tree.getPathForRow(selectionRow); |
||||||
|
if (selectionPath == null) return; |
||||||
|
|
||||||
|
if (tree.getModel().isLeaf(selectionPath.getLastPathComponent()) || tree.isCollapsed(selectionRow)) { |
||||||
|
final TreePath parentPath = tree.getPathForRow(selectionRow).getParentPath(); |
||||||
|
if (parentPath != null) { |
||||||
|
if (parentPath.getParentPath() != null || tree.isRootVisible()) { |
||||||
|
final int parentRow = tree.getRowForPath(parentPath); |
||||||
|
tree.scrollRowToVisible(parentRow); |
||||||
|
tree.setSelectionInterval(parentRow, parentRow); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
tree.collapseRow(selectionRow); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public void setForceDontPaintLines() { |
||||||
|
myForceDontPaintLines = true; |
||||||
|
} |
||||||
|
|
||||||
|
private abstract static class TreeUIAction extends AbstractAction implements UIResource { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected int getRowX(int row, int depth) { |
||||||
|
return isSkinny() ? 8 * depth + 8 : super.getRowX(row, depth); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintHorizontalPartOfLeg(final Graphics g, |
||||||
|
final Rectangle clipBounds, |
||||||
|
final Insets insets, |
||||||
|
final Rectangle bounds, |
||||||
|
final TreePath path, |
||||||
|
final int row, |
||||||
|
final boolean isExpanded, |
||||||
|
final boolean hasBeenExpanded, |
||||||
|
final boolean isLeaf) { |
||||||
|
} |
||||||
|
|
||||||
|
private boolean shouldPaintLines() { |
||||||
|
return myForceDontPaintLines || !"None".equals(tree.getClientProperty("JTree.lineStyle")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean isToggleSelectionEvent(MouseEvent e) { |
||||||
|
return SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown()) && !e.isPopupTrigger(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintVerticalPartOfLeg(final Graphics g, final Rectangle clipBounds, final Insets insets, final TreePath path) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Color getHashColor() { |
||||||
|
if (invertLineColor && !equalsNullable(UIUtil.getTreeSelectionForeground(), UIUtil.getTreeForeground())) { |
||||||
|
final Color c = UIUtil.getTreeSelectionForeground(); |
||||||
|
if (c != null) { |
||||||
|
return c.darker(); |
||||||
|
} |
||||||
|
} |
||||||
|
return super.getHashColor(); |
||||||
|
} |
||||||
|
|
||||||
|
private static <T> boolean equalsNullable(T a, T b) { |
||||||
|
if (a == null) { |
||||||
|
return b == null; |
||||||
|
} else { |
||||||
|
return b != null && a.equals(b); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintRow(final Graphics g, |
||||||
|
final Rectangle clipBounds, |
||||||
|
final Insets insets, |
||||||
|
final Rectangle bounds, |
||||||
|
final TreePath path, |
||||||
|
final int row, |
||||||
|
final boolean isExpanded, |
||||||
|
final boolean hasBeenExpanded, |
||||||
|
final boolean isLeaf) { |
||||||
|
final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth(); |
||||||
|
final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0; |
||||||
|
|
||||||
|
if (path != null) { |
||||||
|
boolean selected = tree.isPathSelected(path); |
||||||
|
Graphics2D rowGraphics = (Graphics2D)g.create(); |
||||||
|
rowGraphics.setClip(clipBounds); |
||||||
|
|
||||||
|
final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY); |
||||||
|
Color background = tree.getBackground(); |
||||||
|
|
||||||
|
if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) { |
||||||
|
background = UIUtil.getDecoratedRowColor(); |
||||||
|
} |
||||||
|
|
||||||
|
if (sourceList != null && (Boolean)sourceList) { |
||||||
|
if (selected) { |
||||||
|
if (tree.hasFocus()) { |
||||||
|
LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height); |
||||||
|
} |
||||||
|
else { |
||||||
|
LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height); |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
rowGraphics.setColor(background); |
||||||
|
rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height); |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
if (selected) { |
||||||
|
Color bg = UIUtil.getTreeSelectionBackground(tree.hasFocus() || Boolean.TRUE.equals(tree.getClientProperty(TREE_TABLE_TREE_KEY))); |
||||||
|
|
||||||
|
rowGraphics.setColor(bg); |
||||||
|
rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) { |
||||||
|
paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); |
||||||
|
} |
||||||
|
|
||||||
|
super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); |
||||||
|
rowGraphics.dispose(); |
||||||
|
} |
||||||
|
else { |
||||||
|
super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paint(Graphics g, JComponent c) { |
||||||
|
final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth(); |
||||||
|
final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport) tree.getParent()).getViewPosition().x : 0; |
||||||
|
final Rectangle bounds = g.getClipBounds(); |
||||||
|
|
||||||
|
// draw background for the given clip bounds
|
||||||
|
final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY); |
||||||
|
if (sourceList != null && (Boolean) sourceList) { |
||||||
|
Graphics2D backgroundGraphics = (Graphics2D) g.create(); |
||||||
|
backgroundGraphics.setClip(xOffset, bounds.y, containerWidth, bounds.height); |
||||||
|
LIST_BACKGROUND_PAINTER.paintBorder(tree, backgroundGraphics, xOffset, bounds.y, containerWidth, bounds.height); |
||||||
|
backgroundGraphics.dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
super.paint(g, c); |
||||||
|
} |
||||||
|
|
||||||
|
protected void paintSelectedRows(Graphics g, JTree tr) { |
||||||
|
final Rectangle rect = tr.getVisibleRect(); |
||||||
|
final int firstVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y); |
||||||
|
final int lastVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y + rect.height); |
||||||
|
|
||||||
|
for (int row = firstVisibleRow; row <= lastVisibleRow; row++) { |
||||||
|
if (tr.getSelectionModel().isRowSelected(row)) { |
||||||
|
final Rectangle bounds = tr.getRowBounds(row); |
||||||
|
Color color = UIUtil.getTreeSelectionBackground(tr.hasFocus()); |
||||||
|
if (color != null) { |
||||||
|
g.setColor(color); |
||||||
|
g.fillRect(0, bounds.y, tr.getWidth(), bounds.height); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected CellRendererPane createCellRendererPane() { |
||||||
|
return new CellRendererPane() { |
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate) { |
||||||
|
if (c instanceof JComponent) { |
||||||
|
((JComponent)c).setOpaque(false); |
||||||
|
} |
||||||
|
|
||||||
|
super.paintComponent(g, c, p, x, y, w, h, shouldValidate); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintExpandControl(Graphics g, |
||||||
|
Rectangle clipBounds, |
||||||
|
Insets insets, |
||||||
|
Rectangle bounds, |
||||||
|
TreePath path, |
||||||
|
int row, |
||||||
|
boolean isExpanded, |
||||||
|
boolean hasBeenExpanded, |
||||||
|
boolean isLeaf) { |
||||||
|
boolean isPathSelected = tree.getSelectionModel().isPathSelected(path); |
||||||
|
if (!isLeaf(row)) { |
||||||
|
setExpandedIcon(UIUtil.getTreeNodeIcon(true, isPathSelected, tree.hasFocus())); |
||||||
|
setCollapsedIcon(UIUtil.getTreeNodeIcon(false, isPathSelected, tree.hasFocus())); |
||||||
|
} |
||||||
|
|
||||||
|
super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package com.bulenkov.darcula.util; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Konstantin Bulenkov |
||||||
|
*/ |
||||||
|
public interface DarculaColors { |
||||||
|
Color BLUE = new Color(0x589df6); |
||||||
|
Color RED = new Color(0xff6464); |
||||||
|
} |
@ -1,142 +0,0 @@ |
|||||||
package com.bulenkov.darcula.util; |
|
||||||
|
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.Collections; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Konstantin Bulenkov |
|
||||||
*/ |
|
||||||
public class StringUtil { |
|
||||||
public static List<String> split(String s, String separator) { |
|
||||||
return split(s, separator, true); |
|
||||||
} |
|
||||||
|
|
||||||
public static List<String> split(String s, String separator, |
|
||||||
boolean excludeSeparator) { |
|
||||||
return split(s, separator, excludeSeparator, true); |
|
||||||
} |
|
||||||
|
|
||||||
public static List<String> split(String s, String separator, |
|
||||||
boolean excludeSeparator, boolean excludeEmptyStrings) { |
|
||||||
if (separator.isEmpty()) { |
|
||||||
return Collections.singletonList(s); |
|
||||||
} |
|
||||||
List<String> result = new ArrayList<String>(); |
|
||||||
int pos = 0; |
|
||||||
while (true) { |
|
||||||
int index = s.indexOf(separator, pos); |
|
||||||
if (index == -1) break; |
|
||||||
final int nextPos = index + separator.length(); |
|
||||||
String token = s.substring(pos, excludeSeparator ? index : nextPos); |
|
||||||
if (!token.isEmpty() || !excludeEmptyStrings) { |
|
||||||
result.add(token); |
|
||||||
} |
|
||||||
pos = nextPos; |
|
||||||
} |
|
||||||
if (pos < s.length() || (!excludeEmptyStrings && pos == s.length())) { |
|
||||||
result.add(s.substring(pos, s.length())); |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
public static int naturalCompare(String string1, String string2) { |
|
||||||
return naturalCompare(string1, string2, false); |
|
||||||
} |
|
||||||
|
|
||||||
private static int naturalCompare(String string1, String string2, boolean caseSensitive) { |
|
||||||
final int string1Length = string1.length(); |
|
||||||
final int string2Length = string2.length(); |
|
||||||
for (int i = 0, j = 0; i < string1Length && j < string2Length; i++, j++) { |
|
||||||
char ch1 = string1.charAt(i); |
|
||||||
char ch2 = string2.charAt(j); |
|
||||||
if ((isDigit(ch1) || ch1 == ' ') && (isDigit(ch2) || ch2 == ' ')) { |
|
||||||
int startNum1 = i; |
|
||||||
while (ch1 == ' ' || ch1 == '0') { // skip leading spaces and zeros
|
|
||||||
startNum1++; |
|
||||||
if (startNum1 >= string1Length) break; |
|
||||||
ch1 = string1.charAt(startNum1); |
|
||||||
} |
|
||||||
int startNum2 = j; |
|
||||||
while (ch2 == ' ' || ch2 == '0') { |
|
||||||
startNum2++; |
|
||||||
if (startNum2 >= string2Length) break; |
|
||||||
ch2 = string2.charAt(startNum2); |
|
||||||
} |
|
||||||
i = startNum1; |
|
||||||
j = startNum2; |
|
||||||
while (i < string1Length && isDigit(string1.charAt(i))) i++; |
|
||||||
while (j < string2Length && isDigit(string2.charAt(j))) j++; |
|
||||||
String digits1 = string1.substring(startNum1, i); |
|
||||||
String digits2 = string2.substring(startNum2, j); |
|
||||||
if (digits1.length() != digits2.length()) { |
|
||||||
return digits1.length() - digits2.length(); |
|
||||||
} |
|
||||||
int numberDiff = digits1.compareTo(digits2); |
|
||||||
if (numberDiff != 0) { |
|
||||||
return numberDiff; |
|
||||||
} |
|
||||||
i--; |
|
||||||
j--; |
|
||||||
final int lengthDiff = (i - startNum1) - (j - startNum2); |
|
||||||
if (lengthDiff != 0) { |
|
||||||
return lengthDiff; |
|
||||||
} |
|
||||||
for (; startNum1 < i; startNum1++, startNum2++) { |
|
||||||
final int diff = string1.charAt(startNum1) - string2.charAt(startNum2); |
|
||||||
if (diff != 0) { |
|
||||||
return diff; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
else { |
|
||||||
if (caseSensitive) { |
|
||||||
return ch1 - ch2; |
|
||||||
} |
|
||||||
else { |
|
||||||
// similar logic to charsMatch() below
|
|
||||||
if (ch1 != ch2) { |
|
||||||
final int diff1 = toUpperCase(ch1) - toUpperCase(ch2); |
|
||||||
if (diff1 != 0) { |
|
||||||
final int diff2 = toLowerCase(ch1) - toLowerCase(ch2); |
|
||||||
if (diff2 != 0) { |
|
||||||
return diff2; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if (!caseSensitive && string1Length == string2Length) { |
|
||||||
// do case sensitive compare if case insensitive strings are equal
|
|
||||||
return naturalCompare(string1, string2, true); |
|
||||||
} |
|
||||||
return string1Length - string2Length; |
|
||||||
} |
|
||||||
|
|
||||||
public static char toUpperCase(char a) { |
|
||||||
if (a < 'a') { |
|
||||||
return a; |
|
||||||
} |
|
||||||
if (a <= 'z') { |
|
||||||
return (char)(a + ('A' - 'a')); |
|
||||||
} |
|
||||||
return Character.toUpperCase(a); |
|
||||||
} |
|
||||||
|
|
||||||
public static char toLowerCase(char a) { |
|
||||||
if (a < 'A' || a >= 'a' && a <= 'z') { |
|
||||||
return a; |
|
||||||
} |
|
||||||
|
|
||||||
if (a <= 'Z') { |
|
||||||
return (char)(a + ('a' - 'A')); |
|
||||||
} |
|
||||||
|
|
||||||
return Character.toLowerCase(a); |
|
||||||
} |
|
||||||
|
|
||||||
private static boolean isDigit(char c) { |
|
||||||
return c >= '0' && c <= '9'; |
|
||||||
} |
|
||||||
} |
|
@ -1,39 +0,0 @@ |
|||||||
package com.bulenkov.darcula.util; |
|
||||||
|
|
||||||
import javax.swing.*; |
|
||||||
import java.awt.*; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Konstantin Bulenkov |
|
||||||
*/ |
|
||||||
public class UIUtil { |
|
||||||
public static <T extends JComponent> T findComponentOfType(JComponent parent, Class<T> cls) { |
|
||||||
if (parent == null || cls.isAssignableFrom(parent.getClass())) { |
|
||||||
@SuppressWarnings({"unchecked"}) final T t = (T)parent; |
|
||||||
return t; |
|
||||||
} |
|
||||||
for (Component component : parent.getComponents()) { |
|
||||||
if (component instanceof JComponent) { |
|
||||||
T comp = findComponentOfType((JComponent)component, cls); |
|
||||||
if (comp != null) return comp; |
|
||||||
} |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public static <T> T getParentOfType(Class<? extends T> cls, Component c) { |
|
||||||
Component eachParent = c; |
|
||||||
while (eachParent != null) { |
|
||||||
if (cls.isAssignableFrom(eachParent.getClass())) { |
|
||||||
@SuppressWarnings({"unchecked"}) final T t = (T)eachParent; |
|
||||||
return t; |
|
||||||
} |
|
||||||
|
|
||||||
eachParent = eachParent.getParent(); |
|
||||||
} |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |