|
|
Re: PercentComplete invisible? [message #871238 is a reply to message #870104] |
Fri, 11 May 2012 14:36 |
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03401 seconds