Search in sources :

Example 1 with DeleteTaxonomyLevelEvent

use of org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent in project OpenOLAT by OpenOLAT.

the class DeleteTaxonomyLevelController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    StringBuilder sb = new StringBuilder();
    if (levels.size() > 1) {
        Collections.sort(levels, new TaxonomyLevelDepthComparator());
    }
    TaxonomyLevel mergeTo = null;
    if (mergeToEl.isOneSelected() && !"-".equals(mergeToEl.getSelectedKey())) {
        String selectedNodeKey = mergeToEl.getSelectedKey();
        TreeNode selectedNode = treeModel.getNodeById(selectedNodeKey);
        mergeTo = (TaxonomyLevel) selectedNode.getUserObject();
    }
    for (TaxonomyLevel level : levels) {
        TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(level);
        if (taxonomyService.deleteTaxonomyLevel(taxonomyLevel, mergeTo)) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(StringHelper.escapeHtml(taxonomyLevel.getDisplayName()));
        }
    }
    // commit before sending event
    dbInstance.commit();
    fireEvent(ureq, new DeleteTaxonomyLevelEvent());
    showInfo("confirm.deleted.level", new String[] { sb.toString() });
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : TaxonomyLevelDepthComparator(org.olat.modules.taxonomy.ui.component.TaxonomyLevelDepthComparator) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) DeleteTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent)

Example 2 with DeleteTaxonomyLevelEvent

use of org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent in project OpenOLAT by OpenOLAT.

the class TaxonomyLevelOverviewController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (metadataCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            taxonomyLevel = metadataCtrl.getTaxonomyLevel();
            updateProperties();
            fireEvent(ureq, event);
        } else if (event == Event.CANCELLED_EVENT) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
        }
    } else if (confirmDeleteCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT || event instanceof DeleteTaxonomyLevelEvent) {
            fireEvent(ureq, new DeleteTaxonomyLevelEvent());
        }
        cmc.deactivate();
        cleanUp();
    } else if (createTaxonomyLevelCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            fireEvent(ureq, new NewTaxonomyLevelEvent(createTaxonomyLevelCtrl.getTaxonomyLevel()));
        }
        cmc.deactivate();
        cleanUp();
    } else if (moveLevelCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            taxonomyLevel = moveLevelCtrl.getMovedTaxonomyLevel();
            fireEvent(ureq, new MoveTaxonomyLevelEvent(moveLevelCtrl.getMovedTaxonomyLevel()));
        }
        cmc.deactivate();
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : MoveTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.MoveTaxonomyLevelEvent) DeleteTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent) NewTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.NewTaxonomyLevelEvent)

Example 3 with DeleteTaxonomyLevelEvent

use of org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent in project openolat by klemens.

the class MergeTaxonomyLevelController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (levels.size() > 1) {
        Collections.sort(levels, new TaxonomyLevelDepthComparator());
    }
    String selectedNodeKey = mergeToEl.getSelectedKey();
    TreeNode selectedNode = treeModel.getNodeById(selectedNodeKey);
    TaxonomyLevel mergeTo = (TaxonomyLevel) selectedNode.getUserObject();
    StringBuilder sb = new StringBuilder();
    for (TaxonomyLevel level : levels) {
        TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(level);
        if (taxonomyService.deleteTaxonomyLevel(taxonomyLevel, mergeTo)) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(StringHelper.escapeHtml(taxonomyLevel.getDisplayName()));
        }
    }
    // commit before sending event
    dbInstance.commit();
    fireEvent(ureq, new DeleteTaxonomyLevelEvent());
    showInfo("confirm.merge.level", new String[] { sb.toString() });
}
Also used : TaxonomyLevelDepthComparator(org.olat.modules.taxonomy.ui.component.TaxonomyLevelDepthComparator) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) DeleteTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent)

Example 4 with DeleteTaxonomyLevelEvent

use of org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent in project OpenOLAT by OpenOLAT.

the class MergeTaxonomyLevelController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (levels.size() > 1) {
        Collections.sort(levels, new TaxonomyLevelDepthComparator());
    }
    String selectedNodeKey = mergeToEl.getSelectedKey();
    TreeNode selectedNode = treeModel.getNodeById(selectedNodeKey);
    TaxonomyLevel mergeTo = (TaxonomyLevel) selectedNode.getUserObject();
    StringBuilder sb = new StringBuilder();
    for (TaxonomyLevel level : levels) {
        TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(level);
        if (taxonomyService.deleteTaxonomyLevel(taxonomyLevel, mergeTo)) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(StringHelper.escapeHtml(taxonomyLevel.getDisplayName()));
        }
    }
    // commit before sending event
    dbInstance.commit();
    fireEvent(ureq, new DeleteTaxonomyLevelEvent());
    showInfo("confirm.merge.level", new String[] { sb.toString() });
}
Also used : TaxonomyLevelDepthComparator(org.olat.modules.taxonomy.ui.component.TaxonomyLevelDepthComparator) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) DeleteTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent)

Example 5 with DeleteTaxonomyLevelEvent

use of org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent in project openolat by klemens.

the class DeleteTaxonomyLevelController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    StringBuilder sb = new StringBuilder();
    if (levels.size() > 1) {
        Collections.sort(levels, new TaxonomyLevelDepthComparator());
    }
    TaxonomyLevel mergeTo = null;
    if (mergeToEl.isOneSelected() && !"-".equals(mergeToEl.getSelectedKey())) {
        String selectedNodeKey = mergeToEl.getSelectedKey();
        TreeNode selectedNode = treeModel.getNodeById(selectedNodeKey);
        mergeTo = (TaxonomyLevel) selectedNode.getUserObject();
    }
    for (TaxonomyLevel level : levels) {
        TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(level);
        if (taxonomyService.deleteTaxonomyLevel(taxonomyLevel, mergeTo)) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(StringHelper.escapeHtml(taxonomyLevel.getDisplayName()));
        }
    }
    // commit before sending event
    dbInstance.commit();
    fireEvent(ureq, new DeleteTaxonomyLevelEvent());
    showInfo("confirm.deleted.level", new String[] { sb.toString() });
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : TaxonomyLevelDepthComparator(org.olat.modules.taxonomy.ui.component.TaxonomyLevelDepthComparator) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) DeleteTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent)

Aggregations

DeleteTaxonomyLevelEvent (org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent)6 TreeNode (org.olat.core.gui.components.tree.TreeNode)4 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)4 TaxonomyLevelDepthComparator (org.olat.modules.taxonomy.ui.component.TaxonomyLevelDepthComparator)4 MoveTaxonomyLevelEvent (org.olat.modules.taxonomy.ui.events.MoveTaxonomyLevelEvent)2 NewTaxonomyLevelEvent (org.olat.modules.taxonomy.ui.events.NewTaxonomyLevelEvent)2