public void actionPerformed(ActionEvent event) { NodeModel selected = Controller.getCurrentController().getSelection().getSelected(); if (selected == null) { return; } else { URI uri = URIUtils.getAbsoluteURI(selected); try { ReadOnlyExceptionWarningHandler warningHandler = new ReadOnlyExceptionWarningHandler(); warningHandler.prepare(); while (warningHandler.retry()) { try { PdfAnnotationImporter importer = new PdfAnnotationImporter(); List<AnnotationModel> annotations = importer.importAnnotations(uri); MonitoringUtils.insertChildNodesFrom(annotations, selected.isLeft(), selected); warningHandler.consume(); } catch (DocumentReadOnlyException e) { if (warningHandler.skip()) { break; } warningHandler.showDialog(URIUtils.getFile(uri)); } } } catch (IOException e) { LogUtils.severe( "ImportAllAnnotationsAction IOException at URI(" + uri + "): ", e); //$NON-NLS-1$ //$NON-NLS-2$ } catch (COSRuntimeException e) { LogUtils.severe( "ImportAllAnnotationsAction COSRuntimeException at URI(" + uri + "): ", e); //$NON-NLS-1$ //$NON-NLS-2$ } } }
private List<NodeModel> getMonitorNodes(NodeModel node) { List<NodeModel> result = new ArrayList<NodeModel>(); if (MonitoringUtils.isMonitoringNode(node)) { result.add(node); } for (NodeModel child : node.getChildren()) { result.addAll(getMonitorNodes(child)); } return result; }
public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof MainView) { MainView view = (MainView) e.getSource(); Rectangle bounds = ((ZoomableLabelUI) view.getUI()).getIconR(view); Point p = e.getPoint(); if (bounds.contains(p)) { if (view.getIcon() instanceof MultipleImage) { Rectangle iconR = ((MultipleImage) view.getIcon()) .getIconR(PdfUtilitiesController.REFRESH_MONITORING_ICON); if (iconR != null) { float zoom = Controller.getCurrentController().getViewController().getZoom(); iconR.setLocation((int) (iconR.x * zoom), iconR.y); iconR.setSize((int) (iconR.width * zoom), (int) (iconR.height * zoom)); iconR.translate(bounds.x, bounds.y); if (iconR.contains(p)) { UpdateMonitoringFolderAction.updateNodesAgainstMonitoringDir( getMonitorNodes( Controller.getCurrentController().getViewController().getMap().getRootNode()), false); return; } } } } // StringBuilder sb = new StringBuilder(); // pdfHeaderExtraction(e, sb); } boolean openOnPage = ResourceController.getResourceController() .getBooleanProperty(PdfUtilitiesController.OPEN_PDF_VIEWER_ON_PAGE_KEY); if (!openOnPage) { this.mouseListener.mouseClicked(e); return; } if ( /*wasFocused() && */ (e.getModifiers() & ~(InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) == InputEvent.BUTTON1_MASK) { final MainView component = (MainView) e.getComponent(); final ModeController modeController = Controller.getCurrentModeController(); NodeModel node = null; try { node = ((MainView) e.getSource()).getNodeView().getModel(); } catch (Exception ex) { } if (node == null) { node = modeController.getMapController().getSelectedNode(); } if (component.isInFollowLinkRegion(e.getX())) { writeToLog(node); } if (!component.isInFollowLinkRegion(e.getX()) || !MonitoringUtils.isPdfLinkedNode(node)) { this.mouseListener.mouseClicked(e); return; } URI uri = Tools.getAbsoluteUri(node); if (uri == null) { this.mouseListener.mouseClicked(e); return; } IAnnotation annotation = null; try { annotation = node.getExtension(AnnotationModel.class); } catch (Exception ex) { } LinkController.getController().onDeselect(node); if (!PdfUtilitiesController.getController().openPdfOnPage(uri, annotation)) { this.mouseListener.mouseClicked(e); return; } LinkController.getController().onSelect(node); } else { this.mouseListener.mouseClicked(e); } }