Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » PercentComplete invisible?
PercentComplete invisible? [message #869763] Fri, 04 May 2012 04:58 Go to next message
fredi fuchs is currently offline fredi fuchs
Messages: 5
Registered: April 2012
Junior Member
Hello,

I have created a Gantt Chart with nebula. But I have a problem I didn't have information about the percentComplete.

How can I set this information in the Gantt chart to invisible? Is there any possibility?

The value 0% or 100% is not the best workaround for me.


Thanks in advanced.
Re: PercentComplete invisible? [message #870104 is a reply to message #869763] Sun, 06 May 2012 10:05 Go to previous messageGo to next message
fredi fuchs is currently offline fredi fuchs
Messages: 5
Registered: April 2012
Junior Member
nobody can help me Sad
Re: PercentComplete invisible? [message #871238 is a reply to message #870104] Fri, 11 May 2012 10:36 Go to previous message
Tim Seed is currently offline Tim Seed
Messages: 4
Registered: May 2012
Junior Member
I found a solution to the problem.

When you construct your GanttChart you can pass in an ISettings instance. Create your own custom settings by extending DefaultSettings, in here you can override many of the settings for the GanttChart. An example will explain this much better!

import java.util.Calendar;

import org.eclipse.nebula.widgets.ganttchart.DefaultSettings;
import org.eclipse.nebula.widgets.ganttchart.GanttChart;
import org.eclipse.nebula.widgets.ganttchart.GanttEvent;
import org.eclipse.nebula.widgets.ganttchart.ISettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * This Snippet shows how to override the default settings for a GanttChart.
 *
 */
public class SettingsExample {

	public static void main(String args []) {
		Display display = new Display ();
		Shell shell = new Shell (display);
		shell.setText("Gantt Chart - Settings Example");
		shell.setSize(600, 500);		
		shell.setLayout(new FillLayout());
		
		// Create your settings
		ISettings settings = new DefaultSettings() {
            @Override
            public boolean showDeleteMenuOption() {
                return false;
            }

            @Override
            public boolean showPropertiesMenuOption() {
                return false;
            }

            @Override
            public int getEventSpacer() {
                return 5;
            }

            @Override
            public String getTextDisplayFormat() {
                return "#name#";
            }
        };
        
		// Create a chart
		GanttChart ganttChart = new GanttChart(shell, SWT.NONE, settings);
		
		// Add some basic events
		Calendar sdEventOne = Calendar.getInstance();
		Calendar edEventOne = Calendar.getInstance();
		edEventOne.add(Calendar.DATE, 10);
		
		new GanttEvent(ganttChart, "Event 1", sdEventOne, edEventOne, 0);
		
		Calendar sdEventTwo = Calendar.getInstance();
		Calendar edEventTwo = Calendar.getInstance();
		sdEventTwo.add(Calendar.DATE, 6);
		edEventTwo.add(Calendar.DATE, 15);
		new GanttEvent(ganttChart, "Event 2", sdEventTwo, edEventTwo, 0);
		
		Calendar sdEventThree = Calendar.getInstance();
		Calendar edEventThree = Calendar.getInstance();
		sdEventThree.add(Calendar.DATE, -2);
		edEventThree.add(Calendar.DATE, 25);
		new GanttEvent(ganttChart, "Event 3", sdEventThree, edEventThree, 0);
		
		// Show chart
		shell.open();	
		
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
		
	}
}


There are lots of things you can override, in the example above I've shown how you can remove the 'Delete' and 'Properties' menu options from pop up menu, change the spacing between the events and set it so the label at the end of an event only shows the name (The default settings uses the format "#name# (#pc#%)"). I also set the percent of the event to 0 when constructing it to prevent it drawing the line showing the percent complete.

I hope this helps.
Previous Topic:Printing Gantt Chart - best approach?
Next Topic:GridTableViewer and sorting
Goto Forum:
  


Current Time: Thu Jul 24 06:53:27 EDT 2014

Powered by FUDForum. Page generated in 0.02011 seconds