use of org.eclipse.swt.events.DisposeListener in project yamcs-studio by yamcs.
the class OverviewOutlinePage method createControl.
@Override
public void createControl(Composite parent) {
overview = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(overview);
thumbnail = new ScrollableThumbnail((Viewport) rootEP.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(rootEP.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
disposeListener = new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (thumbnail != null) {
thumbnail.deactivate();
thumbnail = null;
}
}
};
rootEP.getViewer().getControl().addDisposeListener(disposeListener);
}
use of org.eclipse.swt.events.DisposeListener in project yamcs-studio by yamcs.
the class ContentProposalAdapter method initPopup.
/*
* Init & open the popup on asynchronous call.
*/
private void initPopup(ContentProposalList proposalList, boolean autoActivated) {
if (proposalList.fullLength() > 0) {
if (DEBUG) {
// $NON-NLS-1$
System.out.println("POPUP OPENED BY PRECEDING EVENT");
}
popup = new ContentProposalPopup(this, null, proposalList);
popup.open();
popup.getShell().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
popup = null;
}
});
internalPopupOpened();
notifyPopupOpened();
} else if (!autoActivated) {
getControl().getDisplay().beep();
}
}
use of org.eclipse.swt.events.DisposeListener in project cubrid-manager by CUBRID.
the class AboutDialog method createDialogArea.
/**
* Creates the page content
*
* @param parent the parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
final Cursor hand = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
final Cursor busy = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
setHandCursor(hand);
setBusyCursor(busy);
getShell().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
setHandCursor(null);
hand.dispose();
setBusyCursor(null);
busy.dispose();
}
});
// brand the about box if there is product info
Image aboutImage = null;
if (product != null && aboutImageDescriptor != null) {
aboutImage = aboutImageDescriptor.createImage();
}
Composite workArea = new Composite(parent, SWT.NONE);
GridLayout workLayout = new GridLayout();
workLayout.marginHeight = 0;
workLayout.marginWidth = 0;
workLayout.verticalSpacing = 0;
workLayout.horizontalSpacing = 0;
workArea.setLayout(workLayout);
workArea.setLayoutData(new GridData(GridData.FILL_BOTH));
// page group
Color background = JFaceColors.getBannerBackground(parent.getDisplay());
Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
Composite top = (Composite) super.createDialogArea(workArea);
// override any layout inherited from createDialogArea
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
top.setLayout(layout);
top.setLayoutData(new GridData(GridData.FILL_BOTH));
top.setBackground(background);
top.setForeground(foreground);
// the image & text
Composite topContainer = new Composite(top, SWT.NONE);
topContainer.setBackground(background);
topContainer.setForeground(foreground);
layout = new GridLayout();
layout.numColumns = (aboutImage == null || getItem() == null ? 1 : 2);
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
topContainer.setLayout(layout);
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
topContainer.setLayoutData(data);
// image on left side of dialog
if (aboutImage != null) {
Label imageLabel = new Label(topContainer, SWT.NONE);
imageLabel.setBackground(background);
imageLabel.setForeground(foreground);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.BEGINNING;
data.grabExcessHorizontalSpace = false;
imageLabel.setLayoutData(data);
imageLabel.setImage(aboutImage);
}
if (getItem() != null) {
Composite textContainer = new Composite(topContainer, SWT.NONE);
textContainer.setBackground(background);
textContainer.setForeground(foreground);
layout = new GridLayout();
layout.numColumns = 1;
textContainer.setLayout(layout);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.BEGINNING;
data.grabExcessHorizontalSpace = true;
textContainer.setLayoutData(data);
// text on the right
text = new StyledText(textContainer, SWT.MULTI | SWT.READ_ONLY);
text.setCaret(null);
text.setFont(parent.getFont());
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.BEGINNING;
data.grabExcessHorizontalSpace = true;
text.setText(getItem().getText());
text.setLayoutData(data);
text.setCursor(null);
text.setBackground(background);
text.setForeground(foreground);
setLinkRanges(text, getItem().getLinkRanges());
addListeners(text);
}
// horizontal bar
Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
bar.setLayoutData(data);
// add image buttons for bundle groups that have them
Composite bottom = (Composite) super.createDialogArea(workArea);
// override any layout inherited from createDialogArea
layout = new GridLayout();
bottom.setLayout(layout);
bottom.setLayoutData(new GridData(GridData.FILL_BOTH));
// spacer
bar = new Label(bottom, SWT.NONE);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
bar.setLayoutData(data);
return workArea;
}
use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class StyleTextCellRenderer method draw.
public void draw(GC gc, JaretTable jaretTable, ICellStyle cellStyle, Rectangle drawingArea, IRow row, IColumn column, boolean drawFocus, boolean selected, boolean printing) {
super.draw(gc, jaretTable, cellStyle, drawingArea, row, column, drawFocus, selected, printing);
// Color bg = gc.getBackground();
// Color fg = gc.getForeground();
Rectangle drect = drawBorder(gc, cellStyle, drawingArea, printing);
Rectangle rect = applyInsets(drect);
String s = convertValue(row, column);
if (s != null && strStyleText != null && !strStyleText.equals("")) {
if (selected && !printing) {
Color color = ColorManager.getColorManager(Display.getCurrent()).getColor(new RGB(218, 218, 218));
gc.setBackground(color);
} else {
gc.setBackground(getBackgroundColor(cellStyle, printing));
}
if (textLayout == null) {
textLayout = new TextLayout(gc.getDevice());
jaretTable.getParent().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
textLayout.dispose();
}
});
}
textLayout.setOrientation(jaretTable.getOrientation());
textLayout.setText(s);
textLayout.setFont(gc.getFont());
textLayout.setWidth(rect.width);
if (blnIsApplyRegular) {
Pattern pattern = null;
if (blnIsCaseSensitive) {
pattern = Pattern.compile(strStyleText);
} else {
pattern = Pattern.compile(strStyleText, Pattern.CASE_INSENSITIVE);
}
Matcher matcher = pattern.matcher(s);
while (matcher.find()) {
textLayout.setStyle(style, matcher.start(), matcher.end() - 1);
}
gc.fillRectangle(rect);
textLayout.draw(gc, rect.x, rect.y);
gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
} else {
int index = -1;
if (!blnIsCaseSensitive) {
index = s.toUpperCase().indexOf(strStyleText.toUpperCase());
} else {
index = s.indexOf(strStyleText);
}
if (index != -1) {
for (int i = 1; i < s.length(); i++) {
int j = TextUtil.indexOf(s, strStyleText, i, blnIsCaseSensitive);
if (j != -1) {
textLayout.setStyle(style, j, j + strStyleText.length() - 1);
} else {
break;
}
}
gc.fillRectangle(rect);
textLayout.draw(gc, rect.x, rect.y);
gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
}
}
}
}
use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class ProjectSettingDialog method createHelpControl.
/**
* 添加帮助按钮
* 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#project-setting", 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;
}
Aggregations