List of usage examples for org.eclipse.jface.dialogs Dialog setBlockOnOpen
public void setBlockOnOpen(boolean shouldBlock)
open
method should block until the window closes. From source file:eu.udig.catalog.jgrass.activeregion.dialogs.FeatureChooserDialog.java
License:Open Source License
public void open(Shell parentShell, final int selectionType) { Dialog dialog = new Dialog(parentShell) { @Override//from w ww. ja v a 2s .c om protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Select vector map"); //$NON-NLS-1$ } @Override protected Point getInitialSize() { return new Point(280, 380); } @Override protected Control createDialogArea(Composite parent) { parentPanel = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) parentPanel.getLayout(); gLayout.numColumns = 1; active = new FeatureLayerTreeViewer(parentPanel, SWT.BORDER, selectionType); makeCheckPanel(); return parentPanel; } @Override protected void buttonPressed(int buttonId) { if (buttonId == OK) { Object tmp = null; try { tmp = ((List) active.getSelectedLayers()).get(0); } catch (Exception e) { e.printStackTrace(); selectedLayers = null; } if (tmp instanceof DataStore) { selectedLayers = (List<DataStore>) active.getSelectedLayers(); } else if (tmp instanceof UDIGSimpleFeatureStore) { List l = (List) active.getSelectedLayers(); List<DataStore> ll = new ArrayList<DataStore>(); for (Object object : l) { UDIGSimpleFeatureStore internal = (UDIGSimpleFeatureStore) object; ll.add(internal.getDataStore()); } selectedLayers = ll; } } else { selectedLayers = null; } super.buttonPressed(buttonId); } }; dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.udig.catalog.jgrass.core.ChooseCoordinateReferenceSystemDialog.java
License:Open Source License
public void open(Shell parentShell) { goGo = false;//from w ww . j a va2 s. c o m Dialog dialog = new Dialog(parentShell) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Choose CRS"); } // @Override // protected Point getInitialSize() { // return new Point(250, 250); // } @Override protected Control createDialogArea(Composite parent) { Composite comp = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) comp.getLayout(); gLayout.numColumns = 1; chooser = new CRSChooser(new Controller() { public void handleClose() { buttonPressed(OK); } public void handleOk() { buttonPressed(OK); } }); return chooser.createControl(parent); } @Override protected void buttonPressed(int buttonId) { if (buttonId == OK) { try { crs = chooser.getCRS(); } catch (Exception e) { } } close(); goGo = true; } }; dialog.setBlockOnOpen(true); dialog.open(); while (!goGo) { if (dialog.getShell().isDisposed()) { break; } if (Display.getCurrent().readAndDispatch()) { // dialog.getShell().getDisplay().readAndDispatch()) { continue; } if (goGo) { break; } try { Thread.sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } }
From source file:eu.udig.catalog.jgrass.operations.GrassReprojectAction.java
License:Open Source License
public void run(IAction action) { Display.getDefault().syncExec(new Runnable() { public void run() { shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); maps.clear();//from w ww . j a v a2 s . c om final List<?> toList = selection.toList(); try { for (Object object : toList) { if (object instanceof JGrassMapGeoResource) { JGrassMapGeoResource mr = (JGrassMapGeoResource) object; maps.add(mr); } } Dialog dialog = new Dialog(shell) { private Text locNameText; private Text mapsetNameText; private Text crsText; private Text xresText; private Text yresText; protected Control createDialogArea(Composite maxparent) { Composite parent = new Composite(maxparent, SWT.None); parent.setLayout(new GridLayout()); parent.setLayoutData(new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); // the location name group Group locNameGroup = new Group(parent, SWT.None); locNameGroup.setLayout(new GridLayout(2, false)); locNameGroup.setLayoutData(new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); locNameGroup.setText("new location name"); locNameText = new Text(locNameGroup, SWT.BORDER); locNameText .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER)); locNameText.setText("newLocation"); // the mapset name group Group mapsetNameGroup = new Group(parent, SWT.None); mapsetNameGroup.setLayout(new GridLayout(2, false)); mapsetNameGroup.setLayoutData(new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); mapsetNameGroup.setText("new mapset name"); mapsetNameText = new Text(mapsetNameGroup, SWT.BORDER); mapsetNameText .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER)); mapsetNameText.setText("newMapset"); // the crs choice group Group crsGroup = new Group(parent, SWT.None); crsGroup.setLayout(new GridLayout(2, false)); crsGroup.setLayoutData(new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); crsGroup.setText("choose the coordinate reference system for the new location"); crsText = new Text(crsGroup, SWT.BORDER); crsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER)); crsText.setEditable(false); final Button crsButton = new Button(crsGroup, SWT.BORDER); crsButton.setText(" Choose CRS "); crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { final ChooseCoordinateReferenceSystemDialog crsChooser = new ChooseCoordinateReferenceSystemDialog(); crsChooser.open(new Shell(Display.getDefault())); CoordinateReferenceSystem readCrs = crsChooser.getCrs(); if (readCrs == null) return; crsText.setText(readCrs.getName().toString()); crsText.setData(readCrs); } }); // the location name group Group resolutionGroup = new Group(parent, SWT.None); resolutionGroup.setLayout(new GridLayout(2, false)); resolutionGroup.setLayoutData(new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); resolutionGroup.setText("output map resolution"); String res = ""; if (maps.size() > 0) { try { JGrassRegion activeWindow = maps.get(0).getActiveWindow(); res = String.valueOf(activeWindow.getNSResolution()); } catch (IOException e1) { e1.printStackTrace(); } } Label xresLabel = new Label(resolutionGroup, SWT.NONE); xresLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); xresLabel.setText("X resolution"); xresText = new Text(resolutionGroup, SWT.BORDER); xresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER)); xresText.setText(res); Label yresLabel = new Label(resolutionGroup, SWT.NONE); yresLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); yresLabel.setText("Y resolution"); yresText = new Text(resolutionGroup, SWT.BORDER); yresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER)); yresText.setText(res); return parent; } protected void okPressed() { locationName = locNameText.getText(); if (locationName == null || locationName.length() < 1) { locationName = "newLocation"; } mapsetName = mapsetNameText.getText(); if (mapsetName == null || mapsetName.length() < 1) { mapsetName = "newMapset"; } xRes = xresText.getText(); yRes = yresText.getText(); Object crsData = crsText.getData(); if (crsData instanceof CoordinateReferenceSystem) { crs = (CoordinateReferenceSystem) crsData; } super.okPressed(); } }; dialog.setBlockOnOpen(true); open = dialog.open(); } catch (Exception e) { String message = "An error occurred while exporting the maps."; ExceptionDetailsDialog.openError("ERROR", message, IStatus.ERROR, JGrassPlugin.PLUGIN_ID, e); } } }); if (open == SWT.CANCEL) { return; } /* * run with backgroundable progress monitoring */ IRunnableWithProgress operation = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (locationName == null || mapsetName == null || crs == null || maps.size() < 1) { MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR); msgBox.setMessage("An error occurred in processing the user supplied data."); msgBox.open(); return; } /* * finally do some processing */ int mapNum = maps.size(); monitor.beginTask("Reprojecting maps to new Location...", mapNum); for (int i = 0; i < mapNum; i++) { JGrassMapGeoResource tmpMap = maps.get(i); JGrassMapEnvironment jgMEnv = new JGrassMapEnvironment(tmpMap.getMapFile()); try { /* * TODO get envelope from original region and reproject it. * then adapt it to the output resolution and * finally reproject the map on the new grid. */ JGrassRegion sourceRegion = jgMEnv.getActiveRegion(); CoordinateReferenceSystem sourceCrs = jgMEnv.getCoordinateReferenceSystem(); com.vividsolutions.jts.geom.Envelope sourceEnvelope = sourceRegion.getEnvelope(); MathTransform tr = CRS.findMathTransform(sourceCrs, crs); com.vividsolutions.jts.geom.Envelope outputEnvelope = JTS.transform(sourceEnvelope, tr); double west = outputEnvelope.getMinX(); double east = outputEnvelope.getMaxX(); double south = outputEnvelope.getMinY(); double north = outputEnvelope.getMaxY(); double xResolution = Double.parseDouble(xRes); double yResolution = Double.parseDouble(yRes); Coordinate tmp1 = new Coordinate(west, south); Coordinate tmp2 = new Coordinate(west + xResolution, south + yResolution); JTS.transform(tmp1, tmp1, tr); JTS.transform(tmp2, tmp2, tr); xResolution = tmp2.x - tmp1.x; yResolution = tmp2.y - tmp1.y; // if in metric, snap to integer bounds int intWest = (int) Math.floor(west); int intSouth = (int) Math.floor(south); if (west - intWest < xResolution && south - intSouth < yResolution) { west = intWest; south = intSouth; } double w = east - west; double h = north - south; // modify the envelope to be in the requested resolution double cols = Math.floor(w / xResolution) + 1.0; double rows = Math.floor(h / yResolution) + 1.0; double newEast = west + cols * xResolution; double newNorth = south + rows * yResolution; ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(west, newEast, south, newNorth, crs); GridToEnvelopeMapper g2eMapper = new GridToEnvelopeMapper(); g2eMapper.setEnvelope(referencedEnvelope); GridEnvelope2D gridEnvelope2D = new GridEnvelope2D(0, 0, (int) cols, (int) rows); g2eMapper.setGridRange(gridEnvelope2D); g2eMapper.setPixelAnchor(PixelInCell.CELL_CENTER); MathTransform gridToEnvelopeTransform = g2eMapper.createTransform(); GridGeometry outputGridGeometry = new GridGeometry2D(gridEnvelope2D, gridToEnvelopeTransform, crs); GridCoverage2D coverage2D = JGrassCatalogUtilities.getGridcoverageFromGrassraster(jgMEnv, sourceRegion); // GrassCoverageReadParam gcReadParam = new // GrassCoverageReadParam(sourceRegion); GridCoverage2D reprojected = (GridCoverage2D) Operations.DEFAULT.resample(coverage2D, crs, outputGridGeometry, Interpolation.getInstance(Interpolation.INTERP_BICUBIC)); JGrassRegion jgRegion = new JGrassRegion(west, newEast, south, newNorth, xResolution, yResolution); // GridCoverage2D coverage2D = tmp.read(null); // GridCoverage2D reprojected = (GridCoverage2D) // Operations.DEFAULT.resample( // coverage2D, crs); // Envelope2D envelope2D = reprojected.getEnvelope2D(); // JGrassRegion jgRegion = new JGrassRegion(envelope2D); if (i == 0) { // create the location structure File grassDbFile = jgMEnv.getLOCATION().getParentFile(); File newLocationFile = new File(grassDbFile, locationName); try { JGrassCatalogUtilities.createLocation(newLocationFile.getAbsolutePath(), crs, jgRegion); JGrassCatalogUtilities.createMapset(newLocationFile.getAbsolutePath(), mapsetName, null, jgRegion); } catch (Exception e) { // ignore this for now } mapsetFile = new File(newLocationFile, mapsetName); } File newMapFile = new File(mapsetFile, JGrassConstants.CELL + File.separator + tmpMap.getMapFile().getName()); JGrassCatalogUtilities.writeGridCoverageFromGrassraster(newMapFile, jgRegion, reprojected); } catch (Exception e) { e.printStackTrace(); } monitor.worked(1); } monitor.done(); JGrassCatalogUtilities.addServiceToCatalog( mapsetFile.getParent() + File.separator + JGrassCatalogUtilities.JGRASS_WORKSPACE_FILENAME, new NullProgressMonitor()); } }; PlatformGIS.runInProgressDialog("Reprojecting maps to new Location...", true, operation, true); }
From source file:eu.udig.imagegeoreferencing.DeleteImageTool.java
License:Open Source License
/** * Show a dialog with the error explaining why the delete would not process *///from w w w. ja v a 2 s . c o m private int showDialog(final boolean error) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final Dialog dialog = new Dialog(shell) { @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(1, true); container.setLayout(layout); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.widthHint = 450; container.setLayoutData(layoutData); Label descLabel = new Label(container, SWT.WRAP); if (error) { descLabel.setText(Messages.DeleteDialog_errordesc); } else { descLabel.setText(Messages.DeleteDialog_desc); } layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.verticalSpan = 1; layoutData.horizontalSpan = 1; descLabel.setLayoutData(layoutData); return container; } @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.DeleteDialog_title); GridLayout layout = new GridLayout(); layout.numColumns = 1; newShell.setLayout(layout); } }; dialog.setBlockOnOpen(true); int result = dialog.open(); return result; }
From source file:eu.udig.imagegeoreferencing.LoadImageTool.java
License:Open Source License
/** * Show the error dialog/*w ww.ja v a2 s . co m*/ */ private void showErrorDialog() { try { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final Dialog dialog = new Dialog(shell) { @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(1, true); container.setLayout(layout); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.widthHint = 450; container.setLayoutData(layoutData); Label descLabel = new Label(container, SWT.WRAP); descLabel.setText(Messages.LoadImageError_desc); layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.verticalSpan = 1; layoutData.horizontalSpan = 1; descLabel.setLayoutData(layoutData); return container; } @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.LoadImageError_title); GridLayout layout = new GridLayout(); layout.numColumns = 1; newShell.setLayout(layout); } }; dialog.setBlockOnOpen(true); dialog.open(); } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.udig.imagegeoreferencing.WarpImageTool.java
License:Open Source License
/** * Show a dialog with the error explaining why the warp would not process *//*from w ww . j a v a2 s .c o m*/ private void showErrorDialog() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final Dialog dialog = new Dialog(shell) { @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(1, true); container.setLayout(layout); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.widthHint = 450; container.setLayoutData(layoutData); Label descLabel = new Label(container, SWT.WRAP); descLabel .setText(MessageFormat.format(Messages.WarpDialog_desc, PlaceMarkersTool.MIN_PLACEMARKERS)); layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.verticalSpan = 1; layoutData.horizontalSpan = 1; descLabel.setLayoutData(layoutData); return container; } @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.WarpDialog_title); GridLayout layout = new GridLayout(); layout.numColumns = 1; newShell.setLayout(layout); } }; dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.udig.omsbox.view.widgets.GuiTextField.java
License:Open Source License
@Override public Control makeGui(Composite parent) { int cols = 1; if (isInFile || isInFolder || isOutFile || isOutFolder || isCrs || isMultiline) { cols = 2;/*w w w . ja va 2 s. c o m*/ } final boolean isFile = isInFile || isOutFile; final boolean isFolder = isInFolder || isOutFolder; parent = new Composite(parent, SWT.NONE); parent.setLayoutData(constraints); GridLayout layout = new GridLayout(cols, false); layout.marginWidth = 0; layout.marginHeight = 0; parent.setLayout(layout); if (!isMultiline) { text = new StyledText(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER); GridData textGD = new GridData(SWT.FILL, SWT.CENTER, true, false); textGD.widthHint = 100; text.setLayoutData(textGD); } else if (isMapcalc) { text = MapcalculatorUtils.createMapcalcPanel(parent, rows); } else { text = new StyledText(parent, SWT.MULTI | SWT.WRAP | SWT.LEAD | SWT.BORDER | SWT.V_SCROLL); GridData textGD = new GridData(SWT.FILL, SWT.FILL, true, true); textGD.verticalSpan = rows; textGD.widthHint = 100; text.setLayoutData(textGD); } if (data.fieldValue != null) { data.fieldValue = checkBackSlash(data.fieldValue, isFile); text.setText(data.fieldValue); } text.addModifyListener(this); text.addFocusListener(this); if (isMultiline) { for (int i = 0; i < rows; i++) { Label dummyLabel = new Label(parent, SWT.NONE); dummyLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); // dummyLabel.setText(""); } } if (isFile) { final Button browseButton = new Button(parent, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); browseButton.setText("..."); browseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(text.getShell(), isInFile ? SWT.OPEN : SWT.SAVE); String lastFolderChosen = OmsBoxPlugin.getDefault().getLastFolderChosen(); fileDialog.setFilterPath(lastFolderChosen); String path = fileDialog.open(); if (path == null || path.length() < 1) { text.setText(""); } else { path = checkBackSlash(path, isFile); text.setText(path); setDataValue(); } OmsBoxPlugin.getDefault().setLastFolderChosen(fileDialog.getFilterPath()); } }); } if (isFolder) { final Button browseButton = new Button(parent, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); browseButton.setText("..."); browseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { DirectoryDialog directoryDialog = new DirectoryDialog(text.getShell(), isInFolder ? SWT.OPEN : SWT.SAVE); String lastFolderChosen = OmsBoxPlugin.getDefault().getLastFolderChosen(); directoryDialog.setFilterPath(lastFolderChosen); String path = directoryDialog.open(); if (path == null || path.length() < 1) { text.setText(""); } else { path = checkBackSlash(path, isFile); text.setText(path); setDataValue(); } OmsBoxPlugin.getDefault().setLastFolderChosen(directoryDialog.getFilterPath()); } }); } if (isCrs) { // the crs choice group final Button crsButton = new Button(parent, SWT.BORDER); crsButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); crsButton.setText("..."); //$NON-NLS-1$ crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { Shell shell = new Shell(text.getShell(), SWT.SHELL_TRIM); Dialog dialog = new Dialog(shell) { private CRSChooser chooser; private CoordinateReferenceSystem crs; @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Choose CRS"); } @Override protected Control createDialogArea(Composite parent) { Composite comp = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) comp.getLayout(); gLayout.numColumns = 1; chooser = new CRSChooser(new Controller() { public void handleClose() { buttonPressed(OK); } public void handleOk() { buttonPressed(OK); } }); return chooser.createControl(parent); } @Override protected void buttonPressed(int buttonId) { if (buttonId == OK) { crs = chooser.getCRS(); try { String codeFromCrs = OmsBoxUtils.getCodeFromCrs(crs); text.setText(codeFromCrs); } catch (Exception e) { e.printStackTrace(); } } close(); } }; dialog.setBlockOnOpen(true); dialog.open(); } }); // initially set to map's crs IMap activeMap = ApplicationGIS.getActiveMap(); if (activeMap != null) { try { CoordinateReferenceSystem crs = activeMap.getViewportModel().getCRS(); String codeFromCrs = OmsBoxUtils.getCodeFromCrs(crs); text.setText(codeFromCrs); setDataValue(); } catch (Exception e) { e.printStackTrace(); } } } if (isNorthing || isEasting || isEastingNorthing) { addMapMouseListener(); } if (isProcessing()) { addRegionListener(); ILayer processingRegionLayer = OmsBoxPlugin.getDefault().getProcessingRegionMapGraphic(); IStyleBlackboard blackboard = processingRegionLayer.getStyleBlackboard(); Object object = blackboard.get(ProcessingRegionStyleContent.ID); if (object instanceof ProcessingRegionStyle) { ProcessingRegionStyle processingStyle = (ProcessingRegionStyle) object; setRegion(processingStyle); } } text.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (isNorthing || isEasting || isEastingNorthing) { removeMapMouseListener(); } if (isProcessing()) { removeRegionListener(); } } }); addDrop(); return text; }
From source file:msi.gama.gui.swt.SwtGui.java
License:Open Source License
private int dialog(final Dialog dialog) { run(new Runnable() { @Override//from ww w . j a v a 2 s.com public void run() { dialog.setBlockOnOpen(true); setReturnCode(dialog.open()); } }); return dialogReturnCode; }
From source file:net.refractions.udig.project.ui.internal.FeatureEditorLoader.java
License:Open Source License
public void open(Display display, ISelection selection) { SimpleFeature feature = (SimpleFeature) ((IStructuredSelection) selection).getFirstElement(); if (viewId != null) { try {// w ww. jav a 2 s . c o m IUDIGView view = (IUDIGView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(viewId, null, IWorkbenchPage.VIEW_VISIBLE); try { view.editFeatureChanged(feature); } catch (Throwable e) { UiPlugin.log(view + " threw an exception", e); //$NON-NLS-1$ } } catch (PartInitException e) { ProjectUIPlugin.log(null, e); } } else if (dialogPage != null) { try { IUDIGDialogPage page = (IUDIGDialogPage) definition.createExecutableExtension("dialogPage"); //$NON-NLS-1$ ToolContext toolContext; synchronized (this.processor.partListener) { toolContext = this.processor.partListener.currentContext; } page.setContext(toolContext); Dialog dialog = new FeatureEditorExtensionProcessor.EditorDialog( new Shell(display.getActiveShell(), SWT.RESIZE | SWT.PRIMARY_MODAL), page); dialog.setBlockOnOpen(false); page.setFeature(feature); dialog.open(); PlatformUI.getPreferenceStore().putValue(FeatureEditorExtensionProcessor.CURRENT_LOADER_ID, id); } catch (CoreException e) { ProjectUIPlugin.log(null, e); } } }
From source file:net.refractions.udig.project.ui.operations.example.MultiTargetOp.java
License:Open Source License
/** * @param display/* w ww .j a v a2 s . co m*/ * @param monitor * @param resource * @throws IOException */ private void op(final Display display, IProgressMonitor monitor, IGeoResource resource) throws IOException { IGeoResourceInfo info = resource.getInfo(monitor); Envelope bounds = info.getBounds(); final List<SummaryData> data = new ArrayList<SummaryData>(); String crs; if (info.getCRS() != null) crs = info.getCRS().getName().toString(); else crs = Messages.MultiTargetOp_unknown; crs = crs.replace('\n', ' '); try { data.add(new SummaryData(Messages.MultiTargetOp_name, info.getName())); data.add(new SummaryData(Messages.MultiTargetOp_title, info.getTitle())); data.add(new SummaryData(Messages.MultiTargetOp_bounds, LayerSummary.parseBounds(bounds))); data.add(new SummaryData(Messages.MultiTargetOp_crs, crs)); data.add(new SummaryData(Messages.MultiTargetOp_featuresource, resource.canResolve(FeatureSource.class))); data.add(new SummaryData(Messages.MultiTargetOp_featurestore, resource.canResolve(FeatureStore.class))); data.add(new SummaryData(Messages.MultiTargetOp_wms, resource.canResolve(WebMapServer.class))); boolean first = false; for (String word : info.getKeywords()) { if (first) data.add(new SummaryData(Messages.MultiTargetOp_keywords, word)); else data.add(new SummaryData(null, word)); } } catch (Exception e) { display.asyncExec(new Runnable() { public void run() { MessageDialog.openError(display.getActiveShell(), Messages.MultiTargetOp_resource_summary, Messages.MultiTargetOp_error); } }); ProjectUIPlugin.log(null, e); } display.asyncExec(new Runnable() { public void run() { Dialog d = new SummaryDialog(display.getActiveShell(), Messages.MultiTargetOp_resource_summary, data); d.setBlockOnOpen(true); d.open(); } }); }