org.openide.NotifyDescriptor Java Examples

The following examples show how to use org.openide.NotifyDescriptor. 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: InsertI18nStringAction.java    From netbeans with 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 #2
Source File: CloneableEditorUserQuestionAsync2Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: MappingPanel.java    From constellation with 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 File: ScaleToolPanel.java    From opensim-gui with 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 #5
Source File: NewWorkspaceAction.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: RenameContainerAction.java    From netbeans with 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 #7
Source File: InternationalizationResourceBundleBrandingPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: AddServerLocationVisualPanel.java    From netbeans with 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 #9
Source File: DatabaseNode.java    From netbeans with 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 #10
Source File: DataEditorSupport.java    From netbeans with 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 #11
Source File: EditDirtyStrategy.java    From BART with 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 #12
Source File: DebugAction.java    From netbeans with 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 #13
Source File: ActionMappings.java    From netbeans with 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 File: JoclVersionAction.java    From constellation with 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 #15
Source File: TargetsPanel.java    From netbeans with 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 #16
Source File: WSITEditor.java    From netbeans with 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 #17
Source File: CreateJREPanel.java    From netbeans with 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 #18
Source File: SysTray.java    From visualvm with 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 #19
Source File: CodeCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void renameInvoked() {
    NotifyDescriptor.InputLine input = new NotifyDescriptor.InputLine(
            NbBundle.getMessage(CodeCustomizer.class, "CTL_RenameLabel"), // NOI18N
            NbBundle.getMessage(CodeCustomizer.class, "CTL_RenameTitle")); // NOI18N
    input.setInputText(customizedComponent.getName());

    if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(input))) {
        // code data must be saved to component before renaming
        retreiveCurrentData();
        CustomCodeData codeData = changedDataMap.get(customizedComponent);
        if (codeData != null) {
            NotifyDescriptor.Confirmation confirm = new NotifyDescriptor.Confirmation(
                    NbBundle.getMessage(CodeCustomizer.class, "CTL_ApplyChangesLabel"), // NOI18N
                    NbBundle.getMessage(CodeCustomizer.class, "CTL_ApplyChangesTitle"), // NOI18N
                    NotifyDescriptor.OK_CANCEL_OPTION);
            if (!NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(confirm)))
                return;

            storeComponent(customizedComponent, codeData, true);
            changedDataMap.remove(customizedComponent);
        }

        try {
            String newName = input.getInputText();
            if (!newName.equals("")) // NOI18N
                customizedComponent.rename(newName);
        }
        catch (IllegalArgumentException e) {
            Exceptions.printStackTrace(e);
            return;
        }

        setupComponentNames();
        codeData = JavaCodeGenerator.getCodeData(customizedComponent);
        codeData.check();
        codeView.setCodeData(customizedComponent.getName(), codeData, getSourceFile(), getSourcePositions());
    }
}
 
Example #20
Source File: RebaseAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "LBL_RebaseResultProcessor.nothingToCommit=Nothing to Commit",
    "MSG_RebaseResultProcessor.nothingToCommit=No modifications to commit for the current rebase step.\n"
        + "Do you want to skip the commit from the rebase and continue?",
    "LBL_RebaseResultProcessor.skipButton.text=&Skip",
    "LBL_RebaseResultProcessor.skipButton.TTtext=Skip the commit and continue rebase."
})
private RebaseOperationType resolveNothingToCommit () {
    RebaseOperationType action = null;
    JButton abort = new JButton();
    Mnemonics.setLocalizedText(abort, Bundle.LBL_RebaseResultProcessor_abortButton_text());
    abort.setToolTipText(Bundle.LBL_RebaseResultProcessor_abortButton_TTtext());
    JButton skip = new JButton();
    Mnemonics.setLocalizedText(skip, Bundle.LBL_RebaseResultProcessor_skipButton_text());
    skip.setToolTipText(Bundle.LBL_RebaseResultProcessor_skipButton_TTtext());
    Object o = DialogDisplayer.getDefault().notify(new NotifyDescriptor(
            Bundle.MSG_RebaseResultProcessor_nothingToCommit(),
            Bundle.LBL_RebaseResultProcessor_nothingToCommit(),
            NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.QUESTION_MESSAGE,
            new Object[] { skip, abort, NotifyDescriptor.CANCEL_OPTION }, skip));
    if (o == skip) {
        action = RebaseOperationType.SKIP;
    } else if (o == abort) {
        action = RebaseOperationType.ABORT;
    }
    return action;
}
 
Example #21
Source File: ImportImageWizard.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean canRewriteTarget(File source, FileObject targetFO) {
    FileObject sourceFO = FileUtil.toFileObject(source);
    if (sourceFO != null && sourceFO.equals(targetFO)) {
        return false;
    }
    NotifyDescriptor d = new NotifyDescriptor.Confirmation(
            MessageFormat.format(NbBundle.getMessage(ImportImageWizard.class, "FMT_ReplaceExistingFileQuestion"), // NOI18N
                                 source.getName()),
            NbBundle.getMessage(ImportImageWizard.class, "TITLE_FileAlreadyExists"), // NOI18N
            NotifyDescriptor.YES_NO_OPTION);
    return DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.YES_OPTION;
}
 
Example #22
Source File: MinifyKeyAction.java    From minifierbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    MinifyProperty minifyProperty = MinifyProperty.getInstance();
    DataObject dob = TopComponent.getRegistry().getActivated().getLookup().lookup(DataObject.class);

    if (dob != null && minifyProperty.isEnableShortKeyAction()) {
        FileObject fileObject = dob.getPrimaryFile();//       p = FileOwnerQuery.getOwner(fo);
        boolean allowAction = true;

        if (minifyProperty.isEnableShortKeyActionConfirmBox()) {
            NotifyDescriptor.Confirmation nd
                    = new NotifyDescriptor.Confirmation(
                            "Are you sure to minify " + fileObject.getNameExt() + " ?",
                            "Minify " + fileObject.getNameExt(),
                            NotifyDescriptor.YES_NO_OPTION);
            nd.setOptions(new Object[]{
                NotifyDescriptor.YES_OPTION,
                NotifyDescriptor.NO_OPTION});
            if (DialogDisplayer.getDefault().notify(nd).equals(NotifyDescriptor.NO_OPTION)) {
                allowAction = false;
            }
        }
        if (allowAction) {
            if (fileObject.isFolder()) {
                targetAction = new Minify(dob);
            } else {
                if (fileObject.getExt().equalsIgnoreCase("js")) {
                    targetAction = new JSMinify(dob);
                } else if (fileObject.getExt().equalsIgnoreCase("css")) {
                    targetAction = new CSSMinify(dob);
                } else if (fileObject.getExt().equalsIgnoreCase("html") || fileObject.getExt().equalsIgnoreCase("htm")) {
                    targetAction = new HTMLMinify(dob);
                }
            }
            targetAction.actionPerformed(e);
        }
    }
}
 
Example #23
Source File: KeystoreOptionsSubPanel.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void changeAliasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeAliasActionPerformed
    // TODO add your handling code here:
    try {
        File f = new File(path.getText());
        if (f.exists()) {
            KeyStore ks = KeyStore.getInstance("jks");
            ks.load(new FileInputStream(f), keystorePassword.getPassword());
            EditKeyStore editKeyStore = new EditKeyStore(ks, alias.getText());
            DialogDescriptor dd = new DialogDescriptor(editKeyStore, "Choose Key", true, null);
            editKeyStore.setDescriptor(dd);
            Object notify = DialogDisplayer.getDefault().notify(dd);
            if (DialogDescriptor.OK_OPTION.equals(notify)) {
                if (editKeyStore.isNewKey()) {
                    ApkUtils.DN dn = editKeyStore.getNewDN();
                    boolean addNewKey = ApkUtils.addNewKey(ks, f, keystorePassword.getPassword(), dn);
                    if (!addNewKey) {
                        NotifyDescriptor nd = new NotifyDescriptor.Message("Unable to save new alias to key store!", NotifyDescriptor.ERROR_MESSAGE);
                        DialogDisplayer.getDefault().notifyLater(nd);
                    } else {
                        alias.setText(dn.getAlias());
                        keyPassword.setText(new String(dn.getPassword()));
                    }
                    keyReleased(null);
                } else {
                    alias.setText(editKeyStore.getAliasName());
                    keyPassword.setText("");
                }
                keyReleased(null);
            }
        }
    } catch (Exception ex) {
    }

}
 
Example #24
Source File: ProfilerDialogsProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void displayMessage(String message, String caption, String details, int type) {
    Object msg = message;
    Object det = details;
    if (isHtmlString(message)) msg = new NBHTMLLabel(message);
    if (isHtmlString(details)) det = new NBHTMLLabel(message);
    NotifyDescriptor nd = det == null ? new NotifyDescriptor.Message(msg, type) :
                    new ProfilerDialogs.MessageWithDetails(msg, det, type, false);
    if (caption != null) nd.setTitle(caption);
    ProfilerDialogs.notify(nd);
}
 
Example #25
Source File: Manager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 */
private void offerRescanAfterIssuesFound(final ReplaceTask task) {
    String msg = NbBundle.getMessage(getClass(),
                                     "MSG_IssuesFound_Rescan_");    //NOI18N
    NotifyDescriptor nd = new NotifyDescriptor.Message(
                                        msg,
                                        NotifyDescriptor.QUESTION_MESSAGE);
    String rerunOption = NbBundle.getMessage(getClass(),
                                             "LBL_Rerun");          //NOI18N
    nd.setOptions(new Object[] {rerunOption,
                                NotifyDescriptor.CANCEL_OPTION});
    Object dlgResult = DialogDisplayer.getDefault().notify(nd);
    if (rerunOption.equals(dlgResult)) {
        /*
         * The rescan method calls 'scheduleSearchTaskRerun()' on this.
         * But it will wait until 'taskFinished()' returns, which is
         * exactly what we need to keep consistency of the manager's fields
         * like 'currentReplaceTask', 'replaceTask' and 'state'.
         * Using this mechanism also requires that, when sending a method
         * to the EventQueue thread, we use invokeLater(...) and not
         * invokeAndWait(...).
         */
        Mutex.EVENT.writeAccess(new Runnable() {
            @Override
            public void run() {
                task.getPanel().rescan();
            }
        });
    }
}
 
Example #26
Source File: ProjectCustomizerProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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 #27
Source File: ModelRenameAction.java    From opensim-gui with 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."));
   }
}
 
Example #28
Source File: PHPPaletteActions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {

    ActiveEditorDrop drop = (ActiveEditorDrop) item.lookup(ActiveEditorDrop.class);

    JTextComponent target = Utilities.getFocusedComponent();
    if (target == null) {
        String msg = NbBundle.getMessage(PHPPaletteActions.class, "MSG_ErrorNoFocusedDocument");
        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE));
        return;
    }
    if (drop == null) {
        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.INFO, "{0} doesn''t provide {1}", new Object[]{item.getClass(), ActiveEditorDrop.class}); //NOI18N
        return;
    }
    try {
        drop.handleTransfer(target);
    } finally {
        Utilities.requestFocus(target);
    }

    try {
        PaletteController paletteController = PHPPaletteFactory.getPalette();
        paletteController.clearSelection();
    } catch (IOException ioe) {
        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.INFO, null, ioe);
    }

}
 
Example #29
Source File: CommonPasswordPanel.java    From netbeans with 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 File: Deadlock60917Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Object notify(org.openide.NotifyDescriptor descriptor) {
try {
	// we need to get into EQ - as the regular DialogDescriptor does
	waitEQ();
} catch (Exception ex) {
	ex.printStackTrace();
}
return NotifyDescriptor.CLOSED_OPTION;
     }