org.openide.util.Exceptions Java Examples

The following examples show how to use org.openide.util.Exceptions. 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: TaskCache.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NonNull
private static Properties loadRelocation(
        @NonNull final File cacheRoot) {
    final Properties result = new Properties();
    final  File relocationFile = new File (cacheRoot, RELOCATION_FILE);
    if (relocationFile.canRead()) {
        try {
            final FileInputStream in = new FileInputStream(relocationFile);
            try {
                result.load(in);
           } finally {
                in.close();
           }
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
    return result;
}
 
Example #2
Source File: OverrideEditorActions.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean delegates(JTextComponent target, PositionRegion region, int pos) {
    if (super.delegates(target, region, pos)) {
        return true;
    }
    LineDocument ld = LineDocumentUtils.as(target.getDocument(), LineDocument.class);
    if (ld == null) {
        return true;
    }
    try {
        int end = LineDocumentUtils.getLineEnd(ld, region.getStartOffset());
        // delegate for all but the first line
        return pos > end;
    } catch (BadLocationException ex) {
        Exceptions.printStackTrace(ex);
        return true;
    }
}
 
Example #3
Source File: ManifestHyperlinkProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private EditCookie getEditorCookie(Document doc, int offset) {
    TokenHierarchy<?> th = TokenHierarchy.get(doc);
    
    TokenSequence ts = th.tokenSequence(Language.find("text/x-manifest"));
    if (ts == null)
        return null;
    
    ts.move(offset);
    if (!ts.moveNext())
        return null;
    
    Token t = ts.token();
    FileObject fo = getFileObject(doc);
    String name = t.toString();
    
    FileObject props = findFile(fo, name);
    if (props != null) {
        try {
            DataObject dobj = DataObject.find(props);
            return  dobj.getLookup().lookup(EditCookie.class);
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    return null;
}
 
Example #4
Source File: ConfigurationModifier.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Replace the content of the document by the graph.
 */
private void replaceDocument(final StyledDocument doc, T graph) {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        graph.write(out);
    } catch (IOException ioe) {
        Exceptions.printStackTrace(ioe);
    }
    NbDocument.runAtomic(doc, new Runnable() {
        public void run() {
            try {
                doc.remove(0, doc.getLength());
                doc.insertString(0, out.toString(), null);
            } catch (BadLocationException ble) {
                Exceptions.printStackTrace(ble);
            }
        }
    });
}
 
Example #5
Source File: SceneApplication.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void handleError(String msg, Throwable t) {
    progressHandle.finish();
    if (msg == null) {
        return;
    }
    if (!started) {
        SceneViewerTopComponent.showOpenGLError(msg);
        Exceptions.printStackTrace(t);
    } else {
        if (lastError != null && !lastError.equals(msg)) {
            Message mesg = new NotifyDescriptor.Message(
                    "Error in scene!\n"
                    + "(" + t + ")",
                    NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(mesg);
            Exceptions.printStackTrace(t);
            lastError = msg;
        }
    }
}
 
Example #6
Source File: BridgeImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public String[] getEnumeratedValues(Class<?> c) {
    if (EnumeratedAttribute.class.isAssignableFrom(c)) {
        try {
            return ((EnumeratedAttribute)c.newInstance()).getValues();
        } catch (Exception e) {
            AntModule.err.notify(ErrorManager.INFORMATIONAL, e);
        }
    } else if (Enum.class.isAssignableFrom(c)) { // Ant 1.7.0 (#41058)
        try {
            Enum<?>[] vals = (Enum<?>[]) c.getMethod("values").invoke(null);
            String[] names = new String[vals.length];
            for (int i = 0; i < vals.length; i++) {
                names[i] = vals[i].name();
            }
            return names;
        } catch (Exception x) {
            Exceptions.printStackTrace(x);
        }
    }
    return null;
}
 
Example #7
Source File: SendJMSMessageCodeGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public List<? extends CodeGenerator> create(Lookup context) {
    ArrayList<CodeGenerator> ret = new ArrayList<CodeGenerator>();
    JTextComponent component = context.lookup(JTextComponent.class);
    CompilationController controller = context.lookup(CompilationController.class);
    TreePath path = context.lookup(TreePath.class);
    path = path != null ? SendEmailCodeGenerator.getPathElementOfKind(TreeUtilities.CLASS_TREE_KINDS, path) : null;
    if (component == null || controller == null || path == null)
        return ret;
    try {
        controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
        Element elem = controller.getTrees().getElement(path);
        if (elem != null) {
            SendJMSMessageCodeGenerator gen = createSendJMSMessageAction(component, controller, elem);
            if (gen != null)
                ret.add(gen);
        }
    } catch (IOException ioe) {
        Exceptions.printStackTrace(ioe);
    }
    return ret;
}
 
Example #8
Source File: CallHierarchyTasks.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void updateCleaner(final RequestProcessor.Task task) {
    if(CLEAN_TASK != null) {
        CLEAN_TASK.cancel();
    }
    CLEAN_TASK = new CleanTask(task);
    final CancellableTask cleanTask = CLEAN_TASK;
    RP.post(new Runnable() {

        @Override
        public void run() {
            try {
                cleanTask.run(null);
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
}
 
Example #9
Source File: ImportantFilesNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public NodeList createNodes(Project project) {

//        this.proj = project;

            //If our item is in the project's lookup,
            //return a new node in the node list:
            ImportantFilesLookupItem item = project.getLookup().lookup(ImportantFilesLookupItem.class);
            if (item != null) {
                try {
                    ImportantFilesNode nd = new ImportantFilesNode(project);
                    return NodeFactorySupport.fixedNodeList(nd);
                } catch (DataObjectNotFoundException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }

            //If our item isn't in the lookup,
            //then return an empty list of nodes:
            return NodeFactorySupport.fixedNodeList();

        }
 
Example #10
Source File: NbRemoteNativeProcess.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected int waitResultImpl() throws InterruptedException {
    if (streams == null || streams.channel == null) {
        return -1;
    }

    try {
        while (streams.channel.isConnected()) {
            Thread.sleep(200);
        }
        
        finishing();

        return streams.channel.getExitStatus();
    } finally {
        if (streams != null) {
            try {
                ConnectionManagerAccessor.getDefault().closeAndReleaseChannel(getExecutionEnvironment(), streams.channel);
            } catch (JSchException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
}
 
Example #11
Source File: Server.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public int acceptClient() {
    ensureStarted();
    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Socket client = socket.accept();
                MessageDispatcherImpl dispatcher = new MessageDispatcherImpl();
                Transport transport = new Transport(client, dispatcher);
                WebKitDebugging webKit = Factory.createWebKitDebugging(transport);
                Lookup context = Lookups.fixed(transport, webKit, dispatcher);
                PageInspector.getDefault().inspectPage(context);
            } catch (IOException ioex) {
                Exceptions.printStackTrace(ioex);
            }
        }
    });
    t.start();
    return socket.getLocalPort();
}
 
Example #12
Source File: ActionFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent evt, final JTextComponent target) {
    Document doc = target.getDocument();
    doc.render(new Runnable() {
        @Override
        public void run() {
            FoldHierarchy hierarchy = FoldHierarchy.get(target);
            int dot = target.getCaret().getDot();
            hierarchy.lock();
            try {
                try {
                    int rowStart = javax.swing.text.Utilities.getRowStart(target, dot);
                    int rowEnd = javax.swing.text.Utilities.getRowEnd(target, dot);
                    Fold fold = getLineFold(hierarchy, dot, rowStart, rowEnd);
                    if (fold != null) {
                        hierarchy.expand(fold);
                    }
                } catch (BadLocationException ble) {
                    Exceptions.printStackTrace(ble);
                }
            } finally {
                hierarchy.unlock();
            }
        }
    });
}
 
Example #13
Source File: ProjectHelper.java    From jeddict with Apache License 2.0 6 votes vote down vote up
/**
 * when ever there is need for non-java files creation or lookup,
 * use this method to get the right location for all projects. 
 * Eg. maven places resources not next to the java files.
 * Please note that the method should not be used for 
 * checking file existence. There can be multiple resource roots, the returned one
 * is just the first in line. Use <code>getResource</code> instead in that case.
 * @param project
 * @return 
 */ 
public static FileObject getResourceDirectory(Project project) {
    Sources srcs = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES);
    if (sourceGroups != null && sourceGroups.length > 0) {
        return sourceGroups[0].getRootFolder();
    }
    try {
        return project.getProjectDirectory()
                .getFileObject("src/main")
                .createFolder("resources");
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
        return null;
    }
}
 
Example #14
Source File: RsrcLoader.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public TemplateModel getSharedVariable(String string) {
    Object value = map.getAttribute(string);
    if (value == null) {
        value = engineScope.get(string);
    }
    if (value == null && fo != null) {
        value = fo.getAttribute(string);
    }
    try {
        return getObjectWrapper().wrap(value);
    } catch (TemplateModelException ex) {
        Exceptions.printStackTrace(ex);
        return null;
    }
}
 
Example #15
Source File: CreateTerrainWizardPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void storeSettings(Object settings) {

        CreateTerrainVisualPanel2 comp = (CreateTerrainVisualPanel2) getComponent();

        if ("Flat".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) {
            heightmap = new FlatHeightmap(terrainTotalSize);
        }
        else if ("Image Based".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) {
            
            BufferedImage bi = null;
            try {
                bi = ImageIO.read(new File(comp.getImageBrowseTextField().getText()));
            } catch (IOException e) {
                e.printStackTrace();
            }
                ImageBasedHeightMap ibhm = new ImageBasedHeightMap(bi, 1f);

            heightmap = ibhm;
        }
        else if ("Hill".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) {
            int iterations = new Integer(comp.getHillIterationsTextField().getText());
            byte flattening = new Byte(comp.getHillFlatteningTextField().getText());
            float min = new Float(comp.getHillMinRadiusTextField().getText());
            float max = new Float(comp.getHillMaxRadiusTextField().getText());
            try {
                heightmap = new HillHeightMap(terrainTotalSize, iterations, min, max, flattening);
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }

        WizardDescriptor wiz = (WizardDescriptor) settings;
        wiz.putProperty("abstractHeightMap", heightmap);
    }
 
Example #16
Source File: JavadocHint.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Hint(id = "error-in-javadoc", category = "JavaDoc", description = "#DESC_ERROR_IN_JAVADOC_HINT", displayName = "#DN_ERROR_IN_JAVADOC_HINT", hintKind = Hint.Kind.INSPECTION, severity = Severity.WARNING, customizerProvider = JavadocHint.CustomizerProviderImplError.class)
@TriggerTreeKind({Kind.METHOD, Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.VARIABLE})
public static List<ErrorDescription> errorHint(final HintContext ctx) {
    Preferences pref = ctx.getPreferences();
    boolean correctJavadocForNonPublic = pref.getBoolean(AVAILABILITY_KEY + false, false);

    CompilationInfo javac = ctx.getInfo();
    Boolean publiclyAccessible = AccessibilityQuery.isPubliclyAccessible(javac.getFileObject().getParent());
    boolean isPubliclyA11e = publiclyAccessible == null ? true : publiclyAccessible;

    if (!isPubliclyA11e && !correctJavadocForNonPublic) {
        return null;
    }

    if (javac.getElements().getTypeElement("java.lang.Object") == null) { // NOI18N
        // broken java platform
        return Collections.<ErrorDescription>emptyList();
    }

    TreePath path = ctx.getPath();
    {
        Document doc = null;
        try {
            doc = javac.getDocument();
        } catch (IOException e) {
            Exceptions.printStackTrace(e);
        }
        if (doc != null && isGuarded(path.getLeaf(), javac, doc)) {
            return null;
        }
    }
    
    Access access = Access.resolve(pref.get(SCOPE_KEY, SCOPE_DEFAULT));
    Analyzer a = new Analyzer(javac, path, access, ctx);
    return a.analyze();
}
 
Example #17
Source File: TooltipWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void computeBounds (JTextPane textPane) {
    Rectangle tpBounds = textPane.getBounds();
    TextUI tui = textPane.getUI();
    this.bounds = new Rectangle();
    try {
        Rectangle startr = tui.modelToView(textPane, docstart, Position.Bias.Forward).getBounds();
        Rectangle endr = tui.modelToView(textPane, docend, Position.Bias.Backward).getBounds();
        this.bounds = new Rectangle(tpBounds.x + startr.x, startr.y, endr.x - startr.x, startr.height);
    } catch (BadLocationException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example #18
Source File: ReloadTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void markModified() throws IOException {
    if (cannotBeModified != null) {
        final String notify = cannotBeModified;
        IOException e = new IOException () {
            public @Override String getLocalizedMessage() {
                return notify;
            }
        };
        Exceptions.attachLocalizedMessage(e, cannotBeModified);
        throw e;
    }
    
    modified = true;
}
 
Example #19
Source File: Page.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setName(String s) {

    String oldDisplayName = getDisplayName();
    try {
        if (!pc.isPageInAnyFacesConfig(oldDisplayName)) {
            original.setName(s);
        } else {
            renaming = true;
            original.setName(s);
            String newDisplayName = original.getDisplayName();
            if (isDataNode()) {
                newDisplayName = getFolderDisplayName(pc.getWebFolder(), ((DataNode) original).getDataObject().getPrimaryFile());
            }
            pc.saveLocation(oldDisplayName, newDisplayName);
            renaming = false;
            pc.renamePageInModel(oldDisplayName, newDisplayName);
        }
    } catch (IllegalArgumentException iae) {

        // determine if "printStackTrace"  and  "new annotation" of this exception is needed
        boolean needToAnnotate = Exceptions.findLocalizedMessage(iae) == null;

        // annotate new localized message only if there is no localized message yet
        if (needToAnnotate) {
            Exceptions.attachLocalizedMessage(iae, NbBundle.getMessage(Page.class, "MSG_BadFormat", oldDisplayName, s));
        }

        Exceptions.printStackTrace(iae);
    }
}
 
Example #20
Source File: VisualGraphTopComponent.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canClose() {
    if (savable.isModified()) {
        final String message = String.format("Graph %s is modified. Save?", getDisplayName());
        final Object[] options = new Object[]{
            SAVE, DISCARD, CANCEL
        };
        final NotifyDescriptor d = new NotifyDescriptor(message, "Close", NotifyDescriptor.YES_NO_CANCEL_OPTION, NotifyDescriptor.QUESTION_MESSAGE, options, "Save");
        final Object o = DialogDisplayer.getDefault().notify(d);

        if (o.equals(DISCARD)) {
            savable.setModified(false);
        } else if (o.equals(SAVE)){
            try {
                savable.handleSave();
                if (!savable.isSaved()){
                    return false;
                }
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        } else {
            return false;
        }
    }

    return true;
}
 
Example #21
Source File: CloneableEditorDoubleLoadingTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void markModified() throws IOException {
    if (cannotBeModified != null) {
        final String notify = cannotBeModified;
        IOException e = new IOException () {
            @Override
            public String getLocalizedMessage () {
                return notify;
            }
        };
        Exceptions.attachLocalizedMessage(e, cannotBeModified);
        throw e;
    }
    
    modified = true;
}
 
Example #22
Source File: WebBrowsersOptionsModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void findPropertyPanel() {
    
    try {
        
        InstanceCookie cookie = browserSettings.getCookie(InstanceCookie.class);
        PropertyDescriptor[] propDesc = Introspector.getBeanInfo(cookie.instanceClass()).getPropertyDescriptors();
        
        PropertyDescriptor fallbackProp = null;
        
        for (PropertyDescriptor pd : propDesc ) {
            
            if (fallbackProp == null && !pd.isExpert() && !pd.isHidden()) {
                fallbackProp = pd;
            }
            
            if (pd.isPreferred() && !pd.isExpert() && !pd.isHidden()) {
                propertyPanel = new PropertyPanel(cookie.instanceCreate(), 
                        pd.getName(), PropertyPanel.PREF_CUSTOM_EDITOR);
                propertyPanelID = "PROPERTY_PANEL_" + propertyPanelIDCounter++;
                propertyPanel.setChangeImmediate(false);
                break;
            }
            
        }
        
        if (propertyPanel == null) {
            propertyPanel = new PropertyPanel(cookie.instanceCreate(),
                    fallbackProp.getName(), PropertyPanel.PREF_CUSTOM_EDITOR);
            propertyPanelID = "PROPERTY_PANEL_" + propertyPanelIDCounter++;
        }
        
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
    
}
 
Example #23
Source File: FeatureManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static synchronized Lookup featureTypesLookup() {
    if (featureTypesLookup != null) {
        return featureTypesLookup;
    }

    String clusters = System.getProperty("netbeans.dirs");
    if (clusters == null) {
        featureTypesLookup = Lookup.EMPTY;
    } else {
        InstanceContent ic = new InstanceContent();
        AbstractLookup l = new AbstractLookup(ic);
        String[] paths = clusters.split(File.pathSeparator);
        for (String c : paths) {
            int last = c.lastIndexOf(File.separatorChar);
            String clusterName = c.substring(last + 1).replaceFirst("[0-9\\.]*$", "");
            String basename = "/org/netbeans/modules/ide/ergonomics/" + clusterName;
            String layerName = basename + "/layer.xml";
            String bundleName = basename + "/Bundle.properties";
            URL layer = FeatureManager.class.getResource(layerName);
            URL bundle = FeatureManager.class.getResource(bundleName);
            if (layer != null && bundle != null) {
                FeatureInfo info;
                try {
                    info = FeatureInfo.create(clusterName, layer, bundle);
                    ic.add(info);
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
        featureTypesLookup = l;
    }
    return featureTypesLookup;
}
 
Example #24
Source File: RepositoryRegistry.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void lockRepositories() {
    try {
        repositorySemaphore.acquire();
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example #25
Source File: FilterTopComponent.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void removeFilter(Filter f) {
    com.sun.hotspot.igv.filter.CustomFilter cf = (com.sun.hotspot.igv.filter.CustomFilter) f;

    sequence.removeFilter(cf);
    try {
        getFileObject(cf).delete();
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }

}
 
Example #26
Source File: CopyDataToExcelFile.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(final ActionEvent e) {
    try {
        if (e.getActionCommand().equals(Bundle.MSG_AllExcel())) {
            processAllRowsToExcel(true);
        } else if (e.getActionCommand().equals(Bundle.MSG_SelectedExcel())) {
            processSelectedRowsToExcel(true);
        }
    } catch (final IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example #27
Source File: EarDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void refreshSourceFolders () {
    ArrayList srcRootList = new ArrayList ();
    
    Project project = FileOwnerQuery.getOwner (getPrimaryFile ());
    if (project != null) {
        Sources sources = ProjectUtils.getSources(project);
        sources.removeChangeListener (this);
        sources.addChangeListener (this);
        SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (int i = 0; i < groups.length; i++) {
            org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(groups[i].getRootFolder());

            if (ejbModule != null && ejbModule.getDeploymentDescriptor() != null) {
                try {
                    FileObject fo = groups[i].getRootFolder();

                    srcRootList.add(groups[i].getRootFolder());
                    FileSystem fs = fo.getFileSystem();

                    fs.removeFileChangeListener(this);
                    fs.addFileChangeListener(this);
                } catch (FileStateInvalidException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }
    srcRoots = (FileObject []) srcRootList.toArray (new FileObject [srcRootList.size ()]);
}
 
Example #28
Source File: SelectProjectPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Loads dependencies outside EQ thread, updates tab state in EQ */
@Override
public void run() {
    Project[] prjs = OpenProjects.getDefault().getOpenProjects();
    final List<Node> toRet = new ArrayList<>();
    for (Project p : prjs) {
        if (p == curProject) {
            continue;
        }
        NbMavenProject mav = p.getLookup().lookup(NbMavenProject.class);
        if (mav != null) {
            LogicalViewProvider lvp = p.getLookup().lookup(LogicalViewProvider.class);
            toRet.add(lvp.createLogicalView());
        }
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Children.Array ch = new Children.Array();
            ch.add(toRet.toArray(new Node[0]));
            Node root = new AbstractNode(ch);
            getExplorerManager().setRootContext(root);
            if (ch.getNodesCount() > 0) {
                Node first = ch.getNodeAt(0);
                try {
                    getExplorerManager().setSelectedNodes(new Node[]{first});
                } catch (PropertyVetoException ex) {
                    // what to do?
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    });
}
 
Example #29
Source File: AddUseImportSuggestion.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private int getOffset() {
    try {
        return LineDocumentUtils.getLineEnd(doc, getReferenceElement().getOffset());
    } catch (BadLocationException ex) {
        Exceptions.printStackTrace(ex);
    }
    return 0;
}
 
Example #30
Source File: MdbLocationPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "MdbLocationPanel.warn.scanning.in.progress=Scanning in progress, parial results shown..."
})
private MdbLocationPanelVisual(Project project, J2eeModuleProvider provider, Set<MessageDestination> moduleDestinations, Set<MessageDestination> serverDestinations) {
    initComponents();
    projectDestinationsCombo.setModel(new ProjectDestinationsComboModel(projectDestinationsCombo.getEditor()));
    this.project = project;
    this.provider = provider;
    this.moduleDestinations = moduleDestinations;
    this.serverDestinations = serverDestinations;
    isDestinationCreationSupportedByServerPlugin = provider.getConfigSupport().supportsCreateMessageDestination();

    // scanning in progress?
    if (!SourceUtils.isScanInProgress()) {
        scanningLabel.setVisible(false);
    } else {
        ClasspathInfo classPathInfo = MdbLocationPanel.getClassPathInfo(project);
        JavaSource javaSource = JavaSource.create(classPathInfo);
        try {
            javaSource.runWhenScanFinished(new Task<CompilationController>() {
                @Override
                public void run(CompilationController parameter) throws Exception {
                    fire(true);
                }
            }, true);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}