Java Code Examples for org.openide.NotifyDescriptor

The following examples show how to use org.openide.NotifyDescriptor. These examples are extracted from open source projects. 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 Project: netbeans   Source File: AddServerLocationVisualPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String newLoc = browseInstallLocation();
    if (newLoc != null && !"".equals(newLoc)) {
        locationTextField.setText(newLoc);
        String configurationFilePath = newLoc + File.separatorChar
                    + "standalone" + File.separatorChar + "configuration"
                    + File.separatorChar + "standalone-full.xml";
        if (configurationTextField.getText() == null || configurationTextField.getText().isEmpty()) {
            if (new File(configurationFilePath).exists()) {
                configurationTextField.setText(configurationFilePath);
            }
        } else if (!configurationTextField.getText().startsWith(newLoc)) {
            NotifyDescriptor d = new NotifyDescriptor.Confirmation(
                    NbBundle.getMessage(AddServerLocationVisualPanel.class, "MSG_WARN_INSTALLATION_DIFFERS_CONFIGURATION", configurationFilePath),
                    NotifyDescriptor.OK_CANCEL_OPTION);
            Object result = DialogDisplayer.getDefault().notify(d);
            if (result == NotifyDescriptor.CANCEL_OPTION) {
                // keep the old content
                return;
            } else {
                configurationTextField.setText(configurationFilePath);
            }
        }
    }
}
 
Example 2
@Override
public void actionPerformed(ActionEvent e) {
    String defaultName = WindowUtilities.getUniqueTitle(Bundle.VAL_NewWorkspaceActionValue(),
                                                        WorkspaceTopComponent.class);
    NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine(Bundle.LBL_NewWorkspaceActionName(),
                                                                  Bundle.CTL_NewWorkspaceActionName());
    d.setInputText(defaultName);
    Object result = DialogDisplayer.getDefault().notify(d);
    if (NotifyDescriptor.OK_OPTION.equals(result)) {
        WorkspaceTopComponent workspaceTopComponent = new WorkspaceTopComponent(d.getInputText());
        Mode editor = WindowManager.getDefault().findMode("editor");
        Assert.notNull(editor, "editor");
        editor.dockInto(workspaceTopComponent);
        workspaceTopComponent.open();
        workspaceTopComponent.requestActive();
    }
}
 
Example 3
Source Project: constellation   Source File: MappingPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveButtonActionPerformed
{//GEN-HEADEREND:event_saveButtonActionPerformed
    final String label = labelText.getText().trim();
    if (label.isEmpty()) {
        final NotifyDescriptor nderr = new NotifyDescriptor.Message("A label must be specified for saving", NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(nderr);
    } else {
        final MappingTableModel vxModel = (MappingTableModel) vxTable.getModel();
        data.vxMappings = JdbcData.copy(vxModel.values);

        final MappingTableModel txModel = (MappingTableModel) txTable.getModel();
        data.txMappings = JdbcData.copy(txModel.values);

        JdbcParameterIO.saveParameters(data, label);
    }
}
 
Example 4
Source Project: netbeans   Source File: RenameContainerAction.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - container name",
    "MSG_Renaming=Renaming {0}"
})
private void perform(final StatefulDockerContainer container, final String name) {
    RequestProcessor.getDefault().post(new Runnable() {
        @Override
        public void run() {
            ProgressHandle handle = ProgressHandle.createHandle(Bundle.MSG_Renaming(container.getDetail().getName()));
            handle.start();
            try {
                DockerAction facade = new DockerAction(container.getContainer().getInstance());
                facade.rename(container.getContainer(), name);
            } catch (DockerException ex) {
                LOGGER.log(Level.INFO, null, ex);
                String msg = ex.getLocalizedMessage();
                NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notify(desc);
            } finally {
                handle.finish();
            }
        }
    });
}
 
Example 5
private boolean addKeyToBranding (String bundlepath, String codenamebase, String key) {
    BrandingSupport.BundleKey bundleKey = getBranding().getGeneralLocalizedBundleKeyForModification(codenamebase, bundlepath, key);
    KeyInput inputLine = new KeyInput(key + ":", bundlepath); // NOI18N
    String oldValue = bundleKey.getValue();
    inputLine.setInputText(oldValue);
    if (DialogDisplayer.getDefault().notify(inputLine)==NotifyDescriptor.OK_OPTION) {
        String newValue = inputLine.getInputText();
        if (newValue.compareTo(oldValue)!=0) {
            bundleKey.setValue(newValue);
            getBranding().addModifiedInternationalizedBundleKey(bundleKey);
            setModified();
            branding.updateProjectInternationalizationLocales();
            return true;
        }
    }
    return false;
}
 
Example 6
Source Project: netbeans   Source File: DataEditorSupport.java    License: Apache License 2.0 6 votes vote down vote up
/** Called from EnvListener if read-only state is externally changed (#129178).
 * @param readOnly true if changed to read-only state, false if changed to read-write
 */
private void readOnlyRefresh() {
    if (initCanWrite(true)) {
        if (!canWrite && isModified()) {
            // notify user if the object is modified and externally changed to read-only
            DialogDisplayer.getDefault().notify(
                    new NotifyDescriptor.Message(
                    NbBundle.getMessage(DataObject.class,
                    "MSG_FileReadOnlyChanging",
                    new Object[]{getFileImpl().getNameExt()}),
                    NotifyDescriptor.WARNING_MESSAGE));
        }
        // event is consumed in CloneableEditorSupport
        firePropertyChange("DataEditorSupport.read-only.changing", !canWrite, canWrite);  //NOI18N
    }
}
 
Example 7
Source Project: constellation   Source File: JoclVersionAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(final ActionEvent e) {
    final com.jogamp.opencl.JoclVersion jv = com.jogamp.opencl.JoclVersion.getInstance();
    final Set<?> names = jv.getAttributeNames();
    final ArrayList<String> lines = new ArrayList<>();
    for (final Object name : names) {
        lines.add(String.format("%s: %s\n", name, jv.getAttribute((Attributes.Name) name)));
    }

    Collections.sort(lines);

    final StringBuilder sb = new StringBuilder();
    sb.append("JOCL Attributes\n");
    for (final String line : lines) {
        sb.append(line);
    }

    final InfoTextPanel itp = new InfoTextPanel(sb.toString());
    final NotifyDescriptor.Message msg = new NotifyDescriptor.Message(itp);
    msg.setTitle(Bundle.CTL_JoclVersionAction());
    DialogDisplayer.getDefault().notify(msg);
}
 
Example 8
Source Project: netbeans   Source File: CreateJREPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void buttonBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBrowseActionPerformed
    final String oldValue = jreCreateLocation.getText();
    final JFileChooser chooser = new JFileChooser() {
        @Override
        public void approveSelection() {
            if (EJDKFileView.isEJDK(getSelectedFile())) {
                super.approveSelection();
            } else {
                DialogDisplayer.getDefault().notify(
                    new NotifyDescriptor.Message(
                        NbBundle.getMessage(CreateJREPanel.class, "TXT_InvalidEJDKFolder", getSelectedFile().getName()),
                        NotifyDescriptor.ERROR_MESSAGE));
            }
        }
    };
    chooser.setFileView(new EJDKFileView(chooser.getFileSystemView()));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (oldValue != null) {
        chooser.setSelectedFile(new File(oldValue));
    }
    chooser.setDialogTitle(NbBundle.getMessage(CreateJREPanel.class, "Title_Chooser_SelectJRECreate")); //NOI18N
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        jreCreateLocation.setText(chooser.getSelectedFile().getAbsolutePath());
    }
}
 
Example 9
Source Project: netbeans   Source File: InsertI18nStringAction.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Basically I18nPanel wrapped by Ok, Cancel and Help buttons shown.
 * Handles OK button.
 */
private void showModalPanel() throws IOException {
    DialogDescriptor dd = new DialogDescriptor(
        createPanel(),
        Util.getString("CTL_InsertI18nDialogTitle"),
        true,
        NotifyDescriptor.OK_CANCEL_OPTION,
        NotifyDescriptor.OK_OPTION,
        DialogDescriptor.DEFAULT_ALIGN,
        new HelpCtx(InsertI18nStringAction.class),
        null
    );
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setVisible(true);
    if (dd.getValue() == NotifyDescriptor.OK_OPTION) {
        insertI18nString();
    }
}
 
Example 10
Source Project: visualvm   Source File: SysTray.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void hideWindow() {
    Window[] windows = mainWindow.getOwnedWindows();
    for (Window window : windows) {
        if (window.isVisible() && window instanceof Dialog)
            if (((Dialog)window).isModal()) {
                trayPopup.setEnabled(false);
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                        Bundle.SysTray_ModalDialog(), NotifyDescriptor.WARNING_MESSAGE));
                trayPopup.setEnabled(true);
                return;
            }
    }

    mainWindow.setVisible(false);
    if (!Utilities.isWindows() && (mainWindow.getExtendedState() & Frame.ICONIFIED) != 0) {
        workaround = true;
    }
    if (showHideItem != null) showHideItem.setLabel(Bundle.SysTray_Show());
}
 
Example 11
Source Project: netbeans   Source File: WSITEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void save(Node node) {
    if (node == null) {
        return;
    }
    try {
        WSDLModel model = WSITModelSupport.getModel(node, jaxWsModel, this, false, createdFiles);
        if (model != null) {
            WSITModelSupport.save(model);
        }
        else {
            NotifyDescriptor descriptor = new NotifyDescriptor.Message(
                    NbBundle.getMessage(WSITEditor.class, "TXT_NO_WSDL_FILE"),  // NOI18N
                    NotifyDescriptor.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notify( descriptor );
        }
    } catch (Exception e){
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example 12
Source Project: netbeans   Source File: TargetsPanel.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void addPartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPartButtonActionPerformed
    
    Object button = DialogDisplayer.getDefault().notify(
            new NotifyDescriptor.Confirmation(
                NbBundle.getMessage(TargetsPanel.class, "WARNING_DISABLE_OPTIMSECURITY")));
    if (NotifyDescriptor.OK_OPTION.equals(button)) {
        MessageElement e = new MessageElement(NbBundle.getMessage(TargetsPanel.class, "TXT_EditHere")); //NOI18N
        Vector row = new Vector();
        row.add(TargetElement.DATA, e);
        row.add(TargetElement.SIGN, Boolean.FALSE);
        row.add(TargetElement.ENCRYPT, Boolean.FALSE);
        row.add(TargetElement.REQUIRE, Boolean.TRUE);
        getTargetsModel().add(row);
        jTable1.updateUI();
    }
}
 
Example 13
Source Project: netbeans   Source File: ActionMappings.java    License: Apache License 2.0 6 votes vote down vote up
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-HEADEREND:event_btnAddActionPerformed
    NotifyDescriptor.InputLine nd = new NonEmptyInputLine(org.openide.util.NbBundle.getMessage(ActionMappings.class, "TIT_Add_action"), org.openide.util.NbBundle.getMessage(ActionMappings.class, "LBL_AddAction"));
    Object ret = DialogDisplayer.getDefault().notify(nd);
    if (ret == NotifyDescriptor.OK_OPTION) {
        NetbeansActionMapping nam = new NetbeansActionMapping();
        nam.setDisplayName(nd.getInputText());
        nam.setActionName(CUSTOM_ACTION_PREFIX + nd.getInputText()); 
        getActionMappings().addAction(nam);
        if (handle != null) {
            handle.markAsModified(getActionMappings());
        }
        MappingWrapper wr = new MappingWrapper(nam);
        wr.setUserDefined(true);
        ((DefaultListModel)lstMappings.getModel()).addElement(wr);
        lstMappings.setSelectedIndex(lstMappings.getModel().getSize() - 1);
        lstMappings.ensureIndexIsVisible(lstMappings.getModel().getSize() - 1);
    }
}
 
Example 14
Source Project: netbeans   Source File: DebugAction.java    License: Apache License 2.0 6 votes vote down vote up
private static void performActionImpl(final ServerInstance si) {
    if (si != null) {
        RP.post(new Runnable() {
            public void run() {
                String title = NbBundle.getMessage(DebugAction.class, "LBL_Debugging", si.getDisplayName());
                ProgressUI progressUI = new ProgressUI(title, false);
                try {
                    progressUI.start();
                    si.startDebug(progressUI);
                } catch (ServerException ex) {
                    String msg = ex.getLocalizedMessage();
                    NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
                    DialogDisplayer.getDefault().notify(desc);
                } finally {
                    progressUI.finish();
                }
            }
        });
    }
}
 
Example 15
Source Project: BART   Source File: EditDirtyStrategy.java    License: MIT License 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    EGTask egt = context.getEgtask();
    if(egt == null)return;
    IDatabase db = egt.getTarget();
    if((db == null)||(db instanceof EmptyDB))   {
        DialogDisplayer.getDefault()
                .notify(new NotifyDescriptor.Message(Bundle.MSG_NO_Target_DB()
                        , NotifyDescriptor.INFORMATION_MESSAGE));
        return;
    }
    if((db.getTableNames() == null)||(db.getTableNames().isEmpty()))   {
        DialogDisplayer.getDefault()
                .notify(new NotifyDescriptor.Message(Bundle.MSG_DB_NO_TABLE()
                        , NotifyDescriptor.INFORMATION_MESSAGE));
        return;
    }
    
    DirtyStrategyPanel panel = new DirtyStrategyPanel();
    panel.initTableCombo(db);
    initButton(panel);
    Dialog d = ControlUtil.createDialog(panel, panel.getButtons());
    d.setTitle(Bundle.CTL_EditDirtyStrategy());
    d.setVisible(true);
}
 
Example 16
Source Project: netbeans   Source File: DatabaseNode.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - Database name",
    "MSG_Confirm_DB_Delete=Really delete database {0}?",
    "MSG_Confirm_DB_Delete_Title=Delete Database"})
@Override
public void destroy() {
    NotifyDescriptor d =
            new NotifyDescriptor.Confirmation(
            Bundle.MSG_Confirm_DB_Delete(model.getDbName()),
            Bundle.MSG_Confirm_DB_Delete_Title(),
            NotifyDescriptor.YES_NO_OPTION);
    Object result = DialogDisplayer.getDefault().notify(d);
    if (!NotifyDescriptor.OK_OPTION.equals(result)) {
        return;
    }
    DatabaseServer server = model.getServer();
    String dbname = model.getDbName();

    server.dropDatabase(dbname);
}
 
Example 17
Source Project: opensim-gui   Source File: ScaleToolPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void update(Observable observable, Object obj) {
   if (observable instanceof OpenSimDB){
        if (obj instanceof ModelEvent) {
             if (OpenSimDB.getInstance().hasModel(scaleToolModel.getOriginalModel()))
                 return;
             else {
                 scaleToolModel.deleteObserver(this);
                 OpenSimDB.getInstance().deleteObserver(this);
                 NotifyDescriptor.Message dlg =
                       new NotifyDescriptor.Message("Model used by the tool is being closed. Closing tool.");
                 DialogDisplayer.getDefault().notify(dlg);
                 this.close();
                 return;
             }        
        }
        return;
   }
   if(observable == scaleToolModel && obj == ScaleToolModel.Operation.ExecutionStateChanged) {
      // Just need to update the buttons
      updateDialogButtons();
   } else {
      updateFromModel();
   }
}
 
Example 18
public void testExceptionThrownWhenDocumentIsBeingReadAWTYes () throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            MyEx my = new MyEx();

            toThrow = my;

            DD.options = null;
            DD.toReturn = NotifyDescriptor.YES_OPTION;
            
            support.open();
            JEditorPane [] panes = support.getOpenedPanes();
            assertNotNull(panes);
            assertEquals(panes.length, 1);
            assertNotNull(panes[0]);
        }
    });
}
 
Example 19
public void addFilterSetting() {
    NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Enter a name:", "Filter");
    if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) {
        String name = l.getInputText();

        FilterSetting toRemove = null;
        for (FilterSetting s : filterSettings) {
            if (s.getName().equals(name)) {
                NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter \"" + name + "\" already exists, to you want to overwrite?", "Filter");
                if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) {
                    toRemove = s;
                    break;
                } else {
                    return;
                }
            }
        }

        if (toRemove != null) {
            filterSettings.remove(toRemove);
        }
        FilterSetting setting = createFilterSetting(name);
        filterSettings.add(setting);

        // Sort alphabetically
        Collections.sort(filterSettings, new Comparator<FilterSetting>() {

            public int compare(FilterSetting o1, FilterSetting o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });

        updateComboBox();
    }
}
 
Example 20
Source Project: netbeans   Source File: UiUtils.java    License: Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "UiUtils.project.noSources=Project {0} has no Source Files."
})
public static void warnNoSources(String projectName) {
    DialogDisplayer.getDefault().notifyLater(
            new NotifyDescriptor.Message(Bundle.UiUtils_project_noSources(projectName), NotifyDescriptor.WARNING_MESSAGE));
}
 
Example 21
Source Project: netbeans   Source File: BasicSearchForm.java    License: Apache License 2.0 5 votes vote down vote up
private void limitReached() {
    String msg = Bundle.MSG_TextTooLong(LIMIT);
    DialogDisplayer.getDefault().notify(
            new NotifyDescriptor.Message(
                    msg, NotifyDescriptor.WARNING_MESSAGE));
    Logger.getLogger(BasicSearchForm.class.getName())
            .log(Level.INFO, msg);
}
 
Example 22
Source Project: netbeans   Source File: ExportDiffAction.java    License: Apache License 2.0 5 votes vote down vote up
void performContextAction (final Node[] nodes, final boolean singleDiffSetup) {
    // reevaluate fast enablement logic guess

    if(!Subversion.getInstance().checkClientAvailable()) {            
        return;
    }
    
    boolean noop;
    Context context = getContext(nodes);
    TopComponent activated = TopComponent.getRegistry().getActivated();
    if (activated instanceof DiffSetupSource) {
        noop = ((DiffSetupSource) activated).getSetups().isEmpty();
    } else {
        noop = !Subversion.getInstance().getStatusCache().containsFiles(context, FileInformation.STATUS_LOCAL_CHANGE, true);
    }
    if (noop) {
        NotifyDescriptor msg = new NotifyDescriptor.Message(NbBundle.getMessage(ExportDiffAction.class, "BK3001"), NotifyDescriptor.INFORMATION_MESSAGE);
        DialogDisplayer.getDefault().notify(msg);
        return;
    }

    ExportDiffSupport exportDiffSupport = new ExportDiffSupport(context.getRootFiles(), SvnModuleConfig.getDefault().getPreferences()) {
        @Override
        public void writeDiffFile(final File toFile) {
            RequestProcessor rp = Subversion.getInstance().getRequestProcessor();
            SvnProgressSupport ps = new SvnProgressSupport() {
                @Override
                protected void perform() {
                    async(this, nodes, toFile, singleDiffSetup);
                }
            };
            ps.start(rp, null, getRunningName(nodes)).waitFinished();
        }
    };
    exportDiffSupport.export();
}
 
Example 23
Source Project: hottub   Source File: FilterTopComponent.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void addFilterSetting() {
    NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Enter a name:", "Filter");
    if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) {
        String name = l.getInputText();

        FilterSetting toRemove = null;
        for (FilterSetting s : filterSettings) {
            if (s.getName().equals(name)) {
                NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter \"" + name + "\" already exists, to you want to overwrite?", "Filter");
                if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) {
                    toRemove = s;
                    break;
                } else {
                    return;
                }
            }
        }

        if (toRemove != null) {
            filterSettings.remove(toRemove);
        }
        FilterSetting setting = createFilterSetting(name);
        filterSettings.add(setting);

        // Sort alphabetically
        Collections.sort(filterSettings, new Comparator<FilterSetting>() {

            public int compare(FilterSetting o1, FilterSetting o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });

        updateComboBox();
    }
}
 
Example 24
public void actionPerformed(ActionEvent ev) {
    final ProjectAssetManager manager = context.getLookup().lookup(ProjectAssetManager.class);
    if (manager == null) {
        return;
    }
    Runnable call = new Runnable() {

        public void run() {
            ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening in Terrain Editor");
            progressHandle.start();

            
            final Spatial asset = context.loadAsset();

            if(asset!=null){
                java.awt.EventQueue.invokeLater(new Runnable() {

                    public void run() {
                        ((DesktopAssetManager)manager.getManager()).clearCache();
                        TerrainEditorTopComponent composer = TerrainEditorTopComponent.findInstance();
                        composer.openScene(asset, context, manager);
                    }
                });
            }else {
                Confirmation msg = new NotifyDescriptor.Confirmation(
                        "Error opening " + context.getPrimaryFile().getNameExt(),
                        NotifyDescriptor.OK_CANCEL_OPTION,
                        NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notify(msg);
            }
            progressHandle.finish();
        }
    };
    new Thread(call).start();
}
 
Example 25
Source Project: netbeans   Source File: ConfigurationSupport.java    License: Apache License 2.0 5 votes vote down vote up
public static void showConfigurationWarning(GrailsPlatform runtime) {
    if (!runtime.isConfigured()) {
        String msg = NbBundle.getMessage(ConfigurationSupport.class, "MSG_Runtime_Not_Configured");
        DialogDisplayer.getDefault().notify(
                new NotifyDescriptor.Message(msg, NotifyDescriptor.WARNING_MESSAGE));
    }
}
 
Example 26
Source Project: netbeans   Source File: NotifyExceptionTest.java    License: Apache License 2.0 5 votes vote down vote up
public Object notify(NotifyDescriptor descriptor) {
    Object t = toReturn;
    toReturn = null;
    assertNotNull("There is something to return", t);
    lastDescriptor = descriptor;
    return t;
}
 
Example 27
Source Project: opensim-gui   Source File: MultiFileSelectorPanel.java    License: Apache License 2.0 5 votes vote down vote up
static public Vector<String> showDialog(Vector<String> initialFileNames, FileFilter fileFilter) {
   // TODO: add file validator callback (FileTextFieldAndChooser needs this)
   MultiFileSelectorPanel panel = new MultiFileSelectorPanel(initialFileNames, fileFilter);
   DialogDescriptor dlg = new DialogDescriptor(panel, "Edit File List");
   Object answer = DialogDisplayer.getDefault().notify(dlg);
   if(answer==NotifyDescriptor.OK_OPTION) return panel.getFileNames();
   else return null;
}
 
Example 28
Source Project: netbeans   Source File: SearchIncoming.java    License: Apache License 2.0 5 votes vote down vote up
public void openSearch(final File repository, final File[] roots, final String contextName) {
    String branchName = getActiveBranchName(repository);
    if (branchName.equals(GitBranch.NO_BRANCH)) {
        NotifyDescriptor nd = new NotifyDescriptor.Message(Bundle.MSG_SearchIncomingTopComponent_err_noBranch(),
            NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
        return;
    }
    openSearch(repository, roots, branchName, contextName);
}
 
Example 29
Source Project: netbeans   Source File: CommonPasswordPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new Payara password panel.
 * <p/>
 * @param descriptor User notification descriptor.
 * @param instance   Payara server instance used to search
 *                   for supported platforms.
 * @param message    Message text.
 */
@SuppressWarnings("LeakingThisInConstructor")
public CommonPasswordPanel(final NotifyDescriptor descriptor,
        final PayaraInstance instance, final String message) {
    this.descriptor = descriptor;
    this.instance = instance;
    this.message = message;
    this.userLabelText = NbBundle.getMessage(
            CommonPasswordPanel.class, "CommonPasswordPanel.userLabel");
    this.passwordLabelText = NbBundle.getMessage(
            CommonPasswordPanel.class, "CommonPasswordPanel.passwordLabel");
    this.instance.getAdminUser();
    this.instance.getAdminPassword();
}
 
Example 30
Source Project: opensim-gui   Source File: ModelRenameAction.java    License: Apache License 2.0 5 votes vote down vote up
public void performAction() {
   Node[] selected = ExplorerTopComponent.findInstance().getExplorerManager().getSelectedNodes();
   if (selected.length == 1){
      OpenSimObjectNode objectNode = (OpenSimObjectNode) selected[0];
      NotifyDescriptor.InputLine dlg =
              new NotifyDescriptor.InputLine("Model Name: ", "Rename ");
      dlg.setInputText(objectNode.getOpenSimObject().getName());
      if(DialogDisplayer.getDefault().notify(dlg)==NotifyDescriptor.OK_OPTION){
          String newName = dlg.getInputText();
          if (OpenSimDB.getInstance().validateName(newName, true)){
              objectNode.getOpenSimObject().setName(newName);
              objectNode.setName(newName);  // Force navigator window update
              // Create event to tell everyone else
              Vector<OpenSimObject> objs = new Vector<OpenSimObject>(1);
              objs.add(objectNode.getOpenSimObject());
              ObjectsRenamedEvent evnt = new ObjectsRenamedEvent(this, null, objs);
              OpenSimDB.getInstance().setChanged();
              OpenSimDB.getInstance().notifyObservers(evnt);
              // The following is specific to renaming a model since
              // other windows may display currentModel's name
              // A more generic scheme using events should be used.
              if (objectNode instanceof OneModelNode) {
                 Model dModel = ((OneModelNode)objectNode).getModel();
                 if (dModel==OpenSimDB.getInstance().getCurrentModel())
                    OpenSimDB.getInstance().setCurrentModel(dModel);   // Need to do this so that model dropdown updates
                 // Mark the model as dirty
                 SingleModelGuiElements guiElem = OpenSimDB.getInstance().getModelGuiElements(dModel);
                 guiElem.setUnsavedChangesFlag(true);
              }
              objectNode.refreshNode();
          } else
              DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Provided name "+newName+" is not valid"));
      }
 
   } else { // Should never happen
      DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Rename of multiple objects is not supported."));
   }
}