Search in sources :

Example 1 with TaskTag

use of org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag in project webtools.sourceediting by eclipse.

the class MainTab method removeTags.

/**
 * @param selection
 */
private void removeTags(ISelection selection) {
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    List taskTags = new ArrayList(Arrays.asList(fTaskTags));
    taskTags.removeAll(structuredSelection.toList());
    fTaskTags = (TaskTag[]) taskTags.toArray(new TaskTag[taskTags.size()]);
    valueTable.setInput(fTaskTags);
}
Also used : TaskTag(org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with TaskTag

use of org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag in project webtools.sourceediting by eclipse.

the class MainTab method addTag.

private void addTag() {
    TaskTagDialog dlg = new TaskTagDialog(fControl.getShell());
    int result = dlg.open();
    if (result == Window.OK) {
        TaskTag newTag = dlg.taskTag;
        List newTags = new ArrayList(Arrays.asList(fTaskTags));
        newTags.add(newTag);
        fTaskTags = (TaskTag[]) newTags.toArray(new TaskTag[newTags.size()]);
        valueTable.setInput(fTaskTags);
        valueTable.getTable().setSelection(fTaskTags.length - 1);
    }
}
Also used : TaskTag(org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Point(org.eclipse.swt.graphics.Point)

Example 3 with TaskTag

use of org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag in project webtools.sourceediting by eclipse.

the class MainTab method loadTagsAndPrioritiesFrom.

/**
 * @param tags
 * @param priorities
 */
private void loadTagsAndPrioritiesFrom(String tagString, String priorityString) {
    String[] tags = StringUtils.unpack(tagString);
    StringTokenizer toker = null;
    List list = new ArrayList();
    // $NON-NLS-1$
    toker = new StringTokenizer(priorityString, ",");
    while (toker.hasMoreTokens()) {
        Integer number = null;
        try {
            number = Integer.valueOf(toker.nextToken());
        } catch (NumberFormatException e) {
            number = new Integer(IMarker.PRIORITY_NORMAL);
        }
        list.add(number);
    }
    Integer[] priorities = (Integer[]) list.toArray(new Integer[0]);
    fTaskTags = new TaskTag[Math.min(tags.length, priorities.length)];
    for (int i = 0; i < fTaskTags.length; i++) {
        fTaskTags[i] = new TaskTag(tags[i], priorities[i].intValue());
    }
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) TaskTag(org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Point(org.eclipse.swt.graphics.Point)

Example 4 with TaskTag

use of org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag in project webtools.sourceediting by eclipse.

the class WorkspaceTaskScanner method init.

private boolean init(IResource resource) {
    IProject project = getProject(resource);
    IPreferencesService preferencesService = Platform.getPreferencesService();
    IScopeContext[] lookupOrder = new IScopeContext[] { new ProjectScope(project), new InstanceScope(), new DefaultScope() };
    boolean proceed = preferencesService.getBoolean(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_ENABLE, false, lookupOrder);
    if (Logger.DEBUG_TASKSPREFS) {
        // $NON-NLS-1$ //$NON-NLS-2$
        System.out.println(getClass().getName() + " scan of " + resource.getFullPath() + ":" + proceed);
    }
    if (proceed) {
        String[] tags = StringUtils.unpack(preferencesService.getString(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_TAGS, null, lookupOrder));
        String[] priorities = StringUtils.unpack(preferencesService.getString(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_PRIORITIES, null, lookupOrder));
        String[] currentIgnoreContentTypeIDs = StringUtils.unpack(preferencesService.getString(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_CONTENTTYPES_IGNORED, null, lookupOrder));
        if (Logger.DEBUG_TASKSPREFS) {
            // $NON-NLS-1$
            System.out.print(getClass().getName() + " tags: ");
            for (int i = 0; i < tags.length; i++) {
                if (i > 0) {
                    // $NON-NLS-1$
                    System.out.print(",");
                }
                System.out.print(tags[i]);
            }
            System.out.println();
            // $NON-NLS-1$
            System.out.print(getClass().getName() + " priorities: ");
            for (int i = 0; i < priorities.length; i++) {
                if (i > 0) {
                    // $NON-NLS-1$
                    System.out.print(",");
                }
                System.out.print(priorities[i]);
            }
            System.out.println();
            // $NON-NLS-1$
            System.out.print(getClass().getName() + " ignored content types: ");
            for (int i = 0; i < currentIgnoreContentTypeIDs.length; i++) {
                if (i > 0) {
                    // $NON-NLS-1$
                    System.out.print(",");
                }
                System.out.print(currentIgnoreContentTypeIDs[i]);
            }
            System.out.println();
        }
        fCurrentIgnoreContentTypes = new IContentType[currentIgnoreContentTypeIDs.length];
        IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
        for (int i = 0; i < currentIgnoreContentTypeIDs.length; i++) {
            fCurrentIgnoreContentTypes[i] = contentTypeManager.getContentType(currentIgnoreContentTypeIDs[i]);
        }
        int max = Math.min(tags.length, priorities.length);
        fCurrentTaskTags = new TaskTag[max];
        for (int i = 0; i < max; i++) {
            int priority = TaskTag.PRIORITY_NORMAL;
            try {
                priority = Integer.parseInt(priorities[i]);
            } catch (NumberFormatException e) {
            // default to normal priority
            }
            fCurrentTaskTags[i] = new TaskTag(tags[i], priority);
        }
    }
    return proceed;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) TaskTag(org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) IProject(org.eclipse.core.resources.IProject) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IContentTypeManager(org.eclipse.core.runtime.content.IContentTypeManager)

Aggregations

TaskTag (org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Point (org.eclipse.swt.graphics.Point)2 StringTokenizer (com.ibm.icu.util.StringTokenizer)1 IProject (org.eclipse.core.resources.IProject)1 ProjectScope (org.eclipse.core.resources.ProjectScope)1 IContentTypeManager (org.eclipse.core.runtime.content.IContentTypeManager)1 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)1 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)1 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)1 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1