Showing posts with label snippet. Show all posts
Showing posts with label snippet. Show all posts

Monday, May 6, 2013

Notify-send Java Class for Linux

Hi folk,

I will share this Java class that I use to display tools information on my Linux operating system.

Sample:




Notify-send is a little, simple On-Screen Display application. It uses the notify bubble pop-up Linux system.

 /**
 * Utils
 *
 * Created on Nov 25, 2010
 *
 * @version 1.0
 * @author Jorge Iglesias, (jorge.iglesias@es.ibm.com)
 *
 * @ Copyright IBM Software Services Rational Spain. 2011. All rights reserved.
 */

package com.ibm.issr.util.linux;

import java.io.IOException;

public class Notify {
  
    public static void sendInfo(String text) {
        send("info",text);
    }

    public static void sendError(String text) {
        send("error",text);
    }

    private static void send(String type, String text) {
        String[] command = new String[] { "notify-send", "-t", "20000", "-i", type, text };
        try {
            Runtime.getRuntime().exec(command);
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
    }
}


Wednesday, September 19, 2012

Get Parent workitem on save precondition

Nice snippet found in jazz.net!!
 
public IWorkItemHandle findParent(AdvisableOperation operation) throws TeamRepositoryException {
Object data = operation.getOperationData();

if (data instanceof ISaveParameter) // from Workitem -> save operation
{
ISaveParameter saveParameter = (ISaveParameter) data;
IWorkItemReferences ref = saveParameter.getNewReferences();
List<IEndPointDescriptor> types = ref.getTypes();
for (IEndPointDescriptor desc : types)
{
if (desc.getId().equalsIgnoreCase("parent")) // "parent" is an RTC/Jazz string ID
{
List<IReference> refList = ref.getReferences(desc);

if (refList.size() > 0)
{
IReference iRef = refList.get(0); // Only one parent
Object obj = iRef.resolve();
if (obj instanceof IWorkItemHandle) // Only looking for Workitems.
{
return (IWorkItemHandle) obj;
}
else
return null;
}
else
return null;
}
}
}
return null;
} 

The WorkItemEndPoints are only a subset. 

Example for requirements: Use the WorkItemLinkTypes and the ILinkRegistry.
ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.IMPLEMENTS_REQUIREMENT).getTargetEndPointDescriptor()