use of org.eclipse.swt.program.Program in project dbeaver by serge-rider.
the class ProgramInfo method getProgram.
public static ProgramInfo getProgram(IResource resource) {
if (resource instanceof IFile) {
final String fileExtension = CommonUtils.notEmpty(resource.getFileExtension());
ProgramInfo programInfo = programMap.get(fileExtension);
if (programInfo == null) {
Program program = Program.findProgram(fileExtension);
programInfo = new ProgramInfo(program);
if (program != null) {
final ImageData imageData = program.getImageData();
if (imageData != null) {
programInfo.image = new DBIconBinary(program.getName(), imageData);
}
}
programMap.put(fileExtension, programInfo);
}
return programInfo.program == null ? null : programInfo;
}
return null;
}
use of org.eclipse.swt.program.Program in project cubrid-manager by CUBRID.
the class BLOBCellPopupDialog method loadProgramMenu.
/**
*
* Load the program menus
*
*/
private void loadProgramMenu() {
if (programMenu != null) {
programMenu.dispose();
}
programMenu = new Menu(getShell(), SWT.POP_UP);
String fileType = getFileType();
// Load the default application
if (fileType != null && fileType.trim().length() > 0) {
final Program program = Program.findProgram(fileType);
if (program != null && program.getName() != null && program.getName().trim().length() > 0) {
programMenuItem = new MenuItem(programMenu, SWT.NONE);
programMenuItem.setText(program.getName());
ImageData imageData = program.getImageData();
if (imageData != null) {
final Image image = new Image(getShell().getDisplay(), imageData);
programMenuItem.setImage(image);
programMenu.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
image.dispose();
}
});
}
programMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
openByExternalProgram(program);
}
});
new MenuItem(programMenu, SWT.SEPARATOR);
}
}
// Load the other applications
Program[] programs = Program.getPrograms();
if (programs != null) {
for (final Program program : programs) {
String name = program.getName();
if (name == null || name.trim().length() == 0) {
continue;
}
if (programMenuItem != null && programMenuItem.getText().equals(name.trim())) {
continue;
}
final MenuItem selectProgramMenuItem = new MenuItem(programMenu, SWT.NONE);
selectProgramMenuItem.setText(name);
ImageData imageData = program.getImageData();
if (imageData != null) {
final Image image = new Image(getShell().getDisplay(), imageData);
selectProgramMenuItem.setImage(image);
selectProgramMenuItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
image.dispose();
}
});
}
selectProgramMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
openByExternalProgram(program);
}
});
}
}
Rectangle rect = openByExternalBtn.getBounds();
Point pt = new Point(rect.x, rect.y + rect.height);
pt = openByExternalBtn.getParent().toDisplay(pt);
programMenu.setLocation(pt);
programMenu.setVisible(true);
}
use of org.eclipse.swt.program.Program in project cubrid-manager by CUBRID.
the class BLOBCellPopupDialog method openByExternalProgram.
/**
*
* Open the external program
*
*/
private void openByExternalProgram() {
if (setNullBtn.getSelection() || currValue == null) {
return;
}
String fileType = getFileType();
if (fileType != null && fileType.trim().length() > 0) {
final Program program = Program.findProgram(fileType);
if (program != null) {
openByExternalProgram(program);
return;
}
}
loadProgramMenu();
}
Aggregations