use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.
the class AutoResizeRowAction method run.
public void run(NatTable natTable, MouseEvent event) {
if (gc == null) {
gc = new GC(natTable);
natTable.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
gc.dispose();
}
});
}
Point clickPoint = new Point(event.x, event.y);
int row = CellEdgeDetectUtil.getRowPositionToResize(natTable, clickPoint);
InitializeAutoResizeRowsCommand command = new InitializeAutoResizeRowsCommand(natTable, row, natTable.getConfigRegistry(), gc);
natTable.doCommand(command);
}
use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.
the class ColumnResizeCursorAction method run.
public void run(NatTable natTable, MouseEvent event) {
if (columnResizeCursor == null) {
columnResizeCursor = new Cursor(Display.getDefault(), SWT.CURSOR_SIZEWE);
natTable.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
columnResizeCursor.dispose();
}
});
}
natTable.setCursor(columnResizeCursor);
}
use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.
the class ImportProjectHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ImportProjectWizard wizard = new ImportProjectWizard();
TSWizardDialog dialog = new TSWizardDialog(window.getShell(), wizard) {
/**
* 添加帮助按钮
* robert 2012-09-06
*/
@Override
protected Control createHelpControl(Composite parent) {
// ROBERTHELP 导入项目
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch07s03.html#import-project", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
};
dialog.setHelpAvailable(true);
dialog.open();
return null;
}
use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.
the class PreMachineTranslationDialog method createHelpControl.
// TODO :帮助按钮URL需要修改
/**
* 添加帮助按钮 robert 2012-09-06
*/
@Override
protected Control createHelpControl(Composite parent) {
// ROBERTHELP 预翻译
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03.html?#prestore-mt", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
use of org.eclipse.swt.events.DisposeEvent in project archi by archimatetool.
the class SaveCanvasAsTemplateWizardPage method createControl.
@Override
public void createControl(Composite parent) {
GridData gd;
Label label;
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout());
setControl(container);
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, HELP_ID);
Group fileComposite = new Group(container, SWT.NULL);
fileComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout layout = new GridLayout(3, false);
fileComposite.setLayout(layout);
label = new Label(fileComposite, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_2);
fFileTextField = new Text(fileComposite, SWT.BORDER | SWT.SINGLE);
fFileTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
File newFile = new File(CURRENT_FOLDER, Messages.SaveCanvasAsTemplateWizardPage_3 + CanvasTemplateManager.CANVAS_TEMPLATE_FILE_EXTENSION);
fFileTextField.setText(newFile.getPath());
// Single text control so strip CRLFs
UIUtils.conformSingleTextControl(fFileTextField);
fFileTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateFields();
}
});
Button fileButton = new Button(fileComposite, SWT.PUSH);
fileButton.setText(Messages.SaveCanvasAsTemplateWizardPage_4);
fileButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
File file = chooseFile();
if (file != null) {
fFileTextField.setText(file.getPath());
CURRENT_FOLDER = file.getParentFile();
}
}
});
Group fieldGroup = new Group(container, SWT.NULL);
fieldGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
layout = new GridLayout(2, false);
fieldGroup.setLayout(layout);
label = new Label(fieldGroup, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_5);
fNameTextField = new Text(fieldGroup, SWT.BORDER | SWT.SINGLE);
fNameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (StringUtils.isSet(fCanvasModel.getName())) {
fNameTextField.setText(fCanvasModel.getName());
}
// Single text control so strip CRLFs
UIUtils.conformSingleTextControl(fNameTextField);
fNameTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateFields();
}
});
label = new Label(fieldGroup, SWT.NULL);
label.setText(Messages.SaveCanvasAsTemplateWizardPage_6);
gd = new GridData(SWT.NULL, SWT.TOP, false, false);
label.setLayoutData(gd);
fDescriptionTextField = new Text(fieldGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 120;
fDescriptionTextField.setLayoutData(gd);
if (StringUtils.isSet(fCanvasModel.getDocumentation())) {
fDescriptionTextField.setText(fCanvasModel.getDocumentation());
}
// Thumbnail
Group thumbsGroup = new Group(container, SWT.NULL);
thumbsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
layout = new GridLayout(2, false);
thumbsGroup.setLayout(layout);
fButtonIncludeThumbnail = new Button(thumbsGroup, SWT.CHECK);
fButtonIncludeThumbnail.setText(Messages.SaveCanvasAsTemplateWizardPage_7);
fButtonIncludeThumbnail.setSelection(true);
fButtonIncludeThumbnail.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fPreviewLabel.setEnabled(fButtonIncludeThumbnail.getSelection());
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fButtonIncludeThumbnail.setLayoutData(gd);
label = new Label(thumbsGroup, SWT.NULL);
// $NON-NLS-1$
label.setText(Messages.SaveCanvasAsTemplateWizardPage_8 + " ");
gd = new GridData(SWT.NULL, SWT.TOP, false, false);
label.setLayoutData(gd);
fPreviewLabel = new Label(thumbsGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 120;
gd.widthHint = 150;
fPreviewLabel.setLayoutData(gd);
// Dispose of the image here not in the main dispose() method because if the help system is showing then
// the TrayDialog is resized and this label is asked to relayout.
fPreviewLabel.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
disposePreviewImage();
}
});
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
TemplateUtils.createThumbnailPreviewImage(fCanvasModel, fPreviewLabel);
}
});
fPreviewLabel.addControlListener(new ControlAdapter() {
int oldTime;
@Override
public void controlResized(ControlEvent e) {
if (e.time - oldTime > 10) {
disposePreviewImage();
TemplateUtils.createThumbnailPreviewImage(fCanvasModel, fPreviewLabel);
}
oldTime = e.time;
}
});
validateFields();
}
Aggregations