org.eclipse.swt.events.MouseAdapter Java Examples

The following examples show how to use org.eclipse.swt.events.MouseAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ERDiagramMultiPageEditor.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void addMouseListenerToTabFolder() {
	CTabFolder tabFolder = (CTabFolder) this.getContainer();

	tabFolder.addMouseListener(new MouseAdapter() {

		@Override
		public void mouseDoubleClick(MouseEvent mouseevent) {
			Category category = getCurrentPageCategory();

			if (category != null) {
				CategoryNameChangeDialog dialog = new CategoryNameChangeDialog(
						PlatformUI.getWorkbench()
								.getActiveWorkbenchWindow().getShell(),
						category);

				if (dialog.open() == IDialogConstants.OK_ID) {
					ChangeCategoryNameCommand command = new ChangeCategoryNameCommand(
							diagram, category, dialog.getCategoryName());
					execute(command);
				}
			}

			super.mouseDoubleClick(mouseevent);
		}
	});
}
 
Example #2
Source File: AbstractSortableHeader.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void makeMouseAdapter() {
	this.sortMouseAdapter = new MouseAdapter() {

		public void mouseDown(MouseEvent e) {
			CLabel label = (CLabel) e.widget;
			int c = labels.indexOf(label);
			if (c != lastSortColumn) {
				sortDescending = null;
				sortIndicator = null;
			}
			lastSortColumn = c;
			sortOnColumn(c, toggleSortDirection());

			for (int i = 0; i < labels.size(); i++) {
				CLabel labelToSet = (CLabel) labels.get(i);
				if (i != c) {
					labelToSet.setImage(null);
				} else {
					labelToSet.setImage(sortIndicator);
				}
			}
		}
	};
}
 
Example #3
Source File: ERDiagramMultiPageEditor.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private void addMouseListenerToTabFolder() {
    final CTabFolder tabFolder = (CTabFolder) getContainer();

    tabFolder.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(final MouseEvent mouseevent) {

            final Category category = getPageCategory(getActivePage());

            if (category != null) {
                final CategoryNameChangeDialog dialog = new CategoryNameChangeDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), category);

                if (dialog.open() == IDialogConstants.OK_ID) {
                    final ChangeCategoryNameCommand command = new ChangeCategoryNameCommand(diagram, category, dialog.getCategoryName());
                    execute(command);
                }
            }

            super.mouseDoubleClick(mouseevent);
        }
    });
}
 
Example #4
Source File: ApiDocumentationResultView.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
public void showApiDocumentation(ApiDocumentation apiDocumentation) {
	lblLabel.setText(apiDocumentation.getLabel());
	lblLabel.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDown(MouseEvent e) {
			eventManager.invoke(l -> l.onOpenUrl());
		}
	});
	lblLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_LINK_FOREGROUND));
	lblLabel.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_HAND));

	textUrl.setText(apiDocumentation.getUrl());
	/*
	 * textUrl.addMouseListener(new MouseAdapter() { public void
	 * mouseDown(MouseEvent e) { textUrl.selectAll(); }; });
	 */
}
 
Example #5
Source File: ItemTable.java    From logbook with MIT License 6 votes vote down vote up
@Override
protected void createContents() {
    TableWrapper<ItemBean> table = this.addTable(this.shell)
            .setContentSupplier(CreateReportLogic::getItemTablecontent)
            .reload()
            .update();

    table.getTable().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDoubleClick(MouseEvent e) {
            ItemBean[] selection = table.getSelection(ItemBean[]::new);
            for (ItemBean item : selection) {
                ShipFilterDto filter = new ShipFilterDto();
                filter.itemname = item.getName();
                new ShipTable(ItemTable.this.getParent(), filter).open();
            }
        }
    });
}
 
Example #6
Source File: DropReportTable.java    From logbook with MIT License 6 votes vote down vote up
@Override
protected void createContents() {
    TableWrapper<DropReportBean> table = this.addTable(this.shell)
            .setContentSupplier(CreateReportLogic::getBattleResultContent)
            .reload()
            .update();

    table.getTable().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDoubleClick(MouseEvent e) {
            DropReportBean[] selection = table.getSelection(DropReportBean[]::new);
            for (DropReportBean item : selection) {
                new BattleDialog(DropReportTable.this.shell, item.getResult()).open();
            }
        }
    });
}
 
Example #7
Source File: HistogramView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void addLinkButtonListeners() {
    fLinkButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            fSelectionEndControl.setEnabled(fLinkState);
            fLinkState = !fLinkState;
            fLinkButton.redraw();
        }
    });

    fLinkButton.addPaintListener(e -> {
        if (fLinkState) {
            Rectangle r = fLinkButton.getBounds();
            r.x = -1;
            r.y = -1;
            e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
            e.gc.drawRectangle(r);
            r.x = 0;
            r.y = 0;
            e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_DARK_GRAY));
            e.gc.drawRectangle(r);
        }
    });
}
 
Example #8
Source File: ViewFilterDialog.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void createCLabels(Composite parent, Composite labels, String currentRegex) {
    CLabel filter = new CLabel(labels, SWT.BORDER);
    filter.setText(currentRegex);
    filter.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    filter.setBackground(fColorScheme.getColor(TimeGraphColorScheme.TOOL_BACKGROUND));
    filter.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e2) {
            deleteCLabel(parent, filter, e2);
        }
    });

    parent.layout();
    Rectangle bounds = parent.getShell().getBounds();
    Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle trim = parent.getShell().computeTrim(0, 0, size.x, size.y);
    parent.getShell().setBounds(bounds.x + bounds.width - trim.width, bounds.y + bounds.height - trim.height, trim.width, trim.height);
}
 
Example #9
Source File: StatechartDefinitionSection.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected Label createSwitchControl() {
	Label switchControl = new Label(this, SWT.PUSH);
	switchControl.setToolTipText(sectionExpanded ? HIDE_SECTION_TOOLTIP : SHOW_SECTION_TOOLTIP);
	switchControl.setImage(sectionExpanded ? StatechartImages.COLLAPSE.image() : StatechartImages.EXPAND.image());
	switchControl.setCursor(new Cursor(getDisplay(), SWT.CURSOR_HAND));
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(-1, -1).hint(MIN_SIZE[0], MIN_SIZE[1])
	.applyTo(switchControl);
	mouseListener = new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			toggleExpandState();
		}
	};
	switchControl.addMouseListener(mouseListener);
	return switchControl;
}
 
Example #10
Source File: AbstractEditorPropertySection.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void createHelpWidget(final Composite parent, final Control control, String helpId) {
	final ImageHyperlink helpWidget = toolkit.createImageHyperlink(parent, SWT.CENTER);
	Image defaultImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP);
	helpWidget.setImage(defaultImage);
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(helpWidget);
	helpWidget.setToolTipText(JFaceResources.getString(IDialogLabelKeys.HELP_LABEL_KEY));
	helpWidget.addMouseListener(new MouseAdapter() {
		public void mouseDown(MouseEvent e) {
			control.setFocus();
			PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
		}
	});
	GridDataFactory.fillDefaults().applyTo(helpWidget);
	helpWidget.setEnabled(true);
	setHelpContext(control, helpId);
}
 
Example #11
Source File: GenericInfoPopupDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public GenericInfoPopupDialog(Shell parentShell, String title, String message, final Runnable runnable)
{
	super(parentShell, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE | SWT.MODELESS, false, true, true, false, false,
			title, null);
	this.message = message;

	clickListener = new MouseAdapter()
	{

		@Override
		public void mouseDown(MouseEvent e)
		{
			if (runnable != null)
			{
				runnable.run();
			}
			close();
		}
	};
}
 
Example #12
Source File: HtmlBrowserEditor.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
	parent.setLayoutData(new GridData(GridData.FILL_BOTH));
	cmp = new Composite(parent, SWT.BORDER);
	GridLayoutFactory.fillDefaults().numColumns(1).applyTo(cmp);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(cmp);
	
	browser = new Browser(cmp, SWT.NONE);
	browser.setLayoutData(new GridData(GridData.FILL_BOTH));
	browser.setUrl(htmlUrl);

	browser.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDown(MouseEvent e) {
			getSite().getPart().setFocus();
			super.mouseDown(e);
		}
	});
}
 
Example #13
Source File: ERFluteMultiPageEditor.java    From erflute with Apache License 2.0 6 votes vote down vote up
private void addMouseListenerToTabFolder() {
    final CTabFolder tabFolder = (CTabFolder) getContainer();
    tabFolder.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDoubleClick(MouseEvent mouseevent) {
            final Category category = getCurrentPageCategory();
            if (category != null) {
                final CategoryNameChangeDialog dialog =
                        new CategoryNameChangeDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), category);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    final ChangeCategoryNameCommand command =
                            new ChangeCategoryNameCommand(diagram, category, dialog.getCategoryName());
                    execute(command);
                }
            }
            super.mouseDoubleClick(mouseevent);
        }
    });
}
 
Example #14
Source File: SquareButton.java    From swt-bling with MIT License 6 votes vote down vote up
public DefaultButtonClickHandler(final SquareButton button) {
  button.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseUp(MouseEvent e) {
      clicked();
    }
  });
  button.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent keyEvent) {
      switch (keyEvent.character) {
        case ' ':
        case '\r':
        case '\n':
          clicked();
          break;
        default:
          break;
      }
    }
  });
}
 
Example #15
Source File: SWTHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Return a Label that acts as a hyperlink
 * 
 * @param parent
 *            parent control
 * @param text
 *            text to display
 * @param lis
 *            hyperlink listener that is called on Mouse click
 * @return a Label
 */
public static Label createHyperlink(final Composite parent, final String text,
	final IHyperlinkListener lis){
	final Label ret = new Label(parent, SWT.NONE);
	ret.setText(text);
	ret.setForeground(UiDesk.getColorRegistry().get(Messages.SWTHelper_blue)); //$NON-NLS-1$
	ret.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDown(final MouseEvent e){
			if (lis != null) {
				lis.linkActivated(new HyperlinkEvent(ret, ret, text, e.stateMask));
			}
		}
		
	});
	return ret;
}
 
Example #16
Source File: ComponentHierarchyMenu.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance
 * 
 * @param hierarchy
 * @param controller
 */
public ComponentHierarchyMenu(ComponentHierarchy hierarchy,
                              Controller controller) {
    
    // Init
    this.hierarchy = hierarchy;
    this.controller = controller;
    this.controller.addListener(ModelPart.MODEL, this);
    this.createMenu();

    // Listen
    this.hierarchy.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(final MouseEvent e) {
            if (e.button == 3) {
                onMouseDown(ComponentHierarchyMenu.this.hierarchy.getControl().toDisplay(e.x, e.y));
            }
        }
    });
}
 
Example #17
Source File: ColorPicker.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public ColorPicker(Composite parent, final Color originalColor) {
    super(parent, SWT.SHADOW_OUT);
    if (originalColor == null) throw new IllegalArgumentException("null");
    this.selectedColor = originalColor;
    setImage(getColorImage(originalColor));
    addMouseListener(
            new MouseAdapter() {
                @Override
                public void mouseDown(MouseEvent e) {
                    ColorDialog dialog = new ColorDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM));
                    dialog.setRGB(selectedColor.getRGB());
                    RGB selected = dialog.open();
                    if (selected != null) {
                        update(selected);
                    }
                }
            });
}
 
Example #18
Source File: HtmlBrowserEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
	parent.setLayoutData(new GridData(GridData.FILL_BOTH));
	cmp = new Composite(parent, SWT.BORDER);
	GridLayoutFactory.fillDefaults().numColumns(1).applyTo(cmp);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(cmp);
	
	browser = new Browser(cmp, SWT.NONE);
	browser.setLayoutData(new GridData(GridData.FILL_BOTH));
	browser.setUrl(htmlUrl);

	browser.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDown(MouseEvent e) {
			getSite().getPart().setFocus();
			super.mouseDown(e);
		}
	});
}
 
Example #19
Source File: CustomFilterDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 初始化自定义过滤器列表
 * @param comp
 *            父容器
 */
private void initCustomFilterList(Composite comp) {
	customFilterList = new List(comp, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
	GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	gridData.widthHint = 110;
	gridData.heightHint = 250;
	customFilterList.setLayoutData(gridData);
	setListData(customFilterList, customFilters);
	customFilterList.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			edit();
		}

	});
}
 
Example #20
Source File: ColorPicker.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public ColorPicker(Composite parent, final Color originalColor) {
    super(parent, SWT.SHADOW_OUT);
    if (originalColor == null) throw new IllegalArgumentException("null");
    this.selectedColor = originalColor;
    setImage(getColorImage(originalColor));
    addMouseListener(
            new MouseAdapter() {
                @Override
                public void mouseDown(MouseEvent e) {
                    ColorDialog dialog = new ColorDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM));
                    dialog.setRGB(selectedColor.getRGB());
                    RGB selected = dialog.open();
                    if (selected != null) {
                        update(selected);
                    }
                }
            });
}
 
Example #21
Source File: CustomFilterDialog.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 初始化自定义过滤器列表
 * @param comp
 *            父容器
 */
private void initCustomFilterList(Composite comp) {
	customFilterList = new List(comp, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
	GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	gridData.widthHint = 110;
	gridData.heightHint = 250;
	customFilterList.setLayoutData(gridData);
	setListData(customFilterList, customFilters);
	customFilterList.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			edit();
		}

	});
}
 
Example #22
Source File: CustomMatchConditionDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 初始化已保存的条件列表
 * @param comp 父容器
 */
private void initCustomFilterList(Composite comp) {
	customFilterList = new List(comp, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
	customFilterList.setLayoutData(new GridData(GridData.FILL_BOTH));
	setListData(customFilterList, customFilters);
	customFilterList.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			// 调编辑的方法
			edit();
		}

	});
}
 
Example #23
Source File: TextFileImportWizardPage1.java    From hop with Apache License 2.0 5 votes vote down vote up
public void createControl( Composite parent ) {
  // create the composite to hold the widgets
  Composite composite = new Composite( parent, SWT.NONE );
  props.setLook( composite );

  FormLayout compLayout = new FormLayout();
  compLayout.marginHeight = Const.FORM_MARGIN;
  compLayout.marginWidth = Const.FORM_MARGIN;
  composite.setLayout( compLayout );

  MouseAdapter lsMouse = new MouseAdapter() {
    public void mouseDown( MouseEvent e ) {
      int s = getSize();
      setPageComplete( s > 0 );
    }
  };

  wTable = new TableDraw( composite, props, this, fields );
  wTable.setRows( rows );
  props.setLook( wTable );
  wTable.setFields( fields );
  fdTable = new FormData();
  fdTable.left = new FormAttachment( 0, 0 );
  fdTable.right = new FormAttachment( 100, 0 );
  fdTable.top = new FormAttachment( 0, 0 );
  fdTable.bottom = new FormAttachment( 100, 0 );
  wTable.setLayoutData( fdTable );
  wTable.addMouseListener( lsMouse );

  // set the composite as the control for this page
  setControl( composite );
}
 
Example #24
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createTableViewerComposite(final Composite parent,
        final TabbedPropertySheetWidgetFactory widgetFactory) {
    viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 70).create());
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(captions != null && !captions.isEmpty());

    provider = new ExpressionCollectionContentProvider();
    viewer.setContentProvider(provider);

    for (int i = 0; i < Math.max(minNbCol, getNbCols()); i++) {
        addColumnToViewer(i);
    }
    viewer.getTable().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            if (minNbRow == 0 || getNbRows() < minNbRow) {
                final Point point = new Point(e.x, e.y);
                final TableItem item = viewer.getTable().getItem(point);
                int currentWidth = 0;
                int colIndex = 0;
                for (int i = 0; i < viewer.getTable().getColumns().length; i++) {
                    final TableColumn c = viewer.getTable().getColumns()[i];
                    if (point.x >= currentWidth && point.x < currentWidth + c.getWidth()) {
                        colIndex = i;
                        break;
                    }
                    currentWidth = currentWidth + c.getWidth();
                }
                if (item == null && fixedRow) { //When fixedRow is true, no add button is present so we need to keep this behavior
                    addRow(colIndex);
                }
            }
        }
    });

}
 
Example #25
Source File: ColumnCategoriesDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void addListenersToTreeViewer() {
	treeViewer.getControl().addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			addSelected();
		}
	});
}
 
Example #26
Source File: BlockControlImage.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public BlockControlImage ( final ControlImage controlImage, final int style, final RegistrationManager registrationManager )
{
    super ( controlImage.getClientSpace (), style );

    this.controlImage = controlImage;

    this.registrationManager = registrationManager;

    setLayout ( new FillLayout () );

    this.icon = new Label ( this, SWT.NONE );
    this.icon.setImage ( getEmptyImage () );
    this.icon.addMouseListener ( new MouseAdapter () {
        @Override
        public void mouseUp ( final MouseEvent e )
        {
            toggleBlock ();
        }
    } );

    this.registrationManager.addListener ( this );

    final LocalResourceManager resources = new LocalResourceManager ( JFaceResources.getResources (), this.icon );

    this.boldFont = resources.createFont ( JFaceResources.getDefaultFontDescriptor ().withStyle ( SWT.BOLD ) );
    this.boldStyler = new Styler () {

        @Override
        public void applyStyles ( final TextStyle textStyle )
        {
            textStyle.font = BlockControlImage.this.boldFont;
        }
    };
}
 
Example #27
Source File: LinkLabel.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static void removeLinkedLabel(Label label ) {
	label.setCursor(null );
    label.setForeground(null);
    label.setData( null );
    MouseAdapter ml = (MouseAdapter)label.getData( MOUSE_LISTENER_KEY );
    if ( ml != null ){
    	label.removeMouseListener(ml);
    }
    ClipboardCopy.removeCopyToClipMenu( label );
}
 
Example #28
Source File: CheckBoxCellEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * As soon as the editor is activated, flip the current data value and commit it.<br/>
 * The repaint will pick up the new value and flip the image.
 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
	setCanonicalValue(originalCanonicalValue);

	checked = !checked;

	canvas = new Canvas(parent, SWT.NONE);

	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent paintEvent) {
			Rectangle bounds = canvas.getBounds();
			Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
			checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
		}

	});

	canvas.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			checked = !checked;
			canvas.redraw();
		}

	});

	commit(MoveDirectionEnum.NONE, false);

	return canvas;
}
 
Example #29
Source File: CheckBoxCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * As soon as the editor is activated, flip the current data value and commit it.<br/>
 * The repaint will pick up the new value and flip the image.
 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
	setCanonicalValue(originalCanonicalValue);

	checked = !checked;

	canvas = new Canvas(parent, SWT.NONE);

	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent paintEvent) {
			Rectangle bounds = canvas.getBounds();
			Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
			checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
		}

	});

	canvas.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			checked = !checked;
			canvas.redraw();
		}

	});

	commit(MoveDirectionEnum.NONE, false);

	return canvas;
}
 
Example #30
Source File: ColumnCategoriesDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private void addListenersToTreeViewer() {
	treeViewer.getControl().addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			addSelected();
		}
	});
}