Java Code Examples for org.openide.util.NbBundle

The following are top voted examples for showing how to use org.openide.util.NbBundle. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: TimestampType.java   Source Code and License 6 votes vote down vote up
public static Timestamp convert(Object value) throws DBException {
    if (null == value) {
        return null;
    } else if (value instanceof Timestamp) {
        return (Timestamp) value;
    } else if (value instanceof java.sql.Date) {
        return new Timestamp(((java.sql.Date)value).getTime());
    }  else if (value instanceof java.util.Date) {
        return new Timestamp(((java.util.Date)value).getTime());
    } else if (value instanceof String) {
        Date dVal = doParse ((String) value);
        if (dVal == null) {
            throw new DBException(NbBundle.getMessage(TimestampType.class, "LBL_invalid_timestamp"));
        }
        return new Timestamp(dVal.getTime());
    } else {
        throw new DBException(NbBundle.getMessage(TimestampType.class, "LBL_invalid_timestamp"));
    }
}
 
Example 2
Project: incubator-netbeans   File: DiffAction.java   Source Code and License 6 votes vote down vote up
@Override
protected void performContextAction(Node[] nodes) {
    VCSContext context = HgUtils.getCurrentContext(nodes);
    String contextName = Utils.getContextDisplayName(context);
            
    File [] files = context.getRootFiles().toArray(new File[context.getRootFiles().size()]);
    boolean bNotManaged = !HgUtils.isFromHgRepository(context) || ( files == null || files.length == 0);

    if (bNotManaged) {
        OutputLogger logger = Mercurial.getInstance().getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE);
        logger.outputInRed( NbBundle.getMessage(DiffAction.class,"MSG_DIFF_TITLE")); // NOI18N
        logger.outputInRed( NbBundle.getMessage(DiffAction.class,"MSG_DIFF_TITLE_SEP")); // NOI18N
        logger.outputInRed(
                NbBundle.getMessage(DiffAction.class, "MSG_DIFF_NOT_SUPPORTED_INVIEW_INFO")); // NOI18N
        logger.output(""); // NOI18N
        logger.closeLog();
        JOptionPane.showMessageDialog(null,
                NbBundle.getMessage(DiffAction.class, "MSG_DIFF_NOT_SUPPORTED_INVIEW"),// NOI18N
                NbBundle.getMessage(DiffAction.class, "MSG_DIFF_NOT_SUPPORTED_INVIEW_TITLE"),// NOI18N
                JOptionPane.INFORMATION_MESSAGE);
        return;
    }

    diff(context, Setup.DIFFTYPE_LOCAL, contextName);
}
 
Example 3
Project: incubator-netbeans   File: Utils.java   Source Code and License 6 votes vote down vote up
public static String getFormatedDate(Calendar calendar) {
    if (calendar == null) {
        return "";
    }
    int evaluation = evaluateDate(calendar);
    switch (evaluation) {
        case DATE_MINUTES_AGO:
            int minutes = calculateMinutes(calendar, Calendar.getInstance());
            return NbBundle.getMessage(Utils.class, minutes == 1 ? "LBL_MinuteAgo" : "LBL_MinutesAgo", minutes);
        case DATE_TODAY:
            return NbBundle.getMessage(Utils.class, "LBL_Today", timeFormat.format(calendar.getTime()));
        case DATE_YESTERDAY:
            return NbBundle.getMessage(Utils.class, "LBL_Yesterday", timeFormat.format(calendar.getTime()));
        default:
            return dateFormat.format(calendar.getTime());
    }
}
 
Example 4
Project: incubator-netbeans   File: IDEServicesImpl.java   Source Code and License 6 votes vote down vote up
private File selectPatchContext() {
    PatchContextChooser chooser = new PatchContextChooser();
    ResourceBundle bundle = NbBundle.getBundle(IDEServicesImpl.class);
    JButton ok = new JButton(bundle.getString("LBL_Apply")); // NOI18N
    JButton cancel = new JButton(bundle.getString("LBL_Cancel")); // NOI18N
    DialogDescriptor descriptor = new DialogDescriptor(
            chooser,
            bundle.getString("LBL_ApplyPatch"), // NOI18N
            true,
            NotifyDescriptor.OK_CANCEL_OPTION,
            ok,
            null);
    descriptor.setOptions(new Object [] {ok, cancel});
    descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.bugtracking.patchContextChooser")); // NOI18N
    File context = null;
    DialogDisplayer.getDefault().createDialog(descriptor).setVisible(true);
    if (descriptor.getValue() == ok) {
        context = chooser.getSelectedFile();
    }
    return context;
}
 
Example 5
Project: incubator-netbeans   File: JPDAWatchImpl.java   Source Code and License 6 votes vote down vote up
protected void setValue (Value value) throws InvalidExpressionException {
    EvaluationContext.VariableInfo vi = getInfo(debugger, getInnerValue());
    if (vi != null) {
        try {
            vi.setValue(value);
        } catch (IllegalStateException isex) {
            if (isex.getCause() instanceof InvalidExpressionException) {
                throw (InvalidExpressionException) isex.getCause();
            } else {
                throw new InvalidExpressionException(isex);
            }
        }
    } else {
        throw new InvalidExpressionException (
                NbBundle.getMessage(JPDAWatchImpl.class, "MSG_CanNotSetValue", getExpression()));
    }
}
 
Example 6
Project: incubator-netbeans   File: Specification.java   Source Code and License 6 votes vote down vote up
/** Creates command identified by commandName on table tableName.
* Returns null if command specified by commandName was not found. It does not
* check tableName existency; it simply waits for relevant execute() command
* which fires SQLException.
*/	
public DDLCommand createCommand(String commandName, String tableName)
throws CommandNotSupportedException
{
    String classname;
    Class cmdclass;
    AbstractCommand cmd;
    HashMap cprops = (HashMap)desc.get(commandName);
    if (cprops != null) classname = (String)cprops.get("Class"); // NOI18N
    //else throw new CommandNotSupportedException(commandName, "command "+commandName+" is not supported by system");
    else throw new CommandNotSupportedException(commandName,
        MessageFormat.format(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_CommandNotSupported"), commandName)); // NOI18N
    try {
        cmdclass = Class.forName(classname);
        cmd = (AbstractCommand)cmdclass.newInstance();
    } catch (Exception e) {
        throw new CommandNotSupportedException(commandName,
            MessageFormat.format(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_UnableFindOrInitCommand"), classname, commandName, e.getMessage())); // NOI18N
    }

    cmd.setObjectName(tableName);
    cmd.setSpecification(this);
    cmd.setFormat((String)cprops.get("Format")); // NOI18N
    return cmd;
}
 
Example 7
Project: incubator-netbeans   File: DerbyActivator.java   Source Code and License 6 votes vote down vote up
private static void doActivate() {
    if (!helper.canBundleDerby()) {
        LOGGER.fine("Default platform cannot bundle Derby"); // NOI18N
        return;
    }

    ProgressHandle handle = ProgressHandleFactory.createSystemHandle(NbBundle.getMessage(DerbyActivator.class, "MSG_RegisterJavaDB"));
    handle.start();
    try {
        if (registerDerby()) {
            registerSampleDatabase();
        }
    } finally {
        handle.finish();
    }
}
 
Example 8
Project: incubator-netbeans   File: ExtractInterfaceRefactoringPlugin.java   Source Code and License 6 votes vote down vote up
@Override
public Problem fastCheckParameters() {
    Problem result = null;
    
    String newName = refactoring.getInterfaceName();
    
    if (!Utilities.isJavaIdentifier(newName)) {
        result = createProblem(result, true, NbBundle.getMessage(ExtractInterfaceRefactoringPlugin.class, "ERR_InvalidIdentifier", newName)); // NOI18N
        return result;
    }
    
    FileObject primFile = refactoring.getSourceType().getFileObject();
    FileObject folder = primFile.getParent();
    FileObject[] children = folder.getChildren();
    for (FileObject child: children) {
        if (!child.isVirtual() && child.getName().equalsIgnoreCase(newName) && "java".equalsIgnoreCase(child.getExt())) { // NOI18N
            result = createProblem(result, true, NbBundle.getMessage(ExtractInterfaceRefactoringPlugin.class, "ERR_ClassClash", newName, pkgName)); // NOI18N
            return result;
        }
    }

    return super.fastCheckParameters();
}
 
Example 9
Project: incubator-netbeans   File: CssHintsProvider.java   Source Code and License 6 votes vote down vote up
private static String getMessageKey(String errorKey, boolean enabled) {
    String param = null;
    String keyEnable = null;
    String keyDisable = null;
    if (CssAnalyser.isUnknownPropertyError(errorKey)) {
        keyEnable = "MSG_Disable_Ignore_Property"; //NOI18N
        keyDisable = "MSG_Enable_Ignore_Property"; //NOI18N
        param = CssAnalyser.getUnknownPropertyName(errorKey);
    } else {
        keyEnable = "MSG_Disable_Check"; //NOI18N
        keyDisable = "MSG_Enable_Check"; //NOI18N

    }
    return enabled
            ? NbBundle.getMessage(CssHintsProvider.class, keyEnable, param)
            : NbBundle.getMessage(CssHintsProvider.class, keyDisable, param);

}
 
Example 10
Project: incubator-netbeans   File: MercurialOptionsPanelController.java   Source Code and License 6 votes vote down vote up
private void onExportFilenameBrowseClick() {
    File oldFile = getExecutableFile();
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(MercurialOptionsPanelController.class, "ACSD_ExportBrowseFolder"), oldFile);   // NOI18N
    fileChooser.setDialogTitle(NbBundle.getMessage(MercurialOptionsPanelController.class, "ExportBrowse_title"));                                            // NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    FileFilter[] old = fileChooser.getChoosableFileFilters();
    for (int i = 0; i < old.length; i++) {
        FileFilter fileFilter = old[i];
        fileChooser.removeChoosableFileFilter(fileFilter);
    }
    fileChooser.showDialog(panel, NbBundle.getMessage(MercurialOptionsPanelController.class, "OK_Button"));                                            // NOI18N
    File f = fileChooser.getSelectedFile();
    if (f != null) {
        panel.exportFilenameTextField.setText(f.getAbsolutePath());
    }
}
 
Example 11
Project: incubator-netbeans   File: AssignmentIssues.java   Source Code and License 6 votes vote down vote up
@Hint(displayName = "#DN_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToForLoopParam", description = "#DESC_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToForLoopParam", category = "assignment_issues", enabled = false, suppressWarnings = "AssignmentToForLoopParameter", options=Options.QUERY) //NOI18N
@TriggerPatterns({
    @TriggerPattern(value = "for ($paramType $param = $init; $expr; $update) $statement;"), //NOI18N
    @TriggerPattern(value = "for ($paramType $param : $expr) $statement;") //NOI18N
})
public static List<ErrorDescription> assignmentToForLoopParam(HintContext context) {
    final Trees trees = context.getInfo().getTrees();
    final TreePath paramPath = context.getVariables().get("$param"); //NOI18N
    final Element param = trees.getElement(paramPath);
    if (param == null || param.getKind() != ElementKind.LOCAL_VARIABLE) {
        return null;
    }
    final TreePath stat = context.getVariables().get("$statement"); //NOI18N
    final List<TreePath> paths = new LinkedList<TreePath>();
    new AssignmentFinder(trees, param).scan(stat, paths);
    final List<ErrorDescription> ret = new ArrayList<ErrorDescription>(paths.size());
    for (TreePath path : paths) {
        ret.add(ErrorDescriptionFactory.forTree(context, path, NbBundle.getMessage(AssignmentIssues.class, "MSG_AssignmentToForLoopParam", param.getSimpleName()))); //NOI18N
    }
    return ret;
}
 
Example 12
Project: NBANDROID-V2   File: SdksCustomizer.java   Source Code and License 6 votes vote down vote up
/**
 * Shows platforms customizer
 *
 * @param platform which should be seelcted, may be null
 * @return boolean for future extension, currently always true
 */
public static boolean showCustomizer() {
    SdksCustomizer customizer
            = new SdksCustomizer();
    javax.swing.JButton close = new javax.swing.JButton(NbBundle.getMessage(SdksCustomizer.class, "CTL_Close"));
    close.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SdksCustomizer.class, "AD_Close"));
    DialogDescriptor descriptor = new DialogDescriptor(customizer, NbBundle.getMessage(SdksCustomizer.class,
            "TXT_PlatformsManager"), true, new Object[]{close}, close, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx("org.nbandroid.netbeans.gradle.v2.sdk.ui.PlatformsCustomizer"), null); // NOI18N
    Dialog dlg = null;
    try {
        dlg = DialogDisplayer.getDefault().createDialog(descriptor);
        dlg.setVisible(true);
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }
    return true;
}
 
Example 13
Project: incubator-netbeans   File: OutputTab.java   Source Code and License 6 votes vote down vote up
/**
 * Invokes a file dialog and if a file is chosen, saves the output to that file.
 */
void saveAs() {
    OutWriter out = getOut();
    if (out == null) {
        return;
    }
    File f = showFileChooser(this);
    if (f != null) {
        try {
            synchronized (out) {
                out.getLines().saveAs(f.getPath());
            }
        } catch (IOException ioe) {
            NotifyDescriptor notifyDesc = new NotifyDescriptor(
                    NbBundle.getMessage(OutputTab.class, "MSG_SaveAsFailed", f.getPath()),
                    NbBundle.getMessage(OutputTab.class, "LBL_SaveAsFailedTitle"),
                    NotifyDescriptor.DEFAULT_OPTION,
                    NotifyDescriptor.ERROR_MESSAGE,
                    new Object[]{NotifyDescriptor.OK_OPTION},
                    NotifyDescriptor.OK_OPTION);

            DialogDisplayer.getDefault().notify(notifyDesc);
        }
    }
}
 
Example 14
Project: incubator-netbeans   File: PersistenceManager.java   Source Code and License 6 votes vote down vote up
public FileObject getRootLocalFolder () throws IOException {
    try {
        if (rootLocalFolder == null) {
            String folderName = ROOT_LOCAL_FOLDER;
            if( null != currentRole )
                folderName += "-" + currentRole;
            rootLocalFolder = FileUtil.createFolder( FileUtil.getConfigRoot(), folderName );
        }
        return rootLocalFolder;
    } catch (IOException exc) {
        String annotation = NbBundle.getMessage(PersistenceManager.class,
            "EXC_RootFolder", ROOT_LOCAL_FOLDER);
        Exceptions.attachLocalizedMessage(exc, annotation);
        throw exc;
    }
}
 
Example 15
Project: incubator-netbeans   File: PomModelUtils.java   Source Code and License 6 votes vote down vote up
public static boolean implementInTransaction(Model m, Runnable r) {
    m.startTransaction();
    try {
        r.run();
    } finally {
        try {
            m.endTransaction();
        } catch (IllegalStateException ex) {
            StatusDisplayer.getDefault().setStatusText(
                    NbBundle.getMessage(PomModelUtils.class, "ERR_UpdatePomModel",
                    Exceptions.findLocalizedMessage(ex)));
            return false;
        }
    }
    return true;
}
 
Example 16
Project: incubator-netbeans   File: EditDependencyPanel.java   Source Code and License 6 votes vote down vote up
public void refreshAvailablePackages() {
    packagesModel.clear();
    if (hasAvailablePackages()) {
        // XXX should show all subpackages in the case of recursion is set
        // to true instead of e.g. org/**
        SortedSet<String> packages = new TreeSet<String>();
        for (int i = 0; i < pp.length; i++) { // add public packages
            packages.add(pp[i].getPackage() + (pp[i].isRecursive() ? ".**" : "")); // NOI18N
        }
        if (implVer.isSelected()) { // add all packages
            packages.addAll(origDep.getModuleEntry().getAllPackageNames());
        }
        for (String pkg : packages) {
            packagesModel.addElement(pkg);
        }
    } else {
        packagesModel.addElement(NbBundle.getMessage(EditDependencyPanel.class, "EditDependencyPanel_empty"));
    }
    availablePkg.setModel(packagesModel);
}
 
Example 17
Project: incubator-netbeans   File: SelectConfigFilesPanel.java   Source Code and License 6 votes vote down vote up
public boolean open() {
    String title = NbBundle.getMessage(SelectConfigFilesPanel.class, "LBL_ConfigFilesTitle");
    descriptor = new DialogDescriptor(this, title, true, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            cancelDetection();
        }
    });
    if (availableFiles == null) {
        // No available files, will run the detection task.
        descriptor.setValid(false);
        configFileTable.setEnabled(true);
        progressBar.setIndeterminate(true);
        detectTask = rp.create(new FileDetector());
        detectTask.schedule(0);
    } else {
        updateAvailableFiles(availableFiles);
    }
    Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    try {
        dialog.setVisible(true);
    } finally {
        dialog.dispose();
    }
    return descriptor.getValue() == DialogDescriptor.OK_OPTION;
}
 
Example 18
Project: incubator-netbeans   File: CssRenameRefactoringPlugin.java   Source Code and License 6 votes vote down vote up
private void refactorElement(ModificationResult modificationResult, CssElementContext.Editor context, CssIndex index) {
    //type selector: div
    //we do refactor only elements in the current css file, and even this is questionable if makes much sense
    Node element = context.getElement();
    String elementImage = element.image().toString();

    CssFileModel model = CssFileModel.create(context.getParserResult());
    List<Difference> diffs = new ArrayList<>();
    CloneableEditorSupport editor = GsfUtilities.findCloneableEditorSupport(context.getFileObject());
    for (Entry entry : model.getHtmlElements()) {
        if (entry.isValidInSourceDocument() && elementImage.equals(entry.getName())) {
            diffs.add(new Difference(Difference.Kind.CHANGE,
                    editor.createPositionRef(entry.getDocumentRange().getStart(), Bias.Forward),
                    editor.createPositionRef(entry.getDocumentRange().getEnd(), Bias.Backward),
                    entry.getName(),
                    refactoring.getNewName(),
                    NbBundle.getMessage(CssRenameRefactoringPlugin.class, "MSG_Rename_Selector"))); //NOI18N
        }
    }
    if (!diffs.isEmpty()) {
        modificationResult.addDifferences(context.getFileObject(), diffs);
    }

}
 
Example 19
Project: incubator-netbeans   File: DocumentationScrollPane.java   Source Code and License 6 votes vote down vote up
/** Creates a new instance of ScrollJavaDocPane */
    public DocumentationScrollPane( boolean keepDefaultBorder ) {
        super();
 
        // Add the completion doc view
        //XXX fix bg color
        view = new HTMLDocView( getDefaultBackground() );
        view.addHyperlinkListener(new HyperlinkAction());
        setViewportView(view);
        getAccessibleContext().setAccessibleName(NbBundle.getMessage(DocumentationScrollPane.class, "ACSN_DocScrollPane"));
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DocumentationScrollPane.class, "ACSD_DocScrollPane"));
        view.getAccessibleContext().setAccessibleName(NbBundle.getMessage(DocumentationScrollPane.class, "ACSN_DocScrollPane"));
        view.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DocumentationScrollPane.class, "ACSD_DocScrollPane"));
        installTitleComponent();
//        installKeybindings(view);
        setFocusable(true);
        
        if( !keepDefaultBorder )
            setBorder( BorderFactory.createEmptyBorder() );
    }
 
Example 20
Project: incubator-netbeans   File: Export.java   Source Code and License 5 votes vote down vote up
public Export(File fromFile, boolean localChanges) {
    
    this.fromFile = fromFile;
    
    panel = new ExportPanel();

    panel.scanCheckBox.setSelected(SvnModuleConfig.getDefault().getPreferences().getBoolean(SCAN_AFTER_EXPORT, false));
    panel.exportFromTextField.setText(fromFile.getAbsolutePath());
    panel.browseToFolderButton.addActionListener(this);
    panel.exportToTextField.getDocument().addDocumentListener(this);

    panel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(Export.class, "CTL_ExportDialog_Title"));                   // NOI18N

    okButton = new JButton(NbBundle.getMessage(Export.class, "CTL_Export"));
    okButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(Export.class, "CTL_Export"));
    cancelButton = new JButton(NbBundle.getMessage(Export.class, "CTL_Cancel"));                                      // NOI18N
    cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Export.class, "CTL_Cancel"));    // NOI18N

    dialogDescriptor =
            new DialogDescriptor(
                panel,
                NbBundle.getMessage(Export.class, "CTL_ExportDialog_Title"),
                true,
                new Object[]{okButton, cancelButton},
                okButton,
                DialogDescriptor.DEFAULT_ALIGN,
                null,
                null);
    okButton.setEnabled(false);

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
    dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Export.class, "CTL_ExportDialog_Title"));                // NOI18N

    validateUserInput();
}
 
Example 21
Project: incubator-netbeans   File: IExplorerBrowser.java   Source Code and License 5 votes vote down vote up
/**
 * Returns a new instance of BrowserImpl implementation.
 * @throws UnsupportedOperationException when method is called and OS is not Windows.
 * @return browserImpl implementation of browser.
 */
@Override
public HtmlBrowser.Impl createHtmlBrowserImpl() {
    ExtBrowserImpl impl = null;

    if (org.openide.util.Utilities.isWindows ()) {
        impl = new NbDdeBrowserImpl (this);
    } else {
        throw new UnsupportedOperationException (NbBundle.getMessage (IExplorerBrowser.class, "MSG_CannotUseBrowser"));
    }
    
    return impl;
}
 
Example 22
Project: incubator-netbeans   File: NoWebBrowserImpl.java   Source Code and License 5 votes vote down vote up
public NoWebBrowserImpl(String cause) {
    JLabel lbl = new JLabel(NbBundle.getMessage(NoWebBrowserImpl.class, "Err_CannotCreateBrowser", cause));
    lbl.setEnabled( false );
    lbl.setHorizontalAlignment( JLabel.CENTER );
    lbl.setVerticalAlignment( JLabel.CENTER );
    component = lbl;
}
 
Example 23
Project: incubator-netbeans   File: JWSCustomizerPanel.java   Source Code and License 5 votes vote down vote up
private void appletParamsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_appletParamsButtonActionPerformed

    List<Map<String,String>> origProps = jwsProps.getAppletParamsProperties();
    List<Map<String,String>> props = copyList(origProps);
    TableModel appletParamsTableModel = new JWSProjectProperties.PropertiesTableModel(props, JWSProjectProperties.appletParamsSuffixes, appletParamsColumnNames);
    JPanel panel = new AppletParametersPanel((PropertiesTableModel) appletParamsTableModel, jwsProps.appletWidthDocument, jwsProps.appletHeightDocument);
    DialogDescriptor dialogDesc = new DialogDescriptor(panel, NbBundle.getMessage(JWSCustomizerPanel.class, "TITLE_AppletParameters"), true, null); //NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDesc);
    dialog.setVisible(true);
    if (dialogDesc.getValue() == DialogDescriptor.OK_OPTION) {
        jwsProps.setAppletParamsProperties(props);
    }
    dialog.dispose();

}
 
Example 24
Project: incubator-netbeans   File: AttachmentsPanel.java   Source Code and License 5 votes vote down vote up
public AttachmentsPanel(JComponent parentPanel) {
    this.parentPanel = parentPanel;
    this.supp = new ChangeSupport(this);
    setBackground(UIManager.getColor("TextArea.background")); // NOI18N
    ResourceBundle bundle = NbBundle.getBundle(AttachmentsPanel.class);
    noneLabel = new JLabel(bundle.getString("AttachmentsPanel.noneLabel.text")); // NOI18N
    createNewButton = new LinkButton(new CreateNewAction());
    createNewButton.getAccessibleContext().setAccessibleDescription(bundle.getString("AttachmentPanels.createNewButton.AccessibleContext.accessibleDescription")); // NOI18N
    try {
        maxMethod = GroupLayout.Group.class.getDeclaredMethod("calculateMaximumSize", int.class); // NOI18N
        maxMethod.setAccessible(true);
    } catch (NoSuchMethodException nsmex) {
        LOG.log(Level.INFO, nsmex.getMessage(), nsmex);
    }
}
 
Example 25
Project: incubator-netbeans   File: UINode.java   Source Code and License 5 votes vote down vote up
@Override
public String getHtmlDisplayName() {
    if (htmlKey == null) {
        return null;
    } else {
        return NbBundle.getMessage(UINode.class, htmlKey, getDisplayName());
    }
}
 
Example 26
Project: incubator-netbeans   File: OutputKeymapManager.java   Source Code and License 5 votes vote down vote up
public OutWinShortCutAction(String id, String bundleKey) {
    this.id = id;
    this.bundleKey = bundleKey;
    this.displayName = NbBundle.getMessage(
            NbIOProvider.class, bundleKey);
    String nbKeysBundleKey = Utilities.isMac()
            ? bundleKey + ".accel.mac" //NOI18N
            : bundleKey + ".accel";                             //NOI18N
    String nbKeys = NbBundle.getMessage(NbIOProvider.class,
            nbKeysBundleKey);
    this.defaultShortcut = nbKeys;
}
 
Example 27
Project: incubator-netbeans   File: ConnectionNode.java   Source Code and License 5 votes vote down vote up
@Override
public String getShortDescription() {
    if (!getName().equals(getDisplayName())) {
        return getName();
    } else {
        return NbBundle.getMessage (ConnectionNode.class, "ND_Connection"); //NOI18N
    }
}
 
Example 28
Project: incubator-netbeans   File: SelectConnectionPanel.java   Source Code and License 5 votes vote down vote up
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    dbconnLabel = new javax.swing.JLabel();
    dbconnComboBox = new javax.swing.JComboBox();

    org.openide.awt.Mnemonics.setLocalizedText(dbconnLabel, org.openide.util.NbBundle.getMessage(SelectConnectionPanel.class, "SelectConnectionPanel.dbconnLabel.text")); // NOI18N

    dbconnComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            dbconnComboBoxActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(dbconnLabel)
                .addComponent(dbconnComboBox, 0, 518, Short.MAX_VALUE))
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(dbconnLabel)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(dbconnComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    dbconnComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SelectConnectionPanel.class, "ChooseConnectionPanel.dbconnComboBox.AccessibleContext.accessibleName")); // NOI18N
    dbconnComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SelectConnectionPanel.class, "ChooseConnectionPanel.dbconnComboBox.AccessibleContext.accessibleDescription")); // NOI18N
}
 
Example 29
Project: incubator-netbeans   File: CloseAllDocumentsAction.java   Source Code and License 5 votes vote down vote up
/**
 * can decide whether to have label with mnemonics or without it.
 */
public CloseAllDocumentsAction(boolean isContext) {
    this.isContext = isContext;
    String key;
    if (isContext) {
        key = "LBL_CloseAllDocumentsAction"; //NOI18N
    } else {
        key = "CTL_CloseAllDocumentsAction"; //NOI18N
    }
    putValue(NAME, NbBundle.getMessage(CloseAllDocumentsAction.class, key));
}
 
Example 30
Project: incubator-netbeans   File: SOAPComponentVisitor.java   Source Code and License 5 votes vote down vote up
public void visit(SOAPFault fault) {
    String name = fault.getName();
    if (name == null) {
        results.add(
                new Validator.ResultItem(mValidator,
                Validator.ResultType.ERROR,
                fault,
                NbBundle.getMessage(SOAPComponentVisitor.class, "SOAPFaultValidator.Missing_name")));
    }
    
    Collection<String> encodingStyles = fault.getEncodingStyles();
    if (encodingStyles != null) {
        // This is optional.  Don't verify contents at this point.
    }
    
    String namespace = fault.getNamespace();
    if (namespace != null) {
        // This is optional.  We should verify that it is a valid URI, but
        // I don't want to be too restrictive at this point.
    }
    
    try {
        SOAPMessageBase.Use use = fault.getUse();
    } catch (Throwable th) {
        results.add(
                new Validator.ResultItem(mValidator,
                Validator.ResultType.ERROR,
                fault,
                NbBundle.getMessage(SOAPComponentVisitor.class, "SOAPFaultValidator.Unsupported_use_attribute")));
    }
}
 
Example 31
Project: incubator-netbeans   File: EncapsulateFieldRefactoringPlugin.java   Source Code and License 5 votes vote down vote up
private Problem fastCheckParameters(String getter, String setter,
        Set<Modifier> methodModifier, Set<Modifier> fieldModifier,
        boolean alwaysUseAccessors) {

    if ((getter != null && !Utilities.isJavaIdentifier(getter))
            || (setter != null && !Utilities.isJavaIdentifier(setter))
            || (getter == null && setter == null)) {
        // user doesn't use valid java identifier, it cannot be used
        // as getter/setter name
        return new Problem(true, NbBundle.getMessage(EncapsulateFieldRefactoringPlugin.class, "ERR_EncapsulateMethods"));
    } else {
        // we have no problem :-)
        return null;
    }
}
 
Example 32
Project: incubator-netbeans   File: DetectPanel.java   Source Code and License 5 votes vote down vote up
private void checkValid () {
    this.wiz.putProperty( WizardDescriptor.PROP_ERROR_MESSAGE, ""); //NOI18N
    final String name = this.component.getPlatformName ();
    boolean vld;
    switch (detected.get()) {
        case INVALID:
            this.wiz.putProperty( WizardDescriptor.PROP_ERROR_MESSAGE,NbBundle.getMessage(DetectPanel.class,"ERROR_NoSDKRegistry"));         //NOI18N
            vld = false;
            break;
        case UNKNOWN:
            vld = false;
            break;
        case VALID:
            vld = true;
            break;
        case UNSUPPORTED:
            this.wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(DetectPanel.class,"ERROR_UnsupportedPlatform", SourceLevelQuery.MINIMAL_SOURCE_LEVEL));         //NOI18N
            vld = false;
            break;
        default:
            throw new IllegalStateException();
    }
    if (vld && name.length() == 0) {
        vld = false;
        this.wiz.putProperty( WizardDescriptor.PROP_ERROR_MESSAGE,NbBundle.getMessage(DetectPanel.class,"ERROR_InvalidDisplayName"));    //NOI18N
    }
    if (vld) {
        for (JavaPlatform platform : JavaPlatformManager.getDefault().getInstalledPlatforms()) {
            if (name.equals (platform.getDisplayName())) {
                vld = false;
                this.wiz.putProperty( WizardDescriptor.PROP_ERROR_MESSAGE,NbBundle.getMessage(DetectPanel.class,"ERROR_UsedDisplayName"));    //NOI18N
                break;
            }
        }
    }
    setValid(vld);
}
 
Example 33
Project: incubator-netbeans   File: NodePopupFactory.java   Source Code and License 5 votes vote down vote up
void addNoFilterItem(ETable et, JPopupMenu popup) {
    if (showQuickFilter && et.getQuickFilterColumn() != -1) {
        String s = NbBundle.getMessage(NodePopupFactory.class, "LBL_QuickFilter");
        JMenu menu = new JMenu(s);
        JMenuItem noFilterItem = et.getQuickFilterNoFilterItem(et.getQuickFilterFormatStrings()[6]);
        menu.add(noFilterItem);
        popup.add(menu);
    }
}
 
Example 34
Project: incubator-netbeans   File: ReplaceTask.java   Source Code and License 5 votes vote down vote up
/**
 */
public ReplaceTask(List<MatchingObject> matchingObjects,
        BasicReplaceResultsPanel panel) {
    this.matchingObjects = matchingObjects;
    this.panel = panel;
    
    problems = new ArrayList<String>(4);
    progressHandle = ProgressHandleFactory.createHandle(
            NbBundle.getMessage(getClass(), "LBL_Replacing"));      //NOI18N
}
 
Example 35
Project: incubator-netbeans   File: GitUtils.java   Source Code and License 5 votes vote down vote up
public static void printInfo (StringBuilder sb, GitRevisionInfo info, boolean endWithNewLine) {
    String lbrevision = NbBundle.getMessage(CommitAction.class, "MSG_CommitAction.logCommit.revision");   // NOI18N
    String lbauthor = NbBundle.getMessage(CommitAction.class, "MSG_CommitAction.logCommit.author");      // NOI18N
    String lbcommitter = NbBundle.getMessage(CommitAction.class, "MSG_CommitAction.logCommit.committer");      // NOI18N
    String lbdate = NbBundle.getMessage(CommitAction.class, "MSG_CommitAction.logCommit.date");        // NOI18N
    String lbsummary = NbBundle.getMessage(CommitAction.class, "MSG_CommitAction.logCommit.summary");     // NOI18N

    String author = info.getAuthor().toString();
    String committer = info.getCommitter().toString();
    sb.append(NbBundle.getMessage(CommitAction.class, "MSG_CommitAction.logCommit.title")).append("\n"); //NOI18N
    sb.append(lbrevision);
    sb.append(info.getRevision());
    sb.append('\n'); // NOI18N
    sb.append(lbauthor);
    sb.append(author);
    sb.append('\n'); // NOI18N
    if (!author.equals(committer)) {
        sb.append(lbcommitter);
        sb.append(committer);
        sb.append('\n'); // NOI18N
    }
    sb.append(lbdate);
    sb.append(DateFormat.getDateTimeInstance().format(new Date(info.getCommitTime())));
    sb.append('\n'); // NOI18N
    sb.append(lbsummary);
    int prefixLen = lbsummary.length();
    sb.append(formatMultiLine(prefixLen, info.getFullMessage()));
    if (endWithNewLine) {
        sb.append('\n');
    }
}
 
Example 36
Project: incubator-netbeans   File: Utilities.java   Source Code and License 5 votes vote down vote up
private static String getFileObjectLocalizedName( FileObject fo ) {
    Object o = fo.getAttribute("SystemFileSystem.localizingBundle"); // NOI18N
    if ( o instanceof String ) {
        String bundleName = (String)o;
        try {
            ResourceBundle rb = NbBundle.getBundle(bundleName);            
            String localizedName = rb.getString(fo.getPath());                
            return localizedName;
        }
        catch(MissingResourceException ex ) {
            // Do nothing return file path;
        }
    }
    return fo.getPath();
}
 
Example 37
Project: incubator-netbeans   File: SpringRefactoringElement.java   Source Code and License 5 votes vote down vote up
@Override
public String getDisplayText() {
    if (oldSimpleName != null) {
        return NbBundle.getMessage(JavaElementRefModification.class, "MSG_UpdateReference", oldSimpleName);
    } else {
        return NbBundle.getMessage(JavaElementRefModification.class, "MSG_Update");
    }
}
 
Example 38
Project: incubator-netbeans   File: NBLoginPanel.java   Source Code and License 5 votes vote down vote up
private boolean showLogin() {
    DialogDescriptor descriptor = new DialogDescriptor (
            this,
            NbBundle.getMessage(NBLoginPanel.class, "LBL_LOGIN_2_NBORG"),   // NOI18N
            true,
            new Object[] {login, cancel},
            login,
            DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx("org.netbeans.modules.bugzilla.api.NBLoginPanel"),  // NOI18N
            null);
    return DialogDisplayer.getDefault().notify(descriptor) == login;
}
 
Example 39
Project: incubator-netbeans   File: EditClusterPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Shows Edit Cluster dialog for existing external cluster.
 * Browse button is disabled, user can only change src and javadoc.
 *
 * @param ci Original cluster info 
 * @return Updated cluster info or null if user cancelled the dialog
 */
static ClusterInfo showEditDialog(ClusterInfo ci, Project prj) {
    EditClusterPanel panel = new EditClusterPanel();
    panel.prjDir = FileUtil.toFile(prj.getProjectDirectory());
    panel.prj = prj;
    SourceRootsSupport srs = new SourceRootsSupport(
            ci.getSourceRoots() == null ? new URL[0] : ci.getSourceRoots(), null);
    panel.sourcesPanel.setSourceRootsProvider(srs);
    JavadocRootsSupport jrs = new JavadocRootsSupport(
            ci.getJavadocRoots() == null ? new URL[0] : ci.getJavadocRoots(), null);
    panel.javadocPanel.setJavadocRootsProvider(jrs);
    DialogDescriptor descriptor = new DialogDescriptor(
            panel,
            NbBundle.getMessage(EditClusterPanel.class, "CTL_EditCluster_Title"), // NOI18N
            true,
            new Object[] { panel.okButton, NotifyDescriptor.CANCEL_OPTION },
            panel.okButton,
            DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.EditClusterPanel"),
            null);
    descriptor.setClosingOptions(null);
    Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor);
    panel.clusterDirText.setText(ci.getClusterDir().toString());
    panel.updateDialog();
    panel.browseButton.setEnabled(false);
    dlg.setVisible(true);
    ClusterInfo retVal = null;
    if (descriptor.getValue() == panel.okButton) {
        retVal = ClusterInfo.createExternal(panel.getAbsoluteClusterPath(), 
                srs.getSourceRoots(), jrs.getJavadocRoots(), true);
    }
    dlg.dispose();
    return retVal;
}
 
Example 40
Project: incubator-netbeans   File: AbstractSearchResultsPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Set btnStopRefresh to show refresh icon.
 */
protected void showRefreshButton() {
    btnStopRefresh.setToolTipText(UiUtils.getText(
            "TEXT_BUTTON_CUSTOMIZE"));                              //NOI18N
    btnStopRefresh.setIcon(
            ImageUtilities.loadImageIcon(REFRESH_ICON, true));
    btnStopRefresh.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(ResultView.class,
            "ACS_TEXT_BUTTON_CUSTOMIZE"));                          //NOI18N
    btnStopRefreshInRefreshMode = true;
}
 
Example 41
Project: incubator-netbeans   File: PlatformShellAction.java   Source Code and License 5 votes vote down vote up
@NbBundle.Messages({
    "# {0} - error message",
    "ERR_RunPlatformShell=Error starting Java Shell: {0}"
})
@Override
public void actionPerformed(ActionEvent e) {
    JavaPlatform platform = options.getSelectedPlatform();
    if (platform == null) {
        NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation(
                Bundle.ERR_NoShellPlatform(), NotifyDescriptor.Confirmation.OK_CANCEL_OPTION
        );
        Object result = DialogDisplayer.getDefault().notify(conf);
        if (result == NotifyDescriptor.Confirmation.OK_OPTION) {
            OptionsDisplayer.getDefault().open("Java/JShell", true);
        }
        platform = options.getSelectedPlatform();
        if (platform == null) {
            return;
        }
    }
    try {
        JShellEnvironment env = ShellRegistry.get().openDefaultSession(platform);
        env.open();
    } catch (IOException ex) {
        Message msg = new Message(Bundle.ERR_RunPlatformShell(ex.getLocalizedMessage()), Message.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(msg);
    }
}
 
Example 42
Project: incubator-netbeans   File: HgCommand.java   Source Code and License 5 votes vote down vote up
public static List<String> doVerify(File repository, OutputLogger logger) throws HgException {
    if (repository == null ) return null;
    List<String> command = new ArrayList<String>();

    command.add(getHgCommand());
    command.add(HG_VERIFY_CMD);
    command.add(HG_OPT_REPOSITORY);
    command.add(repository.getAbsolutePath());

    List<String> list = exec(command);
    if (list.isEmpty())
        handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_VERIFY_FAILED"), logger);

    return list;
}
 
Example 43
Project: incubator-netbeans   File: ClassEditor.java   Source Code and License 5 votes vote down vote up
/** Set the property value by parsing a given String.  May raise
* java.lang.IllegalArgumentException if either the String is
* badly formatted or if this kind of property can't be expressed
* as text.
* @param text  The string to be parsed.
*/
public void setAsText(String text) throws java.lang.IllegalArgumentException {
    try {
        ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class);
        setValue (loader.loadClass (text));
    } catch (ClassNotFoundException e) {
        IllegalArgumentException iae = new IllegalArgumentException (e.getMessage());
        String msg = MessageFormat.format(
            NbBundle.getMessage(
                ClassEditor.class, "FMT_EXC_CANT_LOAD_CLASS"), new Object[] {text}); //NOI18N
        UIExceptions.annotateUser(iae, e.getMessage(), msg, e,
                                 new java.util.Date());
        throw iae;
    }
}
 
Example 44
Project: incubator-netbeans   File: DerbyOptionsBeanInfo.java   Source Code and License 5 votes vote down vote up
public PropertyDescriptor[] getPropertyDescriptors() {
    try {
        PropertyDescriptor[] descriptors = new PropertyDescriptor[2];
        descriptors[0] = new PropertyDescriptor(DerbyOptions.PROP_DERBY_LOCATION, DerbyOptions.class);
        descriptors[0].setDisplayName(NbBundle.getMessage(DerbyOptionsBeanInfo.class, "LBL_DerbyLocation"));
        descriptors[0].setShortDescription(NbBundle.getMessage(DerbyOptionsBeanInfo.class, "HINT_DerbyLocation"));
        descriptors[1] = new PropertyDescriptor(DerbyOptions.PROP_DERBY_SYSTEM_HOME, DerbyOptions.class);
        descriptors[1].setDisplayName(NbBundle.getMessage(DerbyOptionsBeanInfo.class, "LBL_DatabaseLocation"));
        descriptors[1].setShortDescription(NbBundle.getMessage(DerbyOptionsBeanInfo.class, "HINT_DatabaseLocation"));
        return descriptors;
    } catch (IntrospectionException ex) {
        Exceptions.printStackTrace(ex);
        return new PropertyDescriptor[0];
    }
}
 
Example 45
Project: incubator-netbeans   File: HgCommand.java   Source Code and License 5 votes vote down vote up
/**
 * Exports a changeset bundle for the given revision range to the given output file
 *
 * @param File repository of the mercurial repository's root directory
 * @param revBase the base revision
 * @param revTo the revision up to which to export, can be null
 * @param outputFile the output file
 * @throws org.netbeans.modules.mercurial.HgException
 */
public static List<String> doBundle (File repository, String revBase, String revTo, File outputFile, OutputLogger logger) throws HgException {
    // Ensure that parent directory of target exists, creating if necessary
    File parentTarget = outputFile.getParentFile();
    try {
        if (!parentTarget.mkdirs()) {
            if (!parentTarget.isDirectory()) {
                Mercurial.LOG.log(Level.WARNING, "File.mkdirs() failed for : {0}", parentTarget.getAbsolutePath()); // NOI18N
                throw (new HgException (NbBundle.getMessage(HgCommand.class, "MSG_UNABLE_TO_CREATE_PARENT_DIR"))); // NOI18N
            }
        }
    } catch (SecurityException e) {
        Mercurial.LOG.log(Level.WARNING, "File.mkdir() for : {0} threw SecurityException {1}", new Object[]{parentTarget.getAbsolutePath(), e.getMessage()}); // NOI18N
        throw (new HgException (NbBundle.getMessage(HgCommand.class, "MSG_UNABLE_TO_CREATE_PARENT_DIR"))); // NOI18N
    }
    List<String> command = new ArrayList<String>();

    command.add(getHgCommand());
    command.add(HG_BUNDLE_CMD);
    command.add(HG_VERBOSE_CMD);
    command.add(HG_OPT_REPOSITORY);
    command.add(repository.getAbsolutePath());
    command.add(HG_BASE_CMD);
    command.add(revBase);
    if (revTo != null) {
        command.add(HG_REV_CMD);
        command.add(revTo);
    }
    command.add(outputFile.getAbsolutePath());

    List<String> list = exec(command);
    if (!list.isEmpty() &&
         isErrorAbort(list.get(list.size() -1))) {
        handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_BUNDLE_FAILED"), logger);
    }
    return list;
}
 
Example 46
Project: incubator-netbeans   File: MavenGroupPanel.java   Source Code and License 5 votes vote down vote up
@Override
@NbBundle.Messages({
    "# {0} - global maven selection",
    "LBL_Global_selection={0} [Global selection]"})
public Component getListCellRendererComponent(JList list, Object value,
        int index, boolean isSelected, boolean cellHasFocus) {
    if (SEPARATOR.equals(value)) {
        return separator;
    }
    if (globalMavenValue.equals(value)) {
        value = LBL_Global_selection(value);
    }
    return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
 
Example 47
Project: incubator-netbeans   File: MoveToDependencyManagementHint.java   Source Code and License 5 votes vote down vote up
@Override
public List<ErrorDescription> getErrorsForDocument(POMModel model, Project prj,
        int selectionStart, int selectionEnd, int caretPosition) {
    List<ErrorDescription> err = new ArrayList<ErrorDescription>();
    if (prj == null) {
        return err;
    }
    DocumentComponent comp1 = model.findComponent(selectionStart);
    DocumentComponent comp2 = model.findComponent(selectionEnd);
    if (comp1 == null || comp2 == null) { //#157213
        return err;
    }
 
    List<Dependency> deps = getSelectedDependencies(model, selectionStart, selectionEnd);
    if (deps != null && !deps.isEmpty()) { //NOI18N
        try {
            Line line = NbEditorUtilities.getLine(model.getBaseDocument(), caretPosition, false);
            err.add(ErrorDescriptionFactory.createErrorDescription(
                    Severity.HINT,
                    NbBundle.getMessage(MoveToDependencyManagementHint.class, "TEXT_MoveToDependencyManagementHint"),
                    Collections.<Fix>singletonList(new MoveFix(selectionStart, selectionEnd, model, prj)),
                    model.getBaseDocument(), line.getLineNumber() + 1));
        } catch (IndexOutOfBoundsException ioob) {
            //#214527
            LOG.log(Level.FINE, "document changed", ioob);
        }
    }
    return err;
}
 
Example 48
Project: incubator-netbeans   File: NbLocalizer.java   Source Code and License 5 votes vote down vote up
/** Get the localized string using the given key. */
public String getString(String key) {
    try {
        return NbBundle.getBundle(bundleClass).getString(key);
    } catch (MissingResourceException e) {
        return null;
    }
}
 
Example 49
Project: incubator-netbeans   File: NbBundleTest.java   Source Code and License 5 votes vote down vote up
public static void testLocalizingSuffixes() throws Exception {
    assertEquals("_en_US,_en,", locSuff());
    Locale.setDefault(Locale.JAPAN);
    assertEquals("_ja_JP,_ja,", locSuff());
    NbBundle.setBranding("f4j_ce");
    Locale.setDefault(Locale.US);
    assertEquals("_f4j_ce_en_US,_f4j_ce_en,_f4j_ce,_f4j_en_US,_f4j_en,_f4j,_en_US,_en,", locSuff());
    Locale.setDefault(Locale.JAPAN);
    assertEquals("_f4j_ce_ja_JP,_f4j_ce_ja,_f4j_ce,_f4j_ja_JP,_f4j_ja,_f4j,_ja_JP,_ja,", locSuff());
}
 
Example 50
Project: incubator-netbeans   File: SearchOutgoingTopComponent.java   Source Code and License 5 votes vote down vote up
public SearchOutgoingTopComponent (File repository, RepositoryInfo info, File[] files, boolean searchInContext) {
    this.repository = repository;
    this.info = info;
    this.files = files;
    getAccessibleContext().setAccessibleName(NbBundle.getMessage(SearchOutgoingTopComponent.class, "ACSN_SearchOutgoingT_Top_Component")); // NOI18N
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SearchOutgoingTopComponent.class, "ACSD_SearchOutgoingT_Top_Component")); // NOI18N
    initComponents();
    scp.setupRemoteSearch(SearchExecutor.Mode.REMOTE_OUT, searchInContext);
}
 
Example 51
Project: incubator-netbeans   File: ConvertToARM.java   Source Code and License 5 votes vote down vote up
@NbBundle.Messages("FIX_MergeTryResources=Add to enclosing try-with-resources")
@TriggerPatterns(
    {
        @TriggerPattern(value=PTR_ENC_OUT_NO_TRY),
        @TriggerPattern(value=PTR_ENC_OUT_NO_TRY_FIN),
        @TriggerPattern(value=PTR_ENC_OUT_NO_TRY_EFIN),
        @TriggerPattern(value=PTR_ENC_OUT_TRY),
        @TriggerPattern(value=PTR_ENC_OUT_TRY_FIN),
        @TriggerPattern(value=PTR_ENC_OUT_TRY_EFIN),
        @TriggerPattern(value=PTR_ENC_OUT_TRY_NULL)
    }
)
public static List<ErrorDescription> hint2(HintContext ctx) {
    return hintImpl(ctx, NestingKind.OUT, "FIX_MergeTryResources");
}
 
Example 52
Project: incubator-netbeans   File: RepositoryStep.java   Source Code and License 5 votes vote down vote up
@Override
protected JComponent createComponent() {
    if (repository == null) {         
        repositoryModeMask = repositoryModeMask | Repository.FLAG_URL_EDITABLE | Repository.FLAG_URL_ENABLED | Repository.FLAG_SHOW_HINTS | Repository.FLAG_SHOW_PROXY;
        String title = org.openide.util.NbBundle.getMessage(RepositoryStep.class, "CTL_Repository_Location");       // NOI18N
        repository = new Repository(repositoryModeMask, title); 
        repository.addPropertyChangeListener(this);
        panel = new RepositoryStepPanel();            
        panel.repositoryPanel.add(repository.getPanel());
        Dimension size = panel.getPreferredSize();
        panel.setPreferredSize(new Dimension(size.width, size.height + new JLabel("A").getPreferredSize().height + new JButton("A").getPreferredSize().height + 20)); //NOI18N
        valid();
    }                        
    return panel;
}
 
Example 53
Project: incubator-netbeans   File: DependencyPanel.java   Source Code and License 5 votes vote down vote up
@NbBundle.Messages({"TIP_listNode=<html><i>GroupId:</i> <b>{0}</b><br/><i>ArtifactId:</i> <b>{1}</b><br/><i>Version:</i> <b>{2}</b><br/><i>State:</i> <b>{3}</b><br/></html>"})
public ListNode(DependencyNode node, final Lookup tcLookup) {
    super(Children.LEAF, Lookups.fixed(node));
    this.tcLookup = tcLookup;
    this.node = node;
    final Artifact artifact = node.getArtifact();
    setName(artifact.getId());
    setDisplayName(artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension());
    if (node.getDepth() > 1) {
        setIconBaseWithExtension(IconResources.TRANSITIVE_DEPENDENCY_ICON);
    } else {
        setIconBaseWithExtension(IconResources.ICON_DEPENDENCY_JAR);
    }
    setShortDescription(Bundle.TIP_listNode(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), calculateStateTipPart(node)));
}
 
Example 54
Project: incubator-netbeans   File: SOAP12ComponentVisitor.java   Source Code and License 5 votes vote down vote up
private void visit(BindingInput bindingInput) {
    Map<MessagePart, SOAP12MessageBase> partMap =
            new HashMap<MessagePart, SOAP12MessageBase>();
    
    List<SOAP12Header> soapHeaders=
            bindingInput.getExtensibilityElements(SOAP12Header.class);
    for (SOAP12Header header: soapHeaders) {
        header.accept(this);
        ensureUniqueParts(partMap, header);
        Collection<SOAP12HeaderFault> soapHeaderFaults = header.getSOAPHeaderFaults();
        for (SOAP12HeaderFault fault: soapHeaderFaults) {
            fault.accept(this);
            ensureUniqueParts(partMap, fault);
        }
    }
                        
    int numSoapBodies = bindingInput.getExtensibilityElements(SOAP12Body.class).size();
    if(numSoapBodies == 0) {
        results.add(
                new Validator.ResultItem(mValidator,
                Validator.ResultType.ERROR,
                bindingInput,
                NbBundle.getMessage(SOAP12ComponentVisitor.class, "SOAPBodyValidator.Atleast_one_body_Required")));

    } else if (numSoapBodies > 0 && numSoapBodies != 1) {
        results.add(
                new Validator.ResultItem(mValidator,
                Validator.ResultType.ERROR,
                bindingInput,
                NbBundle.getMessage(SOAP12ComponentVisitor.class, "SOAPBodyValidator.Only_one_body_allowed")));
    }
    List<SOAP12Body> soapBodies = bindingInput.getExtensibilityElements(SOAP12Body.class);
    for (SOAP12Body body: soapBodies) {
        body.accept(this);
        ensureUniqueParts(partMap, body, bindingInput);
    }
}
 
Example 55
Project: incubator-netbeans   File: ImportImageWizard.java   Source Code and License 5 votes vote down vote up
private ImportImageWizard(WizardDescriptor.Iterator iterator) {
    super(iterator);
    wizardIterator = iterator;

    putProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE); // NOI18N
    putProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE); // NOI18N
    putProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE); // NOI18N

    setTitle(NbBundle.getMessage(ImportImageWizard.class, "ImportImageWizard.Title")); // NOI18N
    setTitleFormat(new java.text.MessageFormat("{0}")); // NOI18N

    putProperty(WizardDescriptor.PROP_CONTENT_DATA,  // NOI18N
                new String[] { NbBundle.getMessage(ImportImageWizard.class, "ImportImageWizard.Step1"), // NOI18N
                               NbBundle.getMessage(ImportImageWizard.class, "ImportImageWizard.Step2") }); // NOI18N
}
 
Example 56
Project: incubator-netbeans   File: CommitAction.java   Source Code and License 5 votes vote down vote up
@Override
@NbBundle.Messages({
    "# {0} - counted context", "# {1} - current branch", "CTL_CommitPanel.title={0} - {1}"
})
protected void performAction (final File repository, final File[] roots, final VCSContext context) {
    RepositoryInfo info = RepositoryInfo.getInstance(repository);
    info.refresh();
    if (!canCommit(repository, info)) {
        return;
    }
    final GitRepositoryState state = info.getRepositoryState();
    final GitUser user = identifyUser(repository);
    final String mergeCommitMessage = getMergeCommitMessage(repository, state);
    final String title = Bundle.CTL_CommitPanel_title(Utils.getContextDisplayName(context), info.getActiveBranch().getName());
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            
            GitCommitPanel panel = state == GitRepositoryState.MERGING_RESOLVED || state == GitRepositoryState.CHERRY_PICKING_RESOLVED
                    ? GitCommitPanelMerged.create(roots, repository, user, mergeCommitMessage)
                    : GitCommitPanel.create(roots, repository, user, isFromGitView(context));
            VCSCommitTable<GitLocalFileNode> table = panel.getCommitTable();
            boolean ok = panel.open(context, new HelpCtx("org.netbeans.modules.git.ui.commit.CommitAction"), title); //NOI18N

            if (ok) {
                final List<GitLocalFileNode> commitFiles = table.getCommitFiles();

                GitModuleConfig.getDefault().setLastCanceledCommitMessage(""); //NOI18N            
                panel.getParameters().storeCommitMessage();

                final VCSCommitFilter selectedFilter = panel.getSelectedFilter();
                RequestProcessor rp = Git.getInstance().getRequestProcessor(repository);
                GitProgressSupport support = new CommitProgressSupport(panel, commitFiles, selectedFilter, state);
                support.start(rp, repository, org.openide.util.NbBundle.getMessage(CommitAction.class, "LBL_Commit_Progress")); // NOI18N
            } else if (!panel.getParameters().getCommitMessage().isEmpty()) {
                GitModuleConfig.getDefault().setLastCanceledCommitMessage(panel.getParameters().getCommitMessage());
            }
        }
    });
}
 
Example 57
Project: incubator-netbeans   File: JPQLEditorTopComponent.java   Source Code and License 5 votes vote down vote up
private void showSQLError(String errorResourceKey, String queryProblems) {
    if (queryProblems != null) {
        sqlEditorPane.setText(queryProblems);
    } else {
        //use default error message
        sqlEditorPane.setText(
                NbBundle.getMessage(JPQLEditorTopComponent.class, errorResourceKey));
    }
    //
    switchToSQLView();
}
 
Example 58
Project: incubator-netbeans   File: MavenGroupPanel.java   Source Code and License 5 votes vote down vote up
/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    lblExternalVersion = new javax.swing.JLabel();
    lblCommandLine = new javax.swing.JLabel();
    comMavenHome = new javax.swing.JComboBox();

    org.openide.awt.Mnemonics.setLocalizedText(lblCommandLine, org.openide.util.NbBundle.getMessage(MavenGroupPanel.class, "MavenGroupPanel.lblCommandLine.text")); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(lblCommandLine)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(lblExternalVersion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(comMavenHome, 0, 325, Short.MAX_VALUE)))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(lblCommandLine)
                .addComponent(comMavenHome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(lblExternalVersion, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(0, 147, Short.MAX_VALUE))
    );
}
 
Example 59
Project: incubator-netbeans   File: PropertyAction.java   Source Code and License 5 votes vote down vote up
private Object[] buttons() {
    ResourceBundle bundle = NbBundle.getBundle(PropertyAction.class);
    JButton okButton = new JButton(); 
    Mnemonics.setLocalizedText(okButton, bundle.getString("CTL_OK")); // NOI18N
    okButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CTL_OK")); // NOI18N
    okButton.setActionCommand(OK_COMMAND);
    JButton cancelButton = new JButton();
    Mnemonics.setLocalizedText(cancelButton, bundle.getString("CTL_Cancel")); // NOI18N
    cancelButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CTL_Cancel")); // NOI18N
    cancelButton.setActionCommand(CANCEL_COMMAND);
    if (property.isDefaultValue()) {
        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
            return new Object[] { cancelButton, okButton };
        } else {
            return new Object[] {okButton, cancelButton};
        }
    } else {
        JButton restoreButton = new JButton();
        Mnemonics.setLocalizedText(restoreButton, bundle.getString("CTL_RestoreDefault")); // NOI18N
        restoreButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CTL_RestoreDefault")); // NOI18N
        restoreButton.setActionCommand(RESTORE_COMMAND);
        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
            return new Object[] { restoreButton, cancelButton, okButton };
        } else {
            return new Object[] {okButton, restoreButton, cancelButton};
        }
    }
}
 
Example 60
Project: incubator-netbeans   File: JavaActionProvider.java   Source Code and License 4 votes vote down vote up
@NbBundle.Messages({
    "ACTION_run=Run Project",
    "ACTION_run.single=Run File",
    "ACTION_run.single.method=Run File",
    "ACTION_debug=Debug Project",
    "ACTION_debug.single=Debug File",
    "ACTION_debug.single.method=Debug File",
    "ACTION_debug.stepinto=Debug Project",
    "ACTION_debug.fix=Apply Code Changes",
    "ACTION_debug.test.single=Debug Test",
    "ACTION_profile=Profile Project",
    "ACTION_profile.single=Profile File",
    "ACTION_profile.test.single=Profile Test",
    "ACTION_rebuild=Rebuild Project",
    "ACTION_build=Build Project",
    "ACTION_clean=Clean Project",
    "ACTION_compile.single=Compile File",
    "ACTION_javadoc=Generate JavaDoc",
    "ACTION_test=Test Project",
    "ACTION_test.single=Test File"
})
private static String getCommandDisplayName(String command) throws MissingResourceException {
    if (command.equals("run")) {
        return Bundle.ACTION_run();
    } else if (command.equals("run.single")) {
        return Bundle.ACTION_run_single();
    } else if (command.equals("run.single.method")) {
        return Bundle.ACTION_run_single_method();
    } else if (command.equals("debug")) {
        return Bundle.ACTION_debug();
    } else if (command.equals("debug.single")) {
        return Bundle.ACTION_debug_single();
    } else if (command.equals("debug.single.method")) {
        return Bundle.ACTION_debug_single_method();
    } else if (command.equals("debug.stepinto")) {
        return Bundle.ACTION_debug_stepinto();
    } else if (command.equals("debug.fix")) {
        return Bundle.ACTION_debug_fix();
    } else if (command.equals("debug.test.single")) {
        return Bundle.ACTION_debug_test_single();
    } else if (command.equals("profile")) {
        return Bundle.ACTION_profile();
    } else if (command.equals("profile.single")) {
        return Bundle.ACTION_profile_single();
    } else if (command.equals("profile.test.single")) {
        return Bundle.ACTION_profile_test_single();
    } else if (command.equals("rebuild")) {
        return Bundle.ACTION_rebuild();
    } else if (command.equals("build")) {
        return Bundle.ACTION_build();
    } else if (command.equals("clean")) {
        return Bundle.ACTION_clean();
    } else if (command.equals("compile.single")) {
        return Bundle.ACTION_compile_single();
    } else if (command.equals("javadoc")) {
        return Bundle.ACTION_javadoc();
    } else if (command.equals("test")) {
        return Bundle.ACTION_test();
    } else if (command.equals("test.single")) {
        return Bundle.ACTION_test_single();
    } else {
        return command;
    }
}