use of javax.swing.JSeparator in project gephi by gephi.
the class LayoutPanel method initEvents.
private void initEvents() {
layoutCombobox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (layoutCombobox.getSelectedItem().equals(NO_SELECTION) && model.getSelectedLayout() != null) {
setSelectedLayout(null);
} else if (layoutCombobox.getSelectedItem() instanceof LayoutBuilderWrapper) {
LayoutBuilder builder = ((LayoutBuilderWrapper) layoutCombobox.getSelectedItem()).getLayoutBuilder();
if (model.getSelectedLayout() == null || model.getSelectedBuilder() != builder) {
setSelectedLayout(builder);
}
}
}
});
infoLabel.addMouseListener(new MouseAdapter() {
RichTooltip richTooltip;
@Override
public void mouseEntered(MouseEvent e) {
if (infoLabel.isEnabled() && model != null && model.getSelectedLayout() != null) {
richTooltip = buildTooltip(model.getSelectedBuilder());
richTooltip.showTooltip(infoLabel, e.getLocationOnScreen());
}
}
@Override
public void mouseExited(MouseEvent e) {
if (richTooltip != null) {
richTooltip.hideTooltip();
richTooltip = null;
}
}
});
presetsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JPopupMenu menu = new JPopupMenu();
List<Preset> presets = layoutPresetPersistence.getPresets(model.getSelectedLayout());
if (presets != null && !presets.isEmpty()) {
for (final Preset p : presets) {
JMenuItem item = new JMenuItem(p.toString());
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
layoutPresetPersistence.loadPreset(p, model.getSelectedLayout());
refreshProperties();
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.loadPreset", model.getSelectedBuilder().getName(), p.toString()));
}
});
menu.add(item);
}
} else {
menu.add("<html><i>" + NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.nopreset") + "</i></html>");
}
JMenuItem saveItem = new JMenuItem(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset"));
saveItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String lastPresetName = NbPreferences.forModule(LayoutPanel.class).get("LayoutPanel.lastPresetName", "");
NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input"), NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input.name"));
question.setInputText(lastPresetName);
if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
String input = question.getInputText();
if (input != null && !input.isEmpty()) {
layoutPresetPersistence.savePreset(input, model.getSelectedLayout());
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.savePreset", model.getSelectedBuilder().getName(), input));
NbPreferences.forModule(LayoutPanel.class).put("LayoutPanel.lastPresetName", input);
}
}
}
});
menu.add(new JSeparator());
menu.add(saveItem);
menu.show(layoutToolbar, 0, -menu.getPreferredSize().height);
}
});
}
use of javax.swing.JSeparator in project binnavi by google.
the class CModuleContainerNodeMenuBuilder method createMenu.
@Override
protected void createMenu(final JComponent menu) {
if (m_containerNode == null) {
m_containerNode = getModuleContainerNode(CNodeExpander.findNode(getProjectTree(), m_database));
}
menu.add(new JMenuItem(CActionProxy.proxy(new CImportModuleAction(getParent(), m_database))));
menu.add(new JMenuItem(CActionProxy.proxy(new CRefreshRawModulesAction(getParent(), m_database))));
menu.add(new JMenuItem(CActionProxy.proxy(new CResolveAllFunctionsAction(menu, m_database))));
menu.add(new JSeparator());
final JMenu sortMenu = new JMenu("Sort");
final JRadioButtonMenuItem idMenu = new JRadioButtonMenuItem(new CActionSortModulesById(m_containerNode));
idMenu.setSelected(!m_containerNode.isSorted());
sortMenu.add(idMenu);
final JRadioButtonMenuItem nameMenu = new JRadioButtonMenuItem(new CActionSortModulesByName(m_containerNode));
nameMenu.setSelected(m_containerNode.isSorted());
sortMenu.add(nameMenu);
menu.add(sortMenu);
}
use of javax.swing.JSeparator in project binnavi by google.
the class CTagNodeMenuBuilder method createMenu.
@Override
protected void createMenu(final JComponent menu) {
menu.add(new JMenuItem(CActionProxy.proxy(new CAddTagAction(getParent(), m_database.getContent().getViewTagManager(), m_tag, "New Tag"))));
menu.add(new JMenuItem(CActionProxy.proxy(new CInsertTagAction(getParent(), m_database.getContent().getViewTagManager(), m_tag, "New Tag"))));
menu.add(new JSeparator());
menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteTagAction(getParent(), m_database.getContent().getViewTagManager(), m_tag))));
menu.add(new JSeparator());
menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteTagSubtreeAction(getParent(), m_database.getContent().getViewTagManager(), m_tag))));
}
use of javax.swing.JSeparator in project binnavi by google.
the class CProjectContainerNodeMenuBuilder method createMenu.
@Override
protected void createMenu(final JComponent menu) {
menu.add(new JMenuItem(CActionProxy.proxy(new CCreateProjectAction(getParent(), database, new CNodeSelectionUpdater(getProjectTree(), findNode())))));
final List<IProjectFolderMenuPlugin> plugins = new ArrayList<IProjectFolderMenuPlugin>();
for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
if (plugin instanceof IProjectFolderMenuPlugin) {
plugins.add((IProjectFolderMenuPlugin) plugin);
}
}
if (!plugins.isEmpty()) {
menu.add(new JSeparator());
for (final IProjectFolderMenuPlugin plugin : plugins) {
try {
final List<JComponent> menuItems = plugin.extendProjectFolderMenu(getPluginDatabase());
if (menuItems != null) {
for (final JComponent menuItem : menuItems) {
menu.add(menuItem);
}
}
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00089: " + "Plugin caused an unexpected exception";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
}
}
}
}
use of javax.swing.JSeparator in project OpenNotebook by jaltekruse.
the class ProblemListPanel method createPanelForProblems.
public JPanel createPanelForProblems() {
ProblemList panel = new ProblemList();
JPanel tempPanel;
GridBagConstraints con = new GridBagConstraints();
JComboBox frequencyChoices;
Component[] othersInRow = new Component[2];
;
int numProblemsToShow = notebookPanel.getDatabase().getAllProblems().size();
if (numProblemsToShow > 20) {
// limit the number of problems in the list
// to 20 at a time
numProblemsToShow = 20;
}
con.gridy = 0;
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
panel.setLayout(new GridBagLayout());
for (final ProblemGenerator g : notebookPanel.getDatabase().getAllProblems()) {
// add checkbox
con.fill = GridBagConstraints.NONE;
con.gridx = 0;
con.gridwidth = 1;
con.weightx = 0;
con.insets = new Insets(0, 0, 0, 0);
final JCheckBox checkbox = new JCheckBox();
checkbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent ev) {
if (ev.getStateChange() == ItemEvent.SELECTED) {
selectedFrequencies.add(10);
selectedProblems.add(g);
} else {
selectedFrequencies.remove(selectedProblems.indexOf(g));
selectedProblems.remove(g);
}
previewPanel.getDoc().getPage(0).removeAllObjects();
// set the page size big to prevent problem generation from spawning pages
previewPanel.getDoc().setHeight(5000);
previewPanel.getDoc().setWidth(5000);
previewPanel.getDoc().generateProblem(g);
previewPanel.resizeViewWindow();
MathObject mObj = previewPanel.getDoc().getPage(0).getObjects().get(0);
previewPanel.getDoc().setWidth(mObj.getWidth() + 2 * problemBuffer);
previewPanel.getDoc().setHeight(mObj.getHeight() + 2 * problemBuffer);
mObj.setxPos(problemBuffer);
mObj.setyPos(problemBuffer);
previewPanel.resizeViewWindow();
}
});
frequencyChoices = new JComboBox(frequencies);
panel.add(checkbox, con);
othersInRow[0] = checkbox;
othersInRow[1] = frequencyChoices;
con.fill = GridBagConstraints.HORIZONTAL;
con.insets = new Insets(0, 5, 0, 0);
con.weightx = 1;
con.gridx = 1;
tempPanel = new ProblemDescriptionPanel(g, othersInRow);
tempPanel.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent arg0) {
}
public void mouseEntered(MouseEvent arg0) {
}
public void mouseExited(MouseEvent arg0) {
}
@Override
public void mousePressed(MouseEvent arg0) {
checkbox.setSelected(!checkbox.isSelected());
}
public void mouseReleased(MouseEvent arg0) {
}
});
panel.add(tempPanel, con);
// // add frequency selection menu
// con.fill = GridBagConstraints.NONE;
// con.gridx = 2;
// con.weightx = 0;
// con.insets = new Insets(0, 5, 0, 5);
// frequencyChoices.setSelectedItem(AVERAGE);
// panel.add(frequencyChoices, con);
con.gridy++;
con.gridx = 0;
con.gridwidth = 2;
con.insets = new Insets(0, 0, 0, 0);
panel.add(new JSeparator(), con);
con.gridy++;
}
return panel;
}
Aggregations