use of java.awt.event.ComponentEvent in project Gargoyle by callakrsos.
the class DesignerFx method createRuleXML.
private void createRuleXML() {
CreateXMLRulePanelFx rulePanel = new CreateXMLRulePanelFx(xpathQueryArea, codeEditorPane);
JFrame xmlframe = new JFrame("Create XML Rule");
xmlframe.setContentPane(rulePanel);
xmlframe.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
xmlframe.setSize(new Dimension(600, 700));
xmlframe.addComponentListener(new java.awt.event.ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
JFrame tmp = (JFrame) e.getSource();
if (tmp.getWidth() < 600 || tmp.getHeight() < 700) {
tmp.setSize(600, 700);
}
}
});
int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
xmlframe.pack();
xmlframe.setLocation((screenWidth - xmlframe.getWidth()) / 2, (screenHeight - xmlframe.getHeight()) / 2);
xmlframe.setVisible(true);
}
use of java.awt.event.ComponentEvent in project knime-core by knime.
the class FilesHistoryPanel method getOutputFileName.
private String getOutputFileName() {
// file chooser triggered by choose button
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(true);
List<SimpleFileFilter> filters = createFiltersFromSuffixes(m_suffixes);
for (SimpleFileFilter filter : filters) {
fileChooser.addChoosableFileFilter(filter);
}
if (filters.size() > 0) {
fileChooser.setFileFilter(filters.get(0));
}
fileChooser.setFileSelectionMode(m_selectMode);
fileChooser.setDialogType(m_dialogType);
// AP-2562
// It seems only resized event is happening when showing the dialog
// Grabbing the focus then makes two clicks to single click selection.
fileChooser.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(final ComponentEvent e) {
fileChooser.grabFocus();
}
});
try {
URL url = FileUtil.toURL(getSelectedFileWithPropertiesReplaced());
Path localPath = FileUtil.resolveToPath(url);
if (localPath != null) {
if (Files.isDirectory(localPath)) {
fileChooser.setCurrentDirectory(localPath.toFile());
} else {
fileChooser.setSelectedFile(localPath.toFile());
}
}
} catch (IOException | URISyntaxException | InvalidPathException ex) {
// ignore
}
int r;
/* This if construct is result of a fix for bug 5841.
* showDialog does not resolve localized folder names correctly under Mac OS,
* so we use the methods showSaveDialog and showOpenDialog if possible.
*/
if (this.m_dialogType == JFileChooser.SAVE_DIALOG) {
r = fileChooser.showSaveDialog(FilesHistoryPanel.this);
} else if (this.m_dialogType == JFileChooser.OPEN_DIALOG) {
r = fileChooser.showOpenDialog(FilesHistoryPanel.this);
} else {
r = fileChooser.showDialog(FilesHistoryPanel.this, "OK");
}
if (r == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
if (m_dialogType == JFileChooser.SAVE_DIALOG) {
String forceFileExtension = StringUtils.defaultString(m_forcedFileExtensionOnSave);
final String fileName = file.getName();
if (!(StringUtils.endsWithAny(fileName, m_suffixes) || StringUtils.endsWithIgnoreCase(fileName, m_forcedFileExtensionOnSave))) {
file = new File(file.getParentFile(), fileName.concat(forceFileExtension));
}
}
if (file.exists() && (m_selectMode == JFileChooser.FILES_ONLY) && file.isDirectory()) {
JOptionPane.showMessageDialog(this, "Error: Please select a file, not a directory.");
return null;
}
return file.getAbsolutePath();
}
return null;
}
use of java.awt.event.ComponentEvent in project freeplane by freeplane.
the class EditNodeDialog method show.
public void show(final RootPaneContainer frame) {
if (title == null) {
title = TextUtils.getText("edit_long_node");
}
final EditDialog dialog = new LongNodeDialog(frame, title, getBackground());
redispatchKeyEvents(textComponent, firstEvent);
if (firstEvent == null) {
textComponent.setCaretPosition(textComponent.getDocument().getLength());
}
dialog.getDialog().setModal(isModal);
dialog.getDialog().pack();
Controller.getCurrentModeController().getController().getMapViewManager().scrollNodeToVisible(node);
if (ResourceController.getResourceController().getBooleanProperty("el__position_window_below_node")) {
UITools.setDialogLocationUnder(dialog.getDialog(), getNode());
} else {
UITools.setDialogLocationRelativeTo(dialog.getDialog(), getNode());
}
dialog.show();
dialog.getDialog().addComponentListener(new ComponentListener() {
public void componentShown(final ComponentEvent e) {
}
public void componentResized(final ComponentEvent e) {
}
public void componentMoved(final ComponentEvent e) {
}
public void componentHidden(final ComponentEvent e) {
dialog.dispose();
}
});
}
use of java.awt.event.ComponentEvent in project freeplane by freeplane.
the class NodeSelector method show.
public void show(final Component component, final INodeSelector externalSelector) {
node = null;
dialog = UITools.createCancelDialog(component, TextUtils.getText("node_selector"), TextUtils.getText("node_selector_message"));
UITools.setDialogLocationRelativeTo(dialog, component);
dialog.getRootPane().addAncestorListener(new GlassPaneManager(SwingUtilities.getRootPane(component), this));
dialog.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
externalSelector.nodeSelected(node);
}
});
dialog.setVisible(true);
}
use of java.awt.event.ComponentEvent in project Spark by igniterealtime.
the class VCardEditor method editProfile.
/**
* Displays the VCard for an individual.
*
* @param vCard
* the users vcard.
* @param parent
* the parent component, used for location.
*/
public void editProfile(final VCard vCard, JComponent parent) {
final JTabbedPane tabbedPane = new JTabbedPane();
// Initialize Panels
personalPanel = new PersonalPanel();
personalPanel.showJID(false);
tabbedPane.addTab(Res.getString("tab.personal"), personalPanel);
businessPanel = new BusinessPanel();
tabbedPane.addTab(Res.getString("tab.business"), businessPanel);
homePanel = new HomePanel();
tabbedPane.addTab(Res.getString("tab.home"), homePanel);
// See if we should remove the Avatar tab in profile dialog
if (!Default.getBoolean("DISABLE_AVATAR_TAB") && Enterprise.containsFeature(Enterprise.AVATAR_TAB_FEATURE)) {
avatarPanel = new AvatarPanel();
tabbedPane.addTab(Res.getString("tab.avatar"), avatarPanel);
}
// Build the UI
buildUI(vCard);
final JOptionPane pane;
final JDialog dlg;
TitlePanel titlePanel;
ImageIcon icon = VCardManager.getAvatarIcon(vCard);
if (icon == null) {
icon = SparkRes.getImageIcon(SparkRes.BLANK_24x24);
}
// Create the title panel for this dialog
titlePanel = new TitlePanel(Res.getString("title.edit.profile"), Res.getString("message.save.profile"), icon, true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
Object[] options = { Res.getString("save"), Res.getString("cancel") };
pane = new JOptionPane(tabbedPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
mainPanel.add(pane, BorderLayout.CENTER);
JOptionPane p = new JOptionPane();
dlg = p.createDialog(parent, Res.getString("title.profile.information"));
dlg.setModal(false);
dlg.pack();
dlg.setResizable(true);
dlg.setContentPane(mainPanel);
final Rectangle bounds = LayoutSettingsManager.getLayoutSettings().getVCardEditorBounds();
if (bounds == null || bounds.width <= 0 || bounds.height <= 0) {
// Use default settings.
dlg.setLocationRelativeTo(parent);
dlg.setSize(600, 400);
} else {
dlg.setBounds(bounds);
}
dlg.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setVCardEditorBounds(dlg.getBounds());
}
@Override
public void componentMoved(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setVCardEditorBounds(dlg.getBounds());
}
});
PropertyChangeListener changeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String value = (String) pane.getValue();
if (Res.getString("cancel").equals(value)) {
pane.removePropertyChangeListener(this);
dlg.dispose();
} else if (Res.getString("save").equals(value)) {
pane.removePropertyChangeListener(this);
dlg.dispose();
saveVCard();
}
}
};
pane.addPropertyChangeListener(changeListener);
// See if we should remove the Avatar tab in profile dialog
if (!Default.getBoolean("DISABLE_AVATAR_TAB") && Enterprise.containsFeature(Enterprise.AVATAR_TAB_FEATURE))
avatarPanel.setParentDialog(dlg);
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
personalPanel.focus();
}
Aggregations