当前位置: 首页>>代码示例>>Java>>正文


Java Path类代码示例

本文整理汇总了Java中org.uberfire.backend.vfs.Path的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Path类属于org.uberfire.backend.vfs包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: menuItemsDisabledWhenNotLockedWithCustomStateHelper

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Test
public void menuItemsDisabledWhenNotLockedWithCustomStateHelper() {
    builder.addSave(new MockSaveButton());
    builder.addRename(mock(Command.class));
    builder.addDelete(mock(Command.class));
    builder.setLockSyncMenuStateHelper((final Path file,
                                        final boolean isLocked,
                                        final boolean isLockedByCurrentUser) -> Operation.DISABLE);

    final Menus menus = builder.build();

    //Not locked, MenuItems should normally be enabled however our custom helper forces disable
    final UpdatedLockStatusEvent event = new UpdatedLockStatusEvent(mock(Path.class),
                                                                    false,
                                                                    false);

    builder.onEditorLockInfo(event);

    assertMenuItemEnabled(menus.getItems().get(0),
                          false);
    assertMenuItemEnabled(menus.getItems().get(1),
                          false);
    assertMenuItemEnabled(menus.getItems().get(2),
                          false);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:26,代码来源:BasicFileMenuBuilderTest.java

示例2: save

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Override
public Path save(final Path resource,
                 final SolverConfigModel config,
                 final Metadata metadata,
                 final String comment) {
    try {
        Metadata currentMetadata = metadataService.getMetadata(resource);
        ioService.write(Paths.convert(resource),
                        configPersistence.toXML(config),
                        metadataService.setUpAttributes(resource,
                                                        metadata),
                        commentedOptionFactory.makeCommentedOption(comment));

        fireMetadataSocialEvents(resource,
                                 currentMetadata,
                                 metadata);

        return resource;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:23,代码来源:SolverEditorServiceImpl.java

示例3: copyRestrictedPathIfExistsTest

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Test
public void copyRestrictedPathIfExistsTest() {
    final List<Path> paths = new ArrayList<Path>();
    paths.add(createFile("file0.txt"));
    paths.add(createFile("file1.txt"));
    paths.add(createFile("file2.txt"));

    givenThatPathIsUnrestricted(paths.get(0));
    givenThatPathIsRestricted(paths.get(1));
    givenThatPathIsUnrestricted(paths.get(2));

    try {
        whenPathsAreCopiedIfExists(paths);
    } catch (RuntimeException e) {
        thenPathWasNotCopiedIfExists(paths.get(1),
                                     e);
    }

    thenPathWasCopiedIfExists(paths.get(0));
    thenPathWasNotCopiedIfExists(paths.get(1));

    // This will not be copied because the process stops when some exception is raised.
    thenPathWasNotCopiedIfExists(paths.get(2));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:CopyServiceImplTest.java

示例4: resolveParentProject

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Override
public Project resolveParentProject(final Path resource) {
    try {
        //Null resource paths cannot resolve to a Project
        if (resource == null) {
            return null;
        }
        //Check if resource is the project root
        org.uberfire.java.nio.file.Path path = Paths.convert(resource).normalize();

        if (hasPom(path)) {
            final Path projectRootPath = Paths.convert(path);
            return new Project(projectRootPath,
                               Paths.convert(path.resolve(POM_PATH)),
                               projectRootPath.getFileName());
        } else {
            return null;
        }
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:23,代码来源:ResourceResolver.java

示例5: testResourceBatchChangesEventDeleteNonPomFile

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Test
public void testResourceBatchChangesEventDeleteNonPomFile() {
    final Path path = mock(Path.class);
    final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class);
    when(path.getFileName()).thenReturn("cheese.drl");
    when(path.toURI()).thenReturn("file://project1/cheese.drl");
    when(ioService.get(any(URI.class))).thenReturn(nioPath);

    final Map<Path, Collection<ResourceChange>> batch = new HashMap<Path, Collection<ResourceChange>>() {{
        put(path,
            new ArrayList<ResourceChange>() {{
                add(new ResourceDeleted(""));
            }});
    }};

    bridge.onBatchResourceChanges(new ResourceBatchChangesEvent(batch,
                                                                "message",
                                                                sessionInfo));

    verify(deleteProjectEvent,
           times(0)).fire(any(DeleteProjectEvent.class));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:23,代码来源:AbstractDeleteProjectObserverBridgeTest.java

示例6: convert

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
public static Path convert(final org.uberfire.java.nio.file.Path path) {
    if (path == null) {
        return null;
    }

    if (path.getFileName() == null) {
        return newPath("/",
                       path.toUri().toString(),
                       new HashMap<String, Object>(1) {{
                           put(PathFactory.VERSION_PROPERTY,
                               path.getFileSystem().supportedFileAttributeViews().contains("version"));
                       }});
    }

    return newPath(path.getFileName().toString(),
                   path.toUri().toString(),
                   new HashMap<String, Object>(1) {{
                       put(PathFactory.VERSION_PROPERTY,
                           path.getFileSystem().supportedFileAttributeViews().contains("version"));
                   }});
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:22,代码来源:Paths.java

示例7: testVersionChangeForSomeOtherFile

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Test
public void testVersionChangeForSomeOtherFile() throws Exception {
    VersionRecord versionRecord1 = getVersionRecord("111");
    records.add(versionRecord1);
    VersionRecord versionRecord2 = getVersionRecord("222");
    records.add(versionRecord2);

    screen.init(path222);

    screen.refresh("222");

    verify(view).setup(eq("222"),
                       any(AsyncDataProvider.class));

    Path pathToFile = mock(Path.class);
    when(pathToFile.toURI()).thenReturn("hehe//another.file");
    screen.onVersionChange(new VersionSelectedEvent(pathToFile,
                                                    getVersionRecord("111")));

    verify(view).setup(eq("222"),
                       any(AsyncDataProvider.class));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:23,代码来源:VersionHistoryPresenterTest.java

示例8: removeExtension

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
public static String removeExtension(final Path path,
                                     final ResourceTypeDefinition type) {
    if (path == null) {
        return null;
    }
    final String fileName = path.getFileName();
    if (type == null) {
        return fileName;
    }
    final int index = indexOfExtension(type,
                                       fileName);
    if (index == -1) {
        return fileName;
    } else {
        return fileName.substring(0,
                                  index);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:FileNameUtil.java

示例9: validate

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Override
public Collection<ValidationMessage> validate(final Path path) {
    if (path != null) {
        String dataObjectSource = ioService.readAllString(Paths.convert(path));
        GenerationResult generationResult = dataModelerService.loadDataObject(path,
                                                                              dataObjectSource,
                                                                              path);

        if (generationResult.hasErrors()) {
            return Collections.emptyList();
        } else {
            DataObject dataObject = generationResult.getDataObject();
            if (dataObject.getAnnotation(PLANNING_SOLUTION_ANNOTATION) != null) {
                return Arrays.asList(new PlanningSolutionToBeDuplicatedMessage(Level.ERROR));
            }
        }
    }
    return Collections.emptyList();
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:20,代码来源:PlanningSolutionCopyValidator.java

示例10: setUp

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Before
public void setUp() {
    initProjectResourcePathResolvers(PROJECT_RESOURCE_PATH_RESOLVERS_SIZE);
    when(resourcePathResolversInstance.iterator()).thenReturn(projectResourcePathResolvers.iterator());

    resourceResolver = spy(new ResourceResolver(ioService,
                                                pomService,
                                                configurationService,
                                                commentedOptionFactory,
                                                backward,
                                                resourcePathResolversInstance) {
        @Override
        public Project resolveProject(Path resource) {
            return null;
        }

        @Override
        public Project simpleProjectInstance(org.uberfire.java.nio.file.Path nioProjectRootPath) {
            return null;
        }
    });
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:23,代码来源:AbstractResourceResolverTest.java

示例11: projectDoesNotExist

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Test
public void projectDoesNotExist() throws Exception {
    when(repository.getDefaultBranch()).thenReturn("master");

    Path path = mock(Path.class);
    when(path.getFileName()).thenReturn("");
    when(path.toURI()).thenReturn("file://project/");

    when(repository.getBranchRoot("master")).thenReturn(path);

    final JobResult jobResult = helper.testProject(null,
                                                   "repositoryAlias",
                                                   "project");
    assertEquals(JobStatus.RESOURCE_NOT_EXIST,
                 jobResult.getStatus());
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:JobRequestHelperTest.java

示例12: retrieveLockInfo

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Override
public LockInfo retrieveLockInfo(Path path)
        throws IllegalArgumentException, IOException {

    final Path vfsLock = PathFactory.newLock(path);
    final org.uberfire.java.nio.file.Path realLock = Paths.convert(vfsLock);

    if (ioService.exists(realLock)) {
        try {
            final String lockedBy = ioService.readAllString(realLock);
            return new LockInfo(true,
                                lockedBy,
                                path,
                                vfsLock);
        } catch (NoSuchFileException nsfe) {
            // We want to avoid starting a batch (to ensure cluster-wide consistent reads) here since 
            // this method is invoked very frequently. Therefore it's possible that the lock file
            // was deleted after the check to exists but before readAllString was invoked. There's
            // no need for special exception handling as it simply means that file is no longer locked.
        }
    }
    return new LockInfo(false,
                        null,
                        path,
                        vfsLock);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:27,代码来源:VFSLockServiceImpl.java

示例13: getScreenWithMainAndTitle

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
public static PluginSimpleContent getScreenWithMainAndTitle() {
    Map<CodeType, String> codeMap = new HashMap<CodeType, String>();
    codeMap.put(CodeType.MAIN,
                "alert('main');");
    codeMap.put(CodeType.TITLE,
                "My Title");
    Path path = null;
    Set<Framework> frameworks = new HashSet<Framework>();
    PluginSimpleContent plugin = new PluginSimpleContent("ScreenWithTitle",
                                                         PluginType.SCREEN,
                                                         path,
                                                         "",
                                                         "",
                                                         codeMap,
                                                         frameworks,
                                                         Language.JAVASCRIPT);
    return plugin;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:PluginSamples.java

示例14: loadContent

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
private void loadContent(final NavigatorItem parent,
                         final Path path) {
    if (path != null) {
        navigatorService.call(new RemoteCallback<NavigatorContent>() {
            @Override
            public void callback(final NavigatorContent response) {
                for (final DataContent dataContent : response.getContent()) {
                    if (dataContent.isDirectory()) {
                        if (options.showDirectories()) {
                            parent.addDirectory(dataContent.getPath());
                        }
                    } else {
                        if (options.showFiles()) {
                            if (!options.showHiddenFiles() && !hiddenTypeDef.accept(dataContent.getPath())) {
                                parent.addFile(dataContent.getPath());
                            } else if (options.showHiddenFiles()) {
                                parent.addFile(dataContent.getPath());
                            }
                        }
                    }
                }
            }
        }).listContent(path);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:26,代码来源:TreeNavigator.java

示例15: hasRestriction

import org.uberfire.backend.vfs.Path; //导入依赖的package包/类
@Override
public boolean hasRestriction(final Path path) {
    for (RenameRestrictor renameRestrictor : getRenameRestrictors()) {
        final PathOperationRestriction renameRestriction = renameRestrictor.hasRestriction(path);
        if (renameRestriction != null) {
            return true;
        }
    }

    return false;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:12,代码来源:RenameServiceImpl.java


注:本文中的org.uberfire.backend.vfs.Path类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。