Skip to content

Commit

Permalink
OPEN - task 72: Update Combat Turn view
Browse files Browse the repository at this point in the history
  • Loading branch information
UrsZeidler committed Aug 17, 2014
1 parent c470b75 commit ad85fd8
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package de.urszeidler.shr5.runtime.ui.dialogs;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class TimetrackingDialog extends TitleAreaDialog {
private DataBindingContext m_bindingContext;
private Scale scale;
private Label lblNewLabel;
private Label lblMinute;
private Label lblHoure;
private int factor;


/**
* Create the dialog.
*
* @param parentShell
*/
public TimetrackingDialog(Shell parentShell) {
super(parentShell);
}

/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
setMessage("Select the time tracking factor.");
setTitle("Time tracking");
Composite area = (Composite)super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new GridLayout(1, false));
container.setLayoutData(new GridData(GridData.FILL_BOTH));

Group grpTimeFactor = new Group(container, SWT.NONE);
grpTimeFactor.setLayout(new GridLayout(1, false));
grpTimeFactor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
grpTimeFactor.setText("Time factor");

scale = new Scale(grpTimeFactor, SWT.NONE);
scale.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
factor = scale.getSelection();
lblNewLabel.setText("==> " + SimpleDateFormat.getTimeInstance(SimpleDateFormat.LONG).format(new Date(scale.getSelection() * 1000L)));
lblMinute.setText("==> "
+ SimpleDateFormat.getTimeInstance(SimpleDateFormat.LONG).format(new Date(scale.getSelection() * 60 * 1000L)));
lblHoure.setText("==> "
+ SimpleDateFormat.getTimeInstance(SimpleDateFormat.LONG).format(new Date(scale.getSelection() * 3600 * 1000L)));
}
});
scale.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

lblNewLabel = new Label(grpTimeFactor, SWT.NONE);
lblNewLabel.setText("factor");

Group grpResult = new Group(container, SWT.NONE);
grpResult.setLayout(new GridLayout(1, false));
grpResult.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
grpResult.setText("Result");

lblMinute = new Label(grpResult, SWT.NONE);
lblMinute.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lblMinute.setText("minute");

lblHoure = new Label(grpResult, SWT.NONE);
lblHoure.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lblHoure.setText("hour");

return area;
}

/**
* Create contents of the button bar.
*
* @param parent
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
// m_bindingContext = initDataBindings();
}

/**
* Return the initial size of the dialog.
*/
@Override
protected Point getInitialSize() {
return new Point(450, 390);
}


public int getFactor() {
return factor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;
Expand Down Expand Up @@ -121,12 +120,12 @@
import de.urszeidler.shr5.ecp.binding.PathToImageConverter;
import de.urszeidler.shr5.ecp.dialogs.FeatureEditorDialogWert;
import de.urszeidler.shr5.ecp.dialogs.GenericEObjectDialog;
import de.urszeidler.shr5.ecp.dialogs.GenericEObjectDialogTitel;
import de.urszeidler.shr5.ecp.service.ScriptService;
import de.urszeidler.shr5.ecp.service.ScriptViewer;
import de.urszeidler.shr5.ecp.util.ShadowrunEditingTools;
import de.urszeidler.shr5.runtime.ui.dialogs.CheckInitaive;
import de.urszeidler.shr5.runtime.ui.dialogs.ProbeFinishedDialog;
import de.urszeidler.shr5.runtime.ui.dialogs.TimetrackingDialog;
import de.urszeidler.shr5.scripting.Placement;
import de.urszeidler.shr5.scripting.Script;
import de.urszeidler.shr5.scripting.ScriptingFactory;
Expand Down Expand Up @@ -172,7 +171,7 @@ protected IStatus run(IProgressMonitor monitor) {

if (plac != null)
if (plac.getActualDate() != null)
plac.setActualDate(new Date(plac.getActualDate().getTime() + 1000));
plac.setActualDate(new Date(plac.getActualDate().getTime() + (1000*timeTrackFactor)));
return Status.OK_STATUS;
}
}
Expand Down Expand Up @@ -250,6 +249,7 @@ public void notifyChanged(Notification notification) {
// protected boolean isTimetracking;
private TimeTracker timeTrackJob;

private int timeTrackFactor = 1;
private Label lblName;
private StyledText styledText;
private StyledText styledText_1;
Expand Down Expand Up @@ -490,6 +490,10 @@ public void widgetSelected(SelectionEvent e) {
timeTrackJob.isTimetracking = false;
tltmTimeTrackingItem.setText("start time tracking");
} else {
TimetrackingDialog timetrackingDialog = new TimetrackingDialog(getSite().getShell());
if(timetrackingDialog.open()==Dialog.CANCEL)
return;
timeTrackFactor = timetrackingDialog.getFactor();
timeTrackJob.isTimetracking = true;
timeTrackJob.schedule();
tltmTimeTrackingItem.setText("stop time tracking");
Expand Down

0 comments on commit ad85fd8

Please sign in to comment.