| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | * Sebastian Davids <sdavids@gmx.de> - bug 77332 - [Markers] Add task dialog improvements |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.eclipse.ui.views.markers.internal; |
| 14 | |
| 15 | import java.util.HashMap; |
| 16 | import java.util.Map; |
| 17 | |
| 18 | import org.eclipse.core.commands.ExecutionException; |
| 19 | import org.eclipse.core.commands.operations.IUndoableOperation; |
| 20 | import org.eclipse.core.resources.IMarker; |
| 21 | import org.eclipse.core.resources.IResource; |
| 22 | import org.eclipse.core.resources.ResourcesPlugin; |
| 23 | import org.eclipse.core.runtime.CoreException; |
| 24 | import org.eclipse.core.runtime.IPath; |
| 25 | import org.eclipse.jface.dialogs.Dialog; |
| 26 | import org.eclipse.jface.dialogs.ErrorDialog; |
| 27 | import org.eclipse.jface.dialogs.IDialogConstants; |
| 28 | import org.eclipse.jface.dialogs.IDialogSettings; |
| 29 | import org.eclipse.jface.dialogs.TrayDialog; |
| 30 | import org.eclipse.osgi.util.NLS; |
| 31 | import org.eclipse.swt.SWT; |
| 32 | import org.eclipse.swt.events.ModifyEvent; |
| 33 | import org.eclipse.swt.events.ModifyListener; |
| 34 | import org.eclipse.swt.layout.GridData; |
| 35 | import org.eclipse.swt.layout.GridLayout; |
| 36 | import org.eclipse.swt.widgets.Composite; |
| 37 | import org.eclipse.swt.widgets.Control; |
| 38 | import org.eclipse.swt.widgets.Label; |
| 39 | import org.eclipse.swt.widgets.Shell; |
| 40 | import org.eclipse.swt.widgets.Text; |
| 41 | import org.eclipse.ui.PlatformUI; |
| 42 | import org.eclipse.ui.ide.undo.CreateMarkersOperation; |
| 43 | import org.eclipse.ui.ide.undo.UpdateMarkersOperation; |
| 44 | import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; |
| 45 | import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; |
| 46 | |
| 47 | /** |
| 48 | * Shows the properties of a new or existing marker |
| 49 | * |
| 50 | * In 3.3, this class was refactored to allow pre-existing public dialog classes |
| 51 | * to share the implementation. Note that certain methods are exposed as API |
| 52 | * in public subclasses, so changes to the methods in this class should be |
| 53 | * treated carefully as they may affect API methods in subclasses. The specific |
| 54 | * methods affected are documented in the method comment. |
| 55 | */ |
| 56 | public class DialogMarkerProperties extends TrayDialog { |
| 57 | |
| 58 | private static final String DIALOG_SETTINGS_SECTION = "DialogMarkerPropertiesDialogSettings"; //$NON-NLS-1$ |
| 59 | |
| 60 | /** |
| 61 | * The marker being shown, or <code>null</code> for a new marker |
| 62 | */ |
| 63 | private IMarker marker = null; |
| 64 | |
| 65 | /** |
| 66 | * The resource on which to create a new marker |
| 67 | */ |
| 68 | private IResource resource = null; |
| 69 | |
| 70 | /** |
| 71 | * The type of marker to be created |
| 72 | */ |
| 73 | private String type = IMarker.MARKER; |
| 74 | |
| 75 | /** |
| 76 | * The initial attributes to use when creating a new marker |
| 77 | */ |
| 78 | private Map initialAttributes = null; |
| 79 | |
| 80 | /** |
| 81 | * The text control for the Description field. |
| 82 | */ |
| 83 | private Text descriptionText; |
| 84 | |
| 85 | /** |
| 86 | * The control for the Creation Time field. |
| 87 | */ |
| 88 | private Label creationTime; |
| 89 | |
| 90 | /** |
| 91 | * The text control for the Resource field. |
| 92 | */ |
| 93 | private Text resourceText; |
| 94 | |
| 95 | /** |
| 96 | * The text control for the Folder field. |
| 97 | */ |
| 98 | private Text folderText; |
| 99 | |
| 100 | /** |
| 101 | * The text control for the Location field. |
| 102 | */ |
| 103 | private Text locationText; |
| 104 | |
| 105 | /** |
| 106 | * Dirty flag. True if any changes have been made. |
| 107 | */ |
| 108 | private boolean dirty; |
| 109 | |
| 110 | private String title; |
| 111 | |
| 112 | /** |
| 113 | * The name used to describe the specific kind of marker. Used when |
| 114 | * creating an undo command for the dialog, so that a specific name such |
| 115 | * as "Undo Create Task" or "Undo Modify Bookmark" can be used. |
| 116 | */ |
| 117 | private String markerName; |
| 118 | |
| 119 | /** |
| 120 | * Creates the dialog. By default this dialog creates a new marker. To set |
| 121 | * the resource and initial attributes for the new marker, use |
| 122 | * <code>setResource</code> and <code>setInitialAttributes</code>. To |
| 123 | * show or modify an existing marker, use <code>setMarker</code>. |
| 124 | * |
| 125 | * @param parentShell |
| 126 | * the parent shell |
| 127 | */ |
| 128 | public DialogMarkerProperties(Shell parentShell) { |
| 129 | super(parentShell); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Creates the dialog. By default this dialog creates a new marker. To set |
| 134 | * the resource and initial attributes for the new marker, use |
| 135 | * <code>setResource</code> and <code>setInitialAttributes</code>. To |
| 136 | * show or modify an existing marker, use <code>setMarker</code>. |
| 137 | * |
| 138 | * @param parentShell |
| 139 | * the parent shell |
| 140 | * @param title |
| 141 | * the title of the dialog |
| 142 | */ |
| 143 | public DialogMarkerProperties(Shell parentShell, String title) { |
| 144 | super(parentShell); |
| 145 | this.title = title; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Creates the dialog. By default this dialog creates a new marker. To set |
| 150 | * the resource and initial attributes for the new marker, use |
| 151 | * <code>setResource</code> and <code>setInitialAttributes</code>. To |
| 152 | * show or modify an existing marker, use <code>setMarker</code>. |
| 153 | * |
| 154 | * @param parentShell |
| 155 | * the parent shell |
| 156 | * @param title |
| 157 | * the title of the dialog |
| 158 | * @param markerName |
| 159 | * the name used to describe the specific kind of marker shown |
| 160 | * |
| 161 | * @since 3.3 |
| 162 | */ |
| 163 | public DialogMarkerProperties(Shell parentShell, String title, String markerName) { |
| 164 | super(parentShell); |
| 165 | this.title = title; |
| 166 | this.markerName = markerName; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Sets the marker to show or modify. |
| 171 | * <p>IMPORTANT: Although this class is internal, there are public |
| 172 | * subclasses that expose this method as API. Changes in |
| 173 | * this implementation should be treated as API changes. |
| 174 | * |
| 175 | * @param marker the marker, or <code>null</code> to create a new marker |
| 176 | * |
| 177 | * @since 3.3 |
| 178 | */ |
| 179 | public void setMarker(IMarker marker) { |
| 180 | this.marker = marker; |
| 181 | if (marker != null) { |
| 182 | try { |
| 183 | type = marker.getType(); |
| 184 | } catch (CoreException e) { |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Returns the marker being created or modified. |
| 191 | * For a new marker, this returns <code>null</code> until |
| 192 | * the dialog returns, but is non-null after. |
| 193 | * <p>IMPORTANT: Although this method is protected and the class is |
| 194 | * internal, there are public subclasses that expose this method as API. |
| 195 | * Changes in this implementation should be treated as API changes. |
| 196 | * |
| 197 | * @return the marker |
| 198 | * |
| 199 | * @since 3.3 |
| 200 | */ |
| 201 | protected IMarker getMarker() { |
| 202 | return marker; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Sets the resource to use when creating a new task. |
| 207 | * If not set, the new task is created on the workspace root. |
| 208 | * <p>IMPORTANT: Although this class is internal, there are public |
| 209 | * subclasses that expose this method as API. Changes in |
| 210 | * this implementation should be treated as API changes. |
| 211 | * |
| 212 | * @param resource the resource |
| 213 | */ |
| 214 | public void setResource(IResource resource) { |
| 215 | this.resource = resource; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Returns the resource to use when creating a new task, |
| 220 | * or <code>null</code> if none has been set. |
| 221 | * If not set, the new task is created on the workspace root. |
| 222 | * <p>IMPORTANT: Although this method is protected and the class is |
| 223 | * internal, there are public subclasses that expose this method as API. |
| 224 | * Changes in this implementation should be treated as API changes. |
| 225 | * |
| 226 | * @return the resource |
| 227 | * |
| 228 | * @since 3.3 |
| 229 | */ |
| 230 | protected IResource getResource() { |
| 231 | return resource; |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Sets initial attributes to use when creating a new task. |
| 236 | * If not set, the new task is created with default attributes. |
| 237 | * <p>IMPORTANT: Although this method is protected and the class is |
| 238 | * internal, there are public subclasses that expose this method as API. |
| 239 | * Changes in this implementation should be treated as API changes. |
| 240 | * |
| 241 | * @param initialAttributes the initial attributes |
| 242 | * |
| 243 | * @since 3.3 |
| 244 | */ |
| 245 | protected void setInitialAttributes(Map initialAttributes) { |
| 246 | this.initialAttributes = initialAttributes; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Returns the initial attributes to use when creating a new task, |
| 251 | * or <code>null</code> if not set. |
| 252 | * If not set, the new task is created with default attributes. |
| 253 | * <p>IMPORTANT: Although this method is protected and the class is |
| 254 | * internal, there are public subclasses that expose this method as API. |
| 255 | * Changes in this implementation should be treated as API changes. |
| 256 | * |
| 257 | * @return the initial attributes |
| 258 | * |
| 259 | * @since 3.3 |
| 260 | */ |
| 261 | protected Map getInitialAttributes() { |
| 262 | if (initialAttributes == null) { |
| 263 | initialAttributes = new HashMap(); |
| 264 | } |
| 265 | return initialAttributes; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Method declared on Window. |
| 270 | */ |
| 271 | protected void configureShell(Shell newShell) { |
| 272 | super.configureShell(newShell); |
| 273 | if (title == null) { |
| 274 | newShell.setText(MarkerMessages.propertiesDialog_title); |
| 275 | } else { |
| 276 | newShell.setText(title); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Method declared on Dialog. |
| 282 | */ |
| 283 | protected Control createDialogArea(Composite parent) { |
| 284 | // initialize resources/properties |
| 285 | if (marker != null) { |
| 286 | resource = marker.getResource(); |
| 287 | try { |
| 288 | initialAttributes = marker.getAttributes(); |
| 289 | } catch (CoreException e) { |
| 290 | } |
| 291 | } else if (resource == null) { |
| 292 | resource = ResourcesPlugin.getWorkspace().getRoot(); |
| 293 | } |
| 294 | |
| 295 | Composite comp = (Composite) super.createDialogArea(parent); |
| 296 | Composite composite = new Composite(comp, SWT.NULL); |
| 297 | GridLayout layout = new GridLayout(2, false); |
| 298 | layout.marginWidth = 0; |
| 299 | layout.marginHeight = 0; |
| 300 | composite.setLayout(layout); |
| 301 | GridData gridData = new GridData(GridData.FILL_HORIZONTAL); |
| 302 | composite.setLayoutData(gridData); |
| 303 | |
| 304 | initializeDialogUnits(composite); |
| 305 | createDescriptionArea(composite); |
| 306 | if (marker != null) { |
| 307 | createSeperator(composite); |
| 308 | createCreationTimeArea(composite); |
| 309 | } |
| 310 | createAttributesArea(composite); |
| 311 | if (resource != null) { |
| 312 | createSeperator(composite); |
| 313 | createResourceArea(composite); |
| 314 | } |
| 315 | updateDialogFromMarker(); |
| 316 | updateEnablement(); |
| 317 | |
| 318 | Dialog.applyDialogFont(composite); |
| 319 | |
| 320 | return composite; |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * Creates a seperator. |
| 325 | */ |
| 326 | protected void createSeperator(Composite parent) { |
| 327 | Label seperator = new Label(parent, SWT.NULL); |
| 328 | GridData gridData = new GridData(GridData.FILL_HORIZONTAL); |
| 329 | gridData.horizontalSpan = 2; |
| 330 | seperator.setLayoutData(gridData); |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Method createCreationTimeArea. |
| 335 | * @param parent |
| 336 | */ |
| 337 | private void createCreationTimeArea(Composite parent) { |
| 338 | Label label = new Label(parent, SWT.NONE); |
| 339 | label.setText(MarkerMessages |
| 340 | .propertiesDialog_creationTime_text); |
| 341 | |
| 342 | creationTime = new Label(parent, SWT.NONE); |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Creates the OK and Cancel buttons. |
| 347 | */ |
| 348 | protected void createButtonsForButtonBar(Composite parent) { |
| 349 | createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, |
| 350 | true); |
| 351 | createButton(parent, IDialogConstants.CANCEL_ID, |
| 352 | IDialogConstants.CANCEL_LABEL, false); |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * Creates the area for the Description field. |
| 357 | */ |
| 358 | private void createDescriptionArea(Composite parent) { |
| 359 | Label label = new Label(parent, SWT.NONE); |
| 360 | label.setText(MarkerMessages.propertiesDialog_description_text); |
| 361 | descriptionText = new Text(parent, (SWT.SINGLE | SWT.BORDER)); |
| 362 | GridData gridData = new GridData(GridData.FILL_HORIZONTAL); |
| 363 | gridData.widthHint = convertHorizontalDLUsToPixels(400); |
| 364 | descriptionText.setLayoutData(gridData); |
| 365 | |
| 366 | descriptionText.addModifyListener(new ModifyListener() { |
| 367 | public void modifyText(ModifyEvent e) { |
| 368 | markDirty(); |
| 369 | } |
| 370 | }); |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * This method is intended to be overridden by subclasses. The attributes |
| 375 | * area is created between the creation time area and the resource area. |
| 376 | * |
| 377 | * @param parent |
| 378 | * the parent composite |
| 379 | */ |
| 380 | protected void createAttributesArea(Composite parent) { |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * Creates the area for the Resource field. |
| 385 | */ |
| 386 | private void createResourceArea(Composite parent) { |
| 387 | Label resourceLabel = new Label(parent, SWT.NONE); |
| 388 | resourceLabel.setText(MarkerMessages.propertiesDialog_resource_text); |
| 389 | resourceText = new Text(parent, SWT.SINGLE | SWT.WRAP |
| 390 | | SWT.READ_ONLY | SWT.BORDER); |
| 391 | GridData gridData = new GridData(GridData.FILL_HORIZONTAL); |
| 392 | resourceText.setLayoutData(gridData); |
| 393 | |
| 394 | Label folderLabel = new Label(parent, SWT.NONE); |
| 395 | folderLabel.setText(MarkerMessages.propertiesDialog_folder_text); |
| 396 | folderText = new Text(parent, SWT.SINGLE | SWT.WRAP | SWT.READ_ONLY |
| 397 | | SWT.BORDER); |
| 398 | gridData = new GridData(GridData.FILL_HORIZONTAL); |
| 399 | folderText.setLayoutData(gridData); |
| 400 | |
| 401 | Label locationLabel = new Label(parent, SWT.NONE); |
| 402 | locationLabel.setText(MarkerMessages.propertiesDialog_location_text); |
| 403 | locationText = new Text(parent, SWT.SINGLE | SWT.WRAP |
| 404 | | SWT.READ_ONLY | SWT.BORDER); |
| 405 | gridData = new GridData(GridData.FILL_HORIZONTAL); |
| 406 | locationText.setLayoutData(gridData); |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * Updates the dialog from the marker state. |
| 411 | */ |
| 412 | protected void updateDialogFromMarker() { |
| 413 | if (marker == null) { |
| 414 | updateDialogForNewMarker(); |
| 415 | return; |
| 416 | } |
| 417 | descriptionText.setText(Util.getProperty(IMarker.MESSAGE, marker)); |
| 418 | if (creationTime != null) { |
| 419 | creationTime.setText(Util.getCreationTime(marker)); |
| 420 | } |
| 421 | if (resourceText != null) { |
| 422 | resourceText.setText(Util.getResourceName(marker)); |
| 423 | } |
| 424 | if (folderText != null) { |
| 425 | folderText.setText(Util.getContainerName(marker)); |
| 426 | } |
| 427 | if (locationText != null) { |
| 428 | String line = Util.getProperty(IMarker.LINE_NUMBER, marker); |
| 429 | if (line.equals("")) { //$NON-NLS-1$ |
| 430 | locationText.setText(""); //$NON-NLS-1$ |
| 431 | } else { |
| 432 | locationText.setText(NLS.bind(MarkerMessages.label_lineNumber, line)); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | descriptionText.selectAll(); |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Updates the dialog from the predefined attributes. |
| 441 | */ |
| 442 | protected void updateDialogForNewMarker() { |
| 443 | if (resource != null && resourceText != null && folderText != null) { |
| 444 | resourceText.setText(resource.getName()); |
| 445 | |
| 446 | IPath path = resource.getFullPath(); |
| 447 | int n = path.segmentCount() - 1; // n is the number of segments in container, not path |
| 448 | if (n > 0) { |
| 449 | int len = 0; |
| 450 | for (int i = 0; i < n; ++i) { |
| 451 | len += path.segment(i).length(); |
| 452 | } |
| 453 | // account for /'s |
| 454 | if (n > 1) { |
| 455 | len += n - 1; |
| 456 | } |
| 457 | StringBuffer sb = new StringBuffer(len); |
| 458 | for (int i = 0; i < n; ++i) { |
| 459 | if (i != 0) { |
| 460 | sb.append('/'); |
| 461 | } |
| 462 | sb.append(path.segment(i)); |
| 463 | } |
| 464 | folderText.setText(sb.toString()); |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | if (initialAttributes != null) { |
| 469 | Object description = initialAttributes.get(IMarker.MESSAGE); |
| 470 | if (description != null && description instanceof String) { |
| 471 | descriptionText.setText((String) description); |
| 472 | } |
| 473 | descriptionText.selectAll(); |
| 474 | |
| 475 | Object line = initialAttributes.get(IMarker.LINE_NUMBER); |
| 476 | if (line != null && line instanceof Integer && locationText != null) { |
| 477 | locationText.setText( |
| 478 | NLS.bind(MarkerMessages.label_lineNumber, line)); |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | * Method declared on Dialog |
| 485 | */ |
| 486 | protected void okPressed() { |
| 487 | if (marker == null || Util.isEditable(marker)) { |
| 488 | saveChanges(); |
| 489 | } |
| 490 | super.okPressed(); |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * Sets the dialog's dirty flag to <code>true</code> |
| 495 | */ |
| 496 | protected void markDirty() { |
| 497 | dirty = true; |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * @return |
| 502 | * <ul> |
| 503 | * <li><code>true</code> if the dirty flag has been set to true.</li> |
| 504 | * <li><code>false</code> otherwise.</li> |
| 505 | * </ul> |
| 506 | */ |
| 507 | protected boolean isDirty() { |
| 508 | return dirty; |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * Saves the changes made in the dialog if needed. Creates a new marker if |
| 513 | * needed. Updates the existing marker only if there have been changes. |
| 514 | */ |
| 515 | private void saveChanges() { |
| 516 | Map attrs = getMarkerAttributes(); |
| 517 | IUndoableOperation op = null; |
| 518 | if (marker == null) { |
| 519 | if (resource == null) |
| 520 | return; |
| 521 | op = new CreateMarkersOperation(type, attrs, |
| 522 | resource, getCreateOperationTitle()); |
| 523 | } else { |
| 524 | if (isDirty()) { |
| 525 | op = new UpdateMarkersOperation(marker, attrs, |
| 526 | getModifyOperationTitle(), true); |
| 527 | } |
| 528 | } |
| 529 | if (op != null) { |
| 530 | try { |
| 531 | PlatformUI.getWorkbench() |
| 532 | .getOperationSupport() |
| 533 | .getOperationHistory().execute(op, |
| 534 | null, WorkspaceUndoUtil.getUIInfoAdapter(getShell())); |
| 535 | } catch (ExecutionException e) { |
| 536 | if (e.getCause() instanceof CoreException) { |
| 537 | ErrorDialog.openError( |
| 538 | getShell(), |
| 539 | MarkerMessages.Error, null, ((CoreException)e.getCause()).getStatus()); |
| 540 | } else |
| 541 | IDEWorkbenchPlugin.log(e.getMessage(), e); |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Returns the marker attributes to save back to the marker, based on the |
| 548 | * current dialog fields. |
| 549 | */ |
| 550 | protected Map getMarkerAttributes() { |
| 551 | Map attrs = getInitialAttributes(); |
| 552 | attrs.put(IMarker.MESSAGE, descriptionText.getText()); |
| 553 | return attrs; |
| 554 | } |
| 555 | |
| 556 | /** |
| 557 | * Updates widget enablement for the dialog. Should be overridden by |
| 558 | * subclasses. |
| 559 | */ |
| 560 | protected void updateEnablement() { |
| 561 | descriptionText.setEditable(isEditable()); |
| 562 | } |
| 563 | |
| 564 | /** |
| 565 | * @return |
| 566 | * <ul> |
| 567 | * <li><code>true</code> if the marker is editable or the dialog is |
| 568 | * creating a new marker.</li> |
| 569 | * <li><code>false</code> if the marker is not editable.</li> |
| 570 | * </ul> |
| 571 | */ |
| 572 | protected boolean isEditable() { |
| 573 | if (marker == null) { |
| 574 | return true; |
| 575 | } |
| 576 | return Util.isEditable(marker); |
| 577 | } |
| 578 | |
| 579 | /** |
| 580 | * Sets the marker type when creating a new marker. |
| 581 | * |
| 582 | * @param type |
| 583 | * the marker type |
| 584 | * |
| 585 | * @since 3.3 this method is protected. |
| 586 | */ |
| 587 | protected void setType(String type) { |
| 588 | this.type = type; |
| 589 | } |
| 590 | |
| 591 | /* (non-Javadoc) |
| 592 | * @see org.eclipse.jface.window.Dialog#getDialogBoundsSettings() |
| 593 | * |
| 594 | * @since 3.2 |
| 595 | */ |
| 596 | protected IDialogSettings getDialogBoundsSettings() { |
| 597 | IDialogSettings settings = IDEWorkbenchPlugin.getDefault().getDialogSettings(); |
| 598 | IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION); |
| 599 | if (section == null) { |
| 600 | section = settings.addNewSection(DIALOG_SETTINGS_SECTION); |
| 601 | } |
| 602 | return section; |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Return the string that describes a modify marker operation. |
| 607 | * Subclasses may override to more specifically describe the marker. |
| 608 | * |
| 609 | * @since 3.3 |
| 610 | */ |
| 611 | protected String getModifyOperationTitle() { |
| 612 | if (markerName == null) { |
| 613 | // we don't know what kind of marker is being modified |
| 614 | return MarkerMessages.DialogMarkerProperties_ModifyMarker; |
| 615 | } |
| 616 | return NLS.bind(MarkerMessages.qualifiedMarkerCommand_title, |
| 617 | MarkerMessages.DialogMarkerProperties_Modify, markerName); |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Return the string that describes a create marker operation. |
| 622 | * Subclasses may override to more specifically describe the marker. |
| 623 | * |
| 624 | * @since 3.3 |
| 625 | */ |
| 626 | protected String getCreateOperationTitle() { |
| 627 | if (markerName == null) { |
| 628 | // we don't know what kind of marker is being created |
| 629 | return MarkerMessages.DialogMarkerProperties_CreateMarker; |
| 630 | } |
| 631 | return NLS.bind(MarkerMessages.qualifiedMarkerCommand_title, |
| 632 | MarkerMessages.DialogMarkerProperties_Create, markerName); |
| 633 | |
| 634 | } |
| 635 | |
| 636 | /* |
| 637 | * (non-Javadoc) |
| 638 | * @see org.eclipse.jface.dialogs.Dialog#isResizable() |
| 639 | */ |
| 640 | protected boolean isResizable() { |
| 641 | return true; |
| 642 | } |
| 643 | |
| 644 | } |