Java Code Examples for java.awt.Dialog#addWindowListener()
The following examples show how to use
java.awt.Dialog#addWindowListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrandingUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Opens branding editor for given project. Must be invoked from EDT. * @param displayName Editor's display name. * @param p Project to be branded. * @param model a branding model to use */ public static void openBrandingEditor(String displayName, final Project p, BrandingModel model) { if( !SwingUtilities.isEventDispatchThread() ) { throw new IllegalStateException("This method must be invoked from EDT."); //NOI18N } synchronized( project2dialog ) { Dialog dlg = project2dialog.get(p); if( null == dlg ) { BrandingEditorPanel editor = new BrandingEditorPanel(displayName, model); dlg = editor.open(); project2dialog.put(p, dlg); dlg.addWindowListener( new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { synchronized( project2dialog ) { project2dialog.remove(p); } } }); } else { dlg.setVisible(true); dlg.requestFocusInWindow(); } } }
Example 2
Source File: CustomizerProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
public void showCustomizer(String preselectedCategory, String preselectedSubCategory) { Dialog dialog = project2Dialog.get(project); if (dialog != null) { dialog.setVisible(true); return; } else { EarProjectProperties uiProperties = new EarProjectProperties(project, project.getUpdateHelper(), project.evaluator(), project.getReferenceHelper()); Lookup context = Lookups.fixed(new Object[] { project, uiProperties, new SubCategoryProvider(preselectedCategory, preselectedSubCategory) }); OptionListener listener = new OptionListener(project, uiProperties); StoreListener storeListener = new StoreListener(uiProperties); dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, preselectedCategory, listener, storeListener, null); dialog.addWindowListener(listener); dialog.setTitle(MessageFormat.format( NbBundle.getMessage(CustomizerProviderImpl.class, "LBL_Customizer_Title"), // NOI18N new Object[] { ProjectUtils.getInformation(project).getDisplayName() })); project2Dialog.put(project, dialog); dialog.setVisible(true); } }
Example 3
Source File: RevisionPicker.java From netbeans with Apache License 2.0 | 6 votes |
public boolean open () { dd = new DialogDescriptor(panel, NbBundle.getMessage(RevisionPicker.class, "LBL_RevisionPickerDialog.title"), //NOI18N true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx("org.netbeans.modules.git.ui.repository.RevisionPickerDialog"), null); //NOI18N Dialog dialog = DialogDisplayer.getDefault().createDialog(dd); updateDialogState(); browserPanel.addPropertyChangeListener(this); Preferences prefs = GitModuleConfig.getDefault().getPreferences(); WindowListener windowListener = new DialogBoundsPreserver(prefs, this.getClass().getName()); dialog.addWindowListener(windowListener); windowListener.windowOpened(new WindowEvent(dialog, WindowEvent.WINDOW_OPENED)); dialog.pack(); updateSliders(prefs); dialog.setVisible(true); persistSliders(prefs); browserPanel.removePropertyChangeListener(this); return dd.getValue() == okButton; }
Example 4
Source File: ProjectCustomizerProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override @NbBundle.Messages("MSG_CustomizerForbidden=The customizer is disabled, using it would revert manual changes done to the nbproject/project.xml file.") public void showCustomizer() { AuxiliaryProperties props = project.getLookup().lookup(AuxiliaryProperties.class); String show = props.get("show.customizer", true); if (show != null && "false".equals(show)) { String message = props.get("show.customizer.message", true); if (message == null) { message = MSG_CustomizerForbidden(); } NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(nd); return; } Dialog dialog = project2Dialog.get (project); if ( dialog != null ) { dialog.setVisible(true); } else { InstanceContent ic = new InstanceContent(); Lookup context = new AbstractLookup(ic); ic.add(project); ic.add(project.getLookup().lookup(ProjectAccessor.class)); ic.add(project.getLookup().lookup(AuxiliaryConfiguration.class)); //TODO replace with generic apis.. ic.add(ic); OptionListener listener = new OptionListener(); dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, null, listener, null ); dialog.addWindowListener( listener ); dialog.setTitle( MessageFormat.format( NbBundle.getMessage( ProjectCustomizerProvider.class, "LBL_Customizer_Title" ), // NOI18N new Object[] { ProjectUtils.getInformation(project).getDisplayName() } ) ); project2Dialog.put(project, dialog); dialog.setVisible(true); } }
Example 5
Source File: JavaHelp.java From netbeans with Apache License 2.0 | 5 votes |
/** * If the help frame is opened from a modal dialog, it should be closed * automatically if that dialog closes. See bug 233543. Also the windows * should be rearranged so that both are visible. See bug #233542. */ private void bindFrameViewerToCurrentDialog() { int maxDepth = 0; Dialog topDialog = null; for (Window w : JDialog.getWindows()) { if (w instanceof Dialog && w.isVisible()) { Dialog d = (Dialog) w; if (isRelevantDialog(d)) { int depth = 0; for (Window o = d.getOwner(); o != null; o = o.getOwner()) { depth++; if (o == WindowManager.getDefault().getMainWindow() && depth > maxDepth) { maxDepth = depth; topDialog = d; break; } } } } } if (topDialog != null) { rearrange(topDialog, frameViewer); final Dialog finalTopDialog = topDialog; topDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { if (frameViewer != null) { frameViewer.setVisible(false); } finalTopDialog.removeWindowListener(this); } }); } }
Example 6
Source File: CustomizerProviderImpl.java From netbeans with Apache License 2.0 | 5 votes |
public void showCustomizer( String preselectedCategory, String preselectedSubCategory ) { Dialog dialog = project2Dialog.get(project); if ( dialog != null ) { dialog.setVisible(true); return; } else { EjbJarProjectProperties uiProperties = new EjbJarProjectProperties( (EjbJarProject)project, updateHelper, evaluator, refHelper ); Lookup context = Lookups.fixed(new Object[] { project, uiProperties, new SubCategoryProvider(preselectedCategory, preselectedSubCategory) }); OptionListener listener = new OptionListener( project, uiProperties ); StoreListener storeListener = new StoreListener(uiProperties); dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, preselectedCategory, listener, storeListener, null); dialog.addWindowListener( listener ); dialog.setTitle( MessageFormat.format( NbBundle.getMessage( CustomizerProviderImpl.class, "LBL_Customizer_Title" ), // NOI18N new Object[] { ProjectUtils.getInformation(project).getDisplayName() } ) ); project2Dialog.put(project, dialog); dialog.setVisible(true); } }
Example 7
Source File: CustomizerProviderImpl.java From netbeans with Apache License 2.0 | 5 votes |
public void showCustomizer( String preselectedCategory, String preselectedSubCategory ) { Dialog dialog = project2Dialog.get (project); if ( dialog != null ) { dialog.setVisible(true); return; } else { AppClientProjectProperties uiProperties = new AppClientProjectProperties( (AppClientProject)project, updateHelper, evaluator, refHelper, genFileHelper ); Lookup context = Lookups.fixed(new Object[] { project, uiProperties, new SubCategoryProvider(preselectedCategory, preselectedSubCategory) }); OptionListener listener = new OptionListener( project, uiProperties ); StoreListener storeListener = new StoreListener(uiProperties); dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, preselectedCategory, listener, storeListener, null); dialog.addWindowListener( listener ); dialog.setTitle( MessageFormat.format( NbBundle.getMessage( CustomizerProviderImpl.class, "LBL_Customizer_Title" ), // NOI18N new Object[] { ProjectUtils.getInformation(project).getDisplayName() } ) ); project2Dialog.put(project, dialog); dialog.setVisible(true); } }
Example 8
Source File: GrailsProjectCustomizerProvider.java From netbeans with Apache License 2.0 | 5 votes |
public void showCustomizer(String preselectedCategory) { GrailsProjectProperties uiProperties = new GrailsProjectProperties(project); Lookup context = Lookups.fixed(project, uiProperties); OptionListener optionListener = new OptionListener(project); StoreListener storeListener = new StoreListener(uiProperties); Dialog dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, preselectedCategory, optionListener, storeListener, null); dialog.addWindowListener(optionListener); dialog.setTitle(ProjectUtils.getInformation(project).getDisplayName()); dialog.setVisible(true); }
Example 9
Source File: VersioningInfo.java From netbeans with Apache License 2.0 | 5 votes |
/** * Shows a dialog listing all given versioning info properties. * @param properties */ public static void show (HashMap<File, Map<String, String>> properties) { PropertySheet ps = new PropertySheet(); ps.setNodes(new VersioningInfoNode[] {new VersioningInfoNode(properties)}); DialogDescriptor dd = new DialogDescriptor(ps, NbBundle.getMessage(VersioningInfo.class, "MSG_VersioningInfo_title"), //NOI18N true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null); Dialog dialog = DialogDisplayer.getDefault().createDialog(dd); dialog.addWindowListener(new DialogBoundsPreserver(NbPreferences.forModule(VersioningInfo.class), "versioning.util.versioningInfo")); //NOI18N dialog.setVisible(true); }
Example 10
Source File: Repository.java From netbeans with Apache License 2.0 | 5 votes |
private void showDialog(DialogDescriptor dialogDescriptor, HelpCtx helpCtx, String name) { dialogDescriptor.setModal(true); dialogDescriptor.setHelpCtx(helpCtx); Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor); if (name != null) { dialog.addWindowListener(new DialogBoundsPreserver(HgModuleConfig.getDefault().getPreferences(), name)); // NOI18N } dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(Repository.class, "ACSD_RepositoryPanel")); dialog.setVisible(true); }
Example 11
Source File: ChartsPanel.java From BART with MIT License | 5 votes |
private Dialog createDialog(JPanel inner, String title) { final Dialog d = new ChartDialog(inner, title); d.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { dialogs.remove(d); } }); return d; }
Example 12
Source File: ProfilingPointsManager.java From netbeans with Apache License 2.0 | 4 votes |
boolean customize(final ValidityAwarePanel customizer, Runnable updater, boolean focusToEditor) { ValidityAwarePanel showingCustomizer = getShowingCustomizer(); if (showingCustomizer != null) { ProfilerDialogs.displayWarning( Bundle.ProfilingPointsManager_AnotherPpEditedMsg()); SwingUtilities.getWindowAncestor(showingCustomizer).requestFocus(); showingCustomizer.requestFocusInWindow(); } else { CustomizerButton cb = getCustomizerButton(); customizer.addValidityListener(cb); cb.setEnabled(customizer.areSettingsValid()); // In fact customizer should be valid but just to be sure... JPanel customizerContainer = new JPanel(new BorderLayout()); JPanel customizerSpacer = new JPanel(new BorderLayout()); customizerSpacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0)); customizerSpacer.add(customizer, BorderLayout.CENTER); customizerContainer.add(customizerSpacer, BorderLayout.CENTER); customizerContainer.add(new JSeparator(), BorderLayout.SOUTH); HelpCtx helpCtx = null; if (customizer instanceof HelpCtx.Provider) { helpCtx = ((HelpCtx.Provider) customizer).getHelpCtx(); } DialogDescriptor dd = new DialogDescriptor(customizerContainer, Bundle.ProfilingPointsManager_PpCustomizerCaption(), false, new Object[] { cb, DialogDescriptor.CANCEL_OPTION }, cb, 0, helpCtx, null); final Dialog d = DialogDisplayer.getDefault().createDialog(dd); d.addWindowListener(new CustomizerListener(d, dd, updater)); d.setModal(true); // give focus to the initial focus target d.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (customizer.getInitialFocusTarget() != null) { customizer.getInitialFocusTarget().requestFocusInWindow(); } } }); if (focusToEditor) { Dimension dim = d.getPreferredSize(); Component masterComponent = WindowManager.getDefault().getRegistry().getActivated(); if (masterComponent != null) { Rectangle b = masterComponent.getBounds(); Point location = new Point((b.x + (b.width / 2)) - (dim.width / 2), (b.y + (b.height / 2)) - (dim.height / 2)); SwingUtilities.convertPointToScreen(location, masterComponent); d.setLocation(location); } } d.setVisible(true); if (dd.getValue() == cb) { return true; } } return false; }
Example 13
Source File: DialogFactory.java From netbeans with Apache License 2.0 | 4 votes |
static Dialog createDialog( final String title, final GoToPanelImpl panel, final GoToPanelImpl.ContentProvider contentProvider, final JButton okButton) { okButton.setEnabled (false); panel.getAccessibleContext().setAccessibleName( NbBundle.getMessage( GoToSymbolAction.class, "AN_GoToSymbol") ); //NOI18N panel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage( GoToSymbolAction.class, "AD_GoToSymbol") ); //NOI18N DialogDescriptor dialogDescriptor = new DialogDescriptor( panel, // innerPane title, // displayName true, new Object[] {okButton, DialogDescriptor.CANCEL_OPTION}, okButton, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, new DialogButtonListener(panel, okButton)); dialogDescriptor.setClosingOptions(new Object[] {okButton, DialogDescriptor.CANCEL_OPTION}); Dialog d = DialogDisplayer.getDefault().createDialog( dialogDescriptor ); // Set size when needed final int width = UiOptions.GoToSymbolDialog.getWidth(); final int height = UiOptions.GoToSymbolDialog.getHeight(); if (width != -1 && height != -1) { d.setPreferredSize(new Dimension(width,height)); } // Center the dialog after the size changed. Rectangle r = Utilities.getUsableScreenBounds(); int maxW = (r.width * 9) / 10; int maxH = (r.height * 9) / 10; final Dimension dim = d.getPreferredSize(); dim.width = Math.min(dim.width, maxW); dim.height = Math.min(dim.height, maxH); d.setBounds(Utilities.findCenterBounds(dim)); initialDimension = dim; d.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { contentProvider.closeDialog(); } }); return d; }
Example 14
Source File: FileSearchAction.java From netbeans with Apache License 2.0 | 4 votes |
private Dialog createDialog( final FileSearchPanel panel) { openBtn = new JButton(); Mnemonics.setLocalizedText(openBtn, NbBundle.getMessage(FileSearchAction.class, "CTL_Open")); openBtn.getAccessibleContext().setAccessibleDescription(openBtn.getText()); openBtn.setEnabled( false ); final Object[] buttons = new Object[] { openBtn, DialogDescriptor.CANCEL_OPTION }; String title = NbBundle.getMessage(FileSearchAction.class, "MSG_FileSearchDlgTitle"); DialogDescriptor dialogDescriptor = new DialogDescriptor( panel, title, true, buttons, openBtn, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, new DialogButtonListener(panel)); dialogDescriptor.setClosingOptions(buttons); Dialog d = DialogDisplayer.getDefault().createDialog(dialogDescriptor); d.getAccessibleContext().setAccessibleName(NbBundle.getMessage(FileSearchAction.class, "AN_FileSearchDialog")); d.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FileSearchAction.class, "AD_FileSearchDialog")); // Set size d.setPreferredSize( new Dimension( FileSearchOptions.getWidth(), FileSearchOptions.getHeight() ) ); // Center the dialog after the size changed. Rectangle r = Utilities.getUsableScreenBounds(); int maxW = (r.width * 9) / 10; int maxH = (r.height * 9) / 10; Dimension dim = d.getPreferredSize(); dim.width = Math.min(dim.width, maxW); dim.height = Math.min(dim.height, maxH); initialDimension = dim; d.setBounds(Utilities.findCenterBounds(dim)); d.addWindowListener(new WindowAdapter() { public @Override void windowClosed(WindowEvent e) { cleanup(false); } }); return d; }
Example 15
Source File: GoToTypeAction.java From netbeans with Apache License 2.0 | 4 votes |
/** Creates the dialog to show */ private Dialog createDialog( final GoToPanel panel) { okButton = new JButton (NbBundle.getMessage(GoToTypeAction.class, "CTL_OK")); okButton.getAccessibleContext().setAccessibleDescription(okButton.getText()); okButton.setEnabled (false); panel.getAccessibleContext().setAccessibleName( NbBundle.getMessage( GoToTypeAction.class, "AN_GoToType") ); //NOI18N panel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage( GoToTypeAction.class, "AD_GoToType") ); //NOI18N DialogDescriptor dialogDescriptor = new DialogDescriptor( panel, // innerPane title, // displayName true, new Object[] {okButton, DialogDescriptor.CANCEL_OPTION}, okButton, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, new DialogButtonListener( panel ) ); // Action listener dialogDescriptor.setClosingOptions(new Object[] {okButton, DialogDescriptor.CANCEL_OPTION}); // panel.addPropertyChangeListener( new HelpCtxChangeListener( dialogDescriptor, helpCtx ) ); // if ( panel instanceof HelpCtx.Provider ) { // dialogDescriptor.setHelpCtx( ((HelpCtx.Provider)panel).getHelpCtx() ); // } Dialog d = DialogDisplayer.getDefault().createDialog( dialogDescriptor ); // Set size when needed final int width = UiOptions.GoToTypeDialog.getWidth(); final int height = UiOptions.GoToTypeDialog.getHeight(); if (width != -1 && height != -1) { d.setPreferredSize(new Dimension(width,height)); } // Center the dialog after the size changed. Rectangle r = Utilities.getUsableScreenBounds(); int maxW = (r.width * 9) / 10; int maxH = (r.height * 9) / 10; final Dimension dim = d.getPreferredSize(); dim.width = Math.min(dim.width, maxW); dim.height = Math.min(dim.height, maxH); d.setBounds(Utilities.findCenterBounds(dim)); initialDimension = dim; d.addWindowListener(new WindowAdapter() { public @Override void windowClosed(WindowEvent e) { cleanup(); } }); return d; }