Revision 1267 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/composer/DefaultJScriptingComposer.java
DefaultJScriptingComposer.java | ||
---|---|---|
12 | 12 |
import java.awt.event.MouseAdapter; |
13 | 13 |
import java.awt.event.MouseEvent; |
14 | 14 |
import java.beans.PropertyChangeEvent; |
15 |
import java.beans.PropertyChangeListener; |
|
16 | 15 |
import java.io.File; |
17 | 16 |
import java.util.ArrayList; |
18 | 17 |
import java.util.Collection; |
... | ... | |
91 | 90 |
import org.gvsig.scripting.swing.api.JScriptingComposer.Problems.Problem; |
92 | 91 |
import org.gvsig.scripting.swing.api.JScriptingConsole; |
93 | 92 |
import org.gvsig.scripting.swing.api.JScriptingLauncher; |
93 |
import org.gvsig.scripting.swing.api.JTextEditor; |
|
94 | 94 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
95 | 95 |
import org.gvsig.scripting.swing.api.ScriptingUIManager.MenuEntry; |
96 | 96 |
import org.gvsig.scripting.swing.api.SyntaxtHighlightTextComponent.UpdateCaretPositionActionEvent; |
... | ... | |
166 | 166 |
@Override |
167 | 167 |
public void actionPerformed(ActionEvent e) { |
168 | 168 |
JEditor editor = getCurrentEditor(); |
169 |
if (!(editor instanceof JCodeEditor)) {
|
|
169 |
if (!(editor instanceof JTextEditor)) {
|
|
170 | 170 |
return; |
171 | 171 |
} |
172 |
JCodeEditor codeEditor = (JCodeEditor) editor;
|
|
172 |
JTextEditor textEditor = (JTextEditor) editor;
|
|
173 | 173 |
if (findDialog.isVisible()) { |
174 | 174 |
findDialog.setVisible(false); |
175 | 175 |
} |
176 | 176 |
if (replaceDialog.isVisible()) { |
177 | 177 |
replaceDialog.setVisible(false); |
178 | 178 |
} |
179 |
gotoDialog.setMaxLineNumberAllowed(codeEditor.getLineCount());
|
|
179 |
gotoDialog.setMaxLineNumberAllowed(textEditor.getLineCount());
|
|
180 | 180 |
gotoDialog.setVisible(true); |
181 | 181 |
int line = gotoDialog.getLineNumber(); |
182 | 182 |
|
183 | 183 |
if (line > 0) { |
184 |
codeEditor.selectLine(line);
|
|
184 |
textEditor.selectLine(line);
|
|
185 | 185 |
} |
186 | 186 |
} |
187 | 187 |
|
188 | 188 |
@Override |
189 | 189 |
public boolean isEnabled() { |
190 | 190 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
191 |
return panel != null && panel.getComponent() instanceof JCodeEditor;
|
|
191 |
return panel != null && panel.getComponent() instanceof JTextEditor;
|
|
192 | 192 |
} |
193 | 193 |
} |
194 | 194 |
|
... | ... | |
215 | 215 |
@Override |
216 | 216 |
public boolean isEnabled() { |
217 | 217 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
218 |
return panel != null && panel.getComponent() instanceof JCodeEditor;
|
|
218 |
return panel != null && panel.getComponent() instanceof JTextEditor;
|
|
219 | 219 |
} |
220 | 220 |
} |
221 | 221 |
|
... | ... | |
242 | 242 |
@Override |
243 | 243 |
public boolean isEnabled() { |
244 | 244 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
245 |
return panel != null && panel.getComponent() instanceof JCodeEditor;
|
|
245 |
return panel != null && panel.getComponent() instanceof JTextEditor;
|
|
246 | 246 |
} |
247 | 247 |
} |
248 | 248 |
|
... | ... | |
287 | 287 |
@Override |
288 | 288 |
public boolean isEnabled() { |
289 | 289 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
290 |
return panel != null && panel.getComponent() instanceof JCodeEditor;
|
|
290 |
return panel != null && panel.getComponent() instanceof JTextEditor;
|
|
291 | 291 |
} |
292 | 292 |
|
293 | 293 |
} |
... | ... | |
353 | 353 |
@Override |
354 | 354 |
public boolean isEnabled() { |
355 | 355 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
356 |
return panel != null && panel.getComponent() instanceof JCodeEditor;
|
|
356 |
return panel != null && panel.getComponent() instanceof JTextEditor;
|
|
357 | 357 |
} |
358 | 358 |
|
359 | 359 |
} |
... | ... | |
378 | 378 |
@Override |
379 | 379 |
public boolean isEnabled() { |
380 | 380 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
381 |
return panel != null && panel.getComponent() instanceof JCodeEditor;
|
|
381 |
return panel != null && panel.getComponent() instanceof JTextEditor;
|
|
382 | 382 |
} |
383 | 383 |
|
384 | 384 |
} |
... | ... | |
403 | 403 |
@Override |
404 | 404 |
public boolean isEnabled() { |
405 | 405 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
406 |
return panel != null && panel.getComponent() instanceof JCodeEditor;
|
|
406 |
return panel != null && panel.getComponent() instanceof JTextEditor;
|
|
407 | 407 |
} |
408 | 408 |
|
409 | 409 |
} |
... | ... | |
954 | 954 |
|
955 | 955 |
tabbedPanelLeft.setTabPlacement(JTabbedPane.BOTTOM); |
956 | 956 |
tabbedPanelCenter.setPreferredSize(new Dimension(500, 300)); |
957 |
tabbedPanelCenter.addChangeListener(new ChangeListener() { |
|
958 |
|
|
959 |
@Override |
|
960 |
public void stateChanged(ChangeEvent e) { |
|
961 |
updateMenusAndTools(); |
|
962 |
try { |
|
963 |
((ScriptUnitEditor)((JTabbedPane)e.getSource()).getSelectedComponent()).getJTextComponent().requestFocusInWindow(); |
|
964 |
} catch(Throwable th) { |
|
965 |
LOGGER.debug("Can't set focus in the editor", th); |
|
966 |
} |
|
957 |
tabbedPanelCenter.addChangeListener((ChangeEvent e) -> { |
|
958 |
updateMenusAndTools(); |
|
959 |
try { |
|
960 |
((ScriptUnitEditor)((JTabbedPane)e.getSource()).getSelectedComponent()).getJTextComponent().requestFocusInWindow(); |
|
961 |
} catch(Throwable th) { |
|
962 |
LOGGER.debug("Can't set focus in the editor", th); |
|
967 | 963 |
} |
968 | 964 |
}); |
969 | 965 |
|
... | ... | |
972 | 968 |
tabbedPanelBottom, |
973 | 969 |
tabbedPanelCenter |
974 | 970 |
); |
975 |
this.dock.addCloseListener(new ActionListener() { |
|
976 |
|
|
977 |
@Override |
|
978 |
public void actionPerformed(ActionEvent e) { |
|
979 |
DockedPanel panel = (DockedPanel) e.getSource(); |
|
980 |
scriptClose(panel); |
|
981 |
} |
|
971 |
this.dock.addCloseListener((ActionEvent e) -> { |
|
972 |
DockedPanel panel = (DockedPanel) e.getSource(); |
|
973 |
scriptClose(panel); |
|
982 | 974 |
}); |
983 | 975 |
//tabbedPanelBottom.setPreferredSize(new Dimension(450, 100)); |
984 | 976 |
|
... | ... | |
1094 | 1086 |
return; |
1095 | 1087 |
} |
1096 | 1088 |
final Problems problems = new DefaultProblems(this.uimanager); |
1097 |
problems.addListSelectionListener(new ListSelectionListener() { |
|
1098 |
|
|
1099 |
@Override |
|
1100 |
public void valueChanged(ListSelectionEvent e) { |
|
1101 |
if (e.getValueIsAdjusting()) { |
|
1102 |
return; |
|
1103 |
} |
|
1104 |
Problem row = problems.getSelect(); |
|
1105 |
if (row != null) { |
|
1106 |
JEditor editor; |
|
1107 |
int lineno = row.getLineNumber(); |
|
1108 |
if( row.getResource() == null ) { |
|
1109 |
editor = getCurrentEditor(); |
|
1110 |
} else { |
|
1111 |
String id = row.getResource().getAbsolutePath(); |
|
1112 |
DockedPanel panel = getDock().get(id); |
|
1113 |
if( panel == null ) { |
|
1114 |
ScriptingBaseScript script = manager.getScript(row.getResource()); |
|
1115 |
scriptEdit(script); |
|
1116 |
panel = getDock().get(id); |
|
1117 |
if( panel == null ) { |
|
1118 |
LOGGER.warn("Can't load script '"+id+"'."); |
|
1119 |
return; |
|
1120 |
} |
|
1121 |
} |
|
1122 |
panel.select(); |
|
1123 |
editor = (JEditor) panel.getComponent(); |
|
1089 |
problems.addListSelectionListener((ListSelectionEvent e) -> { |
|
1090 |
if (e.getValueIsAdjusting()) { |
|
1091 |
return; |
|
1092 |
} |
|
1093 |
Problem row = problems.getSelect(); |
|
1094 |
if (row != null) { |
|
1095 |
JEditor editor; |
|
1096 |
int lineno = row.getLineNumber(); |
|
1097 |
if (row.getResource() == null) { |
|
1098 |
editor = getCurrentEditor(); |
|
1099 |
} else { |
|
1100 |
String id = row.getResource().getAbsolutePath(); |
|
1101 |
DockedPanel panel1 = getDock().get(id); |
|
1102 |
if (panel1 == null) { |
|
1103 |
ScriptingBaseScript script = manager.getScript(row.getResource()); |
|
1104 |
scriptEdit(script); |
|
1105 |
panel1 = getDock().get(id); |
|
1106 |
if (panel1 == null) { |
|
1107 |
LOGGER.warn("Can't load script '"+id+"'."); |
|
1108 |
return; |
|
1109 |
} |
|
1124 | 1110 |
} |
1125 |
if ( editor instanceof JCodeEditor) { |
|
1126 |
((JCodeEditor) editor).gotoline(lineno); |
|
1127 |
} |
|
1111 |
panel1.select(); |
|
1112 |
editor = (JEditor) panel1.getComponent(); |
|
1128 | 1113 |
} |
1114 |
if ( editor instanceof JCodeEditor) { |
|
1115 |
((JCodeEditor) editor).gotoline(lineno); |
|
1116 |
} |
|
1129 | 1117 |
} |
1130 | 1118 |
}); |
1131 | 1119 |
this.dock.add( |
... | ... | |
1160 | 1148 |
return; |
1161 | 1149 |
} |
1162 | 1150 |
JScriptingLauncher launcher = uimanager.createLauncher(); |
1163 |
launcher.addDefaultActionListener(new ActionListener() { |
|
1164 |
|
|
1165 |
@Override |
|
1166 |
public void actionPerformed(ActionEvent e) { |
|
1167 |
BrowserActionEvent e2 = (BrowserActionEvent) e; |
|
1168 |
switch (e.getID()) { |
|
1169 |
case JScriptingBrowser.DEFAULT_ACTION: |
|
1170 |
ScriptingUnit unit = e2.getUnit(); |
|
1171 |
if( unit instanceof ScriptingFolder ) { |
|
1172 |
return; |
|
1173 |
} |
|
1174 |
if( uimanager.hasEditor(unit) ) { |
|
1175 |
scriptEdit(unit); |
|
1176 |
} |
|
1177 |
break; |
|
1178 |
case JScriptingBrowser.DROPDOWN_ACTION: |
|
1179 |
case JScriptingBrowser.SELECTION_ACTION: |
|
1180 |
break; |
|
1181 |
} |
|
1151 |
launcher.addDefaultActionListener((ActionEvent e) -> { |
|
1152 |
BrowserActionEvent e2 = (BrowserActionEvent) e; |
|
1153 |
switch (e.getID()) { |
|
1154 |
case JScriptingBrowser.DEFAULT_ACTION: |
|
1155 |
ScriptingUnit unit = e2.getUnit(); |
|
1156 |
if( unit instanceof ScriptingFolder ) { |
|
1157 |
return; |
|
1158 |
} |
|
1159 |
if( uimanager.hasEditor(unit) ) { |
|
1160 |
scriptEdit(unit); |
|
1161 |
} |
|
1162 |
break; |
|
1163 |
case JScriptingBrowser.DROPDOWN_ACTION: |
|
1164 |
case JScriptingBrowser.SELECTION_ACTION: |
|
1165 |
break; |
|
1182 | 1166 |
} |
1183 | 1167 |
}); |
1184 | 1168 |
launcher.asJComponent().setPreferredSize(new Dimension(200, 450)); |
... | ... | |
1261 | 1245 |
manager.getRootUserFolder(), |
1262 | 1246 |
manager.getPackagesFolder() |
1263 | 1247 |
); |
1264 |
packager.addBeforePackingListener(new PackageBuildder.BeforePackingListener() { |
|
1265 |
@Override |
|
1266 |
public void perfrom(PackageBuildder builder) { |
|
1267 |
// Clean $py.class files before packing |
|
1268 |
Collection<File> files = FileUtils.listFiles( |
|
1269 |
builder.getFolderToPackaging(), |
|
1270 |
FileFilterUtils.suffixFileFilter("$py.class", IOCase.INSENSITIVE), |
|
1271 |
FileFilterUtils.trueFileFilter() |
|
1272 |
); |
|
1273 |
if( files!=null ) { |
|
1274 |
for (File file : files) { |
|
1275 |
FileUtils.deleteQuietly(file); |
|
1276 |
} |
|
1248 |
packager.addBeforePackingListener((PackageBuildder builder) -> { |
|
1249 |
// Clean $py.class files before packing |
|
1250 |
Collection<File> files = FileUtils.listFiles( |
|
1251 |
builder.getFolderToPackaging(), |
|
1252 |
FileFilterUtils.suffixFileFilter("$py.class", IOCase.INSENSITIVE), |
|
1253 |
FileFilterUtils.trueFileFilter() |
|
1254 |
); |
|
1255 |
if( files!=null ) { |
|
1256 |
for (File file : files) { |
|
1257 |
FileUtils.deleteQuietly(file); |
|
1277 | 1258 |
} |
1278 | 1259 |
} |
1279 | 1260 |
}); |
... | ... | |
1368 | 1349 |
} |
1369 | 1350 |
final DockedPanel panel = this.dock.add(id, unit.getName(), editor, Dock.DOCK_CENTER); |
1370 | 1351 |
panel.select(); |
1371 |
editor.addChangeListener(new PropertyChangeListener() { |
|
1372 |
|
|
1373 |
@Override |
|
1374 |
public void propertyChange(PropertyChangeEvent evt) { |
|
1375 |
panel.setModified(true); |
|
1376 |
fireChangeEditor(new ChangeEvent(editor)); |
|
1377 |
} |
|
1352 |
editor.addChangeListener((PropertyChangeEvent evt) -> { |
|
1353 |
panel.setModified(true); |
|
1354 |
fireChangeEditor(new ChangeEvent(editor)); |
|
1378 | 1355 |
}); |
1379 |
if (editor instanceof JCodeEditor) { |
|
1380 |
((JCodeEditor) editor).addUpdateCaretPositionActionListener(new ActionListener() { |
|
1381 |
|
|
1382 |
@Override |
|
1383 |
public void actionPerformed(ActionEvent e) { |
|
1384 |
UpdateCaretPositionActionEvent event = (UpdateCaretPositionActionEvent) e; |
|
1385 |
getStatusbar().setPosition( |
|
1386 |
event.getLine(), |
|
1387 |
event.getColumn() |
|
1388 |
); |
|
1389 |
} |
|
1356 |
if (editor instanceof JTextEditor) { |
|
1357 |
((JTextEditor) editor).addUpdateCaretPositionActionListener((ActionEvent e) -> { |
|
1358 |
UpdateCaretPositionActionEvent event = (UpdateCaretPositionActionEvent) e; |
|
1359 |
getStatusbar().setPosition( |
|
1360 |
event.getLine(), |
|
1361 |
event.getColumn() |
|
1362 |
); |
|
1390 | 1363 |
}); |
1391 | 1364 |
} |
1392 | 1365 |
ScriptingUnit xx = editor.getUnit(); |
... | ... | |
1546 | 1519 |
} |
1547 | 1520 |
|
1548 | 1521 |
public void scriptDelete(final ScriptingUnit unit, boolean isRecursive) { |
1522 |
if( unit==null ) { |
|
1523 |
return; |
|
1524 |
} |
|
1549 | 1525 |
int n = 0; |
1550 | 1526 |
if (!isRecursive) { |
1551 | 1527 |
n = JOptionPane.showConfirmDialog( |
... | ... | |
1676 | 1652 |
*/ |
1677 | 1653 |
public void currentScriptCopy() { |
1678 | 1654 |
DockedPanel panel = this.dock.getSelected(Dock.DOCK_CENTER); |
1679 |
if (panel.getComponent().asJComponent() instanceof JCodeEditor) {
|
|
1680 |
JCodeEditor editor = (JCodeEditor) panel.getComponent().asJComponent();
|
|
1655 |
if (panel.getComponent().asJComponent() instanceof JTextEditor) {
|
|
1656 |
JTextEditor editor = (JTextEditor) panel.getComponent().asJComponent();
|
|
1681 | 1657 |
editor.getJTextComponent().copy(); |
1682 | 1658 |
} |
1683 | 1659 |
} |
1684 | 1660 |
|
1685 | 1661 |
public void currentScriptCut() { |
1686 | 1662 |
DockedPanel panel = this.dock.getSelected(Dock.DOCK_CENTER); |
1687 |
if (panel.getComponent().asJComponent() instanceof JCodeEditor) {
|
|
1688 |
JCodeEditor editor = (JCodeEditor) panel.getComponent().asJComponent();
|
|
1663 |
if (panel.getComponent().asJComponent() instanceof JTextEditor) {
|
|
1664 |
JTextEditor editor = (JTextEditor) panel.getComponent().asJComponent();
|
|
1689 | 1665 |
editor.getJTextComponent().cut(); |
1690 | 1666 |
panel.setModified(true); |
1691 | 1667 |
} |
... | ... | |
1693 | 1669 |
|
1694 | 1670 |
public void currentScriptPaste() { |
1695 | 1671 |
DockedPanel panel = this.dock.getSelected(Dock.DOCK_CENTER); |
1696 |
if (panel.getComponent().asJComponent() instanceof JCodeEditor) {
|
|
1697 |
JCodeEditor editor = (JCodeEditor) panel.getComponent().asJComponent();
|
|
1672 |
if (panel.getComponent().asJComponent() instanceof JTextEditor) {
|
|
1673 |
JTextEditor editor = (JTextEditor) panel.getComponent().asJComponent();
|
|
1698 | 1674 |
editor.getJTextComponent().paste(); |
1699 | 1675 |
panel.setModified(true); |
1700 | 1676 |
} |
... | ... | |
1702 | 1678 |
|
1703 | 1679 |
public void currentScriptSelectAll() { |
1704 | 1680 |
DockedPanel panel = this.dock.getSelected(Dock.DOCK_CENTER); |
1705 |
if (panel.getComponent().asJComponent() instanceof JCodeEditor) {
|
|
1706 |
JCodeEditor editor = (JCodeEditor) panel.getComponent().asJComponent();
|
|
1681 |
if (panel.getComponent().asJComponent() instanceof JTextEditor) {
|
|
1682 |
JTextEditor editor = (JTextEditor) panel.getComponent().asJComponent();
|
|
1707 | 1683 |
editor.getJTextComponent().selectAll(); |
1708 | 1684 |
} |
1709 | 1685 |
} |
... | ... | |
1739 | 1715 |
null, |
1740 | 1716 |
WindowManager_v2.BUTTONS_OK_CANCEL |
1741 | 1717 |
); |
1742 |
dialog.addActionListener(new ActionListener() { |
|
1743 |
@Override |
|
1744 |
public void actionPerformed(ActionEvent e) { |
|
1745 |
if( dialog.getAction()==WindowManager_v2.BUTTON_OK ) { |
|
1746 |
ScriptingUnit script = browser.getSelectedNode(); |
|
1747 |
if( script instanceof ScriptingScript ) { |
|
1748 |
mainScriptSelect((ScriptingScript)script); |
|
1749 |
} else { |
|
1750 |
JOptionPane.showMessageDialog( |
|
1751 |
DefaultJScriptingComposer.this, |
|
1752 |
uimanager.getTranslation("_The_selected_script_is_invalid"), |
|
1753 |
uimanager.getTranslation("_Warning"), |
|
1754 |
JOptionPane.INFORMATION_MESSAGE |
|
1755 |
); |
|
1756 |
} |
|
1718 |
dialog.addActionListener((ActionEvent e) -> { |
|
1719 |
if( dialog.getAction()==WindowManager_v2.BUTTON_OK ) { |
|
1720 |
ScriptingUnit script = browser.getSelectedNode(); |
|
1721 |
if( script instanceof ScriptingScript ) { |
|
1722 |
mainScriptSelect((ScriptingScript)script); |
|
1723 |
} else { |
|
1724 |
JOptionPane.showMessageDialog( |
|
1725 |
DefaultJScriptingComposer.this, |
|
1726 |
uimanager.getTranslation("_The_selected_script_is_invalid"), |
|
1727 |
uimanager.getTranslation("_Warning"), |
|
1728 |
JOptionPane.INFORMATION_MESSAGE |
|
1729 |
); |
|
1757 | 1730 |
} |
1758 | 1731 |
} |
1759 | 1732 |
}); |
... | ... | |
1872 | 1845 |
@Override |
1873 | 1846 |
public void update(final Observable observable, final Object notification) { |
1874 | 1847 |
if (!SwingUtilities.isEventDispatchThread()) { |
1875 |
SwingUtilities.invokeLater(new Runnable() { |
|
1876 |
@Override |
|
1877 |
public void run() { |
|
1878 |
update(observable, notification); |
|
1879 |
} |
|
1880 |
}); |
|
1848 |
SwingUtilities.invokeLater(() -> {update(observable, notification);}); |
|
1881 | 1849 |
return; |
1882 | 1850 |
} |
1883 | 1851 |
if (notification instanceof ScriptingNotification) { |
... | ... | |
2020 | 1988 |
this.button.setRolloverEnabled(true); |
2021 | 1989 |
this.button.setIcon(uimanager.getIcon("scripting-tabclose-inactive")); |
2022 | 1990 |
this.button.setRolloverIcon(uimanager.getIcon("scripting-tabclose-active")); |
2023 |
this.button.addActionListener(new ActionListener() { |
|
2024 |
@Override |
|
2025 |
public void actionPerformed(ActionEvent ae) { |
|
2026 |
ae.setSource(TabTitleComponent.this); |
|
2027 |
onclose.actionPerformed(ae); |
|
2028 |
} |
|
1991 |
this.button.addActionListener((ActionEvent ae) -> { |
|
1992 |
ae.setSource(TabTitleComponent.this); |
|
1993 |
onclose.actionPerformed(ae); |
|
2029 | 1994 |
}); |
2030 | 1995 |
this.setLayout(new BorderLayout()); |
2031 | 1996 |
this.add(this.label, BorderLayout.CENTER); |
... | ... | |
2101 | 2066 |
public void addTab(String title, java.awt.Component component) { |
2102 | 2067 |
super.addTab(null, component); |
2103 | 2068 |
final int index = getTabCount() - 1; |
2104 |
TabTitleComponent tabcomponent = new TabTitleComponent(title, new ActionListener() { |
|
2105 |
|
|
2106 |
@Override |
|
2107 |
public void actionPerformed(ActionEvent ae) { |
|
2108 |
TabTitleComponent tabTitleComponent = (TabTitleComponent) ae.getSource(); |
|
2109 |
int index = indexOfTabComponent(tabTitleComponent); |
|
2110 |
setSelectedIndex(index); |
|
2111 |
ae.setSource(JTabbedPaneClosable.this); |
|
2112 |
closeTabListeners.fireActionEvent(ae); |
|
2113 |
} |
|
2069 |
TabTitleComponent tabcomponent = new TabTitleComponent(title, (ActionEvent ae) -> { |
|
2070 |
TabTitleComponent tabTitleComponent = (TabTitleComponent) ae.getSource(); |
|
2071 |
int index1 = indexOfTabComponent(tabTitleComponent); |
|
2072 |
setSelectedIndex(index1); |
|
2073 |
ae.setSource(JTabbedPaneClosable.this); |
|
2074 |
closeTabListeners.fireActionEvent(ae); |
|
2114 | 2075 |
}); |
2115 | 2076 |
super.setTabComponentAt(index, tabcomponent); |
2116 | 2077 |
} |
... | ... | |
2395 | 2356 |
} else { |
2396 | 2357 |
this.add("Error", |
2397 | 2358 |
"Error", |
2398 |
e.getMessage(), |
|
2359 |
e==null? "unknown":e.getMessage(),
|
|
2399 | 2360 |
null |
2400 | 2361 |
); |
2401 | 2362 |
} |
... | ... | |
2515 | 2476 |
this.tabbedPanelLeft = tabbedPanelLeft; |
2516 | 2477 |
this.tabbedPanelCenter = tabbedPanelCenter; |
2517 | 2478 |
|
2518 |
ActionListener onCloseTab = new ActionListener() { |
|
2519 |
|
|
2520 |
@Override |
|
2521 |
public void actionPerformed(ActionEvent e) { |
|
2522 |
JTabbedPaneClosable tabbedPanel = (JTabbedPaneClosable) e.getSource(); |
|
2523 |
java.awt.Component component = tabbedPanel.getSelectedComponent(); |
|
2524 |
if (component != null) { |
|
2525 |
DockedPanel panel = getDockedPanel(component); |
|
2526 |
if (panel != null) { |
|
2527 |
fireCloseListener(new ActionEvent(panel, 0, ACTION_CLOSE_PANEL)); |
|
2528 |
} |
|
2479 |
ActionListener onCloseTab = (ActionEvent e) -> { |
|
2480 |
JTabbedPaneClosable tabbedPanel = (JTabbedPaneClosable) e.getSource(); |
|
2481 |
java.awt.Component component1 = tabbedPanel.getSelectedComponent(); |
|
2482 |
if (component1 != null) { |
|
2483 |
DockedPanel panel = getDockedPanel(component1); |
|
2484 |
if (panel != null) { |
|
2485 |
fireCloseListener(new ActionEvent(panel, 0, ACTION_CLOSE_PANEL)); |
|
2486 |
} |
|
2529 | 2487 |
// panels.remove(panel.getId()); |
2530 | 2488 |
// tabbedPanel.remove(panel.getComponent().asJComponent()); |
2531 |
} |
|
2532 | 2489 |
} |
2533 | 2490 |
}; |
2534 | 2491 |
ChangeListener onChangeTab = new ChangeListener() { |
Also available in: Unified diff