Search in sources :

Example 16 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class BaseViewPresenter method copyItem.

public void copyItem(final FolderItem folderItem) {
    final Path path = getFolderItemPath(folderItem);
    validationService.call(messages -> {
        if (((List<ValidationMessage>) messages).isEmpty()) {
            showCopyPopup(folderItem, path);
        } else {
            validationPopup.showCopyValidationMessages(() -> showCopyPopup(folderItem, path), () -> {
            }, (List<ValidationMessage>) messages);
        }
    }).validateForCopy(path);
}
Also used : Path(org.uberfire.backend.vfs.Path) Utils(org.kie.workbench.common.screens.explorer.client.utils.Utils) LockInfo(org.uberfire.backend.vfs.impl.LockInfo) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) UberfireDocks(org.uberfire.client.workbench.docks.UberfireDocks) ApplicationPreferences(org.kie.workbench.common.services.shared.preferences.ApplicationPreferences) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ExplorerService(org.kie.workbench.common.screens.explorer.service.ExplorerService) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) URLHelper(org.kie.workbench.common.screens.explorer.client.utils.URLHelper) Validator(org.uberfire.ext.editor.commons.client.validation.Validator) Observes(javax.enterprise.event.Observes) Module(org.guvnor.common.services.project.model.Module) TagChangedEvent(org.kie.workbench.common.screens.explorer.client.widgets.tagSelector.TagChangedEvent) BuildService(org.guvnor.common.services.project.builder.service.BuildService) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing) RenamePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.RenamePopUpPresenter) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ResourceRenamedEvent(org.uberfire.workbench.events.ResourceRenamedEvent) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) ResourceUpdatedEvent(org.uberfire.workbench.events.ResourceUpdatedEvent) ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback) Explorer(org.kie.workbench.common.screens.explorer.client.widgets.navigator.Explorer) List(java.util.List) Caller(org.jboss.errai.common.client.api.Caller) PostConstruct(javax.annotation.PostConstruct) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) ProjectExplorerContent(org.kie.workbench.common.screens.explorer.model.ProjectExplorerContent) PlaceManager(org.uberfire.client.mvp.PlaceManager) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package) Inject(javax.inject.Inject) ResourceCopiedEvent(org.uberfire.workbench.events.ResourceCopiedEvent) CommonConstants(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants) Window(com.google.gwt.user.client.Window) Path(org.uberfire.backend.vfs.Path) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Event(javax.enterprise.event.Event) ResourceAddedEvent(org.uberfire.workbench.events.ResourceAddedEvent) FolderItemType(org.kie.workbench.common.screens.explorer.model.FolderItemType) CopyPopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.CopyPopUpPresenter) ValidationService(org.kie.workbench.common.services.shared.validation.ValidationService) ValidationPopup(org.kie.workbench.common.widgets.client.popups.validation.ValidationPopup) VFSService(org.uberfire.backend.vfs.VFSService) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) ResourceDeletedEvent(org.uberfire.workbench.events.ResourceDeletedEvent) Message(org.jboss.errai.bus.client.api.messaging.Message) DeletePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.DeletePopUpPresenter) User(org.jboss.errai.security.shared.api.identity.User) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) List(java.util.List) ArrayList(java.util.ArrayList)

Example 17 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class BaseViewPresenter method deleteItem.

public void deleteItem(final FolderItem folderItem) {
    final Path path = getFolderItemPath(folderItem);
    validationService.call(messages -> {
        if (((List<ValidationMessage>) messages).isEmpty()) {
            showDeletePopup(folderItem);
        } else {
            validationPopup.showDeleteValidationMessages(() -> showDeletePopup(folderItem), () -> {
            }, (List<ValidationMessage>) messages);
        }
    }).validateForDelete(path);
}
Also used : Path(org.uberfire.backend.vfs.Path) Utils(org.kie.workbench.common.screens.explorer.client.utils.Utils) LockInfo(org.uberfire.backend.vfs.impl.LockInfo) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) UberfireDocks(org.uberfire.client.workbench.docks.UberfireDocks) ApplicationPreferences(org.kie.workbench.common.services.shared.preferences.ApplicationPreferences) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ExplorerService(org.kie.workbench.common.screens.explorer.service.ExplorerService) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) URLHelper(org.kie.workbench.common.screens.explorer.client.utils.URLHelper) Validator(org.uberfire.ext.editor.commons.client.validation.Validator) Observes(javax.enterprise.event.Observes) Module(org.guvnor.common.services.project.model.Module) TagChangedEvent(org.kie.workbench.common.screens.explorer.client.widgets.tagSelector.TagChangedEvent) BuildService(org.guvnor.common.services.project.builder.service.BuildService) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing) RenamePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.RenamePopUpPresenter) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ResourceRenamedEvent(org.uberfire.workbench.events.ResourceRenamedEvent) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) ResourceUpdatedEvent(org.uberfire.workbench.events.ResourceUpdatedEvent) ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback) Explorer(org.kie.workbench.common.screens.explorer.client.widgets.navigator.Explorer) List(java.util.List) Caller(org.jboss.errai.common.client.api.Caller) PostConstruct(javax.annotation.PostConstruct) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) ProjectExplorerContent(org.kie.workbench.common.screens.explorer.model.ProjectExplorerContent) PlaceManager(org.uberfire.client.mvp.PlaceManager) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package) Inject(javax.inject.Inject) ResourceCopiedEvent(org.uberfire.workbench.events.ResourceCopiedEvent) CommonConstants(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants) Window(com.google.gwt.user.client.Window) Path(org.uberfire.backend.vfs.Path) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Event(javax.enterprise.event.Event) ResourceAddedEvent(org.uberfire.workbench.events.ResourceAddedEvent) FolderItemType(org.kie.workbench.common.screens.explorer.model.FolderItemType) CopyPopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.CopyPopUpPresenter) ValidationService(org.kie.workbench.common.services.shared.validation.ValidationService) ValidationPopup(org.kie.workbench.common.widgets.client.popups.validation.ValidationPopup) VFSService(org.uberfire.backend.vfs.VFSService) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) ResourceDeletedEvent(org.uberfire.workbench.events.ResourceDeletedEvent) Message(org.jboss.errai.bus.client.api.messaging.Message) DeletePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.DeletePopUpPresenter) User(org.jboss.errai.security.shared.api.identity.User) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) List(java.util.List) ArrayList(java.util.ArrayList)

Example 18 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class BaseViewPresenter method filterByTag.

protected void filterByTag(String tag) {
    currentTag = tag;
    List<FolderItem> filteredItems = new ArrayList<FolderItem>();
    for (FolderItem item : activeContextItems.getActiveContent().getContent()) {
        if (tag == null || item.getTags().contains(tag) || item.getType().equals(FolderItemType.FOLDER)) {
            filteredItems.add(item);
        }
    }
    FolderListing filteredContent = new FolderListing(activeContextItems.getActiveContent().getItem(), filteredItems, activeContextItems.getActiveContent().getSegments());
    baseView.renderItems(filteredContent);
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) ArrayList(java.util.ArrayList) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing)

Example 19 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class BreadcrumbNavigator method setupContent.

// Package protected for unit-testing
void setupContent(final FolderListing content) {
    final int folderCount = getFolderCount(content.getContent());
    if (activeOptions.isTechnicalViewActive() || folderCount > 0) {
        showNavigatorPanel();
    } else {
        hideNavigatorPanel();
    }
    int base = navigator.getRowCount();
    for (int i = 0; i < content.getContent().size(); i++) {
        final FolderItem folderItem = content.getContent().get(i);
        if (folderItem.getType().equals(FolderItemType.FOLDER) && options.showDirectories()) {
            createDirectory(base + i, folderItem);
        } else if (folderItem.getType().equals(FolderItemType.FILE) && options.showFiles()) {
            if (!options.showHiddenFiles() && !hiddenTypeDef.accept((Path) folderItem.getItem())) {
                createFile(base + i, folderItem);
            } else if (options.showHiddenFiles()) {
                createFile(base + i, folderItem);
            }
        }
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem)

Example 20 with FolderItem

use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.

the class TreeNavigator method loadContent.

@Override
public void loadContent(final FolderListing content, final Map<FolderItem, List<FolderItem>> siblings) {
    if (content == null || content.getItem() == null) {
        clear();
        return;
    }
    if (content.equals(activeContent)) {
        if (tree.getSelectedItem() != null) {
            tree.getSelectedItem().setState(TreeItem.State.OPEN, true, false);
        }
        return;
    }
    this.activeContent = content;
    FSTreeItem item = null;
    if (!tree.isEmpty()) {
        item = findItemInTree(content.getItem());
    }
    if (item == null) {
        if (content.getSegments().isEmpty()) {
            final FolderItem rootItem = content.getItem();
            item = new FSTreeItem(FSTreeItem.FSType.FOLDER, rootItem.getFileName().replaceAll(" ", "\u00a0"));
            tree.addItem(item);
            item.setUserObject(rootItem);
        } else {
            final FSTreeItem parent = loadRoots(content.getSegments(), siblings);
            if (parent != null) {
                item = loadSiblings(content.getItem(), new TreeNavigatorItemImpl(parent), siblings);
                if (item != null) {
                    item.setUserObject(content.getItem());
                }
            }
        }
    }
    if (item != null) {
        item.setState(TreeItem.State.OPEN, true, false);
        tree.setSelectedItem(item);
        item.removeItems();
        loadContent(new TreeNavigatorItemImpl(item), content);
    }
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) FSTreeItem(org.uberfire.ext.widgets.core.client.tree.FSTreeItem)

Aggregations

FolderItem (org.kie.workbench.common.screens.explorer.model.FolderItem)31 ArrayList (java.util.ArrayList)15 Path (org.uberfire.backend.vfs.Path)14 Test (org.junit.Test)13 Package (org.guvnor.common.services.project.model.Package)8 FolderListing (org.kie.workbench.common.screens.explorer.model.FolderListing)8 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)5 List (java.util.List)4 Set (java.util.Set)3 Inject (javax.inject.Inject)3 Module (org.guvnor.common.services.project.model.Module)3 FolderItemType (org.kie.workbench.common.screens.explorer.model.FolderItemType)3 ClientResourceType (org.uberfire.client.workbench.type.ClientResourceType)3 Window (com.google.gwt.user.client.Window)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 PostConstruct (javax.annotation.PostConstruct)2 Event (javax.enterprise.event.Event)2