public void dispose() { handlerRegistration.removeHandler(); } }
public static File getUserPluginDirectory() { if (userPluginDirectory == null) { userPluginDirectory = new File(getDataDirectory(), "plugins"); userPluginDirectory.mkdir(); } return userPluginDirectory; } }
String path = calculatePath(f); if (f.isFile()) { if (f.equals(getManifest())) { if (logger.isDebugEnabled()) { logger.debug("Skipping manifest entry " + f); addDirectory(jar, f);
public void createJarFile(File jar) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Creating jar file " + jar + " from directory " + topLevelDirectory); } File manifest = getManifest(); if (manifest == null) { throw new IOException("No manifest found"); } FileOutputStream fileOutputStream = null; FileInputStream manifestInputStream = null; JarOutputStream jarOutputStream = null; try { fileOutputStream = new FileOutputStream(jar); manifestInputStream = new FileInputStream(manifest); jarOutputStream = new JarOutputStream(fileOutputStream, new Manifest(manifestInputStream)); addDirectory(jarOutputStream, topLevelDirectory); } finally { if (jarOutputStream != null) { jarOutputStream.close(); } else { if (fileOutputStream != null) fileOutputStream.close(); if (manifestInputStream != null) manifestInputStream.close(); } } }
/** * Constructs a WizardPanel that will ask the user whether they want to make siblings disjoint. * @param owlEditorKit The relevant editor kit. * @param entityType The type of sibling. * @param recommendation Whether or not it is recommended that siblings be disjoint. */ public MakeSiblingsDisjointPanel(OWLEditorKit owlEditorKit, EntityType<?> entityType, Recommendation recommendation) { super(ID, String.format("Make sibling %s disjoint?", entityType.getPluralPrintName().toLowerCase()), owlEditorKit); this.checkBox = new JCheckBox(String.format("Do you want to make sibling %s disjoint? (%s)", entityType.getPluralPrintName().toLowerCase(), recommendation.getPrintName()), recommendation == Recommendation.RECOMMENDED); checkBox.setBackground(null); this.entityType = entityType; this.recommendation = recommendation; setInstructions(String.format("Make sibling %s disjoint (%s)", entityType.getPluralPrintName().toLowerCase(), recommendation.getPrintName())); JPanel parent = new JPanel(new BorderLayout()); parent.add(checkBox, BorderLayout.NORTH); setContent(parent); }
private void handleSaveErrors(Map<OWLOntology, OWLOntologyStorageException> saveErrors) { if (saveErrors.isEmpty()) { return; } StringBuilder errorMessage = new StringBuilder(); errorMessage.append("<html><body><b>Some errors where encountered during the save operation.</b><br><br>" + "The following ontologies were not saved:<br><br>"); for (OWLOntology erroredOntology : saveErrors.keySet()) { OWLOntologyStorageException error = saveErrors.get(erroredOntology); logger.error("An error occurred whilst saving the {} ontology: {}", error.getMessage(), error); String rendering = getModelManager().getRendering(erroredOntology); errorMessage .append("<b>") .append(rendering) .append("</b><br><span style=\"color:gray;\">Reason: ") .append(StringAbbreviator.abbreviateString(error.getMessage().trim(), 100).replace("\n", "<br>")) .append("</span><br><br>"); } JOptionPane.showMessageDialog(getWorkspace(), errorMessage.toString(), "Save Errors", JOptionPane.ERROR_MESSAGE); }
private static Optional<File> copyPluginToInstallLocation(File downloadedPlugin, PluginInfo info) throws URISyntaxException { final Optional<File> backupFileName = moveExistingPluginToBackupLocation(info); final File pluginsFolder = new File(System.getProperty(ProtegeApplication.BUNDLE_DIR_PROP)); final String destinationFileName = String.format("%s-%s.jar", info.getId(), info.getAvailableVersion()); final File downloadedPluginDestination = new File(pluginsFolder, destinationFileName); try { FileUtils.copyFile(downloadedPlugin, downloadedPluginDestination); logger.info("Copied the {} plugin to {} in the plugins directory", info.getLabel(), downloadedPluginDestination.getName()); deletePluginBackup(backupFileName); return Optional.of(downloadedPluginDestination); } catch (IOException e) { try { File userPluginDirectory = ProtegeDirectories.getUserPluginDirectory(); logger.info("Could not copy the plugin to Protege plugins directory: {}", e.getMessage()); File userDirectoryPluginFile = new File(userPluginDirectory, info.getId() + ".jar"); FileUtils.copyFileToDirectory(downloadedPlugin, userDirectoryPluginFile); logger.info("Copied the {} plugin to the user plugin directory at {}. " + "This plugin will only be use-able by the current user.", info.getLabel(), userPluginDirectory); deletePluginBackup(backupFileName); return Optional.of(userDirectoryPluginFile); } catch (IOException ioe) { logger.error("An error occurred whilst attempting to save the plugin: {}", ioe.getMessage(), ioe); return Optional.empty(); } } }
@Override public void setDisplayedBreadcrumbTrail(@Nonnull List<Breadcrumb> path) { this.removeAll(); if(path.isEmpty()) { this.validate(); this.repaint(); return; } OWLObject firstBreadcrumb = path.get(0).getObject(); // Don't display obvious top entities as this justs wastes valuable horizontal space int skip = firstBreadcrumb.isTopEntity() ? 1 : 0; path.stream() .skip(skip) .map(breadcrumb -> { String rendering = workspace.getOWLModelManager().getRendering(breadcrumb.getObject()); String displayText = stripSingleQuotes(rendering); BreadcrumbView breadcrumbView = new BreadcrumbViewImpl(breadcrumb.getObject(), displayText); breadcrumbView.setViewClickedHandler(owlObject -> breadcrumbClickHandler.handleClicked(breadcrumb)); return breadcrumbView; }) .forEach(v -> this.add(v.asJComponent())); this.validate(); this.repaint(); }
private void addDirectory(JarOutputStream jar, File dir) throws IOException { for (File f : dir.listFiles()) { String path = calculatePath(f); if (f.isFile()) { if (f.equals(getManifest())) { if (log.isDebugEnabled()) { log.debug("Skipping manifest entry " + f); addDirectory(jar, f);
public void createJarFile(File jar) throws IOException { if (log.isDebugEnabled()) { log.debug("Creating jar file " + jar + " from directory " + topLevelDirectory); } File manifest = getManifest(); if (manifest == null) { throw new IOException("No manifest found"); } FileOutputStream fileOutputStream = null; FileInputStream manifestInputStream = null; JarOutputStream jarOutputStream = null; try { fileOutputStream = new FileOutputStream(jar); manifestInputStream = new FileInputStream(manifest); jarOutputStream = new JarOutputStream(fileOutputStream, new Manifest(manifestInputStream)); addDirectory(jarOutputStream, topLevelDirectory); } finally { if (jarOutputStream != null) { jarOutputStream.close(); } else { if (fileOutputStream != null) fileOutputStream.close(); if (manifestInputStream != null) manifestInputStream.close(); } } }
public static File getGlobalCatalogFile() { return getCatalogFile(ProtegeDirectories.getDataDirectory()); }
public void disposeView() { // Dispose of the assertedTree selection listener if (assertedTree != null) { assertedTree.removeTreeSelectionListener(listener); assertedTree.dispose(); } inferredTree.ifPresent(tree -> { tree.removeTreeSelectionListener(listener); tree.dispose(); }); if (breadCrumbTrailProviderRegistration != null) { breadCrumbTrailProviderRegistration.removeHandler(); } }
/** * Constructs a WizardPanel that will ask the user whether they want to make siblings disjoint. * @param owlEditorKit The relevant editor kit. * @param entityType The type of sibling. * @param recommendation Whether or not it is recommended that siblings be disjoint. */ public MakeSiblingsDisjointPanel(OWLEditorKit owlEditorKit, EntityType<?> entityType, Recommendation recommendation) { super(ID, String.format("Make sibling %s disjoint?", entityType.getPluralPrintName().toLowerCase()), owlEditorKit); this.checkBox = new JCheckBox(String.format("Do you want to make sibling %s disjoint? (%s)", entityType.getPluralPrintName().toLowerCase(), recommendation.getPrintName()), recommendation == Recommendation.RECOMMENDED); checkBox.setBackground(null); this.entityType = entityType; this.recommendation = recommendation; setInstructions(String.format("Do you want to make sibling %s disjoint? (%s)", entityType.getPluralPrintName().toLowerCase(), recommendation.getPrintName())); JPanel parent = new JPanel(new BorderLayout()); parent.add(checkBox, BorderLayout.NORTH); setContent(parent); }
private void handleSaveErrors(Map<OWLOntology, OWLOntologyStorageException> saveErrors) { if (saveErrors.isEmpty()) { return; } StringBuilder errorMessage = new StringBuilder(); errorMessage.append("<html><body><b>Some errors where encountered during the save operation.</b><br><br>" + "The following ontologies were not saved:<br><br>"); for (OWLOntology erroredOntology : saveErrors.keySet()) { OWLOntologyStorageException error = saveErrors.get(erroredOntology); logger.error("An error occurred whilst saving the {} ontology: {}", error.getMessage(), error); String rendering = getModelManager().getRendering(erroredOntology); errorMessage .append("<b>") .append(rendering) .append("</b><br><span style=\"color:gray;\">Reason: ") .append(StringAbbreviator.abbreviateString(error.getMessage().trim(), 100).replace("\n", "<br>")) .append("</span><br><br>"); } JOptionPane.showMessageDialog(getWorkspace(), errorMessage.toString(), "Save Errors", JOptionPane.ERROR_MESSAGE); }
private void addDirectory(JarOutputStream jar, File dir) throws IOException { for (File f : dir.listFiles()) { String path = calculatePath(f); if (f.isFile()) { if (f.equals(getManifest())) { if (log.isDebugEnabled()) { log.debug("Skipping manifest entry " + f); addDirectory(jar, f);
public void createJarFile(File jar) throws IOException { if (log.isDebugEnabled()) { log.debug("Creating jar file " + jar + " from directory " + topLevelDirectory); } File manifest = getManifest(); if (manifest == null) { throw new IOException("No manifest found"); } FileOutputStream fileOutputStream = null; FileInputStream manifestInputStream = null; JarOutputStream jarOutputStream = null; try { fileOutputStream = new FileOutputStream(jar); manifestInputStream = new FileInputStream(manifest); jarOutputStream = new JarOutputStream(fileOutputStream, new Manifest(manifestInputStream)); addDirectory(jarOutputStream, topLevelDirectory); } finally { if (jarOutputStream != null) { jarOutputStream.close(); } else { if (fileOutputStream != null) fileOutputStream.close(); if (manifestInputStream != null) manifestInputStream.close(); } } }
@Nonnull public static File getGlobalCatalogFile() { return getCatalogFile(ProtegeDirectories.getDataDirectory()); }
@Nonnull public HandlerRegistration registerBreadcrumbTrailProvider(@Nonnull BreadcrumbTrailProvider provider) { // Add provider to our list registeredProviders.add(checkNotNull(provider)); provider.asJComponent().addHierarchyListener(e -> { Optional<BreadcrumbTrailProvider> activeProvider = getActiveProvider(); if(!activeProvider.equals(currentProvider)) { currentProvider = activeProvider; fireBreadcrumbTrailChanged(); } }); fireBreadcrumbTrailChanged(); // Listen for trail changed and pass on the handling if it changes HandlerRegistration reg = provider.addBreadcrumbTrailChangedHandler(this::fireBreadcrumbTrailChanged); return () -> { registeredProviders.remove(provider); reg.removeHandler(); }; }