-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tags in Blocks for filtering blocks
* Built in block with developerOnly tag will never be shown to user * Developer can use any block everywhere if it is tagged with developer
- Loading branch information
1 parent
1dbc7d9
commit bd143ec
Showing
5 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.dragon.ide.utils; | ||
|
||
import com.dragon.ide.BuildConfig; | ||
import com.dragon.ide.objects.Block; | ||
import editor.tsd.tools.Language; | ||
import java.util.ArrayList; | ||
|
||
public class FilterBlocks { | ||
public static ArrayList<Block> filterBlocksWithTag(ArrayList<Block> blocks, String language) { | ||
ArrayList<Block> filteredBlocks = new ArrayList<Block>(); | ||
for (int i = 0; i < blocks.size(); ++i) { | ||
boolean addHolder = false; | ||
boolean forHtml = false; | ||
boolean forCss = false; | ||
boolean forJavaScript = false; | ||
boolean forDeveloper = false; | ||
boolean forDeveloperOnly = false; | ||
|
||
for (int blockTagIndex = 0; blockTagIndex < blocks.get(i).getTags().length; ++blockTagIndex) { | ||
if (blocks.get(i).getTags()[blockTagIndex].equals("developerOnly")) { | ||
forDeveloperOnly = true; | ||
} | ||
if (blocks.get(i).getTags()[blockTagIndex].equals("developer")) { | ||
forDeveloper = true; | ||
} | ||
if (blocks.get(i).getTags()[blockTagIndex].equals(Language.HTML)) { | ||
forHtml = true; | ||
} | ||
if (blocks.get(i).getTags()[blockTagIndex].equals(Language.CSS)) { | ||
forCss = true; | ||
} | ||
if (blocks.get(i).getTags()[blockTagIndex].equals(Language.JavaScript)) { | ||
forJavaScript = true; | ||
} | ||
} | ||
|
||
if (forHtml) { | ||
if (language.equals(Language.HTML)) { | ||
addHolder = true; | ||
} | ||
} | ||
|
||
if (forCss) { | ||
if (language.equals(Language.CSS)) { | ||
addHolder = true; | ||
} | ||
} | ||
|
||
if (forJavaScript) { | ||
if (language.equals(Language.JavaScript)) { | ||
addHolder = true; | ||
} | ||
} | ||
|
||
if (forDeveloper) { | ||
if (BuildConfig.enableDeveloperBlocks) { | ||
addHolder = true; | ||
} | ||
} | ||
|
||
if (forDeveloperOnly) { | ||
if (BuildConfig.enableDeveloperBlocks) { | ||
addHolder = true; | ||
} else { | ||
addHolder = false; | ||
} | ||
} | ||
|
||
if (addHolder) { | ||
filteredBlocks.add(blocks.get(i)); | ||
} | ||
} | ||
return filteredBlocks; | ||
} | ||
} |