All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.netbeans.api.io.Fold Maven / Gradle / Ivy

There is a newer version: RELEASE230
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.netbeans.api.io;

import java.io.PrintWriter;
import org.netbeans.spi.io.InputOutputProvider;

/**
 * A fold (nested or standalone) in the output window.
 *
 * 

* Methods of this class can be called in any thread. *

* * @author jhavlin */ public abstract class Fold { static final Fold UNSUPPORTED = new Fold() { @Override public void setExpanded(boolean expanded) { } @Override void endFold() { } }; private Fold() { } static Fold create( InputOutputProvider provider, IO io, OW writer, F fold) { if (fold == null) { return UNSUPPORTED; } else { return new Impl(provider, io, writer, fold); } } /** * Set fold expansion state. * * @param expanded True to expand the fold, false to collapse it. */ public abstract void setExpanded(boolean expanded); abstract void endFold(); /** * Expand the fold. */ public final void expand() { setExpanded(true); } /** * Collapse the fold. */ public final void collapse() { setExpanded(false); } private static class Impl extends Fold { private final InputOutputProvider provider; private final IO io; private final OW writer; private final F fold; public Impl(InputOutputProvider provider, IO io, OW writer, F fold) { this.provider = provider; this.io = io; this.writer = writer; this.fold = fold; } @Override public void setExpanded(boolean expanded) { provider.setFoldExpanded(io, writer, fold, expanded); } @Override void endFold() { provider.endFold(io, writer, fold); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy