Java Code Examples for org.eclipse.swt.widgets.Display

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project bundlemaker, under directory /main/org.bundlemaker.core.ui.editor.dsm/src/org/bundlemaker/core/ui/editor/dsm/utils/.

Source file: Main.java

  19 
vote

public static void main(String args[]){
  Display d=new Display();
  final Shell shell=new Shell(d);
  shell.setSize(800,800);
  shell.setLayout(new BorderLayout());
  Canvas canvas=new Canvas(shell,SWT.NONE);
  draw(canvas,new DemoDsmViewModel(500));
  shell.open();
  while (!shell.isDisposed())   while (!d.readAndDispatch())   d.sleep();
}
 

Example 2

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/rca/.

Source file: Archimedes.java

  18 
vote

public Object start(IApplicationContext context) throws Exception {
  Display display=PlatformUI.createDisplay();
  try {
    int returnCode=PlatformUI.createAndRunWorkbench(display,new ApplicationWorkbenchAdvisor());
    if (returnCode == PlatformUI.RETURN_RESTART) {
      return IApplication.EXIT_RESTART;
    }
    return IApplication.EXIT_OK;
  }
  finally {
    display.dispose();
  }
}
 

Example 3

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/swt/.

Source file: TextEditor.java

  18 
vote

/** 
 * Opens the dialog for displaying. Disables the ability of the parent window to receive any events.
 */
public String open(){
  getParent().setEnabled(false);
  shell.open();
  Display display=parent.getDisplay();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch())     display.sleep();
  }
  return contents;
}
 

Example 4

From project BHT-FPA, under directory /patterns-codebeispiele/de.bht.fpa.examples.icashbox/src/de/bht/fpa/icashbox/ui/rcp/.

Source file: Application.java

  18 
vote

@Override public Object start(IApplicationContext context){
  Display display=PlatformUI.createDisplay();
  try {
    int returnCode=PlatformUI.createAndRunWorkbench(display,new ApplicationWorkbenchAdvisor());
    if (returnCode == PlatformUI.RETURN_RESTART) {
      return IApplication.EXIT_RESTART;
    }
    return IApplication.EXIT_OK;
  }
  finally {
    display.dispose();
  }
}
 

Example 5

From project BHT-FPA, under directory /template-codebeispiele/de.bht.fpa.mail.s000000.templates.tableviewerbuilder/src/de/bht/fpa/mail/s000000/templates/tableviewerbuilder/.

Source file: Main.java

  18 
vote

public static void main(String[] args){
  Display display=new Display();
  Shell shell=new Shell(display);
  shell.setLayout(new FillLayout());
  CityStatsView navigationView=new CityStatsView();
  navigationView.createPartControl(shell);
  shell.open();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
      display.sleep();
    }
  }
  display.dispose();
}
 

Example 6

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/structgen/.

Source file: AnnealingLogPane.java

  18 
vote

public AnnealingLogPane(Composite parent,int maxT,int maxS){
  super(parent,SWT.NO_SCROLL | SWT.NO_BACKGROUND | SWT.NO_FOCUS);
  this.setBackground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
  this.addPaintListener(this);
  this.graph=new AnnealingGraph(maxT,maxS,PREF_WIDTH,PREF_HEIGHT);
  this.xScale=20;
  this.yScale=20;
  Display display=getDisplay();
  this.backgroundColor=display.getSystemColor(SWT.COLOR_GRAY);
  this.gridColor=display.getSystemColor(SWT.COLOR_DARK_GRAY);
}
 

Example 7

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.specmol/src/net/bioclipse/specmol/editor/.

Source file: AssignmentPage.java

  18 
vote

/** 
 * propagates a change in the dirty state of the editor
 */
private void fireSetDirtyChanged(){
  Runnable r=new Runnable(){
    public void run(){
      firePropertyChange(PROP_DIRTY);
    }
  }
;
  Display fDisplay=getSite().getShell().getDisplay();
  fDisplay.asyncExec(r);
}
 

Example 8

From project bndtools, under directory /bndtools.core/src/bndtools/editor/project/.

Source file: AvailableBundlesPart.java

  18 
vote

public void run(){
  Display display=viewer.getControl().getDisplay();
  Runnable update=new Runnable(){
    public void run(){
      updatedFilter(searchStr);
    }
  }
;
  if (display.getThread() == Thread.currentThread())   update.run();
 else   display.asyncExec(update);
}
 

Example 9

From project bndtools, under directory /bndtools.core/src/org/bndtools/core/utils/swt/.

Source file: FilterPanelPart.java

  18 
vote

public void run(){
  Display display=panel.getDisplay();
  Runnable update=new Runnable(){
    public void run(){
      String newFilter=txtFilter.getText();
      setFilter(newFilter);
    }
  }
;
  if (display.getThread() == Thread.currentThread())   update.run();
 else   display.asyncExec(update);
}
 

Example 10

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/.

Source file: BPELUnitActivator.java

  18 
vote

/** 
 * Returns the current, or default display
 * @return
 */
public static Display getDisplay(){
  Display display=Display.getCurrent();
  if (display == null) {
    display=Display.getDefault();
  }
  return display;
}
 

Example 11

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/views/.

Source file: BPELUnitProgressBar.java

  18 
vote

private void paint(PaintEvent event){
  GC gc=event.gc;
  Display disp=getDisplay();
  Rectangle rect=getClientArea();
  gc.fillRectangle(rect);
  drawBevelRect(gc,rect.x,rect.y,rect.width - 1,rect.height - 1,disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
  setStatusColor(gc);
  fColorBarWidth=Math.min(rect.width - 2,fColorBarWidth);
  gc.fillRectangle(1,1,fColorBarWidth,rect.height - 2);
}
 

Example 12

From project ccw, under directory /ccw.util/src/java/ccw/util/.

Source file: DisplayUtil.java

  18 
vote

public static void asyncExec(Runnable r){
  Display display=PlatformUI.getWorkbench().getDisplay();
  if (!display.isDisposed()) {
    display.asyncExec(r);
  }
}
 

Example 13

From project ccw, under directory /ccw.util/src/java/ccw/util/.

Source file: DisplayUtil.java

  18 
vote

public static void syncExec(Runnable r){
  if (Display.getCurrent() == null) {
    Display display=PlatformUI.getWorkbench().getDisplay();
    if (!display.isDisposed()) {
      display.syncExec(r);
    }
  }
 else {
    r.run();
  }
}
 

Example 14

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/outline/.

Source file: CeylonLabelDecorator.java

  18 
vote

/** 
 * Returns the standard display to be used. The method first checks, if the thread calling this method has an associated display. If so, this display is returned. Otherwise the method returns the default display.
 */
public static Display getStandardDisplay(){
  Display display;
  display=Display.getCurrent();
  if (display == null)   display=Display.getDefault();
  return display;
}
 

Example 15

From project cilia-workbench, under directory /cilia-workbench-monitoring/src/fr/liglab/adele/cilia/workbench/monitoring/topologyview/.

Source file: TopologyView.java

  18 
vote

/** 
 * Reloads the model and refresh the viewer. This operation is performed in a separated thread, according to SWT specifications.
 */
public void reloadModel(){
  Display display=PlatformUI.getWorkbench().getDisplay();
  display.asyncExec(new Runnable(){
    @Override public void run(){
      reloadModelInternal();
    }
  }
);
}
 

Example 16

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.datatools.sqltools.tablewizard.simpledb/src/com/amazonaws/eclipse/datatools/sqltools/tablewizard/simpledb/ui/popup/actions/.

Source file: NewAttributeWizardAction.java

  17 
vote

@Override public void run(){
  if (!this.event.getSelection().isEmpty()) {
    try {
      Display display=Display.getCurrent();
      Object o=((IStructuredSelection)this.event.getSelection()).getFirstElement();
      Table table=findTable(o);
      Database db=findDatabase(o);
      if (table != null && db != null) {
        if (!closeEditors(table)) {
          return;
        }
        ConnectionInfo info=ConnectionUtil.getConnectionForEObject(db);
        if (info != null) {
          InputDialog dlg=new InputDialog(display.getActiveShell(),Messages.CreateNewAttribute,Messages.NewAttributeName,"",new IInputValidator(){
            public String isValid(            final String newText){
              return newText != null && newText.trim().length() > 0 ? null : Messages.EmptyAttributeName;
            }
          }
);
          if (dlg.open() == Window.OK) {
            performFinish(info,table.getName(),dlg.getValue(),o);
          }
        }
      }
    }
 catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
}
 

Example 17

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.datatools.sqltools.tablewizard.simpledb/src/com/amazonaws/eclipse/datatools/sqltools/tablewizard/simpledb/ui/popup/actions/.

Source file: NewDomainWizardAction.java

  17 
vote

@Override public void run(){
  if (!this.event.getSelection().isEmpty()) {
    try {
      Display display=Display.getCurrent();
      Object o=((IStructuredSelection)this.event.getSelection()).getFirstElement();
      Database db=findDatabase(o);
      if (db != null) {
        ConnectionInfo info=ConnectionUtil.getConnectionForEObject(db);
        if (info != null) {
          InputDialog dlg=new InputDialog(display.getActiveShell(),Messages.CreateNewDomain,Messages.NewDomainName,"",new IInputValidator(){
            public String isValid(            final String newText){
              return newText != null && newText.trim().length() > 0 ? null : Messages.EmptyDomainName;
            }
          }
);
          if (dlg.open() == Window.OK) {
            String domainName=dlg.getValue();
            if (!Pattern.matches("^[\\w\\.-]{3,255}+$",domainName)) {
              MessageDialog.openError(Display.getCurrent().getActiveShell(),Messages.InvalidDomainName,Messages.InvalidDomainNameDescription);
              return;
            }
            performFinish(info,domainName,db);
          }
        }
      }
    }
 catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
}
 

Example 18

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/views/.

Source file: NamespaceView.java

  17 
vote

/** 
 * This is a callback that will allow us to create the viewer and initialize it.
 */
@Override public void createPartControl(final Composite parent){
  final Composite child=new Composite(parent,SWT.NONE);
  child.setLayout(new GridLayout(2,false));
  combo=new Combo(child,SWT.NONE);
  combo.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,false,1,1));
  combo.addSelectionListener(new SelectionListener(){
    @Override public void widgetSelected(    SelectionEvent e){
      final int selected=combo.getSelectionIndex();
      if (selected == oldSelection) {
        return;
      }
      final NamespaceInfo ns=getSelectedNamespaceInfo(selected);
      if (ns != null) {
        final Display display=parent.getDisplay();
        display.asyncExec(new LoadData(ns,table));
        oldSelection=selected;
      }
    }
    @Override public void widgetDefaultSelected(    SelectionEvent e){
      widgetSelected(e);
    }
  }
);
  new Label(child,SWT.NONE);
  table=new Table(child,SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
  table.setLinesVisible(true);
  table.setHeaderVisible(true);
  table.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,1));
  final TableColumn fullColumn=new TableColumn(table,SWT.NONE);
  fullColumn.setWidth(212);
  fullColumn.setText("Value");
  new Label(child,SWT.NONE);
  new Label(child,SWT.NONE);
  makeActions();
  makeTableDoubleClick();
  contributeToActionBars();
  loadContent();
}
 

Example 19

From project Bio-PEPA, under directory /uk.ac.ed.inf.common.ui.plotview/src/uk/ac/ed/inf/common/ui/plotview/.

Source file: PlotViewPlugin.java

  17 
vote

/** 
 * Shows the chart in the Plot View
 * @param chart
 */
public void reveal(final IChart chart){
  Display display=PlatformUI.getWorkbench().getDisplay();
  display.syncExec(new Runnable(){
    public void run(){
      IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      if (window == null)       return;
      PlotView plotView=null;
      try {
        plotView=(PlotView)window.getActivePage().showView(PlotView.ID);
      }
 catch (      PartInitException e) {
        PlotViewPlugin.getDefault().getLog().log(e.getStatus());
      }
      plotView.reveal(chart);
    }
  }
);
}
 

Example 20

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/structgen/.

Source file: AnnealingLogPane.java

  17 
vote

public Image paintToImage(){
  Display display=getDisplay();
  Rectangle r=getBounds();
  Image image=new Image(display,r);
  GC gc=new GC(image);
  gc.setBackground(this.backgroundColor);
  gc.fillRectangle(r);
  gc.setForeground(this.gridColor);
  gc.drawRectangle(BORDER_WIDTH,BORDER_WIDTH,r.width - 2 * BORDER_WIDTH,r.height - 2 * BORDER_WIDTH);
  int lowerline=PREF_HEIGHT - BORDER_WIDTH + TICK_LENGTH;
  for (int w=BORDER_WIDTH; w < PREF_WIDTH; w+=xScale) {
    gc.drawLine(w,BORDER_WIDTH,w,lowerline);
  }
  int leftline=BORDER_WIDTH - TICK_LENGTH;
  for (int h=BORDER_WIDTH; h < PREF_WIDTH; h+=yScale) {
    gc.drawLine(leftline,h,PREF_WIDTH - BORDER_WIDTH,h);
  }
  AnnealingGraph.Point last=graph.createPoint(0,0);
  for (  AnnealingGraph.Point p : graph) {
    int h=PREF_HEIGHT * (PREF_WIDTH / PREF_HEIGHT);
    Color currentColor=colorRamp(display,h - p.x,0,h);
    gc.setForeground(currentColor);
    gc.drawLine(last.x + BORDER_WIDTH,last.y + BORDER_WIDTH,p.x + BORDER_WIDTH,p.y + BORDER_WIDTH);
    last=p;
    currentColor.dispose();
  }
  gc.dispose();
  return image;
}
 

Example 21

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/wizards/.

Source file: NewSpectrumDetailWizardPage.java

  17 
vote

/** 
 * Opens the dialog and returns the input
 * @return String
 */
public String open(NewSpectrumDetailWizardPage wizardpage){
  this.wizardpage=wizardpage;
  Shell shell=new Shell(getParent(),getStyle());
  shell.setText(getText());
  createContents(shell);
  shell.pack();
  shell.open();
  Display display=getParent().getDisplay();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
      display.sleep();
    }
  }
  return input;
}
 

Example 22

From project bundlemaker, under directory /main/org.bundlemaker.core.ui.editor.dsm/src/org/bundlemaker/core/ui/editor/dsm/utils/.

Source file: BorderLayout.java

  17 
vote

public static void main(String[] args){
  Display display=new Display();
  final Shell shell=new Shell(display);
  shell.setLayout(new BorderLayout());
  Button b1=new Button(shell,SWT.PUSH);
  b1.setText("North");
  b1.setLayoutData(BorderData.NORTH);
  Button b2=new Button(shell,SWT.PUSH);
  b2.setText("South");
  b2.setLayoutData(BorderData.SOUTH);
  Button b3=new Button(shell,SWT.PUSH);
  b3.setText("East");
  b3.setLayoutData(BorderData.EAST);
  Button b4=new Button(shell,SWT.PUSH);
  b4.setText("West");
  b4.setLayoutData(BorderData.WEST);
  Button b5=new Button(shell,SWT.PUSH);
  b5.setText("Center");
  b5.setLayoutData(BorderData.CENTER);
  shell.pack();
  shell.open();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
      display.sleep();
    }
  }
  display.dispose();
}
 

Example 23

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: ProblemMarkerManager.java

  17 
vote

private void fireChanges(final IResource[] changes,final boolean isMarkerChange){
  Display display=Display.getCurrent();
  if (display == null)   display=Display.getDefault();
  if (display != null && !display.isDisposed()) {
    display.asyncExec(new Runnable(){
      public void run(){
        Object[] listeners=fListeners.getListeners();
        for (int i=0; i < listeners.length; i++) {
          IProblemChangedListener curr=(IProblemChangedListener)listeners[i];
          curr.problemsChanged(changes,isMarkerChange);
        }
      }
    }
);
  }
}
 

Example 24

From project CIShell, under directory /clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/.

Source file: AbstractDialog.java

  17 
vote

/** 
 * Opens this AbstractDialog.
 * @return true if this AbstractDialog was closed by clicking the 'x' in the upper rightcorner of the window, signifying a cancellation, false if the dialog is exited otherwise.
 */
public boolean open(){
  if (shell.getDisplay().getThread() == Thread.currentThread()) {
    doOpen();
  }
 else {
    shell.getDisplay().syncExec(new Runnable(){
      public void run(){
        doOpen();
      }
    }
);
  }
  Display display=getParent().getDisplay();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
      display.sleep();
    }
  }
  return success;
}
 

Example 25

From project CIShell, under directory /clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/.

Source file: SWTGui.java

  17 
vote

/** 
 * @see org.cishell.service.guibuilder.GUI#openAndWait()
 */
public Dictionary<String,Object> openAndWait(){
  open();
  final Display display=shell.getDisplay();
  OpenAndWaitListener listener=new OpenAndWaitListener();
  setSelectionListener(listener);
  display.syncExec(new Runnable(){
    public void run(){
      while (!isClosed()) {
        if (!display.readAndDispatch())         display.sleep();
      }
    }
  }
);
  return listener.valuesEntered;
}
 

Example 26

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/actions/.

Source file: Visualize.java

  15 
vote

private boolean checkCytoscapeHome(){
  String cythome=getDefault().getCytoscapeHome();
  if (validateCytoscape(cythome) != FileState.OK) {
    final String title="Cytoscape disabled";
    final String msg="Cytoscape support is disabled.";
    Display.getDefault().syncExec(new Runnable(){
      @Override public void run(){
        okDialog(title,msg,ERROR);
      }
    }
);
    return false;
  }
  return true;
}
 

Example 27

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/actions/.

Source file: ComponentRelationsAction.java

  15 
vote

public void run(IAction action){
  WizardDialog dialog=null;
  try {
    CompRelationsWizard wizard=new CompRelationsWizard(model);
    dialog=new WizardDialog(Display.getDefault().getActiveShell(),wizard);
    dialog.open();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 28

From project bioclipse.vscreen, under directory /net.bioclipse.vscreen.ui/src/net/bioclipse/vscreen/ui/editors/.

Source file: VScreenEditor.java

  15 
vote

private void closeEditor(){
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      getSite().getPage().closeEditor(VScreenEditor.this,true);
    }
  }
);
}