use of org.freeplane.core.ui.components.BlindIcon in project freeplane by freeplane.
the class NodeList method startup.
public void startup() {
if (dialog != null) {
dialog.toFront();
return;
}
NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED);
NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED);
NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS);
NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT);
NodeList.COLUMN_DETAILS = TextUtils.getText(PLUGINS_TIME_LIST_XML_DETAILS);
NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE);
NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES);
dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal);
String windowTitle;
if (showAllNodes) {
windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES;
} else {
windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE;
}
dialog.setTitle(TextUtils.getText(windowTitle));
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
final WindowAdapter windowListener = new WindowAdapter() {
@Override
public void windowGainedFocus(WindowEvent e) {
mFilterTextSearchField.getEditor().selectAll();
}
@Override
public void windowClosing(final WindowEvent event) {
disposeDialog();
}
};
dialog.addWindowListener(windowListener);
dialog.addWindowFocusListener(windowListener);
UITools.addEscapeActionToDialog(dialog, new AbstractAction() {
/**
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(final ActionEvent arg0) {
disposeDialog();
}
});
final Container contentPane = dialog.getContentPane();
final GridBagLayout gbl = new GridBagLayout();
contentPane.setLayout(gbl);
final GridBagConstraints layoutConstraints = new GridBagConstraints();
layoutConstraints.gridx = 0;
layoutConstraints.gridy = 0;
layoutConstraints.gridwidth = 1;
layoutConstraints.gridheight = 1;
layoutConstraints.weightx = 0.0;
layoutConstraints.weighty = 0.0;
layoutConstraints.anchor = GridBagConstraints.WEST;
layoutConstraints.fill = GridBagConstraints.HORIZONTAL;
contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints);
layoutConstraints.gridwidth = 1;
layoutConstraints.gridx++;
contentPane.add(Box.createHorizontalStrut(40), layoutConstraints);
layoutConstraints.gridx++;
contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints);
layoutConstraints.gridx++;
contentPane.add(matchCase, layoutConstraints);
layoutConstraints.gridx++;
contentPane.add(Box.createHorizontalStrut(40), layoutConstraints);
layoutConstraints.gridx++;
contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints);
layoutConstraints.gridx++;
contentPane.add(useRegexInFind, layoutConstraints);
layoutConstraints.gridx = 0;
layoutConstraints.weightx = 1.0;
layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
layoutConstraints.gridy++;
contentPane.add(/* new JScrollPane */
(mFilterTextSearchField), layoutConstraints);
layoutConstraints.gridy++;
layoutConstraints.weightx = 0.0;
layoutConstraints.gridwidth = 1;
contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints);
layoutConstraints.gridx = 5;
contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints);
layoutConstraints.gridx++;
contentPane.add(useRegexInReplace, layoutConstraints);
layoutConstraints.gridx = 0;
layoutConstraints.weightx = 1.0;
layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
layoutConstraints.gridy++;
contentPane.add(/* new JScrollPane */
(mFilterTextReplaceField), layoutConstraints);
dateRenderer = new DateRenderer();
textRenderer = new TextRenderer();
iconsRenderer = new IconsRenderer();
tableView = new FlatNodeTable();
tableView.addKeyListener(new FlatNodeTableKeyListener());
tableView.addMouseListener(new FlatNodeTableMouseAdapter());
tableView.getTableHeader().setReorderingAllowed(false);
tableModel = updateModel();
mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(tableModel, new int[] { NodeList.NODE_TEXT_COLUMN, NodeList.NODE_DETAILS_COLUMN, NodeList.NODE_NOTES_COLUMN });
sorter = new TableSorter(mFlatNodeTableFilterModel);
tableView.setModel(sorter);
sorter.setTableHeader(tableView.getTableHeader());
sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR);
sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR);
sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR);
sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING);
final JScrollPane pane = new JScrollPane(tableView);
UITools.setScrollbarIncrement(pane);
layoutConstraints.gridy++;
GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone();
tableConstraints.weightx = 1;
tableConstraints.weighty = 10;
tableConstraints.fill = GridBagConstraints.BOTH;
contentPane.add(pane, tableConstraints);
mTreeLabel = new JLabel();
layoutConstraints.gridy++;
GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone();
treeConstraints.fill = GridBagConstraints.BOTH;
@SuppressWarnings("serial") JScrollPane scrollPane = new JScrollPane(mTreeLabel) {
@Override
public boolean isValidateRoot() {
return false;
}
};
contentPane.add(scrollPane, treeConstraints);
final AbstractAction exportAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Export")) {
/**
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(final ActionEvent arg0) {
exportSelectedRowsAndClose();
}
};
final JButton exportButton = new JButton(exportAction);
final AbstractAction replaceAllAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) {
/**
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(final ActionEvent arg0) {
replace(new HolderAccessor(false));
}
};
final JButton replaceAllButton = new JButton(replaceAllAction);
final AbstractAction replaceSelectedAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) {
/**
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(final ActionEvent arg0) {
replace(new HolderAccessor(true));
}
};
final JButton replaceSelectedButton = new JButton(replaceSelectedAction);
final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) {
/**
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(final ActionEvent arg0) {
selectSelectedRows();
}
};
final JButton gotoButton = new JButton(gotoAction);
final AbstractAction disposeAction = new AbstractAction(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) {
/**
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(final ActionEvent arg0) {
disposeDialog();
}
};
final JButton cancelButton = new JButton(disposeAction);
/* Initial State */
gotoAction.setEnabled(false);
exportAction.setEnabled(false);
replaceSelectedAction.setEnabled(false);
final Box bar = Box.createHorizontalBox();
bar.add(Box.createHorizontalGlue());
bar.add(cancelButton);
bar.add(exportButton);
bar.add(replaceAllButton);
bar.add(replaceSelectedButton);
bar.add(gotoButton);
bar.add(Box.createHorizontalGlue());
layoutConstraints.gridy++;
contentPane.add(/* new JScrollPane */
(bar), layoutConstraints);
final JMenuBar menuBar = new JMenuBar();
final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions"));
final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction, replaceAllAction, exportAction, disposeAction };
for (int i = 0; i < actionList.length; i++) {
final AbstractAction action = actionList[i];
final JMenuItem item = menu.add(action);
item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE));
}
menuBar.add(menu);
dialog.setJMenuBar(menuBar);
final ListSelectionModel rowSM = tableView.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
final ListSelectionModel lsm = (ListSelectionModel) e.getSource();
final boolean enable = !(lsm.isSelectionEmpty());
replaceSelectedAction.setEnabled(enable);
gotoAction.setEnabled(enable);
exportAction.setEnabled(enable);
}
});
rowSM.addListSelectionListener(new ListSelectionListener() {
String getNodeText(final NodeModel node) {
return TextController.getController().getShortText(node) + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode())));
}
public void valueChanged(final ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
final ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (lsm.isSelectionEmpty()) {
mTreeLabel.setText("");
return;
}
final int selectedRow = lsm.getLeadSelectionIndex();
final NodeModel mindMapNode = getMindMapNode(selectedRow);
mTreeLabel.setText(getNodeText(mindMapNode));
}
});
final String marshalled = ResourceController.getResourceController().getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY);
final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog);
final WindowConfigurationStorage storage = result;
if (storage != null) {
tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
int column = 0;
for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage).getListTimeWindowColumnSettingList()) {
tableView.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth());
sorter.setSortingStatus(column, setting.getColumnSorting());
column++;
}
}
mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(), matchCase.isSelected(), useRegexInFind.isSelected());
dialog.setVisible(true);
}
use of org.freeplane.core.ui.components.BlindIcon in project freeplane by freeplane.
the class ScriptEditorPanel method addAction.
private void addAction(final JMenu menu, final AbstractAction action) {
final JMenuItem item = menu.add(action);
MenuBuilder.setLabelAndMnemonic(item, (String) action.getValue(Action.NAME));
item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE));
}
Aggregations