Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.workbench.screens.workitems.client.editor;
 
 import java.util.List;
 
Editor for Work Item definitions
 
 @WorkbenchEditor(identifier = "WorkItemsEditor", supportedTypes = { WorkItemsResourceType.class })
 public class WorkItemsEditorPresenter {
 
     @Inject
 
     @Inject
 
     @Inject
     private Event<NotificationEventnotification;
 
     @Inject
     private PlaceManager placeManager;
 
     @Inject
     private WorkItemsEditorView view;
 
     @Inject
     private MetadataWidget metadataWidget;
 
     @Inject
     private MultiPageEditor multiPage;
 
     @Inject
     @New
     private FileMenuBuilder menuBuilder;
     private Menus menus;
 
     private Path path;
     private PlaceRequest place;
     private boolean isReadOnly;
 
     @OnStart
     public void onStartfinal Path path,
                          final PlaceRequest place ) {
        this. = path;
        this. = place;
        this. = place.getParameter"readOnly"null ) == null ? false : true;
        makeMenuBar();
        .addWidget,
                             ..WorkItemDescription() );
        .addPagenew Page,
                                     ..MetadataTabTitle() ) {
            @Override
            public void onFocus() {
                .showBusyIndicator..Loading() );
                .callnew MetadataSuccessCallback,
                                                                    ),
                                      new HasBusyIndicatorDefaultErrorCallback ) ).getMetadatapath );
            }
            @Override
            public void onLostFocus() {
                //Nothing to do
            }
        } );
        loadContent();
    }
    private void loadContent() {
                               new HasBusyIndicatorDefaultErrorCallback ) ).loadContent );
    }
    private void makeMenuBar() {
        if (  ) {
             = .addRestoreVersion ).build();
        } else {
             = 
                    .addSavenew Command() {
                        @Override
                        public void execute() {
                            onSave();
                        }
                    } )
                    .addCopy )
                    .addRename )
                    .addDelete )
                    .build();
        }
    }
        return new RemoteCallback<WorkItemsModelContent>() {
            @Override
            public void callbackfinal WorkItemsModelContent content ) {
                final String definition = content.getDefinition();
                final List<StringworkItemImages = content.getWorkItemImages();
                .setContentdefinition,
                                 workItemImages );
                .hideBusyIndicator();
            }
        };
    }
    @OnSave
    public void onSave() {
        if (  ) {
            .alertReadOnly();
            return;
        }
        new SaveOperationService().save,
                                         new CommandWithCommitMessage() {
                                             @Override
                                             public void executefinal String commitMessage ) {
                                                 .showBusyIndicator..Saving() );
                                                 .callgetSaveSuccessCallback(),
                                                                        new HasBusyIndicatorDefaultErrorCallback ) ).save,
                                                                                                                                 .getContent(),
                                                                                                                                 .getContent(),
                                                                                                                                 commitMessage );
                                             }
                                         } );
    }
        return new RemoteCallback<Path>() {
            @Override
            public void callbackfinal Path path ) {
                .setNotDirty();
                .hideBusyIndicator();
                .resetDirty();
                .firenew NotificationEvent..ItemSavedSuccessfully() ) );
            }
        };
    }
    @IsDirty
    public boolean isDirty() {
        return .isDirty();
    }
    @OnClose
    public void onClose() {
        this. = null;
    }
    @OnMayClose
    public boolean checkIfDirty() {
        if ( isDirty() ) {
            return .confirmClose();
        }
        return true;
    }
    public String getTitle() {
        return ..Title() + " [" + .getFileName() + "]";
    }
    public IsWidget getWidget() {
        return ;
    }
    public Menus getMenus() {
        return ;
    }
    public void onRestore( @Observes RestoreEvent restore ) {
        if (  == null || restore == null || restore.getPath() == null ) {
            return;
        }
        if ( .equalsrestore.getPath() ) ) {
            loadContent();
        }
    }
New to GrepCode? Check out our FAQ X