org.openide.ErrorManager Java Examples

The following examples show how to use org.openide.ErrorManager. 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: DataSourceWizard.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Set instantiate(){
    try{
        if(this.holder.hasCPHelper()){
            String poolName = this.cphelper.getData().getString(__Name);
            this.helper.getData().setString(__PoolName, poolName);
            this.cphelper.getData().setTargetFile(poolName);
            this.cphelper.getData().setTargetFileObject(this.helper.getData().getTargetFileObject());
            ResourceUtils.saveJDBCResourceDatatoXml(this.helper.getData(), this.cphelper.getData(),Util.getBaseName(project));
        }else{
            ResourceUtils.saveJDBCResourceDatatoXml(this.helper.getData(), null,Util.getBaseName(project));
        }    
    }catch (Exception ex){
                            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,
                                    ex);
    }
    return java.util.Collections.EMPTY_SET;
}
 
Example #2
Source File: SuiteSubprojectProviderImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Set<NbModuleProject> loadProjects() {
    Set<NbModuleProject> newProjects = new HashSet<NbModuleProject>();
    String modules = eval.getProperty("modules"); // NOI18N
    if (modules != null) {
        for (String piece : PropertyUtils.tokenizePath(modules)) {
            FileObject dir = helper.resolveFileObject(piece);
            if (dir != null) {
                try {
                    Project subp = ProjectManager.getDefault().findProject(dir);
                    if (subp != null && subp instanceof NbModuleProject) {
                        newProjects.add((NbModuleProject) subp);
                    }
                } catch (IOException e) {
                    Util.err.notify(ErrorManager.INFORMATIONAL, e);
                }
            }
        }
    }
    return Collections.unmodifiableSet(newProjects);
}
 
Example #3
Source File: OperationEditorDrop.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public boolean handleTransfer(JTextComponent targetComponent) {
    Object mimeType = targetComponent.getDocument().getProperty("mimeType"); //NOI18N
    if (mimeType!=null && ("text/x-java".equals(mimeType) || "text/x-jsp".equals(mimeType) )) { //NOI18N
        
        try {
            Node clientNode = operationNode.getParentNode().getParentNode().getParentNode();
            FileObject srcRoot = clientNode.getLookup().lookup(FileObject.class);
            Project clientProject = FileOwnerQuery.getOwner(srcRoot);
            FileObject targetFo = NbEditorUtilities.getFileObject(targetComponent.getDocument());
            if (JaxWsUtils.addProjectReference(clientProject, targetFo)) {
                JaxWsCodeGenerator.insertMethod(targetComponent.getDocument(), targetComponent.getCaret().getDot(), operationNode);

                // logging usage of action
                Object[] params = new Object[2];
                params[0] = LogUtils.WS_STACK_JAXWS;
                params[1] = "DRAG & DROP WS OPERATION"; // NOI18N
                LogUtils.logWsAction(params);
                
                return true;
            }
        } catch (Exception ex) {
            ErrorManager.getDefault().log(ex.getLocalizedMessage());
        }
    }
    return false;
}
 
Example #4
Source File: BasicConfVisualPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean cnbIsAlreadyInSuite(String suiteDir, String cnb) {
    FileObject suiteDirFO = FileUtil.toFileObject(new File(suiteDir));
    try {
        Project suite = ProjectManager.getDefault().findProject(suiteDirFO);
        if (suite == null) { // #180644
            return false;
        }
        for (Project p : SuiteUtils.getSubProjects(suite)) {
            if (ProjectUtils.getInformation(p).getName().equals(cnb)) {
                return true;
            }
        }
    } catch (IOException e) {
        Util.err.notify(ErrorManager.INFORMATIONAL, e);
    }
    return false;
}
 
Example #5
Source File: ParametersPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Implementation of ProgressListener.step method. Increments progress bar
 * value by 1.
 *
 * @param event Event object.
 */
@Override
public void step(final ProgressEvent event) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                if (progressHandle == null) {
                    return;
                }

                if (isIndeterminate && event.getCount() > 0) {
                    progressHandle.switchToDeterminate(event.getCount());
                    isIndeterminate = false;
                } else {
                    progressHandle.progress(isIndeterminate ? -2 : event.getCount());
                }
            } catch (Throwable e) {
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
            }
        }
    });
}
 
Example #6
Source File: EditorContextImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Shows source with given url on given line number.
 *
 * @param url a url of source to be shown
 * @param lineNumber a number of line to be shown
 * @param timeStamp a time stamp to be used
 */
public boolean showSource (String url, int lineNumber, int column, int length, Object timeStamp) {
    Line l = LineTranslations.getTranslations().getLine (url, lineNumber, timeStamp); // false = use original ln
    if (l == null) {
        ErrorManager.getDefault().log(ErrorManager.WARNING,
                "Show Source: Have no line for URL = "+url+", line number = "+lineNumber);
        return false;
    }
    if ("true".equalsIgnoreCase(fronting)) {
        l.show (ShowOpenType.OPEN, ShowVisibilityType.FRONT, column); //FIX 47825
    } else {
        l.show (ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
    }
    addPositionToJumpList(url, l, column);
    return true;
}
 
Example #7
Source File: DocumentParseSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void propertyChange(final PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(EditorCookie.Observable.PROP_DOCUMENT)) {
        logger.finer("DPS.pC<PROP_DOCUMENT>");
        //new Exception("got PROP_DOCUMENT on " + DocumentParseSupport.this).printStackTrace();
        try {
            refreshDocument(true);
        } catch (IOException e) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
        }
        // Avoid blocking: because CES fires
        // PROP_DOCUMENT from within a RP task, and we may already be locking
        // the EQ with CES.open or .openDocument.
        getLock().readLater(new Runnable() {
            public void run() {
                invalidate(new DocumentParseSupportDelta(evt));
            }
        });
    }
}
 
Example #8
Source File: NodeFactoryUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Annotates <code>htmlDisplayName</code>, if it is needed, and returns the
 * result; <code>null</code> otherwise.
 */
public static String computeAnnotatedHtmlDisplayName(
        final String htmlDisplayName, final Set<? extends FileObject> files) {

    String result = null;
    if (files != null && files.iterator().hasNext()) {
        try {
            FileObject fo = (FileObject) files.iterator().next();
            StatusDecorator stat = fo.getFileSystem().getDecorator();
            String annotated = stat.annotateNameHtml(htmlDisplayName, files);
            // Make sure the super string was really modified (XXX why?)
            if (annotated != null && !htmlDisplayName.equals(annotated)) {
                result = annotated;
            }
        } catch (FileStateInvalidException e) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
        }
    }
    return result;
}
 
Example #9
Source File: gui.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Generic method to invoke commands available from the menu bar. The actionName passed in is usually
 * the concatentaion of the words making the menu items:
 * e.g. performAction("FileOpen") is equivalent to picking the cascade menu File->Open Model
 * 
 * @param actionName
 */
static public void performAction(String actionName) {
    FileObject myActionsFolder = FileUtil.getConfigFile("Actions/Edit");
    FileObject[] myActionsFolderKids = myActionsFolder.getChildren();
    for (FileObject fileObject : myActionsFolderKids) {
        //Probably want to make this more robust,
        //but the point is that here we find a particular Action:
        if (fileObject.getName().contains(actionName)) {
            try {
                DataObject dob = DataObject.find(fileObject);
                InstanceCookie ic = dob.getLookup().lookup(InstanceCookie.class);
                if (ic != null) {
                    Object instance = ic.instanceCreate();
                    if (instance instanceof CallableSystemAction) {
                        CallableSystemAction a = (CallableSystemAction) instance;
                        a.performAction();
                    }
                }
                break;
            } catch (Exception e) {
                ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
             }
        }
    }

}
 
Example #10
Source File: NbModuleProject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Find marked extra compilation units.
 * Gives a map from the package root to the defining XML element.
 */
public Map<FileObject,Element> getExtraCompilationUnits() {
    if (extraCompilationUnits == null) {
        extraCompilationUnits = new HashMap<FileObject,Element>();
        for (Element ecu : XMLUtil.findSubElements(getPrimaryConfigurationData())) {
            if (ecu.getLocalName().equals("extra-compilation-unit")) { // NOI18N
                Element pkgrootEl = XMLUtil.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
                String pkgrootS = XMLUtil.findText(pkgrootEl);
                String pkgrootEval = evaluator().evaluate(pkgrootS);
                FileObject pkgroot = pkgrootEval != null ? getHelper().resolveFileObject(pkgrootEval) : null;
                if (pkgroot == null) {
                    Util.err.log(ErrorManager.WARNING, "Could not find package-root " + pkgrootEval + " for " + getCodeNameBase());
                    continue;
                }
                extraCompilationUnits.put(pkgroot, ecu);
            }
        }
    }
    return extraCompilationUnits;
}
 
Example #11
Source File: AbstractTestGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 */
private <T extends Element> List<T> resolveHandles(
                                        CompilationInfo compInfo,
                                        List<ElementHandle<T>> handles) {
    if (handles == null) {
        return null;
    }
    if (handles.isEmpty()) {
        return Collections.<T>emptyList();
    }

    List<T> elements = new ArrayList<T>(handles.size());
    for (ElementHandle<T> handle : handles) {
        T element = handle.resolve(compInfo);
        if (element != null) {
            elements.add(element);
        } else {
            ErrorManager.getDefault().log(
                    ErrorManager.WARNING,
                    "JUnit: Could not resolve element handle "      //NOI18N
                            + handle.getBinaryName());
        }
    }
    return elements;
}
 
Example #12
Source File: DiffPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void addEmptyLines(StyledDocument doc, int line, int numLines) {
    int lastOffset = doc.getEndPosition().getOffset();
    int totLines = org.openide.text.NbDocument.findLineNumber(doc, lastOffset);
    //int totLines = doc.getDefaultRootElement().getElementIndex(lastOffset);
    int offset = lastOffset-1;
    if (line <= totLines) {
        offset = org.openide.text.NbDocument.findLineOffset(doc, line);
        //offset = doc.getDefaultRootElement().getElement(line).getStartOffset();
    }
    //int endOffset = doc.getEndPosition().getOffset();
    //if (offset > endOffset) offset = endOffset;
    String insStr = strCharacters('\n', numLines);
    try {
        doc.insertString(offset, insStr, null);
    } catch (BadLocationException e) {
        org.openide.ErrorManager.getDefault().notify(e);
    }
    //initScrollBars();
}
 
Example #13
Source File: ProjectFileExplorer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void addNotify() {
    super.addNotify();
    manager.addPropertyChangeListener(this);
    for (int i = 0; i < projects.length; i++) {
        try {
            Project project = projects[i];
            FileObject projectDir = project.getProjectDirectory();
            DataObject projectDirDObj = DataObject.find(projectDir);
            Node rootNode = projectDirDObj.getNodeDelegate();
            FilterNode node = new FilterNode(rootNode);
            projectNodeList.add(node);

        } catch (DataObjectNotFoundException ex) {
            ErrorManager.getDefault().notify(ex);
        }
    }
    Node[] projectNodes = new Node[projectNodeList.size()];
    projectNodeList.<Node>toArray(projectNodes);
    rootChildren.add(projectNodes);
    manager.setRootContext(explorerClientRoot);

    descriptor.setValid(false);
}
 
Example #14
Source File: PatchAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static boolean performPatch(File patch, File file) throws MissingResourceException {
    List<ContextualPatch.PatchReport> report = null;
    try (ProgressHandle ph = ProgressHandle.createHandle(NbBundle.getMessage(PatchAction.class, "MSG_AplyingPatch", new Object[] {patch.getName()}))) {
        ph.start();
        ContextualPatch cp = ContextualPatch.create(patch, file);
        try {
            report = cp.patch(false, ph);
        } catch (Exception ioex) {
            ErrorManager.getDefault().annotate(ioex, NbBundle.getMessage(PatchAction.class, "EXC_PatchParsingFailed", ioex.getLocalizedMessage()));
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioex);
            ErrorManager.getDefault().notify(ErrorManager.USER, ioex);
            return false;
        }
    }
    return displayPatchReport(report, patch);
}
 
Example #15
Source File: RenameHandlerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void handleRename(Node node, String newName) {
    InstanceContent ic = new InstanceContent();
    ic.add(node);
    ExplorerContext d = new ExplorerContext();
    d.setNewName(newName);
    ic.add(d);
    Lookup l = new AbstractLookup(ic);
    DataObject dob = node.getCookie(DataObject.class);
    Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
    if (Boolean.TRUE.equals(a.getValue("applicable"))) {//NOI18N
        a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
    } else {
        try {
            dob.rename(newName);
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
    }
}
 
Example #16
Source File: JaxWsClientCreator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void createClient() throws IOException {
    
    
    WSStackUtils stackUtils = new WSStackUtils(project);
    final boolean isJsr109Supported = stackUtils.isJsr109Supported();
    //final boolean isJWSDPSupported = isJWSDPSupported();
    
    // Use Progress API to display generator messages.
    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(JaxWsClientCreator.class, "MSG_WizCreateClient")); //NOI18N
    
    task = new Task(new Runnable() {
        public void run() {
            try {
                handle.start();
                generate15Client((isJsr109Supported /*|| isJWSDPSupported*/), handle);
            } catch (IOException exc) {
                //finish progress bar
                handle.finish();
                
                ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, exc);
            }
        }
    });
    RequestProcessor.getDefault().post(task);
}
 
Example #17
Source File: JaxWsClientNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
WsdlModeler getWsdlModeler() {
    if (getLocalWsdl()!=null) {
        WsdlModeler modeler = WsdlModelerFactory.getDefault().getWsdlModeler(wsdlFileObject.toURL());
        if (modeler!=null) {
            String packageName = client.getPackageName();
            if (packageName!=null && client.isPackageNameForceReplace()) {
                // set the package name for the modeler
                modeler.setPackageName(packageName);
            } else {
                modeler.setPackageName(null);
            }
            modeler.setCatalog(getJAXWSClientSupport().getCatalog());
            setBindings(modeler);
            return modeler;
        }
    } else {
        ErrorManager.getDefault().log(ErrorManager.ERROR, NbBundle.getMessage(JaxWsNode.class,"ERR_missingLocalWsdl"));
    }
    return null;
}
 
Example #18
Source File: JaxWsClientCreator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static List<FileObject> getFileObjects(URL[] urls) {
    List<FileObject> result = new ArrayList<FileObject>();
    for (int i = 0; i < urls.length; i++) {
        FileObject sourceRoot = URLMapper.findFileObject(urls[i]);
        if (sourceRoot != null) {
            result.add(sourceRoot);
        } else {
            int severity = ErrorManager.INFORMATIONAL;
            if (ErrorManager.getDefault().isNotifiable(severity)) {
                ErrorManager.getDefault().notify(severity, new IllegalStateException(
                        "No FileObject found for the following URL: " + urls[i])); //NOI18N
            }
        }
    }
    return result;
}
 
Example #19
Source File: JAXBElementTreeNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * This method will use the parameter name of the child to update the value of this element
 * @param inData - the TypeNodeData of the child that called this method.
 */
public void updateValueFromChildren(TypeNodeData inData) {
    
    DefaultMutableTreeNode localPartNode = (DefaultMutableTreeNode) this.getChildAt(0);
    DefaultMutableTreeNode valueNode = (DefaultMutableTreeNode)this.getChildAt(1);
    
    //TypeNodeData localPartData = (TypeNodeData) localPartNode.getUserObject();
    TypeNodeData valueData = (TypeNodeData) valueNode.getUserObject();
    
    Object value = valueData.getTypeValue();
    String localPart = (String)localPartNode.getUserObject();
    if (value != null && localPart != null) {
        Object jaxBElement = ((TypeNodeData) this.getUserObject()).getTypeValue();
        try {
            if (jaxBElement != null) {
                ReflectionHelper.setJAXBElementValue(jaxBElement, value);
            }else {
                jaxBElement = ReflectionHelper.makeJAXBElement(valueData.getTypeClass(), localPart, value, urlClassLoader);
                this.setUserObject(jaxBElement);
            }
        } catch (Exception ex) {
            ErrorManager.getDefault().notify(ex);
        }
    }
}
 
Example #20
Source File: SingleModuleProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
String[] getAllTokens() {
    if (allTokens == null) {
        try {
            SortedSet<String> provTokens = new TreeSet<String>();
            provTokens.addAll(Arrays.asList(IDE_TOKENS));
            for (ModuleEntry me : getModuleList().getAllEntries()) {
                provTokens.addAll(Arrays.asList(me.getProvidedTokens()));
            }
            String[] result = new String[provTokens.size()];
            return provTokens.toArray(result);
        } catch (IOException e) {
            allTokens = new String[0];
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
        }
    }
    return allTokens;
}
 
Example #21
Source File: ProfilingPointsManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public RuntimeProfilingPoint[] createCodeProfilingConfiguration(Lookup.Provider project, ProfilingSettings profilingSettings) {
    
    checkProfilingPoints(); // NOTE: Probably not neccessary but we need to be sure here
    
    nextUniqueRPPIdentificator = 0;

    List<RuntimeProfilingPoint> runtimeProfilingPoints = new ArrayList();
    List<ProfilingPoint> compatibleProfilingPoints = getCompatibleProfilingPoints(project, profilingSettings, false);

    for (ProfilingPoint compatibleProfilingPoint : compatibleProfilingPoints) {
        if (compatibleProfilingPoint.isEnabled() && compatibleProfilingPoint instanceof CodeProfilingPoint) {
            CodeProfilingPoint compatibleCodeProfilingPoint = (CodeProfilingPoint) compatibleProfilingPoint;
            RuntimeProfilingPoint[] rpps = compatibleCodeProfilingPoint.createRuntimeProfilingPoints();
            
            if (rpps.length == 0) ErrorManager.getDefault().log(ErrorManager.USER, "Cannot resolve RuntimeProfilingPoint(s) for " + compatibleCodeProfilingPoint.getName() + ", check location"); // NOI18N

            for (int i = 0; i < rpps.length; i++) {
                runtimeProfilingPoints.add(rpps[i]);
                activeCodeProfilingPoints.put(rpps[i].getId(),
                                              new RuntimeProfilingPointMapper(compatibleCodeProfilingPoint, i)); // Note that profiled project may be closed but it's active Profiling Points are still referenced by this map => will be processed
            }
        }
    }

    return runtimeProfilingPoints.toArray(new RuntimeProfilingPoint[0]);
}
 
Example #22
Source File: AbstractTestGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 */
private <T extends Element> List<T> resolveHandles(
                                        CompilationInfo compInfo,
                                        List<ElementHandle<T>> handles) {
    if (handles == null) {
        return null;
    }
    if (handles.isEmpty()) {
        return Collections.<T>emptyList();
    }

    List<T> elements = new ArrayList<T>(handles.size());
    for (ElementHandle<T> handle : handles) {
        T element = handle.resolve(compInfo);
        if (element != null) {
            elements.add(element);
        } else {
            ErrorManager.getDefault().log(
                    ErrorManager.WARNING,
                    "TestNG: Could not resolve element handle "      //NOI18N
                            + handle.getBinaryName());
        }
    }
    return elements;
}
 
Example #23
Source File: AbstractNBTask.java    From jeddict with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    if (progressContribs != null && progressContribs.length > 0) {
        progressHandle = AggregateProgressFactory.createHandle(
                getTaskName(), progressContribs, this, null);
    }

    try {
        beginTask();
    } catch (Exception e) {
        fail();
        ErrorManager.getDefault().notify(e);
    } finally {
        finishTask();
        progressHandle.finish();
    }

}
 
Example #24
Source File: WebPagesNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public String getHtmlDisplayName() {
    if (!isTopLevelNode) {
        return getOriginal().getHtmlDisplayName();
    }
     try {
        String s = LBL_Web_Pages();
        String result = file.getFileSystem().getDecorator().annotateNameHtml (
            s, Collections.singleton(file));

        //Make sure the super string was really modified
        if (result != null && !s.equals(result)) {
            return result;
        }
     } catch (FileStateInvalidException e) {
         ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
     }
     return super.getHtmlDisplayName();
}
 
Example #25
Source File: JvmstatModelImpl.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public String findByName(String name) {
    String value = valueCache.get(name);
    if (value != null) return value;
    
    try {
        Monitor mon = monitoredVm.findByName(name);
        if (mon != null) {
            value = mon.getValue().toString();
            if (Utils.getVariability(mon).toString().equals(Variability_CONSTANT)) {
                valueCache.put(name,value);
            }
        }
        return value;
    } catch (MonitorException ex) {
        ErrorManager.getDefault().notify(ErrorManager.WARNING,ex);
    }
    return null;
}
 
Example #26
Source File: CamelCaseOperations.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static void replaceText(JTextComponent textComponent, final int offset, final int length, final String text) {
    if (!textComponent.isEditable()) {
        return;
    }
    final Document document = textComponent.getDocument();
    Runnable r = new Runnable() {
        public @Override void run() {
            try {
                if (length > 0) {
                    document.remove(offset, length);
                }
                document.insertString(offset, text, null);
            } catch (BadLocationException ble) {
                ErrorManager.getDefault().notify(ble);
            }
        }
    };
    if (document instanceof BaseDocument) {
        ((BaseDocument)document).runAtomic(r);
    } else {
        r.run();
    }
}
 
Example #27
Source File: WhereUsedActionPlugin.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected Problem processFile(final Project project, final int level, final File projectFolder, final FileObject fileObject) {
  final MMapURI fileAsURI = MMapURI.makeFromFilePath(projectFolder, fileObject.getPath(), null);

  for (final FileObject mmap : allMapsInProject(project)) {
    if (isCanceled()) {
      break;
    }
    try {
      if (doesMindMapContainFileLink(project, mmap, fileAsURI)) {
          addElement(new WhereUsedElement(new MindMapLink(mmap), projectFolder, MMapURI.makeFromFilePath(projectFolder, fileObject.getPath(), null)));
      }
    }
    catch (Exception ex) {
      ErrorManager.getDefault().notify(ex);
      return new Problem(true, BUNDLE.getString("Refactoring.CantProcessMindMap"));
    }
  }

  return null;
}
 
Example #28
Source File: CopySupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Transferable paste() throws IOException {
    if (java.awt.EventQueue.isDispatchThread()) {
        return doPaste();
    }
    else { // reinvoke synchronously in AWT thread
        try {
            return Mutex.EVENT.readAccess(this);
        }
        catch (MutexException ex) {
            Exception e = ex.getException();
            if (e instanceof IOException)
                throw (IOException) e;
            else { // should not happen, ignore
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
                return transferable;
            }
        }
    }
}
 
Example #29
Source File: NbErrorManagerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** @see "#15611" */
public void testNestedThrowables() throws Exception {
    NullPointerException npe = new NullPointerException("unloc msg");
    ClassNotFoundException cnfe = new ClassNotFoundException("other msg", npe);
    err.notify(ErrorManager.INFORMATIONAL, cnfe);
    String s = readLog();
    assertTrue(s.indexOf("java.lang.NullPointerException: unloc msg") != -1);
    assertTrue(s.indexOf("java.lang.ClassNotFoundException") != -1);
    npe = new NullPointerException("msg1");
    IOException ioe = new IOException("msg2");
    ioe.initCause(npe); // only works in right order with initCause, not ErrorManager.annotate
    InvocationTargetException ite = new InvocationTargetException(ioe, "msg3");
    IllegalStateException ise = new IllegalStateException("msg4");
    ise.initCause(ite);
    err.notify(ErrorManager.INFORMATIONAL, ise);
    s = readLog();
    assertTrue(s, s.indexOf("java.lang.NullPointerException: msg1") != -1);
    assertTrue(s, s.indexOf("java.io.IOException: msg2") != -1);
    assertTrue(s.indexOf("msg3") != -1);
    assertTrue(s, s.indexOf("java.lang.IllegalStateException: msg4") != -1);
    // #91541: check that stack traces are printed in a pleasant order.
    assertTrue(s, s.indexOf("java.lang.NullPointerException: msg1") < s.indexOf("java.io.IOException: msg2"));
    assertTrue(s, s.indexOf("java.io.IOException: msg2") < s.indexOf("msg3"));
    assertTrue(s, s.indexOf("msg3") < s.indexOf("java.lang.IllegalStateException: msg4"));
}
 
Example #30
Source File: JSMinifyClipboard.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
protected final void jsMinify(final Node[] activatedNodes) {
    final EditorCookie editorCookie
            = Utilities.actionsGlobalContext().lookup(EditorCookie.class);

    for (final JEditorPane pane : editorCookie.getOpenedPanes()) {
        if (pane.isShowing()
                && pane.getSelectionEnd() > pane.getSelectionStart()) {
            try {
                StringSelection content = new StringSelection(selectedSourceAsMinify(pane));
                Toolkit.getDefaultToolkit().getSystemClipboard().
                        setContents(content, content);
                return;
            } catch (final HeadlessException e) {
                ErrorManager.getDefault().notify(e);
            }
        }
    }
}